-- cgit From 7dbb6441c95aa5691a59dc918f864b4bf4e2e2ed Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 18 Jul 2017 20:35:53 -0400 Subject: [CCSDK-6] Populate seed code Add seed code for sli/plugins repository Changed groupId to org.onap.ccsdk.sli.plugins Updated to compile against CCSDK version of SLI Change-Id: Ib392530ea79b8544087692964bd65179896aa595 Signed-off-by: Dan Timoney --- .gitignore | 38 ++ LICENSE.txt | 22 + README.md | 9 + example-settings.xml | 163 +++++ jenkins-settings.xml | 168 +++++ pom.xml | 118 ++++ properties-node/.gitignore | 34 + properties-node/features/pom.xml | 135 ++++ .../features/src/main/resources/features.xml | 39 ++ properties-node/installer/pom.xml | 139 ++++ .../src/assembly/assemble_installer_zip.xml | 59 ++ .../src/assembly/assemble_mvnrepo_zip.xml | 49 ++ .../src/main/resources/scripts/install-feature.sh | 40 ++ properties-node/pom.xml | 43 ++ properties-node/provider/pom.xml | 89 +++ .../org/openecomp/sdnc/prop/PropertiesNode.java | 97 +++ .../META-INF/spring/properties-node-context.xml | 32 + .../spring/properties-node-osgi-context.xml | 32 + restapi-call-node/.gitignore | 34 + restapi-call-node/features/pom.xml | 135 ++++ .../features/src/main/resources/features.xml | 40 ++ restapi-call-node/installer/pom.xml | 139 ++++ .../src/assembly/assemble_installer_zip.xml | 59 ++ .../src/assembly/assemble_mvnrepo_zip.xml | 49 ++ .../src/main/resources/scripts/install-feature.sh | 40 ++ restapi-call-node/pom.xml | 42 ++ restapi-call-node/provider/pom.xml | 101 +++ .../org/openecomp/sdnc/restapicall/Format.java | 36 + .../org/openecomp/sdnc/restapicall/HttpMethod.java | 42 ++ .../openecomp/sdnc/restapicall/HttpResponse.java | 31 + .../org/openecomp/sdnc/restapicall/JsonParser.java | 85 +++ .../org/openecomp/sdnc/restapicall/Parameters.java | 46 ++ .../sdnc/restapicall/RestapiCallNode.java | 759 +++++++++++++++++++++ .../openecomp/sdnc/restapicall/RetryException.java | 30 + .../openecomp/sdnc/restapicall/RetryPolicy.java | 59 ++ .../sdnc/restapicall/RetryPolicyStore.java | 54 ++ .../openecomp/sdnc/restapicall/XmlJsonUtil.java | 372 ++++++++++ .../org/openecomp/sdnc/restapicall/XmlParser.java | 160 +++++ .../META-INF/spring/restapi-call-node-context.xml | 49 ++ .../spring/restapi-call-node-osgi-context.xml | 32 + .../src/main/resources/default-ueb-message.json | 32 + .../src/main/resources/get-multicast-data.json | 34 + .../main/resources/northbound-api-template.json | 43 ++ .../src/main/resources/northbound-api-template.xml | 43 ++ ...iguration-notification-northbound-template.json | 44 ++ .../update-vpe-data-with-apply-group.json | 53 ++ .../src/main/resources/vnf-information-update.json | 24 + .../src/main/resources/vpn-allocation-request.json | 36 + .../src/main/resources/vpn-information-update.json | 24 + ...service-configuration-information-template.json | 37 + .../resources/vrf-update-vlan-status-template.json | 33 + .../provider/src/main/resources/vrf-update.json | 77 +++ .../openecomp/sdnc/restapicall/TestJsonParser.java | 65 ++ .../sdnc/restapicall/TestRestapiCallNode.java | 92 +++ .../sdnc/restapicall/TestXmlJsonUtil.java | 215 ++++++ .../openecomp/sdnc/restapicall/TestXmlParser.java | 75 ++ .../provider/src/test/resources/test-template.json | 57 ++ .../provider/src/test/resources/test.json | 48 ++ .../provider/src/test/resources/test.xml | 172 +++++ .../provider/src/test/resources/test3.xml | 82 +++ version.properties | 16 + 61 files changed, 5002 insertions(+) create mode 100755 .gitignore create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100644 example-settings.xml create mode 100644 jenkins-settings.xml create mode 100755 pom.xml create mode 100755 properties-node/.gitignore create mode 100755 properties-node/features/pom.xml create mode 100644 properties-node/features/src/main/resources/features.xml create mode 100755 properties-node/installer/pom.xml create mode 100644 properties-node/installer/src/assembly/assemble_installer_zip.xml create mode 100644 properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml create mode 100644 properties-node/installer/src/main/resources/scripts/install-feature.sh create mode 100755 properties-node/pom.xml create mode 100755 properties-node/provider/pom.xml create mode 100644 properties-node/provider/src/main/java/org/openecomp/sdnc/prop/PropertiesNode.java create mode 100644 properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml create mode 100644 properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml create mode 100755 restapi-call-node/.gitignore create mode 100755 restapi-call-node/features/pom.xml create mode 100644 restapi-call-node/features/src/main/resources/features.xml create mode 100755 restapi-call-node/installer/pom.xml create mode 100644 restapi-call-node/installer/src/assembly/assemble_installer_zip.xml create mode 100644 restapi-call-node/installer/src/assembly/assemble_mvnrepo_zip.xml create mode 100644 restapi-call-node/installer/src/main/resources/scripts/install-feature.sh create mode 100755 restapi-call-node/pom.xml create mode 100755 restapi-call-node/provider/pom.xml create mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/Format.java create mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/HttpMethod.java create mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/HttpResponse.java create mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/JsonParser.java create mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/Parameters.java create mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RestapiCallNode.java create mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryException.java create mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryPolicy.java create mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryPolicyStore.java create mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/XmlJsonUtil.java create mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/XmlParser.java create mode 100644 restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml create mode 100644 restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml create mode 100644 restapi-call-node/provider/src/main/resources/default-ueb-message.json create mode 100644 restapi-call-node/provider/src/main/resources/get-multicast-data.json create mode 100644 restapi-call-node/provider/src/main/resources/northbound-api-template.json create mode 100644 restapi-call-node/provider/src/main/resources/northbound-api-template.xml create mode 100644 restapi-call-node/provider/src/main/resources/service-configuration-notification-northbound-template.json create mode 100644 restapi-call-node/provider/src/main/resources/update-vpe-data-with-apply-group.json create mode 100644 restapi-call-node/provider/src/main/resources/vnf-information-update.json create mode 100644 restapi-call-node/provider/src/main/resources/vpn-allocation-request.json create mode 100644 restapi-call-node/provider/src/main/resources/vpn-information-update.json create mode 100644 restapi-call-node/provider/src/main/resources/vrf-service-configuration-information-template.json create mode 100644 restapi-call-node/provider/src/main/resources/vrf-update-vlan-status-template.json create mode 100644 restapi-call-node/provider/src/main/resources/vrf-update.json create mode 100644 restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestJsonParser.java create mode 100644 restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestRestapiCallNode.java create mode 100644 restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestXmlJsonUtil.java create mode 100644 restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestXmlParser.java create mode 100644 restapi-call-node/provider/src/test/resources/test-template.json create mode 100644 restapi-call-node/provider/src/test/resources/test.json create mode 100644 restapi-call-node/provider/src/test/resources/test.xml create mode 100644 restapi-call-node/provider/src/test/resources/test3.xml create mode 100644 version.properties diff --git a/.gitignore b/.gitignore new file mode 100755 index 000000000..fabe495f5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +#####standard .git ignore entries##### + +## IDE Specific Files ## +org.eclipse.core.resources.prefs +.classpath +.project +.settings +.idea +.externalToolBuilders +.checkstyle +maven-eclipse.xml +workspace + +## Compilation Files ## +*.class +**/target +target +target-ide +MANIFEST.MF + +## Misc Ignores (OS specific etc) ## +bin/ +dist +*~ +*.ipr +*.iml +*.iws +classes +out/ +.DS_STORE +.metadata +provider/src/main/java/META-INF/ +provider/src/main/java/inventory/ + +# BlackDuck generated file +sdnc-plugins_bdio.jsonld +blackDuckHubProjectName.txt +blackDuckHubProjectVersionName.txt diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 000000000..3ea5081a0 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,22 @@ +/* + * ============LICENSE_START========================================== + * =================================================================== + * Copyright © 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============================================ + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + * + */ diff --git a/README.md b/README.md new file mode 100644 index 000000000..4e733caff --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +This source repository contains the code for the SDN Controller plugins. + +To compile this code: + +1. Make sure your local Maven settings file ($HOME/.m2/settings.xml) contains references to the OpenECOMP repositories and OpenDaylight repositories. See example-settings.xml for an example. + +2. To compile, run "mvn clean install". + + diff --git a/example-settings.xml b/example-settings.xml new file mode 100644 index 000000000..2e7ce6445 --- /dev/null +++ b/example-settings.xml @@ -0,0 +1,163 @@ + + + + + + + + openecomp-release + + + openecomp-release + openecomp-release + https://ecomp-nexus:8443/repository/maven-releases/ + + true + never + + + false + + + + + + openecomp-release + openecomp-release + https://ecomp-nexus:8443/repository/maven-releases/ + + true + never + + + false + + + + + + + openecomp-snapshots + + + openecomp-snapshot + openecomp-snapshot + https://ecomp-nexus:8443/repository/maven-snapshots/ + + false + + + true + + + + + + openecomp-snapshot + openecomp-snapshot + https://ecomp-nexus:8443/repository/maven-snapshots/ + + false + + + true + + + + + + opendaylight-release + + + opendaylight-mirror + opendaylight-mirror + https://nexus.opendaylight.org/content/repositories/public/ + + true + never + + + false + + + + + + opendaylight-mirror + opendaylight-mirror + https://nexus.opendaylight.org/content/repositories/public/ + + true + never + + + false + + + + + + + opendaylight-snapshots + + + opendaylight-snapshot + opendaylight-snapshot + https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ + + false + + + true + + + + + + opendaylight-snapshot + opendaylight-snapshot + https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ + + false + + + true + + + + + + + + openecomp-release + openecomp-snapshots + opendaylight-release + opendaylight-snapshots + + + + + nexus + USERNAME + PASSWORD + + + openecomp-release + USERNAME + PASSWORD + + + openecomp-snapshot + USERNAME + PASSWORD + + + diff --git a/jenkins-settings.xml b/jenkins-settings.xml new file mode 100644 index 000000000..344994f85 --- /dev/null +++ b/jenkins-settings.xml @@ -0,0 +1,168 @@ + + + + + + + + openecomp-release + + + openecomp-release + openecomp-release + https://ecomp-nexus:8443/repository/maven-releases/ + + true + never + + + false + + + + + + openecomp-release + openecomp-release + https://ecomp-nexus:8443/repository/maven-releases/ + + true + never + + + false + + + + + + + openecomp-snapshots + + + openecomp-snapshot + openecomp-snapshot + https://ecomp-nexus:8443/repository/maven-snapshots/ + + false + + + true + + + + + + openecomp-snapshot + openecomp-snapshot + https://ecomp-nexus:8443/repository/maven-snapshots/ + + false + + + true + + + + + + opendaylight-release + + + opendaylight-mirror + opendaylight-mirror + https://nexus.opendaylight.org/content/repositories/public/ + + true + never + + + false + + + + + + opendaylight-mirror + opendaylight-mirror + https://nexus.opendaylight.org/content/repositories/public/ + + true + never + + + false + + + + + + + opendaylight-snapshots + + + opendaylight-snapshot + opendaylight-snapshot + https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ + + false + + + true + + + + + + opendaylight-snapshot + opendaylight-snapshot + https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ + + false + + + true + + + + + + + + openecomp-release + openecomp-snapshots + opendaylight-release + opendaylight-snapshots + + + + + nexus + ${ecomp.nexus.user} + ${ecomp.nexus.password} + + + openecomp-release + ${ecomp.nexus.user} + ${ecomp.nexus.password} + + + openecomp-snapshot + ${ecomp.nexus.user} + ${ecomp.nexus.password} + + + sdnc-javadoc + ${ecomp.nexus.user} + ${ecomp.nexus.password} + + + diff --git a/pom.xml b/pom.xml new file mode 100755 index 000000000..96436f7ef --- /dev/null +++ b/pom.xml @@ -0,0 +1,118 @@ + + + + + org.onap.ccsdk.parent + odlparent-boron-sr3 + 0.0.1-SNAPSHOT + + + 4.0.0 + pom + org.onap.ccsdk.sli.plugins + sdnc-plugins + + SDN-C Java Plugins + https://wiki.openecomp.org + The SDN-C core components contains the SLI, dblib and root pom + + + + JIRA + https://jira.openecomp.org/ + + + + + scm:git:ssh://git@${openecomp.git.host}/sdnc-plugins.git + scm:git:ssh://${openecomp.git.host}:${openecomp.git.port}/${openecomp.git.project}/sdnc-iplugins.git + ${openecomp.git.protocol}://${openecomp.git.host}/projects/${openecomp.git.project}/repos/sdnc-plugins/browse + HEAD + + + + Jenkins + https://jenkins.openecomp.org + + + + + + sdnc-javadoc + dav:https://${openecomp.nexus.host}/content/sites/site/org/onap/sdnc/plugins/${project.artifactId}/${project.version} + + + + + + blackduck + + + blackduck-scan + + + + + + com.blackducksoftware.integration + hub-maven-plugin + 1.4.0 + false + + ${project.name} + ${project.basedir} + + + + create-bdio-file + package + + createHubOutput + + + + + + + + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.17 + + true + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + https://${openecomp.nexus.host} + ${openecomp.nexus.staging.profile-id} + ${openecomp.nexus.staging.server-id} + + + + + + + properties-node + restapi-call-node + + + AT&T + + 0.0.1-SNAPSHOT + + + diff --git a/properties-node/.gitignore b/properties-node/.gitignore new file mode 100755 index 000000000..b73caf31e --- /dev/null +++ b/properties-node/.gitignore @@ -0,0 +1,34 @@ +#####standard .git ignore entries##### + +## IDE Specific Files ## +org.eclipse.core.resources.prefs +.classpath +.project +.settings +.idea +.externalToolBuilders +maven-eclipse.xml +workspace + +## Compilation Files ## +*.class +**/target +target +target-ide +MANIFEST.MF + +## Misc Ignores (OS specific etc) ## +bin/ +dist +*~ +*.ipr +*.iml +*.iws +classes +out/ +.DS_STORE +.metadata + +## Folders which contain auto generated source code ## +yang-gen-config +yang-gen-sal diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml new file mode 100755 index 000000000..159ac4740 --- /dev/null +++ b/properties-node/features/pom.xml @@ -0,0 +1,135 @@ + + + 4.0.0 + + properties-node + org.onap.ccsdk.sli.plugins + 0.0.1-SNAPSHOT + + org.onap.ccsdk.sli.plugins + 0.0.1-SNAPSHOT + properties-node-features + Properties Node - Features + + jar + + + + + org.onap.ccsdk.sli.plugins + properties-node-provider + ${project.version} + + + + commons-lang + commons-lang + 2.6 + compile + + + + org.opendaylight.mdsal + features-mdsal + ${odl.mdsal.features.version} + features + xml + + runtime + + + + + + org.opendaylight.controller + opendaylight-karaf-empty + ${odl.karaf.empty.distro.version} + zip + + + + + + org.opendaylight.odlparent + features-test + ${odl.commons.opendaylight.version} + test + + + + org.opendaylight.yangtools + features-yangtools + ${odl.yangtools.version} + features + xml + runtime + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + diff --git a/properties-node/features/src/main/resources/features.xml b/properties-node/features/src/main/resources/features.xml new file mode 100644 index 000000000..e89b333e9 --- /dev/null +++ b/properties-node/features/src/main/resources/features.xml @@ -0,0 +1,39 @@ + + + + + + + mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features + + + sdnc-sli + spring + spring-dm + mvn:org.openecomp.sdnc.plugins/properties-node-provider/${project.version} + + + + diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml new file mode 100755 index 000000000..5749a9b99 --- /dev/null +++ b/properties-node/installer/pom.xml @@ -0,0 +1,139 @@ + + + 4.0.0 + + properties-node + org.onap.ccsdk.sli.plugins + 0.0.1-SNAPSHOT + + properties-node-installer + Properties node - Karaf Installer + pom + + + sdnc-properties-node + sdnc-properties-node + mvn:org.onap.ccsdk.sli.plugins/properties-node-features/${project.version}/xml/features + false + + + + + + org.onap.ccsdk.sli.plugins + properties-node-features + ${project.version} + features + xml + + + * + * + + + + + + org.onap.ccsdk.sli.plugins + properties-node-provider + ${project.version} + + + + + + + + maven-assembly-plugin + 2.6 + + + maven-repo-zip + + single + + package + + false + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + false + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli + sli-common,sli-provider,dblib-provider + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + + + + diff --git a/properties-node/installer/src/assembly/assemble_installer_zip.xml b/properties-node/installer/src/assembly/assemble_installer_zip.xml new file mode 100644 index 000000000..e278872a1 --- /dev/null +++ b/properties-node/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,59 @@ + + + + + + installer_zip + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + + + + diff --git a/properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml b/properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100644 index 000000000..1edacdb6d --- /dev/null +++ b/properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,49 @@ + + + + + + mvnrepo_zip + + zip + + + + false + + + + target/assembly/ + . + + + + + + + + diff --git a/properties-node/installer/src/main/resources/scripts/install-feature.sh b/properties-node/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..9a47d2225 --- /dev/null +++ b/properties-node/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +### +# ============LICENSE_START======================================================= +# openECOMP : SDN-C +# ================================================================================ +# Copyright (C) 2017 ONAP 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========================================================= +### + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} diff --git a/properties-node/pom.xml b/properties-node/pom.xml new file mode 100755 index 000000000..8d6af7c57 --- /dev/null +++ b/properties-node/pom.xml @@ -0,0 +1,43 @@ + + + + org.onap.ccsdk.sli.plugins + sdnc-plugins + 0.0.1-SNAPSHOT + + + 4.0.0 + pom + + org.onap.ccsdk.sli.plugins + properties-node + 0.0.1-SNAPSHOT + + Properties Node + This is an implementation of DG Execute Node that reads property file and + puts the properties in the DG context + + + + + org.onap.ccsdk.sli.plugins + properties-node-features + features + xml + ${project.version} + + + org.onap.ccsdk.sli.plugins + properties-node-provider + ${project.version} + + + + + + provider + features + installer + + + diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml new file mode 100755 index 000000000..43369adf7 --- /dev/null +++ b/properties-node/provider/pom.xml @@ -0,0 +1,89 @@ + + + 4.0.0 + + org.onap.ccsdk.sli.plugins + properties-node + 0.0.1-SNAPSHOT + + org.onap.ccsdk.sli.plugins + 0.0.1-SNAPSHOT + properties-node-provider + bundle + Properties Node - Provider + http://maven.apache.org + + UTF-8 + + + + junit + junit + test + + + org.springframework + spring-test + ${spring.version} + test + + + org.onap.ccsdk.sli.core + sli-common + ${sdnctl.sli.version} + compile + + + org.onap.ccsdk.sli.core + sli-provider + ${sdnctl.sli.version} + compile + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + org.springframework + spring-beans + ${spring.version} + + + org.springframework + spring-context + ${spring.version} + + + + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + org.onap.ccsdk.sli.prop + org.onap.ccsdk.sli.prop + * + + + + + + + + + + + + diff --git a/properties-node/provider/src/main/java/org/openecomp/sdnc/prop/PropertiesNode.java b/properties-node/provider/src/main/java/org/openecomp/sdnc/prop/PropertiesNode.java new file mode 100644 index 000000000..9856b1948 --- /dev/null +++ b/properties-node/provider/src/main/java/org/openecomp/sdnc/prop/PropertiesNode.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.prop; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Map; +import java.util.Properties; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class PropertiesNode implements SvcLogicJavaPlugin { + + private static final Logger log = LoggerFactory.getLogger(PropertiesNode.class); + + public void readProperties(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { + String fileName = parseParam(paramMap, "fileName", true, null); + String contextPrefix = parseParam(paramMap, "contextPrefix", false, null); + + try { + Properties pp = new Properties(); + InputStream in = new FileInputStream(fileName); + pp.load(in); + for (Object key : pp.keySet()) { + String pfx = contextPrefix != null ? contextPrefix + '.' : ""; + String name = (String) key; + String value = pp.getProperty(name); + if (value != null && value.trim().length() > 0) { + ctx.setAttribute(pfx + name, value.trim()); + log.info("+++ " + pfx + name + ": [" + value + "]"); + } + } + } catch (IOException e) { + throw new SvcLogicException("Cannot read property file: " + fileName + ": " + e.getMessage(), e); + } + } + + private String parseParam(Map paramMap, String name, boolean required, String def) + throws SvcLogicException { + String s = paramMap.get(name); + + if (s == null || s.trim().length() == 0) { + if (!required) + return def; + throw new SvcLogicException("Parameter " + name + " is required in PropertiesNode"); + } + + s = s.trim(); + String value = ""; + int i = 0; + int i1 = s.indexOf('%'); + while (i1 >= 0) { + int i2 = s.indexOf('%', i1 + 1); + if (i2 < 0) + throw new SvcLogicException("Cannot parse parameter " + name + ": " + s + ": no matching %"); + + String varName = s.substring(i1 + 1, i2); + String varValue = System.getenv(varName); + if (varValue == null) + varValue = ""; + + value += s.substring(i, i1); + value += varValue; + + i = i2 + 1; + i1 = s.indexOf('%', i); + } + value += s.substring(i); + + log.info("Parameter " + name + ": " + value); + return value; + } +} diff --git a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml new file mode 100644 index 000000000..a53ea1414 --- /dev/null +++ b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml @@ -0,0 +1,32 @@ + + + + + + + + + diff --git a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml new file mode 100644 index 000000000..7d74fd4f0 --- /dev/null +++ b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml @@ -0,0 +1,32 @@ + + + + + + + + diff --git a/restapi-call-node/.gitignore b/restapi-call-node/.gitignore new file mode 100755 index 000000000..b73caf31e --- /dev/null +++ b/restapi-call-node/.gitignore @@ -0,0 +1,34 @@ +#####standard .git ignore entries##### + +## IDE Specific Files ## +org.eclipse.core.resources.prefs +.classpath +.project +.settings +.idea +.externalToolBuilders +maven-eclipse.xml +workspace + +## Compilation Files ## +*.class +**/target +target +target-ide +MANIFEST.MF + +## Misc Ignores (OS specific etc) ## +bin/ +dist +*~ +*.ipr +*.iml +*.iws +classes +out/ +.DS_STORE +.metadata + +## Folders which contain auto generated source code ## +yang-gen-config +yang-gen-sal diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml new file mode 100755 index 000000000..cf9473383 --- /dev/null +++ b/restapi-call-node/features/pom.xml @@ -0,0 +1,135 @@ + + + 4.0.0 + + restapi-call-node + org.onap.ccsdk.sli.plugins + 0.0.1-SNAPSHOT + + org.onap.ccsdk.sli.plugins + 0.0.1-SNAPSHOT + restapi-call-node-features + RESTAPI Call Node - Features + + jar + + + + + org.onap.ccsdk.sli.plugins + restapi-call-node-provider + ${project.version} + + + + commons-lang + commons-lang + 2.6 + compile + + + + org.opendaylight.mdsal + features-mdsal + ${odl.mdsal.features.version} + features + xml + + runtime + + + + + + org.opendaylight.controller + opendaylight-karaf-empty + ${odl.karaf.empty.distro.version} + zip + + + + + + org.opendaylight.odlparent + features-test + ${odl.commons.opendaylight.version} + test + + + + org.opendaylight.yangtools + features-yangtools + ${odl.yangtools.version} + features + xml + runtime + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + diff --git a/restapi-call-node/features/src/main/resources/features.xml b/restapi-call-node/features/src/main/resources/features.xml new file mode 100644 index 000000000..648e6f78f --- /dev/null +++ b/restapi-call-node/features/src/main/resources/features.xml @@ -0,0 +1,40 @@ + + + + + + + mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features + + + sdnc-sli + spring + spring-dm + mvn:com.sun.jersey/jersey-client/${jersey.version} + mvn:org.codehaus.jettison/jettison/${jettison.version} + mvn:org.openecomp.sdnc.plugins/restapi-call-node-provider/${project.version} + + + diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml new file mode 100755 index 000000000..db0aae60d --- /dev/null +++ b/restapi-call-node/installer/pom.xml @@ -0,0 +1,139 @@ + + + 4.0.0 + + restapi-call-node + org.onap.ccsdk.sli.plugins + 0.0.1-SNAPSHOT + + restapi-call-node-installer + Properties node - Karaf Installer + pom + + + sdnc-restapi-call-node + sdnc-restapi-call-node + mvn:org.onap.ccsdk.sli.plugins/restapi-call-node-features/${project.version}/xml/features + false + + + + + + org.onap.ccsdk.sli.plugins + restapi-call-node-features + ${project.version} + features + xml + + + * + * + + + + + + org.onap.ccsdk.sli.plugins + restapi-call-node-provider + ${project.version} + + + + + + + + maven-assembly-plugin + 2.6 + + + maven-repo-zip + + single + + package + + false + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + false + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli + sli-common,sli-provider,dblib-provider + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + + + + diff --git a/restapi-call-node/installer/src/assembly/assemble_installer_zip.xml b/restapi-call-node/installer/src/assembly/assemble_installer_zip.xml new file mode 100644 index 000000000..e278872a1 --- /dev/null +++ b/restapi-call-node/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,59 @@ + + + + + + installer_zip + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + + + + diff --git a/restapi-call-node/installer/src/assembly/assemble_mvnrepo_zip.xml b/restapi-call-node/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100644 index 000000000..1edacdb6d --- /dev/null +++ b/restapi-call-node/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,49 @@ + + + + + + mvnrepo_zip + + zip + + + + false + + + + target/assembly/ + . + + + + + + + + diff --git a/restapi-call-node/installer/src/main/resources/scripts/install-feature.sh b/restapi-call-node/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..9a47d2225 --- /dev/null +++ b/restapi-call-node/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +### +# ============LICENSE_START======================================================= +# openECOMP : SDN-C +# ================================================================================ +# Copyright (C) 2017 ONAP 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========================================================= +### + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml new file mode 100755 index 000000000..86a27bb0d --- /dev/null +++ b/restapi-call-node/pom.xml @@ -0,0 +1,42 @@ + + + + org.onap.ccsdk.sli.plugins + sdnc-plugins + 0.0.1-SNAPSHOT + + + 4.0.0 + pom + + org.onap.ccsdk.sli.plugins + restapi-call-node + 0.0.1-SNAPSHOT + + RESTAPI Call Node + This is an implementation of DG Execute Node that makes a call to an external REST API + + + + + org.onap.ccsdk.sli.plugins + restapi-call-node-features + features + xml + ${project.version} + + + org.onap.ccsdk.sli.plugins + restapi-call-node-provider + ${project.version} + + + + + + provider + features + installer + + + diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml new file mode 100755 index 000000000..f864c2914 --- /dev/null +++ b/restapi-call-node/provider/pom.xml @@ -0,0 +1,101 @@ + + + 4.0.0 + + org.onap.ccsdk.sli.plugins + restapi-call-node + 0.0.1-SNAPSHOT + + org.onap.ccsdk.sli.plugins + restapi-call-node-provider + 0.0.1-SNAPSHOT + bundle + RESTAPI Call Node - Provider + http://maven.apache.org + + UTF-8 + + + + junit + junit + test + + + org.springframework + spring-test + ${spring.version} + test + + + org.onap.ccsdk.sli.core + sli-common + ${sdnctl.sli.version} + compile + + + org.onap.ccsdk.sli.core + sli-provider + ${sdnctl.sli.version} + compile + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + org.springframework + spring-beans + ${spring.version} + + + org.springframework + spring-context + ${spring.version} + + + com.sun.jersey + jersey-client + ${jersey.version} + provided + + + org.codehaus.jettison + jettison + ${jettison.version} + provided + + + + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + org.onap.ccsdk.sli.restapicall + org.openecomp.sdnc.restapicall + * + + + + + + + + + + + + diff --git a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/Format.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/Format.java new file mode 100644 index 000000000..52086255f --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/Format.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +public enum Format { + JSON, XML; + + public static Format fromString(String s) { + if (s == null) + return null; + if (s.equalsIgnoreCase("json")) + return JSON; + if (s.equalsIgnoreCase("xml")) + return XML; + throw new IllegalArgumentException("Invalid value for format: " + s); + } +} diff --git a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/HttpMethod.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/HttpMethod.java new file mode 100644 index 000000000..059074bf9 --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/HttpMethod.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +public enum HttpMethod { + GET, POST, PUT, DELETE, PATCH; + + public static HttpMethod fromString(String s) { + if (s == null) + return null; + if (s.equalsIgnoreCase("get")) + return GET; + if (s.equalsIgnoreCase("post")) + return POST; + if (s.equalsIgnoreCase("put")) + return PUT; + if (s.equalsIgnoreCase("delete")) + return DELETE; + if (s.equalsIgnoreCase("patch")) + return PATCH; + throw new IllegalArgumentException("Invalid value for HTTP Method: " + s); + } +} diff --git a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/HttpResponse.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/HttpResponse.java new file mode 100644 index 000000000..761e4264e --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/HttpResponse.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +import javax.ws.rs.core.MultivaluedMap; + +public class HttpResponse { + public int code; + public String message; + public String body; + public MultivaluedMap headers; +} diff --git a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/JsonParser.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/JsonParser.java new file mode 100644 index 000000000..27e9a82ef --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/JsonParser.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +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.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class JsonParser { + + private static final Logger log = LoggerFactory.getLogger(JsonParser.class); + + @SuppressWarnings("unchecked") + public static Map convertToProperties(String s) throws JSONException { + JSONObject json = new JSONObject(s); + + Map wm = new HashMap(); + Iterator ii = json.keys(); + while (ii.hasNext()) { + String key1 = ii.next(); + wm.put(key1, json.get(key1)); + } + + Map 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 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: " + key + "_length" + ": " + String.valueOf(ja.length())); + + for (int i = 0; i < ja.length(); i++) + wm.put(key + '[' + i + ']', ja.get(i)); + } + } + + return mm; + } +} diff --git a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/Parameters.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/Parameters.java new file mode 100644 index 000000000..0cba4e6b1 --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/Parameters.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +import java.util.Set; + +public class Parameters { + public String templateFileName; + public String restapiUrl; + public String restapiUser; + public String restapiPassword; + public Format format; + public String contentType; + public HttpMethod httpMethod; + public String responsePrefix; + public Set listNameList; + public boolean skipSending; + public boolean convertResponse; + public String keyStoreFileName; + public String keyStorePassword; + public String trustStoreFileName; + public String trustStorePassword; + public boolean ssl; + public String customHttpHeaders; + public String partner; + public Boolean dumpHeaders; +} diff --git a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RestapiCallNode.java new file mode 100644 index 000000000..b7598480c --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RestapiCallNode.java @@ -0,0 +1,759 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +import java.io.FileInputStream; +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.KeyStore; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.ws.rs.core.EntityTag; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.UriBuilder; + +import org.apache.commons.lang3.StringUtils; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.client.config.DefaultClientConfig; +import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; +import com.sun.jersey.client.urlconnection.HTTPSProperties; + +public class RestapiCallNode implements SvcLogicJavaPlugin { + + private static final Logger log = LoggerFactory.getLogger(RestapiCallNode.class); + + private String uebServers; + private String defaultUebTemplateFileName = "/opt/bvc/restapi/templates/default-ueb-message.json"; + protected RetryPolicyStore retryPolicyStore; + + protected RetryPolicyStore getRetryPolicyStore() { + return retryPolicyStore; + } + + public void setRetryPolicyStore(RetryPolicyStore retryPolicyStore) { + this.retryPolicyStore = retryPolicyStore; + } + + public RestapiCallNode() { + + } + + /** + * Allows Directed Graphs the ability to interact with REST APIs. + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + * + * + * + * vpn-information.vrf-details + * + * + * + * + * + * + *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/restapi/templates/vnf_service-configuration-operation_minimal.json
restapiUrlMandatoryurl to send the request tohttps://sdncodl:8543/restconf/operations/L3VNF-API:create-update-vnf-request
restapiUserOptionaluser name to use for http basic authenticationsdnc_ws
restapiPasswordOptionalunencrypted password to use for http basic authenticationplain_password
contentTypeOptionalhttp content type to set in the http headerusually application/json or application/xml
formatOptionalshould match request body formatjson or xml
httpMethodOptionalhttp method to use when sending the requestget post put delete patch
responsePrefixOptionallocation the response will be written to in context memorytmp.restapi.result
listName[i]OptionalUsed for processing XML responses with repeating elements.
skipSendingOptionaltrue or false
convertResponse Optionalwhether the response should be convertedtrue or false
customHttpHeadersOptionala list additional http headers to be passed in, follow the format in the exampleX-CSI-MessageId=messageId,headerFieldName=headerFieldValue
dumpHeadersOptionalwhen true writes http header content to context memorytrue or false
partnerOptionalneeded for DME2 callsdme2proxy
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + * @see String#split(String, int) + */ + public void sendRequest(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { + sendRequest(paramMap, ctx, null); + } + + public void sendRequest(Map paramMap, SvcLogicContext ctx, Integer retryCount) + throws SvcLogicException { + + RetryPolicy retryPolicy = null; + HttpResponse r = null; + try { + Parameters p = getParameters(paramMap); + if (p.partner != null) { + retryPolicy = retryPolicyStore.getRetryPolicy(p.partner); + } + String pp = p.responsePrefix != null ? p.responsePrefix + '.' : ""; + + String req = null; + if (p.templateFileName != null) { + String reqTemplate = readFile(p.templateFileName); + req = buildXmlJsonRequest(ctx, reqTemplate, p.format); + } + r = sendHttpRequest(req, p); + setResponseStatus(ctx, p.responsePrefix, r); + + if (p.dumpHeaders && r.headers != null) { + for (Entry> a : r.headers.entrySet()) { + ctx.setAttribute(pp + "header." + a.getKey(), StringUtils.join(a.getValue(), ",")); + } + } + + if (r.body != null && r.body.trim().length() > 0) { + ctx.setAttribute(pp + "httpResponse", r.body); + + if (p.convertResponse) { + Map mm = null; + if (p.format == Format.XML) + mm = XmlParser.convertToProperties(r.body, p.listNameList); + else if (p.format == Format.JSON) + mm = JsonParser.convertToProperties(r.body); + + if (mm != null) + for (String key : mm.keySet()) + ctx.setAttribute(pp + key, mm.get(key)); + } + } + } catch (Exception e) { + boolean shouldRetry = false; + if (e.getCause() instanceof java.net.SocketException) { + shouldRetry = true; + } + + log.error("Error sending the request: " + e.getMessage(), e); + String prefix = parseParam(paramMap, "responsePrefix", false, null); + if (retryPolicy == null || shouldRetry == false) { + setFailureResponseStatus(ctx, prefix, e.getMessage(), r); + } else { + if (retryCount == null) { + retryCount = 0; + } + String retryMessage = retryCount + " attempts were made out of " + retryPolicy.getMaximumRetries() + + " maximum retries."; + log.debug(retryMessage); + try { + retryCount = retryCount + 1; + if (retryCount < retryPolicy.getMaximumRetries() + 1) { + URI uri = new URI(paramMap.get("restapiUrl")); + String hostname = uri.getHost(); + String retryString = retryPolicy.getNextHostName((uri.toString())); + URI uriTwo = new URI(retryString); + URI retryUri = UriBuilder.fromUri(uri).host(uriTwo.getHost()).port(uriTwo.getPort()).scheme( + uriTwo.getScheme()).build(); + paramMap.put("restapiUrl", retryUri.toString()); + log.debug("URL was set to " + retryUri.toString()); + log.debug("Failed to communicate with host " + hostname + + ". Request will be re-attempted using the host " + retryString + "."); + log.debug("This is retry attempt " + retryCount + " out of " + retryPolicy.getMaximumRetries()); + sendRequest(paramMap, ctx, retryCount); + } else { + log.debug("Maximum retries reached, calling setFailureResponseStatus."); + setFailureResponseStatus(ctx, prefix, e.getMessage(), r); + } + } catch (Exception ex) { + log.error("Could not attempt retry.", ex); + String retryErrorMessage = + "Retry attempt has failed. No further retry shall be attempted, calling setFailureResponseStatus."; + setFailureResponseStatus(ctx, prefix, retryErrorMessage, r); + } + } + } + + if (r != null && r.code >= 300) + throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); + } + + protected Parameters getParameters(Map paramMap) throws SvcLogicException { + Parameters p = new Parameters(); + p.templateFileName = parseParam(paramMap, "templateFileName", false, null); + p.restapiUrl = parseParam(paramMap, "restapiUrl", true, null); + p.restapiUser = parseParam(paramMap, "restapiUser", false, null); + p.restapiPassword = parseParam(paramMap, "restapiPassword", false, null); + p.contentType = parseParam(paramMap, "contentType", false, null); + p.format = Format.fromString(parseParam(paramMap, "format", false, "json")); + p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post")); + p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); + p.listNameList = getListNameList(paramMap); + String skipSendingStr = paramMap.get("skipSending"); + p.skipSending = skipSendingStr != null && skipSendingStr.equalsIgnoreCase("true"); + p.convertResponse = Boolean.valueOf(parseParam(paramMap, "convertResponse", false, "true")); + p.trustStoreFileName = parseParam(paramMap, "trustStoreFileName", false, null); + p.trustStorePassword = parseParam(paramMap, "trustStorePassword", false, null); + p.keyStoreFileName = parseParam(paramMap, "keyStoreFileName", false, null); + p.keyStorePassword = parseParam(paramMap, "keyStorePassword", false, null); + p.ssl = p.trustStoreFileName != null && p.trustStorePassword != null && p.keyStoreFileName != null && + p.keyStorePassword != null; + p.customHttpHeaders = parseParam(paramMap, "customHttpHeaders", false, null); + p.partner = parseParam(paramMap, "partner", false, null); + p.dumpHeaders = Boolean.valueOf(parseParam(paramMap, "dumpHeaders", false, null)); + return p; + } + + protected Set getListNameList(Map paramMap) { + Set ll = new HashSet(); + for (String key : paramMap.keySet()) + if (key.startsWith("listName")) + ll.add(paramMap.get(key)); + return ll; + } + + protected String parseParam(Map paramMap, String name, boolean required, String def) + throws SvcLogicException { + String s = paramMap.get(name); + + if (s == null || s.trim().length() == 0) { + if (!required) + return def; + throw new SvcLogicException("Parameter " + name + " is required in RestapiCallNode"); + } + + s = s.trim(); + String value = ""; + int i = 0; + int i1 = s.indexOf('%'); + while (i1 >= 0) { + int i2 = s.indexOf('%', i1 + 1); + if (i2 < 0) + break; + + String varName = s.substring(i1 + 1, i2); + String varValue = System.getenv(varName); + if (varValue == null) + varValue = "%" + varName + "%"; + + value += s.substring(i, i1); + value += varValue; + + i = i2 + 1; + i1 = s.indexOf('%', i); + } + value += s.substring(i); + + log.info("Parameter " + name + ": [" + value + "]"); + return value; + } + + protected String buildXmlJsonRequest(SvcLogicContext ctx, String template, Format format) { + log.info("Building " + format + " started"); + long t1 = System.currentTimeMillis(); + + template = expandRepeats(ctx, template, 1); + + Map mm = new HashMap<>(); + for (String s : ctx.getAttributeKeySet()) + mm.put(s, ctx.getAttribute(s)); + + StringBuilder ss = new StringBuilder(); + int i = 0; + while (i < template.length()) { + int i1 = template.indexOf("${", i); + if (i1 < 0) { + ss.append(template.substring(i)); + break; + } + + int i2 = template.indexOf('}', i1 + 2); + if (i2 < 0) + throw new RuntimeException("Template error: Matching } not found"); + + String var1 = template.substring(i1 + 2, i2); + String value1 = format == Format.XML ? XmlJsonUtil.getXml(mm, var1) : XmlJsonUtil.getJson(mm, var1); + // log.info(" " + var1 + ": " + value1); + if (value1 == null || value1.trim().length() == 0) { + // delete the whole element (line) + int i3 = template.lastIndexOf('\n', i1); + if (i3 < 0) + i3 = 0; + int i4 = template.indexOf('\n', i1); + if (i4 < 0) + i4 = template.length(); + + if (i < i3) + ss.append(template.substring(i, i3)); + i = i4; + } else { + ss.append(template.substring(i, i1)).append(value1); + i = i2 + 1; + } + } + + String req = format == Format.XML + ? XmlJsonUtil.removeEmptyStructXml(ss.toString()) : XmlJsonUtil.removeEmptyStructJson(ss.toString()); + + if (format == Format.JSON) + req = XmlJsonUtil.removeLastCommaJson(req); + + long t2 = System.currentTimeMillis(); + log.info("Building " + format + " completed. Time: " + (t2 - t1)); + + return req; + } + + protected String expandRepeats(SvcLogicContext ctx, String template, int level) { + StringBuilder newTemplate = new StringBuilder(); + int k = 0; + while (k < template.length()) { + int i1 = template.indexOf("${repeat:", k); + if (i1 < 0) { + newTemplate.append(template.substring(k)); + break; + } + + int i2 = template.indexOf(':', i1 + 9); + if (i2 < 0) + throw new RuntimeException( + "Template error: Context variable name followed by : is required after repeat"); + + // Find the closing }, store in i3 + int nn = 1; + int i3 = -1; + int i = i2; + while (nn > 0 && i < template.length()) { + i3 = template.indexOf('}', i); + if (i3 < 0) + throw new RuntimeException("Template error: Matching } not found"); + int i32 = template.indexOf('{', i); + if (i32 >= 0 && i32 < i3) { + nn++; + i = i32 + 1; + } else { + nn--; + i = i3 + 1; + } + } + + String var1 = template.substring(i1 + 9, i2); + String value1 = ctx.getAttribute(var1); + log.info(" " + var1 + ": " + value1); + int n = 0; + try { + n = Integer.parseInt(value1); + } catch (Exception e) { + n = 0; + } + + newTemplate.append(template.substring(k, i1)); + + String rpt = template.substring(i2 + 1, i3); + + for (int ii = 0; ii < n; ii++) { + String ss = rpt.replaceAll("\\[\\$\\{" + level + "\\}\\]", "[" + ii + "]"); + if (ii == n - 1 && ss.trim().endsWith(",")) { + int i4 = ss.lastIndexOf(','); + if (i4 > 0) + ss = ss.substring(0, i4) + ss.substring(i4 + 1); + } + newTemplate.append(ss); + } + + k = i3 + 1; + } + + if (k == 0) + return newTemplate.toString(); + + return expandRepeats(ctx, newTemplate.toString(), level + 1); + } + + protected String readFile(String fileName) throws Exception { + byte[] encoded = Files.readAllBytes(Paths.get(fileName)); + return new String(encoded, "UTF-8"); + } + + protected HttpResponse sendHttpRequest(String request, Parameters p) throws Exception { + ClientConfig config = new DefaultClientConfig(); + SSLContext ssl = null; + if (p.ssl && p.restapiUrl.startsWith("https")) + ssl = createSSLContext(p); + if (ssl != null) { + HostnameVerifier hostnameVerifier = new HostnameVerifier() { + + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + }; + + config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, + new HTTPSProperties(hostnameVerifier, ssl)); + } + + logProperties(config.getProperties()); + + Client client = Client.create(config); + client.setConnectTimeout(5000); + if (p.restapiUser != null) + client.addFilter(new HTTPBasicAuthFilter(p.restapiUser, p.restapiPassword)); + WebResource webResource = client.resource(p.restapiUrl); + + log.info("Sending request:"); + log.info(request); + long t1 = System.currentTimeMillis(); + + HttpResponse r = new HttpResponse(); + r.code = 200; + + if (!p.skipSending) { + String tt = p.format == Format.XML ? "application/xml" : "application/json"; + String tt1 = tt + ";charset=UTF-8"; + if (p.contentType != null) { + tt = p.contentType; + tt1 = p.contentType; + } + + WebResource.Builder webResourceBuilder = webResource.accept(tt).type(tt1); + + if (p.customHttpHeaders != null && p.customHttpHeaders.length() > 0) { + String[] keyValuePairs = p.customHttpHeaders.split(","); + for (String singlePair : keyValuePairs) { + int equalPosition = singlePair.indexOf('='); + webResourceBuilder.header(singlePair.substring(0, equalPosition), singlePair.substring(equalPosition + 1, singlePair.length())); + } + } + + webResourceBuilder.header("X-ECOMP-RequestID",org.slf4j.MDC.get("X-ECOMP-RequestID")); + + ClientResponse response = webResourceBuilder.method(p.httpMethod.toString(), ClientResponse.class, request); + + r.code = response.getStatus(); + r.headers = response.getHeaders(); + EntityTag etag = response.getEntityTag(); + if (etag != null) + r.message = etag.getValue(); + if (response.hasEntity() && r.code != 204) + r.body = response.getEntity(String.class); + } + + long t2 = System.currentTimeMillis(); + log.info("Response received. Time: " + (t2 - t1)); + log.info("HTTP response code: " + r.code); + log.info("HTTP response message: " + r.message); + logHeaders(r.headers); + log.info("HTTP response: " + r.body); + + return r; + } + + protected SSLContext createSSLContext(Parameters p) { + try { + System.setProperty("jsse.enableSNIExtension", "false"); + System.setProperty("javax.net.ssl.trustStore", p.trustStoreFileName); + System.setProperty("javax.net.ssl.trustStorePassword", p.trustStorePassword); + + HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { + + @Override + public boolean verify(String string, SSLSession ssls) { + return true; + } + }); + + KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); + FileInputStream in = new FileInputStream(p.keyStoreFileName); + KeyStore ks = KeyStore.getInstance("PKCS12"); + char[] pwd = p.keyStorePassword.toCharArray(); + ks.load(in, pwd); + kmf.init(ks, pwd); + + SSLContext ctx = SSLContext.getInstance("TLS"); + ctx.init(kmf.getKeyManagers(), null, null); + return ctx; + } catch (Exception e) { + log.error("Error creating SSLContext: " + e.getMessage(), e); + } + return null; + } + + protected void setFailureResponseStatus(SvcLogicContext ctx, String prefix, String errorMessage, HttpResponse r) { + r = new HttpResponse(); + r.code = 500; + r.message = errorMessage; + String pp = prefix != null ? prefix + '.' : ""; + ctx.setAttribute(pp + "response-code", String.valueOf(r.code)); + ctx.setAttribute(pp + "response-message", r.message); + } + + protected void setResponseStatus(SvcLogicContext ctx, String prefix, HttpResponse r) { + String pp = prefix != null ? prefix + '.' : ""; + ctx.setAttribute(pp + "response-code", String.valueOf(r.code)); + ctx.setAttribute(pp + "response-message", r.message); + } + + public void sendFile(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { + HttpResponse r = null; + try { + FileParam p = getFileParameters(paramMap); + byte[] data = Files.readAllBytes(Paths.get(p.fileName)); + + r = sendHttpData(data, p); + setResponseStatus(ctx, p.responsePrefix, r); + + } catch (Exception e) { + log.error("Error sending the request: " + e.getMessage(), e); + + r = new HttpResponse(); + r.code = 500; + r.message = e.getMessage(); + String prefix = parseParam(paramMap, "responsePrefix", false, null); + setResponseStatus(ctx, prefix, r); + } + + if (r != null && r.code >= 300) + throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); + } + + private static class FileParam { + + public String fileName; + public String url; + public String user; + public String password; + public HttpMethod httpMethod; + public String responsePrefix; + public boolean skipSending; + } + + private FileParam getFileParameters(Map paramMap) throws SvcLogicException { + FileParam p = new FileParam(); + p.fileName = parseParam(paramMap, "fileName", true, null); + p.url = parseParam(paramMap, "url", true, null); + p.user = parseParam(paramMap, "user", false, null); + p.password = parseParam(paramMap, "password", false, null); + p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post")); + p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); + String skipSendingStr = paramMap.get("skipSending"); + p.skipSending = skipSendingStr != null && skipSendingStr.equalsIgnoreCase("true"); + return p; + } + + protected HttpResponse sendHttpData(byte[] data, FileParam p) { + Client client = Client.create(); + client.setConnectTimeout(5000); + client.setFollowRedirects(true); + if (p.user != null) + client.addFilter(new HTTPBasicAuthFilter(p.user, p.password)); + WebResource webResource = client.resource(p.url); + + log.info("Sending file"); + long t1 = System.currentTimeMillis(); + + HttpResponse r = new HttpResponse(); + r.code = 200; + + if (!p.skipSending) { + String tt = "application/octet-stream"; + + ClientResponse response = null; + if (p.httpMethod == HttpMethod.POST) + response = webResource.accept(tt).type(tt).post(ClientResponse.class, data); + else if (p.httpMethod == HttpMethod.PUT) + response = webResource.accept(tt).type(tt).put(ClientResponse.class, data); + + r.code = response.getStatus(); + r.headers = response.getHeaders(); + EntityTag etag = response.getEntityTag(); + if (etag != null) + r.message = etag.getValue(); + if (response.hasEntity() && r.code != 204) + r.body = response.getEntity(String.class); + + if (r.code == 301) { + String newUrl = response.getHeaders().getFirst("Location"); + + log.info("Got response code 301. Sending same request to URL: " + newUrl); + + webResource = client.resource(newUrl); + + if (p.httpMethod == HttpMethod.POST) + response = webResource.accept(tt).type(tt).post(ClientResponse.class, data); + else if (p.httpMethod == HttpMethod.PUT) + response = webResource.accept(tt).type(tt).put(ClientResponse.class, data); + + r.code = response.getStatus(); + etag = response.getEntityTag(); + if (etag != null) + r.message = etag.getValue(); + if (response.hasEntity() && r.code != 204) + r.body = response.getEntity(String.class); + } + } + + long t2 = System.currentTimeMillis(); + log.info("Response received. Time: " + (t2 - t1)); + log.info("HTTP response code: " + r.code); + log.info("HTTP response message: " + r.message); + logHeaders(r.headers); + log.info("HTTP response: " + r.body); + + return r; + } + + public void postMessageOnUeb(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { + HttpResponse r = null; + try { + UebParam p = getUebParameters(paramMap); + + String pp = p.responsePrefix != null ? p.responsePrefix + '.' : ""; + + String req = null; + + if (p.templateFileName == null) { + log.info("No template file name specified. Using default UEB template: " + defaultUebTemplateFileName); + p.templateFileName = defaultUebTemplateFileName; + } + + String reqTemplate = readFile(p.templateFileName); + reqTemplate = reqTemplate.replaceAll("rootVarName", p.rootVarName); + req = buildXmlJsonRequest(ctx, reqTemplate, Format.JSON); + + r = postOnUeb(req, p); + setResponseStatus(ctx, p.responsePrefix, r); + if (r.body != null) + ctx.setAttribute(pp + "httpResponse", r.body); + + } catch (Exception e) { + log.error("Error sending the request: " + e.getMessage(), e); + + r = new HttpResponse(); + r.code = 500; + r.message = e.getMessage(); + String prefix = parseParam(paramMap, "responsePrefix", false, null); + setResponseStatus(ctx, prefix, r); + } + + if (r != null && r.code >= 300) + throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); + } + + private static class UebParam { + + public String topic; + public String templateFileName; + public String rootVarName; + public String responsePrefix; + public boolean skipSending; + } + + private UebParam getUebParameters(Map paramMap) throws SvcLogicException { + UebParam p = new UebParam(); + p.topic = parseParam(paramMap, "topic", true, null); + p.templateFileName = parseParam(paramMap, "templateFileName", false, null); + p.rootVarName = parseParam(paramMap, "rootVarName", false, null); + p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); + String skipSendingStr = paramMap.get("skipSending"); + p.skipSending = skipSendingStr != null && skipSendingStr.equalsIgnoreCase("true"); + return p; + } + + protected HttpResponse postOnUeb(String request, UebParam p) throws Exception { + String[] urls = uebServers.split(" "); + for (int i = 0; i < urls.length; i++) { + if (!urls[i].endsWith("/")) + urls[i] += "/"; + urls[i] += "events/" + p.topic; + } + + Client client = Client.create(); + client.setConnectTimeout(5000); + WebResource webResource = client.resource(urls[0]); + + log.info("UEB URL: " + urls[0]); + log.info("Sending request:"); + log.info(request); + long t1 = System.currentTimeMillis(); + + HttpResponse r = new HttpResponse(); + r.code = 200; + + if (!p.skipSending) { + String tt = "application/json"; + String tt1 = tt + ";charset=UTF-8"; + + ClientResponse response = webResource.accept(tt).type(tt1).post(ClientResponse.class, request); + + r.code = response.getStatus(); + r.headers = response.getHeaders(); + if (response.hasEntity()) + r.body = response.getEntity(String.class); + } + + long t2 = System.currentTimeMillis(); + log.info("Response received. Time: " + (t2 - t1)); + log.info("HTTP response code: " + r.code); + logHeaders(r.headers); + log.info("HTTP response:\n" + r.body); + + return r; + } + + protected void logProperties(Map mm) { + List 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 + ": " + String.valueOf(mm.get(name))); + } + + protected void logHeaders(MultivaluedMap mm) { + log.info("HTTP response headers:"); + + if (mm == null) + return; + + List ll = new ArrayList<>(); + for (Object o : mm.keySet()) + ll.add((String) o); + Collections.sort(ll); + + for (String name : ll) + log.info("--- " + name + ": " + String.valueOf(mm.get(name))); + } + + public void setUebServers(String uebServers) { + this.uebServers = uebServers; + } + + public void setDefaultUebTemplateFileName(String defaultUebTemplateFileName) { + this.defaultUebTemplateFileName = defaultUebTemplateFileName; + } +} diff --git a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryException.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryException.java new file mode 100644 index 000000000..bf6ccc056 --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryException.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +public class RetryException extends Exception { + + public RetryException(String message) { + super(message); + } + +} diff --git a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryPolicy.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryPolicy.java new file mode 100644 index 000000000..2a27a1d02 --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryPolicy.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +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/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryPolicyStore.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryPolicyStore.java new file mode 100644 index 000000000..baf60d2e8 --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryPolicyStore.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +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 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/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/XmlJsonUtil.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/XmlJsonUtil.java new file mode 100644 index 000000000..66bf08b3d --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/XmlJsonUtil.java @@ -0,0 +1,372 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +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 class XmlJsonUtil { + + private static final Logger log = LoggerFactory.getLogger(XmlJsonUtil.class); + + public static String getXml(Map 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 varmap, String var) { + boolean escape = true; + if (var.startsWith("'")) { + var = var.substring(1); + escape = false; + } + + Object o = createStructure(varmap, var); + return generateJson(o, escape); + } + + private static Object createStructure(Map flatmap, String var) { + if (flatmap.containsKey(var)) { + if (var.endsWith("_length") || var.endsWith("].key")) + return null; + return flatmap.get(var); + } + + Map 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 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 " + var + "_length:" + lengthStr); + } + } + + 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 mm = (Map) o; + for (String k : mm.keySet()) { + Object v = mm.get(k); + if (v instanceof String) { + String s = escape ? escapeXml((String) v) : (String) v; + ss.append(pad(indent)).append('<').append(k).append('>'); + ss.append(s); + ss.append("').append('\n'); + } else if (v instanceof Map) { + ss.append(pad(indent)).append('<').append(k).append('>').append('\n'); + ss.append(generateXml(v, indent + 1, escape)); + ss.append(pad(indent)).append("').append('\n'); + } else if (v instanceof List) { + List ll = (List) v; + for (Object o1 : ll) { + ss.append(pad(indent)).append('<').append(k).append('>').append('\n'); + ss.append(generateXml(o1, indent + 1, escape)); + ss.append(pad(indent)).append("').append('\n'); + } + } + } + return ss.toString(); + } + + return null; + } + + private static String generateJson(Object o, boolean escape) { + if (o == null) + return null; + + StringBuilder ss = new StringBuilder(); + generateJson(ss, o, 0, false, escape); + return ss.toString(); + } + + @SuppressWarnings("unchecked") + private static void generateJson(StringBuilder ss, Object o, int indent, boolean padFirst, boolean escape) { + if (o instanceof String) { + String s = escape ? escapeJson((String) o) : (String) o; + if (padFirst) + ss.append(pad(indent)); + ss.append('"').append(s).append('"'); + return; + } + + if (o instanceof Map) { + Map mm = (Map) o; + + if (padFirst) + ss.append(pad(indent)); + ss.append("{\n"); + + boolean first = true; + for (String k : mm.keySet()) { + if (!first) + ss.append(",\n"); + first = false; + + Object v = mm.get(k); + ss.append(pad(indent + 1)).append('"').append(k).append("\": "); + generateJson(ss, v, indent + 1, false, escape); + } + + ss.append("\n"); + ss.append(pad(indent)).append('}'); + + return; + } + + if (o instanceof List) { + List ll = (List) 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); + } + + 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 = " 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("&", "&"); + s = s.replaceAll("<", "<"); + s = s.replaceAll("'", "'"); + s = s.replaceAll("\"", """); + s = s.replaceAll(">", ">"); + return s; + } + + private static String escapeJson(String v) { + String s = v.replaceAll("\\\\", "\\\\\\\\"); + s = s.replaceAll("\"", "\\\\\""); + return s; + } + + private static String pad(int n) { + String s = ""; + for (int i = 0; i < n; i++) + s += '\t'; + return s; + } +} diff --git a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/XmlParser.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/XmlParser.java new file mode 100644 index 000000000..e90a44fb8 --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/XmlParser.java @@ -0,0 +1,160 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +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 class XmlParser { + + private static final Logger log = LoggerFactory.getLogger(XmlParser.class); + + public static Map convertToProperties(String s, Set listNameList) { + 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 (Exception e) { + e.printStackTrace(); + } + + return handler.getProperties(); + } + + private static class Handler extends DefaultHandler { + + private Set listNameList; + + private Map properties = new HashMap<>(); + + public Map getProperties() { + return properties; + } + + public Handler(Set listNameList) { + super(); + this.listNameList = listNameList; + if (this.listNameList == null) + this.listNameList = new HashSet(); + } + + String currentName = ""; + String currentValue = ""; + + @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 += '.'; + currentName += name; + + String listName = removeIndexes(currentName); + + if (listNameList.contains(listName)) { + int len = getInt(properties, currentName + "_length"); + properties.put(currentName + "_length", String.valueOf(len + 1)); + currentName += "[" + len + "]"; + } + } + + @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); + + if (currentValue.trim().length() > 0) { + currentValue = currentValue.trim(); + properties.put(currentName, currentValue); + + log.info("Added property: " + currentName + ": " + currentValue); + + currentValue = ""; + } + + int i1 = currentName.lastIndexOf("." + name); + if (i1 <= 0) + currentName = ""; + else + currentName = 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 += value; + } + + private static int getInt(Map mm, String name) { + String s = mm.get(name); + if (s == null) + return 0; + return Integer.parseInt(s); + } + + private String removeIndexes(String currentName) { + String s = ""; + 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) + s += c; + } + return s; + } + } +} diff --git a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml new file mode 100644 index 000000000..a7b1a8923 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml @@ -0,0 +1,49 @@ + + + + + + + + + file:${SDNC_CONFIG_DIR}/ueb.properties + file:${SDNC_CONFIG_DIR}/dme2.properties + + + + + + + + + + + + + + + + + diff --git a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml new file mode 100644 index 000000000..09e3de783 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml @@ -0,0 +1,32 @@ + + + + + + + + diff --git a/restapi-call-node/provider/src/main/resources/default-ueb-message.json b/restapi-call-node/provider/src/main/resources/default-ueb-message.json new file mode 100644 index 000000000..4b1aa0386 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/default-ueb-message.json @@ -0,0 +1,32 @@ +/*- + * ============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========================================================= + */ + +{ + "event":{ + "header":{ + "eventSource":"sdn-c" + }, + "body": + +${rootVarName} + + } +} diff --git a/restapi-call-node/provider/src/main/resources/get-multicast-data.json b/restapi-call-node/provider/src/main/resources/get-multicast-data.json new file mode 100644 index 000000000..f6155ee32 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/get-multicast-data.json @@ -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========================================================= + */ + +{ + "input": { + "sdnc-request-header": { + "svc-request-id": ${connection-details-notification-input.configuration-response-common.svc-request-id}, + "svc-action": "updatemulticastvpn" + }, + "service-information": { + "service-type": "AVPN", + "service-instance-id": ${tmp.ete-vpn-key} + } + } +} + diff --git a/restapi-call-node/provider/src/main/resources/northbound-api-template.json b/restapi-call-node/provider/src/main/resources/northbound-api-template.json new file mode 100644 index 000000000..d48c41ce9 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/northbound-api-template.json @@ -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========================================================= + */ + +{ +"input": + { + "sdnc-request-header":{ + "svc-request-id": ${service-topology-operation-input.sdnc-request-header.svc-request-id}, + "svc-notification-url": ${service-topology-operation-input.sdnc-request-header.svc-notification-url} + }, + "request-information":{ + "request-id": ${service-topology-operation-input.request-information.request-id}, + "request-action": ${service-topology-operation-input.request-information.request-action}, + "request-sub-action": ${service-topology-operation-input.request-information.request-sub-action}, + "source": ${service-topology-operation-input.request-information.source}, + "notification-url": ${service-topology-operation-input.request-information.notification-url} + }, + "service-information":{ + "service-type": ${service-topology-operation-input.service-information.service-type}, + "service-instance-id": ${service-topology-operation-input.service-information.service-instance-id}, + "subscriber-name": ${service-topology-operation-input.service-information.subscriber-name}, + "subscriber-global-id": ${service-topology-operation-input.service-information.subscriber-global-id} + } +} + diff --git a/restapi-call-node/provider/src/main/resources/northbound-api-template.xml b/restapi-call-node/provider/src/main/resources/northbound-api-template.xml new file mode 100644 index 000000000..03530a729 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/northbound-api-template.xml @@ -0,0 +1,43 @@ + + + + <${northbound-Container}> + + ${service-topology-operation-input.request-information.notification-url} + ${service-topology-operation-input.request-information.request-action} + ${service-topology-operation-input.request-information.request-id} + ${service-topology-operation-input.request-information.request-sub-action} + ${service-topology-operation-input.request-information.source} + + + ${service-topology-operation-input.sdnc-request-header.svc-notification-url} + ${service-topology-operation-input.sdnc-request-header.svc-request-id} + + + ${service-topology-operation-input.service-information.service-instance-id} + ${service-topology-operation-input.service-information.service-type} + ${service-topology-operation-input.service-information.subscriber-global-id} + ${service-topology-operation-input.service-information.subscriber-name} + + ${'northbound-anyData} + + diff --git a/restapi-call-node/provider/src/main/resources/service-configuration-notification-northbound-template.json b/restapi-call-node/provider/src/main/resources/service-configuration-notification-northbound-template.json new file mode 100644 index 000000000..0cb7d0b06 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/service-configuration-notification-northbound-template.json @@ -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========================================================= + */ + +{ + "input": { + "svc-request-id": ${service-configuration-notification-input.svc-request-id}, + "response-code": ${service-configuration-notification-input.response-code}, + "response-message": ${service-configuration-notification-input.response-message}, + "ack-final-indicator": ${service-configuration-notification-input.ack-final-indicator}, + "service-information": { + "service-type": ${service-data.service-information.service-type}, + "service-instance-id": ${service-data.service-information.service-instance-id}, + "subscriber-name": ${service-data.service-information.subscriber-name}, + "subscriber-global-id": ${service-data.service-information.subscriber-global-id} + }, + "response-parameters": [ + ${repeat:service-configuration-notification-input.response-parameters_length: + { + "sequence-number": ${service-configuration-notification-input.response-parameters[${1}].sequence-number}, + "tag-name": ${service-configuration-notification-input.response-parameters[${1}].tag-name}, + "tag-value": ${service-configuration-notification-input.response-parameters[${1}].tag-value} + } + } + ] + } +} diff --git a/restapi-call-node/provider/src/main/resources/update-vpe-data-with-apply-group.json b/restapi-call-node/provider/src/main/resources/update-vpe-data-with-apply-group.json new file mode 100644 index 000000000..a82a6b4a6 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/update-vpe-data-with-apply-group.json @@ -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========================================================= + */ + +{ + "vrf-export-details": [ + ${repeat:restapi-result.ApplyGroupResponse.ApplyGroupResponseData[0].VrfDetails.VrfExport_length: + { + "vrf-export": ${restapi-result.ApplyGroupResponse.ApplyGroupResponseData[0].VrfDetails.VrfExport[${1}]} + } + } + ], + "vrf-import-details": [ + ${repeat:restapi-result.ApplyGroupResponse.ApplyGroupResponseData[0].VrfDetails.VrfImport_length: + { + "vrf-import": ${restapi-result.ApplyGroupResponse.ApplyGroupResponseData[0].VrfDetails.VrfImport[${1}]} + } + } + ], + "apply-group-template": [ + ${repeat:restapi-result.ApplyGroupResponse.ApplyGroupResponseData[0].VrfDetails.ApplyGroup_length: + { + "apply-group": ${restapi-result.ApplyGroupResponse.ApplyGroupResponseData[0].VrfDetails.ApplyGroup[${1}].ApplyGroup} + } + } + ], + "community-list": [ + ${repeat:restapi-result.ApplyGroupResponse.ApplyGroupResponseData[0].VrfDetails.CommunityList_length: + { + "member": ${restapi-result.ApplyGroupResponse.ApplyGroupResponseData[0].VrfDetails.CommunityList[${1}].member}, + "name": ${restapi-result.ApplyGroupResponse.ApplyGroupResponseData[0].VrfDetails.CommunityList[${1}].name} + } + } + ] +} + diff --git a/restapi-call-node/provider/src/main/resources/vnf-information-update.json b/restapi-call-node/provider/src/main/resources/vnf-information-update.json new file mode 100644 index 000000000..425f0f3d7 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/vnf-information-update.json @@ -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========================================================= + */ + +{ +"generic-vnf-service" :${vnf-service.generic-vnf-service} +} diff --git a/restapi-call-node/provider/src/main/resources/vpn-allocation-request.json b/restapi-call-node/provider/src/main/resources/vpn-allocation-request.json new file mode 100644 index 000000000..6c8427495 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/vpn-allocation-request.json @@ -0,0 +1,36 @@ +/*- + * ============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========================================================= + */ + +{ + "AllocateVpnResourcesRequest": { + "message-id": "${service-data.oper-status.modify-timestamp}", + "service-instance-id": "${service-data.service-information.service-instance-id}", + "vrf-request-type": { + "vpn-id": "${service-data.avpn-logicalchannel-information.vpn-id}", + "vpn-service": "${service-data.service-information.service-type}", + "e2e-vpn-id": "${service-data.avpn-logicalchannel-information.e2e-vpn-id}", + "vpe-name": "${service-data.avpn-logicalchannel-information.evc-endpoint-information.vpe-name}", + "asn": "${service-data.avpn-logicalchannel-information.carrier-asn}", + "route-group-name": "${service-data.avpn-logicalchannel-information.bgp-options.neighbor-address-information.route-group-name}", + "hub-or-spoke": "${service-data.avpn-logicalchannel-information.hub-or-spoke}" + } + } +} diff --git a/restapi-call-node/provider/src/main/resources/vpn-information-update.json b/restapi-call-node/provider/src/main/resources/vpn-information-update.json new file mode 100644 index 000000000..7977066bd --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/vpn-information-update.json @@ -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========================================================= + */ + +{ +"vpn-information" :${vpe-vpn-service.vpn-information} +} diff --git a/restapi-call-node/provider/src/main/resources/vrf-service-configuration-information-template.json b/restapi-call-node/provider/src/main/resources/vrf-service-configuration-information-template.json new file mode 100644 index 000000000..f7e843246 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/vrf-service-configuration-information-template.json @@ -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========================================================= + */ + +{ + "input": { + + "e2e-vpn-key": ${service-data.avpn-logicalchannel-information.e2e-vpn-id}, + "logical-channel-id": ${service-data.service-information.service-instance-id}, + "vpe-name": ${service-data.avpn-logicalchannel-information.evc-endpoint-information.vpe-name}, + "rpc-action": ${tmp.rpc-action}, + + "vpn-information": ${vpe-vpn-service.vpn-information}, + "vrf-details": ${vpe-vpn-service.vpn-information.vrf-details}, + "vrf-vlan-resources": { + "logical-channel-id": ${service-data.service-information.service-instance-id}, + "logical-channel-status": ${tmp.logical-channel-status} + } + } +} diff --git a/restapi-call-node/provider/src/main/resources/vrf-update-vlan-status-template.json b/restapi-call-node/provider/src/main/resources/vrf-update-vlan-status-template.json new file mode 100644 index 000000000..7a6cab35e --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/vrf-update-vlan-status-template.json @@ -0,0 +1,33 @@ +/*- + * ============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========================================================= + */ + +{ + "input": { + "e2e-vpn-key": ${service-data.avpn-logicalchannel-information.e2e-vpn-id}, + "logical-channel-id": ${service-data.service-information.service-instance-id}, + "vpe-name": ${service-data.avpn-logicalchannel-information.evc-endpoint-information.vpe-name}, + "rpc-action": ${tmp.rpc-action}, + "vrf-vlan-resources": { + "logical-channel-id": ${service-data.service-information.service-instance-id}, + "logical-channel-status": ${tmp.logical-channel-status} + } + } +} diff --git a/restapi-call-node/provider/src/main/resources/vrf-update.json b/restapi-call-node/provider/src/main/resources/vrf-update.json new file mode 100644 index 000000000..778e4b294 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/vrf-update.json @@ -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========================================================= + */ + +{ + "vpn-vame": ${allocate-vpn-resource-notification-input.vpn-data[0].vpn-name}, + "vpn-id": ${allocate-vpn-resource-notification-input.vpn-data[0].vpn-id}, + "vrf-details": [ + ${repeat:allocate-vpn-resource-notification-input.vpn-data[0].vrf-information_length: + { + "vrf-export-details": [ + ${repeat:allocate-vpn-resource-notification-input.vpn-data[0].vrf-information[${1}].vrf-export-details_length: + { + "vrf-export": ${allocate-vpn-resource-notification-input.vpn-data[0].vrf-information[${1}].vrf-export-details[${2}].vrf-export} + } + } + ], + "vrf-name": ${allocate-vpn-resource-notification-input.vpn-data[0].vrf-information[${1}].vrf-name}, + "vpe-name": ${allocate-vpn-resource-notification-input.vpn-data[0].vrf-information[${1}].vpe-name}, + "vrf-import-details": [ + ${repeat:allocate-vpn-resource-notification-input.vpn-data[0].vrf-information[${1}].vrf-import-details_length: + { + "vrf-import": ${allocate-vpn-resource-notification-input.vpn-data[0].vrf-information[${1}].vrf-import-details[${2}].vrf-import} + } + } + ], + "apply-group-template": [ + ${repeat:allocate-vpn-resource-notification-input.vpn-data[0].vrf-information[${1}].apply-group-template_length: + { + "apply-group": ${allocate-vpn-resource-notification-input.vpn-data[0].vrf-information[${1}].apply-group-template[${2}].apply-group} + } + } + ], + "community-list": [ + ${repeat:allocate-vpn-resource-notification-input.vpn-data[0].vrf-information[${1}].community-list_length: + { + "member": ${allocate-vpn-resource-notification-input.vpn-data[0].vrf-information[${1}].community-list[${2}].name}, + "name": ${allocate-vpn-resource-notification-input.vpn-data[0].vrf-information[${1}].community-list[${2}].member} + } + } + ], + "router-distinguisher": ${allocate-vpn-resource-notification-input.vpn-data[0].vrf-information[${1}].router-distinguisher} + } + } + ], + "spoke-routes": { + "route-target": ${allocate-vpn-resource-notification-input.vpn-data[0].spoke-route-target.route-target} + }, + + "route-target-details": [ + ${repeat:allocate-vpn-resource-notification-input.vpn-data[0].route-target-details_length: + { + "route-target": ${allocate-vpn-resource-notification-input.vpn-data[0].route-target-details[${1}].route-target}, + "route-target-type": ${allocate-vpn-resource-notification-input.vpn-data[0].route-target-details[${1}].route-target-type} + } + } + ], + + "e2e-vpn-key": ${allocate-vpn-resource-notification-input.vpn-data[0].e2e-vpn-id} +} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestJsonParser.java b/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestJsonParser.java new file mode 100644 index 000000000..16fa68594 --- /dev/null +++ b/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestJsonParser.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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 jtest.org.openecomp.sdnc.restapicall; + +import java.io.BufferedReader; +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.openecomp.sdnc.restapicall.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 Exception { + BufferedReader in = new BufferedReader(new InputStreamReader(ClassLoader.getSystemResourceAsStream("test.json"))); + String ss = ""; + String line = null; + while ((line = in.readLine()) != null) + ss += line + '\n'; + + Map mm = JsonParser.convertToProperties(ss); + + logProperties(mm); + + in.close(); + } + + private void logProperties(Map mm) { + List 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/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestRestapiCallNode.java new file mode 100644 index 000000000..e0e58ad50 --- /dev/null +++ b/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestRestapiCallNode.java @@ -0,0 +1,92 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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 jtest.org.openecomp.sdnc.restapicall; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.openecomp.sdnc.restapicall.RestapiCallNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestRestapiCallNode { + + private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class); + + + @Test + public void testDelete() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "pwd1"); + p.put("httpMethod", "delete"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testJsonTemplate() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "3"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].clci", "clci"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].clci", "clci"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } +} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestXmlJsonUtil.java b/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestXmlJsonUtil.java new file mode 100644 index 000000000..dbcf98a98 --- /dev/null +++ b/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestXmlJsonUtil.java @@ -0,0 +1,215 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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 jtest.org.openecomp.sdnc.restapicall; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.sdnc.restapicall.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 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); + } + + @Test + public void testRemoveEmptyStructXml() { + String xmlin = "" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " blah\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " blah blah\n" + + "\n"; + + String xmloutexpected = "" + + "\n" + + " \n" + + " blah\n" + + " \n" + + " blah blah\n" + + "\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/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestXmlParser.java b/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestXmlParser.java new file mode 100644 index 000000000..980eded4e --- /dev/null +++ b/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestXmlParser.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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 jtest.org.openecomp.sdnc.restapicall; + +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.openecomp.sdnc.restapicall.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"))); + String ss = ""; + String line = null; + while ((line = in.readLine()) != null) + ss += line + '\n'; + + Set listNameList = new HashSet(); + 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 mm = XmlParser.convertToProperties(ss, listNameList); + + logProperties(mm); + + in.close(); + } + + private void logProperties(Map mm) { + List 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/restapi-call-node/provider/src/test/resources/test-template.json b/restapi-call-node/provider/src/test/resources/test-template.json new file mode 100644 index 000000000..4adc6637a --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/test-template.json @@ -0,0 +1,57 @@ +/*- + * ============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========================================================= + */ + +{ + "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/restapi-call-node/provider/src/test/resources/test.json b/restapi-call-node/provider/src/test/resources/test.json new file mode 100644 index 000000000..885e66028 --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/test.json @@ -0,0 +1,48 @@ +/*- + * ============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========================================================= + */ + +{ + "equipment-data": [ + { + "server-count": "4", + "max-server-speed": "1600000", + "number-primary-servers": "2", + "equipment-id": "Server1", + "server-model": "Unknown", + "server-id": "Server1" + } + ], + "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/restapi-call-node/provider/src/test/resources/test.xml b/restapi-call-node/provider/src/test/resources/test.xml new file mode 100644 index 000000000..76205ddec --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/test.xml @@ -0,0 +1,172 @@ + + + + + 4.0.0 + + org.openecomp.sdnctl + restapi-call-node + 6.0.0-SNAPSHOT + + restapi-call-node-provider + bundle + RESTAPI Call Node - Provider + http://maven.apache.org + + UTF-8 + + + + junit + junit + test + + + org.springframework + spring-test + 3.1.4.RELEASE + test + + + org.openecomp.sdnctl + sli-common + compile + + + org.openecomp.sdnctl + sli-provider + compile + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + org.springframework + spring-beans + 3.1.4.RELEASE + + + org.springframework + spring-context + 3.1.4.RELEASE + + + xerces + xerces + 2.4.0 + provided + + + com.sun.jersey + jersey-client + 1.17 + + + commons-codec + commons-codec + + + + + + + com.brocade.developer + providermodule-plugin + + org.openecomp.sdnctl + restapi-call-node + + + + process-sources + + process + + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + org.openecomp.sdnc.restapicall + org.openecomp.sdnc.restapicall + * + + + ${project.basedir}/src/main/resources/META-INF + + + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + com.brocade.developer + + + providermodule-plugin + + + [1.2.0.100-SNAPSHOT,) + + + process + + + + + + + + + + + + + + diff --git a/restapi-call-node/provider/src/test/resources/test3.xml b/restapi-call-node/provider/src/test/resources/test3.xml new file mode 100644 index 000000000..2bf3be356 --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/test3.xml @@ -0,0 +1,82 @@ + + + + + + ICOREPVC-81114561 + + VPNL811182 + 811182 + 21302:811182 + SET_BVOIP_IN + SET6_BVOIP_IN + SET6_DSU + SET_DSU + SET6_MANAGED + SET_MANAGED + SET_LOVRF_COMMUNITY + SET_RESET_LP + + AG_MAX_MCASTROUTES + + + + BGP4_PROTOCOL + v4 + gp_21302:811182 + + AG_L3VPN_EBGP + + + AG_MAX_PREFIX + + + AG_BGP_UNMANAGED + + + AG_BFD_BGP_3000 + + + + BGP4_PROTOCOL + v6 + gp6_21302:811182 + + AG6_L3VPN_EBGP + + + AG6_MAX_PREFIX + + + AG6_BGP_UNMANAGED + + + AG6_BFD_BGP_3000 + + + + 200 + Success + Y + + diff --git a/version.properties b/version.properties new file mode 100644 index 000000000..256546630 --- /dev/null +++ b/version.properties @@ -0,0 +1,16 @@ +########################################################### +# Versioning variables +# Note that these variables cannot be structured (e.g. : version.release or version.snapshot etc... ) +# because they are used in Jenkins, whose plug-in doesn't support + +# Comment + +release_name=1 +sprint_number=1 +feature_revision=2 + +base_version=${release_name}.${sprint_number}.${feature_revision} + +release_version=${base_version} +snapshot_version=${base_version}-SNAPSHOT + -- cgit From 4515ffa52bc89b1bf40c791749fe518930441d82 Mon Sep 17 00:00:00 2001 From: "Stilwell, David (stilwelld)" Date: Thu, 10 Aug 2017 00:50:12 +0000 Subject: Refactor plugins to org onap ccsdk Refactor code to use new package name org.onap.ccsdk.sli.plugins Change-Id: Ia5399b21e95d556890aef5ad27437f1ac120ef8d Issue-ID: CCSDK-21 Signed-off-by: Stilwell, David (stilwelld) --- example-settings.xml | 28 +- jenkins-settings.xml | 28 +- pom.xml | 20 +- .../features/src/main/resources/features.xml | 2 +- .../ccsdk/sli/plugins/prop/PropertiesNode.java | 97 +++ .../org/openecomp/sdnc/prop/PropertiesNode.java | 97 --- .../META-INF/spring/properties-node-context.xml | 2 +- .../spring/properties-node-osgi-context.xml | 2 +- .../features/src/main/resources/features.xml | 2 +- restapi-call-node/provider/pom.xml | 2 +- .../onap/ccsdk/sli/plugins/restapicall/Format.java | 36 + .../ccsdk/sli/plugins/restapicall/HttpMethod.java | 42 ++ .../sli/plugins/restapicall/HttpResponse.java | 31 + .../ccsdk/sli/plugins/restapicall/JsonParser.java | 85 +++ .../ccsdk/sli/plugins/restapicall/Parameters.java | 46 ++ .../sli/plugins/restapicall/RestapiCallNode.java | 759 +++++++++++++++++++++ .../sli/plugins/restapicall/RetryException.java | 30 + .../ccsdk/sli/plugins/restapicall/RetryPolicy.java | 59 ++ .../sli/plugins/restapicall/RetryPolicyStore.java | 54 ++ .../ccsdk/sli/plugins/restapicall/XmlJsonUtil.java | 372 ++++++++++ .../ccsdk/sli/plugins/restapicall/XmlParser.java | 160 +++++ .../org/openecomp/sdnc/restapicall/Format.java | 36 - .../org/openecomp/sdnc/restapicall/HttpMethod.java | 42 -- .../openecomp/sdnc/restapicall/HttpResponse.java | 31 - .../org/openecomp/sdnc/restapicall/JsonParser.java | 85 --- .../org/openecomp/sdnc/restapicall/Parameters.java | 46 -- .../sdnc/restapicall/RestapiCallNode.java | 759 --------------------- .../openecomp/sdnc/restapicall/RetryException.java | 30 - .../openecomp/sdnc/restapicall/RetryPolicy.java | 59 -- .../sdnc/restapicall/RetryPolicyStore.java | 54 -- .../openecomp/sdnc/restapicall/XmlJsonUtil.java | 372 ---------- .../org/openecomp/sdnc/restapicall/XmlParser.java | 160 ----- .../META-INF/spring/restapi-call-node-context.xml | 4 +- .../spring/restapi-call-node-osgi-context.xml | 2 +- .../sli/plugins/restapicall/TestJsonParser.java | 65 ++ .../plugins/restapicall/TestRestapiCallNode.java | 92 +++ .../sli/plugins/restapicall/TestXmlJsonUtil.java | 215 ++++++ .../sli/plugins/restapicall/TestXmlParser.java | 75 ++ .../openecomp/sdnc/restapicall/TestJsonParser.java | 65 -- .../sdnc/restapicall/TestRestapiCallNode.java | 92 --- .../sdnc/restapicall/TestXmlJsonUtil.java | 215 ------ .../openecomp/sdnc/restapicall/TestXmlParser.java | 75 -- .../provider/src/test/resources/test.xml | 12 +- .../provider/src/test/resources/test3.xml | 4 +- 44 files changed, 2272 insertions(+), 2272 deletions(-) create mode 100644 properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java delete mode 100644 properties-node/provider/src/main/java/org/openecomp/sdnc/prop/PropertiesNode.java create mode 100644 restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java create mode 100644 restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpMethod.java create mode 100644 restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpResponse.java create mode 100644 restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java create mode 100644 restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java create mode 100644 restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java create mode 100644 restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryException.java create mode 100644 restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java create mode 100644 restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java create mode 100644 restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java create mode 100644 restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java delete mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/Format.java delete mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/HttpMethod.java delete mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/HttpResponse.java delete mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/JsonParser.java delete mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/Parameters.java delete mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RestapiCallNode.java delete mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryException.java delete mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryPolicy.java delete mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryPolicyStore.java delete mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/XmlJsonUtil.java delete mode 100644 restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/XmlParser.java create mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java create mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java create mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java create mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java delete mode 100644 restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestJsonParser.java delete mode 100644 restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestRestapiCallNode.java delete mode 100644 restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestXmlJsonUtil.java delete mode 100644 restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestXmlParser.java diff --git a/example-settings.xml b/example-settings.xml index 2e7ce6445..06c84eb6d 100644 --- a/example-settings.xml +++ b/example-settings.xml @@ -13,11 +13,11 @@ - openecomp-release + onap-release - openecomp-release - openecomp-release + onap-release + onap-release https://ecomp-nexus:8443/repository/maven-releases/ true @@ -30,8 +30,8 @@ - openecomp-release - openecomp-release + onap-release + onap-release https://ecomp-nexus:8443/repository/maven-releases/ true @@ -45,11 +45,11 @@ - openecomp-snapshots + onap-snapshots - openecomp-snapshot - openecomp-snapshot + onap-snapshot + onap-snapshot https://ecomp-nexus:8443/repository/maven-snapshots/ false @@ -61,8 +61,8 @@ - openecomp-snapshot - openecomp-snapshot + onap-snapshot + onap-snapshot https://ecomp-nexus:8443/repository/maven-snapshots/ false @@ -137,8 +137,8 @@ - openecomp-release - openecomp-snapshots + onap-release + onap-snapshots opendaylight-release opendaylight-snapshots @@ -150,12 +150,12 @@ PASSWORD - openecomp-release + onap-release USERNAME PASSWORD - openecomp-snapshot + onap-snapshot USERNAME PASSWORD diff --git a/jenkins-settings.xml b/jenkins-settings.xml index 344994f85..88f9805f1 100644 --- a/jenkins-settings.xml +++ b/jenkins-settings.xml @@ -13,11 +13,11 @@ - openecomp-release + onap-release - openecomp-release - openecomp-release + onap-release + onap-release https://ecomp-nexus:8443/repository/maven-releases/ true @@ -30,8 +30,8 @@ - openecomp-release - openecomp-release + onap-release + onap-release https://ecomp-nexus:8443/repository/maven-releases/ true @@ -45,11 +45,11 @@ - openecomp-snapshots + onap-snapshots - openecomp-snapshot - openecomp-snapshot + onap-snapshot + onap-snapshot https://ecomp-nexus:8443/repository/maven-snapshots/ false @@ -61,8 +61,8 @@ - openecomp-snapshot - openecomp-snapshot + onap-snapshot + onap-snapshot https://ecomp-nexus:8443/repository/maven-snapshots/ false @@ -137,8 +137,8 @@ - openecomp-release - openecomp-snapshots + onap-release + onap-snapshots opendaylight-release opendaylight-snapshots @@ -150,12 +150,12 @@ ${ecomp.nexus.password} - openecomp-release + onap-release ${ecomp.nexus.user} ${ecomp.nexus.password} - openecomp-snapshot + onap-snapshot ${ecomp.nexus.user} ${ecomp.nexus.password} diff --git a/pom.xml b/pom.xml index 96436f7ef..215f173fd 100755 --- a/pom.xml +++ b/pom.xml @@ -14,33 +14,33 @@ sdnc-plugins SDN-C Java Plugins - https://wiki.openecomp.org + https://wiki.onap.org The SDN-C core components contains the SLI, dblib and root pom JIRA - https://jira.openecomp.org/ + https://jira.onap.org/ - scm:git:ssh://git@${openecomp.git.host}/sdnc-plugins.git - scm:git:ssh://${openecomp.git.host}:${openecomp.git.port}/${openecomp.git.project}/sdnc-iplugins.git - ${openecomp.git.protocol}://${openecomp.git.host}/projects/${openecomp.git.project}/repos/sdnc-plugins/browse + scm:git:ssh://git@${onap.git.host}/ccsdk/sli/plugins.git + scm:git:ssh://${onap.git.host}:${onap.git.port}/${onap.git.project}/ccsdk/sli/plugins.git + ${onap.git.protocol}://${onap.git.host}/projects/${onap.git.project}/repos/ccsdk/sli/plugins/browse HEAD Jenkins - https://jenkins.openecomp.org + https://jenkins.onap.org sdnc-javadoc - dav:https://${openecomp.nexus.host}/content/sites/site/org/onap/sdnc/plugins/${project.artifactId}/${project.version} + dav:https://${onap.nexus.host}/content/sites/site/org/onap/sdnc/plugins/${project.artifactId}/${project.version} @@ -97,9 +97,9 @@ 1.6.7 true - https://${openecomp.nexus.host} - ${openecomp.nexus.staging.profile-id} - ${openecomp.nexus.staging.server-id} + https://${onap.nexus.host} + ${onap.nexus.staging.profile-id} + ${onap.nexus.staging.server-id} diff --git a/properties-node/features/src/main/resources/features.xml b/properties-node/features/src/main/resources/features.xml index e89b333e9..2ed98a124 100644 --- a/properties-node/features/src/main/resources/features.xml +++ b/properties-node/features/src/main/resources/features.xml @@ -32,7 +32,7 @@ sdnc-sli spring spring-dm - mvn:org.openecomp.sdnc.plugins/properties-node-provider/${project.version} + mvn:org.onap.ccsdk.sli.plugins/properties-node-provider/${project.version} diff --git a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java new file mode 100644 index 000000000..aa5663066 --- /dev/null +++ b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.prop; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Map; +import java.util.Properties; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class PropertiesNode implements SvcLogicJavaPlugin { + + private static final Logger log = LoggerFactory.getLogger(PropertiesNode.class); + + public void readProperties(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { + String fileName = parseParam(paramMap, "fileName", true, null); + String contextPrefix = parseParam(paramMap, "contextPrefix", false, null); + + try { + Properties pp = new Properties(); + InputStream in = new FileInputStream(fileName); + pp.load(in); + for (Object key : pp.keySet()) { + String pfx = contextPrefix != null ? contextPrefix + '.' : ""; + String name = (String) key; + String value = pp.getProperty(name); + if (value != null && value.trim().length() > 0) { + ctx.setAttribute(pfx + name, value.trim()); + log.info("+++ " + pfx + name + ": [" + value + "]"); + } + } + } catch (IOException e) { + throw new SvcLogicException("Cannot read property file: " + fileName + ": " + e.getMessage(), e); + } + } + + private String parseParam(Map paramMap, String name, boolean required, String def) + throws SvcLogicException { + String s = paramMap.get(name); + + if (s == null || s.trim().length() == 0) { + if (!required) + return def; + throw new SvcLogicException("Parameter " + name + " is required in PropertiesNode"); + } + + s = s.trim(); + String value = ""; + int i = 0; + int i1 = s.indexOf('%'); + while (i1 >= 0) { + int i2 = s.indexOf('%', i1 + 1); + if (i2 < 0) + throw new SvcLogicException("Cannot parse parameter " + name + ": " + s + ": no matching %"); + + String varName = s.substring(i1 + 1, i2); + String varValue = System.getenv(varName); + if (varValue == null) + varValue = ""; + + value += s.substring(i, i1); + value += varValue; + + i = i2 + 1; + i1 = s.indexOf('%', i); + } + value += s.substring(i); + + log.info("Parameter " + name + ": " + value); + return value; + } +} diff --git a/properties-node/provider/src/main/java/org/openecomp/sdnc/prop/PropertiesNode.java b/properties-node/provider/src/main/java/org/openecomp/sdnc/prop/PropertiesNode.java deleted file mode 100644 index 9856b1948..000000000 --- a/properties-node/provider/src/main/java/org/openecomp/sdnc/prop/PropertiesNode.java +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 ONAP 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.prop; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Map; -import java.util.Properties; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class PropertiesNode implements SvcLogicJavaPlugin { - - private static final Logger log = LoggerFactory.getLogger(PropertiesNode.class); - - public void readProperties(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { - String fileName = parseParam(paramMap, "fileName", true, null); - String contextPrefix = parseParam(paramMap, "contextPrefix", false, null); - - try { - Properties pp = new Properties(); - InputStream in = new FileInputStream(fileName); - pp.load(in); - for (Object key : pp.keySet()) { - String pfx = contextPrefix != null ? contextPrefix + '.' : ""; - String name = (String) key; - String value = pp.getProperty(name); - if (value != null && value.trim().length() > 0) { - ctx.setAttribute(pfx + name, value.trim()); - log.info("+++ " + pfx + name + ": [" + value + "]"); - } - } - } catch (IOException e) { - throw new SvcLogicException("Cannot read property file: " + fileName + ": " + e.getMessage(), e); - } - } - - private String parseParam(Map paramMap, String name, boolean required, String def) - throws SvcLogicException { - String s = paramMap.get(name); - - if (s == null || s.trim().length() == 0) { - if (!required) - return def; - throw new SvcLogicException("Parameter " + name + " is required in PropertiesNode"); - } - - s = s.trim(); - String value = ""; - int i = 0; - int i1 = s.indexOf('%'); - while (i1 >= 0) { - int i2 = s.indexOf('%', i1 + 1); - if (i2 < 0) - throw new SvcLogicException("Cannot parse parameter " + name + ": " + s + ": no matching %"); - - String varName = s.substring(i1 + 1, i2); - String varValue = System.getenv(varName); - if (varValue == null) - varValue = ""; - - value += s.substring(i, i1); - value += varValue; - - i = i2 + 1; - i1 = s.indexOf('%', i); - } - value += s.substring(i); - - log.info("Parameter " + name + ": " + value); - return value; - } -} diff --git a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml index a53ea1414..048acc4aa 100644 --- a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml +++ b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml @@ -26,7 +26,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - + diff --git a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml index 7d74fd4f0..ce17a4611 100644 --- a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml +++ b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml @@ -27,6 +27,6 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - + diff --git a/restapi-call-node/features/src/main/resources/features.xml b/restapi-call-node/features/src/main/resources/features.xml index 648e6f78f..dbbe1b1c1 100644 --- a/restapi-call-node/features/src/main/resources/features.xml +++ b/restapi-call-node/features/src/main/resources/features.xml @@ -34,7 +34,7 @@ spring-dm mvn:com.sun.jersey/jersey-client/${jersey.version} mvn:org.codehaus.jettison/jettison/${jettison.version} - mvn:org.openecomp.sdnc.plugins/restapi-call-node-provider/${project.version} + mvn:org.onap.ccsdk.sli.plugins/restapi-call-node-provider/${project.version} diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index f864c2914..4b328d3d0 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -85,7 +85,7 @@ org.onap.ccsdk.sli.restapicall - org.openecomp.sdnc.restapicall + org.onap.ccsdk.sli.plugins.restapicall * diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java new file mode 100644 index 000000000..249378a06 --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +public enum Format { + JSON, XML; + + public static Format fromString(String s) { + if (s == null) + return null; + if (s.equalsIgnoreCase("json")) + return JSON; + if (s.equalsIgnoreCase("xml")) + return XML; + throw new IllegalArgumentException("Invalid value for format: " + s); + } +} diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpMethod.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpMethod.java new file mode 100644 index 000000000..e991a72b3 --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpMethod.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +public enum HttpMethod { + GET, POST, PUT, DELETE, PATCH; + + public static HttpMethod fromString(String s) { + if (s == null) + return null; + if (s.equalsIgnoreCase("get")) + return GET; + if (s.equalsIgnoreCase("post")) + return POST; + if (s.equalsIgnoreCase("put")) + return PUT; + if (s.equalsIgnoreCase("delete")) + return DELETE; + if (s.equalsIgnoreCase("patch")) + return PATCH; + throw new IllegalArgumentException("Invalid value for HTTP Method: " + s); + } +} diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpResponse.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpResponse.java new file mode 100644 index 000000000..9fe449c75 --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpResponse.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +import javax.ws.rs.core.MultivaluedMap; + +public class HttpResponse { + public int code; + public String message; + public String body; + public MultivaluedMap headers; +} diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java new file mode 100644 index 000000000..2a9716079 --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +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.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class JsonParser { + + private static final Logger log = LoggerFactory.getLogger(JsonParser.class); + + @SuppressWarnings("unchecked") + public static Map convertToProperties(String s) throws JSONException { + JSONObject json = new JSONObject(s); + + Map wm = new HashMap(); + Iterator ii = json.keys(); + while (ii.hasNext()) { + String key1 = ii.next(); + wm.put(key1, json.get(key1)); + } + + Map 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 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: " + key + "_length" + ": " + String.valueOf(ja.length())); + + for (int i = 0; i < ja.length(); i++) + wm.put(key + '[' + i + ']', ja.get(i)); + } + } + + return mm; + } +} diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java new file mode 100644 index 000000000..8d1335cc5 --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +import java.util.Set; + +public class Parameters { + public String templateFileName; + public String restapiUrl; + public String restapiUser; + public String restapiPassword; + public Format format; + public String contentType; + public HttpMethod httpMethod; + public String responsePrefix; + public Set listNameList; + public boolean skipSending; + public boolean convertResponse; + public String keyStoreFileName; + public String keyStorePassword; + public String trustStoreFileName; + public String trustStorePassword; + public boolean ssl; + public String customHttpHeaders; + public String partner; + public Boolean dumpHeaders; +} diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java new file mode 100644 index 000000000..9de11fb0a --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -0,0 +1,759 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +import java.io.FileInputStream; +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.KeyStore; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.ws.rs.core.EntityTag; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.UriBuilder; + +import org.apache.commons.lang3.StringUtils; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.client.config.DefaultClientConfig; +import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; +import com.sun.jersey.client.urlconnection.HTTPSProperties; + +public class RestapiCallNode implements SvcLogicJavaPlugin { + + private static final Logger log = LoggerFactory.getLogger(RestapiCallNode.class); + + private String uebServers; + private String defaultUebTemplateFileName = "/opt/bvc/restapi/templates/default-ueb-message.json"; + protected RetryPolicyStore retryPolicyStore; + + protected RetryPolicyStore getRetryPolicyStore() { + return retryPolicyStore; + } + + public void setRetryPolicyStore(RetryPolicyStore retryPolicyStore) { + this.retryPolicyStore = retryPolicyStore; + } + + public RestapiCallNode() { + + } + + /** + * Allows Directed Graphs the ability to interact with REST APIs. + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + * + * + * + * vpn-information.vrf-details + * + * + * + * + * + * + *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/restapi/templates/vnf_service-configuration-operation_minimal.json
restapiUrlMandatoryurl to send the request tohttps://sdncodl:8543/restconf/operations/L3VNF-API:create-update-vnf-request
restapiUserOptionaluser name to use for http basic authenticationsdnc_ws
restapiPasswordOptionalunencrypted password to use for http basic authenticationplain_password
contentTypeOptionalhttp content type to set in the http headerusually application/json or application/xml
formatOptionalshould match request body formatjson or xml
httpMethodOptionalhttp method to use when sending the requestget post put delete patch
responsePrefixOptionallocation the response will be written to in context memorytmp.restapi.result
listName[i]OptionalUsed for processing XML responses with repeating elements.
skipSendingOptionaltrue or false
convertResponse Optionalwhether the response should be convertedtrue or false
customHttpHeadersOptionala list additional http headers to be passed in, follow the format in the exampleX-CSI-MessageId=messageId,headerFieldName=headerFieldValue
dumpHeadersOptionalwhen true writes http header content to context memorytrue or false
partnerOptionalneeded for DME2 callsdme2proxy
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + * @see String#split(String, int) + */ + public void sendRequest(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { + sendRequest(paramMap, ctx, null); + } + + public void sendRequest(Map paramMap, SvcLogicContext ctx, Integer retryCount) + throws SvcLogicException { + + RetryPolicy retryPolicy = null; + HttpResponse r = null; + try { + Parameters p = getParameters(paramMap); + if (p.partner != null) { + retryPolicy = retryPolicyStore.getRetryPolicy(p.partner); + } + String pp = p.responsePrefix != null ? p.responsePrefix + '.' : ""; + + String req = null; + if (p.templateFileName != null) { + String reqTemplate = readFile(p.templateFileName); + req = buildXmlJsonRequest(ctx, reqTemplate, p.format); + } + r = sendHttpRequest(req, p); + setResponseStatus(ctx, p.responsePrefix, r); + + if (p.dumpHeaders && r.headers != null) { + for (Entry> a : r.headers.entrySet()) { + ctx.setAttribute(pp + "header." + a.getKey(), StringUtils.join(a.getValue(), ",")); + } + } + + if (r.body != null && r.body.trim().length() > 0) { + ctx.setAttribute(pp + "httpResponse", r.body); + + if (p.convertResponse) { + Map mm = null; + if (p.format == Format.XML) + mm = XmlParser.convertToProperties(r.body, p.listNameList); + else if (p.format == Format.JSON) + mm = JsonParser.convertToProperties(r.body); + + if (mm != null) + for (String key : mm.keySet()) + ctx.setAttribute(pp + key, mm.get(key)); + } + } + } catch (Exception e) { + boolean shouldRetry = false; + if (e.getCause() instanceof java.net.SocketException) { + shouldRetry = true; + } + + log.error("Error sending the request: " + e.getMessage(), e); + String prefix = parseParam(paramMap, "responsePrefix", false, null); + if (retryPolicy == null || shouldRetry == false) { + setFailureResponseStatus(ctx, prefix, e.getMessage(), r); + } else { + if (retryCount == null) { + retryCount = 0; + } + String retryMessage = retryCount + " attempts were made out of " + retryPolicy.getMaximumRetries() + + " maximum retries."; + log.debug(retryMessage); + try { + retryCount = retryCount + 1; + if (retryCount < retryPolicy.getMaximumRetries() + 1) { + URI uri = new URI(paramMap.get("restapiUrl")); + String hostname = uri.getHost(); + String retryString = retryPolicy.getNextHostName((uri.toString())); + URI uriTwo = new URI(retryString); + URI retryUri = UriBuilder.fromUri(uri).host(uriTwo.getHost()).port(uriTwo.getPort()).scheme( + uriTwo.getScheme()).build(); + paramMap.put("restapiUrl", retryUri.toString()); + log.debug("URL was set to " + retryUri.toString()); + log.debug("Failed to communicate with host " + hostname + + ". Request will be re-attempted using the host " + retryString + "."); + log.debug("This is retry attempt " + retryCount + " out of " + retryPolicy.getMaximumRetries()); + sendRequest(paramMap, ctx, retryCount); + } else { + log.debug("Maximum retries reached, calling setFailureResponseStatus."); + setFailureResponseStatus(ctx, prefix, e.getMessage(), r); + } + } catch (Exception ex) { + log.error("Could not attempt retry.", ex); + String retryErrorMessage = + "Retry attempt has failed. No further retry shall be attempted, calling setFailureResponseStatus."; + setFailureResponseStatus(ctx, prefix, retryErrorMessage, r); + } + } + } + + if (r != null && r.code >= 300) + throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); + } + + protected Parameters getParameters(Map paramMap) throws SvcLogicException { + Parameters p = new Parameters(); + p.templateFileName = parseParam(paramMap, "templateFileName", false, null); + p.restapiUrl = parseParam(paramMap, "restapiUrl", true, null); + p.restapiUser = parseParam(paramMap, "restapiUser", false, null); + p.restapiPassword = parseParam(paramMap, "restapiPassword", false, null); + p.contentType = parseParam(paramMap, "contentType", false, null); + p.format = Format.fromString(parseParam(paramMap, "format", false, "json")); + p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post")); + p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); + p.listNameList = getListNameList(paramMap); + String skipSendingStr = paramMap.get("skipSending"); + p.skipSending = skipSendingStr != null && skipSendingStr.equalsIgnoreCase("true"); + p.convertResponse = Boolean.valueOf(parseParam(paramMap, "convertResponse", false, "true")); + p.trustStoreFileName = parseParam(paramMap, "trustStoreFileName", false, null); + p.trustStorePassword = parseParam(paramMap, "trustStorePassword", false, null); + p.keyStoreFileName = parseParam(paramMap, "keyStoreFileName", false, null); + p.keyStorePassword = parseParam(paramMap, "keyStorePassword", false, null); + p.ssl = p.trustStoreFileName != null && p.trustStorePassword != null && p.keyStoreFileName != null && + p.keyStorePassword != null; + p.customHttpHeaders = parseParam(paramMap, "customHttpHeaders", false, null); + p.partner = parseParam(paramMap, "partner", false, null); + p.dumpHeaders = Boolean.valueOf(parseParam(paramMap, "dumpHeaders", false, null)); + return p; + } + + protected Set getListNameList(Map paramMap) { + Set ll = new HashSet(); + for (String key : paramMap.keySet()) + if (key.startsWith("listName")) + ll.add(paramMap.get(key)); + return ll; + } + + protected String parseParam(Map paramMap, String name, boolean required, String def) + throws SvcLogicException { + String s = paramMap.get(name); + + if (s == null || s.trim().length() == 0) { + if (!required) + return def; + throw new SvcLogicException("Parameter " + name + " is required in RestapiCallNode"); + } + + s = s.trim(); + String value = ""; + int i = 0; + int i1 = s.indexOf('%'); + while (i1 >= 0) { + int i2 = s.indexOf('%', i1 + 1); + if (i2 < 0) + break; + + String varName = s.substring(i1 + 1, i2); + String varValue = System.getenv(varName); + if (varValue == null) + varValue = "%" + varName + "%"; + + value += s.substring(i, i1); + value += varValue; + + i = i2 + 1; + i1 = s.indexOf('%', i); + } + value += s.substring(i); + + log.info("Parameter " + name + ": [" + value + "]"); + return value; + } + + protected String buildXmlJsonRequest(SvcLogicContext ctx, String template, Format format) { + log.info("Building " + format + " started"); + long t1 = System.currentTimeMillis(); + + template = expandRepeats(ctx, template, 1); + + Map mm = new HashMap<>(); + for (String s : ctx.getAttributeKeySet()) + mm.put(s, ctx.getAttribute(s)); + + StringBuilder ss = new StringBuilder(); + int i = 0; + while (i < template.length()) { + int i1 = template.indexOf("${", i); + if (i1 < 0) { + ss.append(template.substring(i)); + break; + } + + int i2 = template.indexOf('}', i1 + 2); + if (i2 < 0) + throw new RuntimeException("Template error: Matching } not found"); + + String var1 = template.substring(i1 + 2, i2); + String value1 = format == Format.XML ? XmlJsonUtil.getXml(mm, var1) : XmlJsonUtil.getJson(mm, var1); + // log.info(" " + var1 + ": " + value1); + if (value1 == null || value1.trim().length() == 0) { + // delete the whole element (line) + int i3 = template.lastIndexOf('\n', i1); + if (i3 < 0) + i3 = 0; + int i4 = template.indexOf('\n', i1); + if (i4 < 0) + i4 = template.length(); + + if (i < i3) + ss.append(template.substring(i, i3)); + i = i4; + } else { + ss.append(template.substring(i, i1)).append(value1); + i = i2 + 1; + } + } + + String req = format == Format.XML + ? XmlJsonUtil.removeEmptyStructXml(ss.toString()) : XmlJsonUtil.removeEmptyStructJson(ss.toString()); + + if (format == Format.JSON) + req = XmlJsonUtil.removeLastCommaJson(req); + + long t2 = System.currentTimeMillis(); + log.info("Building " + format + " completed. Time: " + (t2 - t1)); + + return req; + } + + protected String expandRepeats(SvcLogicContext ctx, String template, int level) { + StringBuilder newTemplate = new StringBuilder(); + int k = 0; + while (k < template.length()) { + int i1 = template.indexOf("${repeat:", k); + if (i1 < 0) { + newTemplate.append(template.substring(k)); + break; + } + + int i2 = template.indexOf(':', i1 + 9); + if (i2 < 0) + throw new RuntimeException( + "Template error: Context variable name followed by : is required after repeat"); + + // Find the closing }, store in i3 + int nn = 1; + int i3 = -1; + int i = i2; + while (nn > 0 && i < template.length()) { + i3 = template.indexOf('}', i); + if (i3 < 0) + throw new RuntimeException("Template error: Matching } not found"); + int i32 = template.indexOf('{', i); + if (i32 >= 0 && i32 < i3) { + nn++; + i = i32 + 1; + } else { + nn--; + i = i3 + 1; + } + } + + String var1 = template.substring(i1 + 9, i2); + String value1 = ctx.getAttribute(var1); + log.info(" " + var1 + ": " + value1); + int n = 0; + try { + n = Integer.parseInt(value1); + } catch (Exception e) { + n = 0; + } + + newTemplate.append(template.substring(k, i1)); + + String rpt = template.substring(i2 + 1, i3); + + for (int ii = 0; ii < n; ii++) { + String ss = rpt.replaceAll("\\[\\$\\{" + level + "\\}\\]", "[" + ii + "]"); + if (ii == n - 1 && ss.trim().endsWith(",")) { + int i4 = ss.lastIndexOf(','); + if (i4 > 0) + ss = ss.substring(0, i4) + ss.substring(i4 + 1); + } + newTemplate.append(ss); + } + + k = i3 + 1; + } + + if (k == 0) + return newTemplate.toString(); + + return expandRepeats(ctx, newTemplate.toString(), level + 1); + } + + protected String readFile(String fileName) throws Exception { + byte[] encoded = Files.readAllBytes(Paths.get(fileName)); + return new String(encoded, "UTF-8"); + } + + protected HttpResponse sendHttpRequest(String request, Parameters p) throws Exception { + ClientConfig config = new DefaultClientConfig(); + SSLContext ssl = null; + if (p.ssl && p.restapiUrl.startsWith("https")) + ssl = createSSLContext(p); + if (ssl != null) { + HostnameVerifier hostnameVerifier = new HostnameVerifier() { + + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + }; + + config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, + new HTTPSProperties(hostnameVerifier, ssl)); + } + + logProperties(config.getProperties()); + + Client client = Client.create(config); + client.setConnectTimeout(5000); + if (p.restapiUser != null) + client.addFilter(new HTTPBasicAuthFilter(p.restapiUser, p.restapiPassword)); + WebResource webResource = client.resource(p.restapiUrl); + + log.info("Sending request:"); + log.info(request); + long t1 = System.currentTimeMillis(); + + HttpResponse r = new HttpResponse(); + r.code = 200; + + if (!p.skipSending) { + String tt = p.format == Format.XML ? "application/xml" : "application/json"; + String tt1 = tt + ";charset=UTF-8"; + if (p.contentType != null) { + tt = p.contentType; + tt1 = p.contentType; + } + + WebResource.Builder webResourceBuilder = webResource.accept(tt).type(tt1); + + if (p.customHttpHeaders != null && p.customHttpHeaders.length() > 0) { + String[] keyValuePairs = p.customHttpHeaders.split(","); + for (String singlePair : keyValuePairs) { + int equalPosition = singlePair.indexOf('='); + webResourceBuilder.header(singlePair.substring(0, equalPosition), singlePair.substring(equalPosition + 1, singlePair.length())); + } + } + + webResourceBuilder.header("X-ECOMP-RequestID",org.slf4j.MDC.get("X-ECOMP-RequestID")); + + ClientResponse response = webResourceBuilder.method(p.httpMethod.toString(), ClientResponse.class, request); + + r.code = response.getStatus(); + r.headers = response.getHeaders(); + EntityTag etag = response.getEntityTag(); + if (etag != null) + r.message = etag.getValue(); + if (response.hasEntity() && r.code != 204) + r.body = response.getEntity(String.class); + } + + long t2 = System.currentTimeMillis(); + log.info("Response received. Time: " + (t2 - t1)); + log.info("HTTP response code: " + r.code); + log.info("HTTP response message: " + r.message); + logHeaders(r.headers); + log.info("HTTP response: " + r.body); + + return r; + } + + protected SSLContext createSSLContext(Parameters p) { + try { + System.setProperty("jsse.enableSNIExtension", "false"); + System.setProperty("javax.net.ssl.trustStore", p.trustStoreFileName); + System.setProperty("javax.net.ssl.trustStorePassword", p.trustStorePassword); + + HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { + + @Override + public boolean verify(String string, SSLSession ssls) { + return true; + } + }); + + KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); + FileInputStream in = new FileInputStream(p.keyStoreFileName); + KeyStore ks = KeyStore.getInstance("PKCS12"); + char[] pwd = p.keyStorePassword.toCharArray(); + ks.load(in, pwd); + kmf.init(ks, pwd); + + SSLContext ctx = SSLContext.getInstance("TLS"); + ctx.init(kmf.getKeyManagers(), null, null); + return ctx; + } catch (Exception e) { + log.error("Error creating SSLContext: " + e.getMessage(), e); + } + return null; + } + + protected void setFailureResponseStatus(SvcLogicContext ctx, String prefix, String errorMessage, HttpResponse r) { + r = new HttpResponse(); + r.code = 500; + r.message = errorMessage; + String pp = prefix != null ? prefix + '.' : ""; + ctx.setAttribute(pp + "response-code", String.valueOf(r.code)); + ctx.setAttribute(pp + "response-message", r.message); + } + + protected void setResponseStatus(SvcLogicContext ctx, String prefix, HttpResponse r) { + String pp = prefix != null ? prefix + '.' : ""; + ctx.setAttribute(pp + "response-code", String.valueOf(r.code)); + ctx.setAttribute(pp + "response-message", r.message); + } + + public void sendFile(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { + HttpResponse r = null; + try { + FileParam p = getFileParameters(paramMap); + byte[] data = Files.readAllBytes(Paths.get(p.fileName)); + + r = sendHttpData(data, p); + setResponseStatus(ctx, p.responsePrefix, r); + + } catch (Exception e) { + log.error("Error sending the request: " + e.getMessage(), e); + + r = new HttpResponse(); + r.code = 500; + r.message = e.getMessage(); + String prefix = parseParam(paramMap, "responsePrefix", false, null); + setResponseStatus(ctx, prefix, r); + } + + if (r != null && r.code >= 300) + throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); + } + + private static class FileParam { + + public String fileName; + public String url; + public String user; + public String password; + public HttpMethod httpMethod; + public String responsePrefix; + public boolean skipSending; + } + + private FileParam getFileParameters(Map paramMap) throws SvcLogicException { + FileParam p = new FileParam(); + p.fileName = parseParam(paramMap, "fileName", true, null); + p.url = parseParam(paramMap, "url", true, null); + p.user = parseParam(paramMap, "user", false, null); + p.password = parseParam(paramMap, "password", false, null); + p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post")); + p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); + String skipSendingStr = paramMap.get("skipSending"); + p.skipSending = skipSendingStr != null && skipSendingStr.equalsIgnoreCase("true"); + return p; + } + + protected HttpResponse sendHttpData(byte[] data, FileParam p) { + Client client = Client.create(); + client.setConnectTimeout(5000); + client.setFollowRedirects(true); + if (p.user != null) + client.addFilter(new HTTPBasicAuthFilter(p.user, p.password)); + WebResource webResource = client.resource(p.url); + + log.info("Sending file"); + long t1 = System.currentTimeMillis(); + + HttpResponse r = new HttpResponse(); + r.code = 200; + + if (!p.skipSending) { + String tt = "application/octet-stream"; + + ClientResponse response = null; + if (p.httpMethod == HttpMethod.POST) + response = webResource.accept(tt).type(tt).post(ClientResponse.class, data); + else if (p.httpMethod == HttpMethod.PUT) + response = webResource.accept(tt).type(tt).put(ClientResponse.class, data); + + r.code = response.getStatus(); + r.headers = response.getHeaders(); + EntityTag etag = response.getEntityTag(); + if (etag != null) + r.message = etag.getValue(); + if (response.hasEntity() && r.code != 204) + r.body = response.getEntity(String.class); + + if (r.code == 301) { + String newUrl = response.getHeaders().getFirst("Location"); + + log.info("Got response code 301. Sending same request to URL: " + newUrl); + + webResource = client.resource(newUrl); + + if (p.httpMethod == HttpMethod.POST) + response = webResource.accept(tt).type(tt).post(ClientResponse.class, data); + else if (p.httpMethod == HttpMethod.PUT) + response = webResource.accept(tt).type(tt).put(ClientResponse.class, data); + + r.code = response.getStatus(); + etag = response.getEntityTag(); + if (etag != null) + r.message = etag.getValue(); + if (response.hasEntity() && r.code != 204) + r.body = response.getEntity(String.class); + } + } + + long t2 = System.currentTimeMillis(); + log.info("Response received. Time: " + (t2 - t1)); + log.info("HTTP response code: " + r.code); + log.info("HTTP response message: " + r.message); + logHeaders(r.headers); + log.info("HTTP response: " + r.body); + + return r; + } + + public void postMessageOnUeb(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { + HttpResponse r = null; + try { + UebParam p = getUebParameters(paramMap); + + String pp = p.responsePrefix != null ? p.responsePrefix + '.' : ""; + + String req = null; + + if (p.templateFileName == null) { + log.info("No template file name specified. Using default UEB template: " + defaultUebTemplateFileName); + p.templateFileName = defaultUebTemplateFileName; + } + + String reqTemplate = readFile(p.templateFileName); + reqTemplate = reqTemplate.replaceAll("rootVarName", p.rootVarName); + req = buildXmlJsonRequest(ctx, reqTemplate, Format.JSON); + + r = postOnUeb(req, p); + setResponseStatus(ctx, p.responsePrefix, r); + if (r.body != null) + ctx.setAttribute(pp + "httpResponse", r.body); + + } catch (Exception e) { + log.error("Error sending the request: " + e.getMessage(), e); + + r = new HttpResponse(); + r.code = 500; + r.message = e.getMessage(); + String prefix = parseParam(paramMap, "responsePrefix", false, null); + setResponseStatus(ctx, prefix, r); + } + + if (r != null && r.code >= 300) + throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); + } + + private static class UebParam { + + public String topic; + public String templateFileName; + public String rootVarName; + public String responsePrefix; + public boolean skipSending; + } + + private UebParam getUebParameters(Map paramMap) throws SvcLogicException { + UebParam p = new UebParam(); + p.topic = parseParam(paramMap, "topic", true, null); + p.templateFileName = parseParam(paramMap, "templateFileName", false, null); + p.rootVarName = parseParam(paramMap, "rootVarName", false, null); + p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); + String skipSendingStr = paramMap.get("skipSending"); + p.skipSending = skipSendingStr != null && skipSendingStr.equalsIgnoreCase("true"); + return p; + } + + protected HttpResponse postOnUeb(String request, UebParam p) throws Exception { + String[] urls = uebServers.split(" "); + for (int i = 0; i < urls.length; i++) { + if (!urls[i].endsWith("/")) + urls[i] += "/"; + urls[i] += "events/" + p.topic; + } + + Client client = Client.create(); + client.setConnectTimeout(5000); + WebResource webResource = client.resource(urls[0]); + + log.info("UEB URL: " + urls[0]); + log.info("Sending request:"); + log.info(request); + long t1 = System.currentTimeMillis(); + + HttpResponse r = new HttpResponse(); + r.code = 200; + + if (!p.skipSending) { + String tt = "application/json"; + String tt1 = tt + ";charset=UTF-8"; + + ClientResponse response = webResource.accept(tt).type(tt1).post(ClientResponse.class, request); + + r.code = response.getStatus(); + r.headers = response.getHeaders(); + if (response.hasEntity()) + r.body = response.getEntity(String.class); + } + + long t2 = System.currentTimeMillis(); + log.info("Response received. Time: " + (t2 - t1)); + log.info("HTTP response code: " + r.code); + logHeaders(r.headers); + log.info("HTTP response:\n" + r.body); + + return r; + } + + protected void logProperties(Map mm) { + List 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 + ": " + String.valueOf(mm.get(name))); + } + + protected void logHeaders(MultivaluedMap mm) { + log.info("HTTP response headers:"); + + if (mm == null) + return; + + List ll = new ArrayList<>(); + for (Object o : mm.keySet()) + ll.add((String) o); + Collections.sort(ll); + + for (String name : ll) + log.info("--- " + name + ": " + String.valueOf(mm.get(name))); + } + + public void setUebServers(String uebServers) { + this.uebServers = uebServers; + } + + public void setDefaultUebTemplateFileName(String defaultUebTemplateFileName) { + this.defaultUebTemplateFileName = defaultUebTemplateFileName; + } +} diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryException.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryException.java new file mode 100644 index 000000000..2a8002819 --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryException.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +public class RetryException extends Exception { + + public RetryException(String message) { + super(message); + } + +} diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java new file mode 100644 index 000000000..3059a4457 --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +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/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java new file mode 100644 index 000000000..18ec2fb76 --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +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 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/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java new file mode 100644 index 000000000..5131c8745 --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java @@ -0,0 +1,372 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +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 class XmlJsonUtil { + + private static final Logger log = LoggerFactory.getLogger(XmlJsonUtil.class); + + public static String getXml(Map 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 varmap, String var) { + boolean escape = true; + if (var.startsWith("'")) { + var = var.substring(1); + escape = false; + } + + Object o = createStructure(varmap, var); + return generateJson(o, escape); + } + + private static Object createStructure(Map flatmap, String var) { + if (flatmap.containsKey(var)) { + if (var.endsWith("_length") || var.endsWith("].key")) + return null; + return flatmap.get(var); + } + + Map 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 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 " + var + "_length:" + lengthStr); + } + } + + 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 mm = (Map) o; + for (String k : mm.keySet()) { + Object v = mm.get(k); + if (v instanceof String) { + String s = escape ? escapeXml((String) v) : (String) v; + ss.append(pad(indent)).append('<').append(k).append('>'); + ss.append(s); + ss.append("').append('\n'); + } else if (v instanceof Map) { + ss.append(pad(indent)).append('<').append(k).append('>').append('\n'); + ss.append(generateXml(v, indent + 1, escape)); + ss.append(pad(indent)).append("').append('\n'); + } else if (v instanceof List) { + List ll = (List) v; + for (Object o1 : ll) { + ss.append(pad(indent)).append('<').append(k).append('>').append('\n'); + ss.append(generateXml(o1, indent + 1, escape)); + ss.append(pad(indent)).append("').append('\n'); + } + } + } + return ss.toString(); + } + + return null; + } + + private static String generateJson(Object o, boolean escape) { + if (o == null) + return null; + + StringBuilder ss = new StringBuilder(); + generateJson(ss, o, 0, false, escape); + return ss.toString(); + } + + @SuppressWarnings("unchecked") + private static void generateJson(StringBuilder ss, Object o, int indent, boolean padFirst, boolean escape) { + if (o instanceof String) { + String s = escape ? escapeJson((String) o) : (String) o; + if (padFirst) + ss.append(pad(indent)); + ss.append('"').append(s).append('"'); + return; + } + + if (o instanceof Map) { + Map mm = (Map) o; + + if (padFirst) + ss.append(pad(indent)); + ss.append("{\n"); + + boolean first = true; + for (String k : mm.keySet()) { + if (!first) + ss.append(",\n"); + first = false; + + Object v = mm.get(k); + ss.append(pad(indent + 1)).append('"').append(k).append("\": "); + generateJson(ss, v, indent + 1, false, escape); + } + + ss.append("\n"); + ss.append(pad(indent)).append('}'); + + return; + } + + if (o instanceof List) { + List ll = (List) 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); + } + + 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 = " 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("&", "&"); + s = s.replaceAll("<", "<"); + s = s.replaceAll("'", "'"); + s = s.replaceAll("\"", """); + s = s.replaceAll(">", ">"); + return s; + } + + private static String escapeJson(String v) { + String s = v.replaceAll("\\\\", "\\\\\\\\"); + s = s.replaceAll("\"", "\\\\\""); + return s; + } + + private static String pad(int n) { + String s = ""; + for (int i = 0; i < n; i++) + s += '\t'; + return s; + } +} diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java new file mode 100644 index 000000000..7a3243762 --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java @@ -0,0 +1,160 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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.restapicall; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +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 class XmlParser { + + private static final Logger log = LoggerFactory.getLogger(XmlParser.class); + + public static Map convertToProperties(String s, Set listNameList) { + 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 (Exception e) { + e.printStackTrace(); + } + + return handler.getProperties(); + } + + private static class Handler extends DefaultHandler { + + private Set listNameList; + + private Map properties = new HashMap<>(); + + public Map getProperties() { + return properties; + } + + public Handler(Set listNameList) { + super(); + this.listNameList = listNameList; + if (this.listNameList == null) + this.listNameList = new HashSet(); + } + + String currentName = ""; + String currentValue = ""; + + @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 += '.'; + currentName += name; + + String listName = removeIndexes(currentName); + + if (listNameList.contains(listName)) { + int len = getInt(properties, currentName + "_length"); + properties.put(currentName + "_length", String.valueOf(len + 1)); + currentName += "[" + len + "]"; + } + } + + @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); + + if (currentValue.trim().length() > 0) { + currentValue = currentValue.trim(); + properties.put(currentName, currentValue); + + log.info("Added property: " + currentName + ": " + currentValue); + + currentValue = ""; + } + + int i1 = currentName.lastIndexOf("." + name); + if (i1 <= 0) + currentName = ""; + else + currentName = 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 += value; + } + + private static int getInt(Map mm, String name) { + String s = mm.get(name); + if (s == null) + return 0; + return Integer.parseInt(s); + } + + private String removeIndexes(String currentName) { + String s = ""; + 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) + s += c; + } + return s; + } + } +} diff --git a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/Format.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/Format.java deleted file mode 100644 index 52086255f..000000000 --- a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/Format.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 ONAP 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.restapicall; - -public enum Format { - JSON, XML; - - public static Format fromString(String s) { - if (s == null) - return null; - if (s.equalsIgnoreCase("json")) - return JSON; - if (s.equalsIgnoreCase("xml")) - return XML; - throw new IllegalArgumentException("Invalid value for format: " + s); - } -} diff --git a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/HttpMethod.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/HttpMethod.java deleted file mode 100644 index 059074bf9..000000000 --- a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/HttpMethod.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 ONAP 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.restapicall; - -public enum HttpMethod { - GET, POST, PUT, DELETE, PATCH; - - public static HttpMethod fromString(String s) { - if (s == null) - return null; - if (s.equalsIgnoreCase("get")) - return GET; - if (s.equalsIgnoreCase("post")) - return POST; - if (s.equalsIgnoreCase("put")) - return PUT; - if (s.equalsIgnoreCase("delete")) - return DELETE; - if (s.equalsIgnoreCase("patch")) - return PATCH; - throw new IllegalArgumentException("Invalid value for HTTP Method: " + s); - } -} diff --git a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/HttpResponse.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/HttpResponse.java deleted file mode 100644 index 761e4264e..000000000 --- a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/HttpResponse.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 ONAP 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.restapicall; - -import javax.ws.rs.core.MultivaluedMap; - -public class HttpResponse { - public int code; - public String message; - public String body; - public MultivaluedMap headers; -} diff --git a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/JsonParser.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/JsonParser.java deleted file mode 100644 index 27e9a82ef..000000000 --- a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/JsonParser.java +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 ONAP 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.restapicall; - -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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class JsonParser { - - private static final Logger log = LoggerFactory.getLogger(JsonParser.class); - - @SuppressWarnings("unchecked") - public static Map convertToProperties(String s) throws JSONException { - JSONObject json = new JSONObject(s); - - Map wm = new HashMap(); - Iterator ii = json.keys(); - while (ii.hasNext()) { - String key1 = ii.next(); - wm.put(key1, json.get(key1)); - } - - Map 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 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: " + key + "_length" + ": " + String.valueOf(ja.length())); - - for (int i = 0; i < ja.length(); i++) - wm.put(key + '[' + i + ']', ja.get(i)); - } - } - - return mm; - } -} diff --git a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/Parameters.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/Parameters.java deleted file mode 100644 index 0cba4e6b1..000000000 --- a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/Parameters.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 ONAP 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.restapicall; - -import java.util.Set; - -public class Parameters { - public String templateFileName; - public String restapiUrl; - public String restapiUser; - public String restapiPassword; - public Format format; - public String contentType; - public HttpMethod httpMethod; - public String responsePrefix; - public Set listNameList; - public boolean skipSending; - public boolean convertResponse; - public String keyStoreFileName; - public String keyStorePassword; - public String trustStoreFileName; - public String trustStorePassword; - public boolean ssl; - public String customHttpHeaders; - public String partner; - public Boolean dumpHeaders; -} diff --git a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RestapiCallNode.java deleted file mode 100644 index b7598480c..000000000 --- a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RestapiCallNode.java +++ /dev/null @@ -1,759 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 ONAP 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.restapicall; - -import java.io.FileInputStream; -import java.net.URI; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.security.KeyStore; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.ws.rs.core.EntityTag; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriBuilder; - -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; -import com.sun.jersey.client.urlconnection.HTTPSProperties; - -public class RestapiCallNode implements SvcLogicJavaPlugin { - - private static final Logger log = LoggerFactory.getLogger(RestapiCallNode.class); - - private String uebServers; - private String defaultUebTemplateFileName = "/opt/bvc/restapi/templates/default-ueb-message.json"; - protected RetryPolicyStore retryPolicyStore; - - protected RetryPolicyStore getRetryPolicyStore() { - return retryPolicyStore; - } - - public void setRetryPolicyStore(RetryPolicyStore retryPolicyStore) { - this.retryPolicyStore = retryPolicyStore; - } - - public RestapiCallNode() { - - } - - /** - * Allows Directed Graphs the ability to interact with REST APIs. - * @param parameters HashMap of parameters passed by the DG to this function - * - * - * - * - * - * - * - * - * - * - * - * vpn-information.vrf-details - * - * - * - * - * - * - *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/restapi/templates/vnf_service-configuration-operation_minimal.json
restapiUrlMandatoryurl to send the request tohttps://sdncodl:8543/restconf/operations/L3VNF-API:create-update-vnf-request
restapiUserOptionaluser name to use for http basic authenticationsdnc_ws
restapiPasswordOptionalunencrypted password to use for http basic authenticationplain_password
contentTypeOptionalhttp content type to set in the http headerusually application/json or application/xml
formatOptionalshould match request body formatjson or xml
httpMethodOptionalhttp method to use when sending the requestget post put delete patch
responsePrefixOptionallocation the response will be written to in context memorytmp.restapi.result
listName[i]OptionalUsed for processing XML responses with repeating elements.
skipSendingOptionaltrue or false
convertResponse Optionalwhether the response should be convertedtrue or false
customHttpHeadersOptionala list additional http headers to be passed in, follow the format in the exampleX-CSI-MessageId=messageId,headerFieldName=headerFieldValue
dumpHeadersOptionalwhen true writes http header content to context memorytrue or false
partnerOptionalneeded for DME2 callsdme2proxy
- * @param ctx Reference to context memory - * @throws SvcLogicException - * @since 11.0.2 - * @see String#split(String, int) - */ - public void sendRequest(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { - sendRequest(paramMap, ctx, null); - } - - public void sendRequest(Map paramMap, SvcLogicContext ctx, Integer retryCount) - throws SvcLogicException { - - RetryPolicy retryPolicy = null; - HttpResponse r = null; - try { - Parameters p = getParameters(paramMap); - if (p.partner != null) { - retryPolicy = retryPolicyStore.getRetryPolicy(p.partner); - } - String pp = p.responsePrefix != null ? p.responsePrefix + '.' : ""; - - String req = null; - if (p.templateFileName != null) { - String reqTemplate = readFile(p.templateFileName); - req = buildXmlJsonRequest(ctx, reqTemplate, p.format); - } - r = sendHttpRequest(req, p); - setResponseStatus(ctx, p.responsePrefix, r); - - if (p.dumpHeaders && r.headers != null) { - for (Entry> a : r.headers.entrySet()) { - ctx.setAttribute(pp + "header." + a.getKey(), StringUtils.join(a.getValue(), ",")); - } - } - - if (r.body != null && r.body.trim().length() > 0) { - ctx.setAttribute(pp + "httpResponse", r.body); - - if (p.convertResponse) { - Map mm = null; - if (p.format == Format.XML) - mm = XmlParser.convertToProperties(r.body, p.listNameList); - else if (p.format == Format.JSON) - mm = JsonParser.convertToProperties(r.body); - - if (mm != null) - for (String key : mm.keySet()) - ctx.setAttribute(pp + key, mm.get(key)); - } - } - } catch (Exception e) { - boolean shouldRetry = false; - if (e.getCause() instanceof java.net.SocketException) { - shouldRetry = true; - } - - log.error("Error sending the request: " + e.getMessage(), e); - String prefix = parseParam(paramMap, "responsePrefix", false, null); - if (retryPolicy == null || shouldRetry == false) { - setFailureResponseStatus(ctx, prefix, e.getMessage(), r); - } else { - if (retryCount == null) { - retryCount = 0; - } - String retryMessage = retryCount + " attempts were made out of " + retryPolicy.getMaximumRetries() + - " maximum retries."; - log.debug(retryMessage); - try { - retryCount = retryCount + 1; - if (retryCount < retryPolicy.getMaximumRetries() + 1) { - URI uri = new URI(paramMap.get("restapiUrl")); - String hostname = uri.getHost(); - String retryString = retryPolicy.getNextHostName((uri.toString())); - URI uriTwo = new URI(retryString); - URI retryUri = UriBuilder.fromUri(uri).host(uriTwo.getHost()).port(uriTwo.getPort()).scheme( - uriTwo.getScheme()).build(); - paramMap.put("restapiUrl", retryUri.toString()); - log.debug("URL was set to " + retryUri.toString()); - log.debug("Failed to communicate with host " + hostname + - ". Request will be re-attempted using the host " + retryString + "."); - log.debug("This is retry attempt " + retryCount + " out of " + retryPolicy.getMaximumRetries()); - sendRequest(paramMap, ctx, retryCount); - } else { - log.debug("Maximum retries reached, calling setFailureResponseStatus."); - setFailureResponseStatus(ctx, prefix, e.getMessage(), r); - } - } catch (Exception ex) { - log.error("Could not attempt retry.", ex); - String retryErrorMessage = - "Retry attempt has failed. No further retry shall be attempted, calling setFailureResponseStatus."; - setFailureResponseStatus(ctx, prefix, retryErrorMessage, r); - } - } - } - - if (r != null && r.code >= 300) - throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); - } - - protected Parameters getParameters(Map paramMap) throws SvcLogicException { - Parameters p = new Parameters(); - p.templateFileName = parseParam(paramMap, "templateFileName", false, null); - p.restapiUrl = parseParam(paramMap, "restapiUrl", true, null); - p.restapiUser = parseParam(paramMap, "restapiUser", false, null); - p.restapiPassword = parseParam(paramMap, "restapiPassword", false, null); - p.contentType = parseParam(paramMap, "contentType", false, null); - p.format = Format.fromString(parseParam(paramMap, "format", false, "json")); - p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post")); - p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); - p.listNameList = getListNameList(paramMap); - String skipSendingStr = paramMap.get("skipSending"); - p.skipSending = skipSendingStr != null && skipSendingStr.equalsIgnoreCase("true"); - p.convertResponse = Boolean.valueOf(parseParam(paramMap, "convertResponse", false, "true")); - p.trustStoreFileName = parseParam(paramMap, "trustStoreFileName", false, null); - p.trustStorePassword = parseParam(paramMap, "trustStorePassword", false, null); - p.keyStoreFileName = parseParam(paramMap, "keyStoreFileName", false, null); - p.keyStorePassword = parseParam(paramMap, "keyStorePassword", false, null); - p.ssl = p.trustStoreFileName != null && p.trustStorePassword != null && p.keyStoreFileName != null && - p.keyStorePassword != null; - p.customHttpHeaders = parseParam(paramMap, "customHttpHeaders", false, null); - p.partner = parseParam(paramMap, "partner", false, null); - p.dumpHeaders = Boolean.valueOf(parseParam(paramMap, "dumpHeaders", false, null)); - return p; - } - - protected Set getListNameList(Map paramMap) { - Set ll = new HashSet(); - for (String key : paramMap.keySet()) - if (key.startsWith("listName")) - ll.add(paramMap.get(key)); - return ll; - } - - protected String parseParam(Map paramMap, String name, boolean required, String def) - throws SvcLogicException { - String s = paramMap.get(name); - - if (s == null || s.trim().length() == 0) { - if (!required) - return def; - throw new SvcLogicException("Parameter " + name + " is required in RestapiCallNode"); - } - - s = s.trim(); - String value = ""; - int i = 0; - int i1 = s.indexOf('%'); - while (i1 >= 0) { - int i2 = s.indexOf('%', i1 + 1); - if (i2 < 0) - break; - - String varName = s.substring(i1 + 1, i2); - String varValue = System.getenv(varName); - if (varValue == null) - varValue = "%" + varName + "%"; - - value += s.substring(i, i1); - value += varValue; - - i = i2 + 1; - i1 = s.indexOf('%', i); - } - value += s.substring(i); - - log.info("Parameter " + name + ": [" + value + "]"); - return value; - } - - protected String buildXmlJsonRequest(SvcLogicContext ctx, String template, Format format) { - log.info("Building " + format + " started"); - long t1 = System.currentTimeMillis(); - - template = expandRepeats(ctx, template, 1); - - Map mm = new HashMap<>(); - for (String s : ctx.getAttributeKeySet()) - mm.put(s, ctx.getAttribute(s)); - - StringBuilder ss = new StringBuilder(); - int i = 0; - while (i < template.length()) { - int i1 = template.indexOf("${", i); - if (i1 < 0) { - ss.append(template.substring(i)); - break; - } - - int i2 = template.indexOf('}', i1 + 2); - if (i2 < 0) - throw new RuntimeException("Template error: Matching } not found"); - - String var1 = template.substring(i1 + 2, i2); - String value1 = format == Format.XML ? XmlJsonUtil.getXml(mm, var1) : XmlJsonUtil.getJson(mm, var1); - // log.info(" " + var1 + ": " + value1); - if (value1 == null || value1.trim().length() == 0) { - // delete the whole element (line) - int i3 = template.lastIndexOf('\n', i1); - if (i3 < 0) - i3 = 0; - int i4 = template.indexOf('\n', i1); - if (i4 < 0) - i4 = template.length(); - - if (i < i3) - ss.append(template.substring(i, i3)); - i = i4; - } else { - ss.append(template.substring(i, i1)).append(value1); - i = i2 + 1; - } - } - - String req = format == Format.XML - ? XmlJsonUtil.removeEmptyStructXml(ss.toString()) : XmlJsonUtil.removeEmptyStructJson(ss.toString()); - - if (format == Format.JSON) - req = XmlJsonUtil.removeLastCommaJson(req); - - long t2 = System.currentTimeMillis(); - log.info("Building " + format + " completed. Time: " + (t2 - t1)); - - return req; - } - - protected String expandRepeats(SvcLogicContext ctx, String template, int level) { - StringBuilder newTemplate = new StringBuilder(); - int k = 0; - while (k < template.length()) { - int i1 = template.indexOf("${repeat:", k); - if (i1 < 0) { - newTemplate.append(template.substring(k)); - break; - } - - int i2 = template.indexOf(':', i1 + 9); - if (i2 < 0) - throw new RuntimeException( - "Template error: Context variable name followed by : is required after repeat"); - - // Find the closing }, store in i3 - int nn = 1; - int i3 = -1; - int i = i2; - while (nn > 0 && i < template.length()) { - i3 = template.indexOf('}', i); - if (i3 < 0) - throw new RuntimeException("Template error: Matching } not found"); - int i32 = template.indexOf('{', i); - if (i32 >= 0 && i32 < i3) { - nn++; - i = i32 + 1; - } else { - nn--; - i = i3 + 1; - } - } - - String var1 = template.substring(i1 + 9, i2); - String value1 = ctx.getAttribute(var1); - log.info(" " + var1 + ": " + value1); - int n = 0; - try { - n = Integer.parseInt(value1); - } catch (Exception e) { - n = 0; - } - - newTemplate.append(template.substring(k, i1)); - - String rpt = template.substring(i2 + 1, i3); - - for (int ii = 0; ii < n; ii++) { - String ss = rpt.replaceAll("\\[\\$\\{" + level + "\\}\\]", "[" + ii + "]"); - if (ii == n - 1 && ss.trim().endsWith(",")) { - int i4 = ss.lastIndexOf(','); - if (i4 > 0) - ss = ss.substring(0, i4) + ss.substring(i4 + 1); - } - newTemplate.append(ss); - } - - k = i3 + 1; - } - - if (k == 0) - return newTemplate.toString(); - - return expandRepeats(ctx, newTemplate.toString(), level + 1); - } - - protected String readFile(String fileName) throws Exception { - byte[] encoded = Files.readAllBytes(Paths.get(fileName)); - return new String(encoded, "UTF-8"); - } - - protected HttpResponse sendHttpRequest(String request, Parameters p) throws Exception { - ClientConfig config = new DefaultClientConfig(); - SSLContext ssl = null; - if (p.ssl && p.restapiUrl.startsWith("https")) - ssl = createSSLContext(p); - if (ssl != null) { - HostnameVerifier hostnameVerifier = new HostnameVerifier() { - - @Override - public boolean verify(String hostname, SSLSession session) { - return true; - } - }; - - config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, - new HTTPSProperties(hostnameVerifier, ssl)); - } - - logProperties(config.getProperties()); - - Client client = Client.create(config); - client.setConnectTimeout(5000); - if (p.restapiUser != null) - client.addFilter(new HTTPBasicAuthFilter(p.restapiUser, p.restapiPassword)); - WebResource webResource = client.resource(p.restapiUrl); - - log.info("Sending request:"); - log.info(request); - long t1 = System.currentTimeMillis(); - - HttpResponse r = new HttpResponse(); - r.code = 200; - - if (!p.skipSending) { - String tt = p.format == Format.XML ? "application/xml" : "application/json"; - String tt1 = tt + ";charset=UTF-8"; - if (p.contentType != null) { - tt = p.contentType; - tt1 = p.contentType; - } - - WebResource.Builder webResourceBuilder = webResource.accept(tt).type(tt1); - - if (p.customHttpHeaders != null && p.customHttpHeaders.length() > 0) { - String[] keyValuePairs = p.customHttpHeaders.split(","); - for (String singlePair : keyValuePairs) { - int equalPosition = singlePair.indexOf('='); - webResourceBuilder.header(singlePair.substring(0, equalPosition), singlePair.substring(equalPosition + 1, singlePair.length())); - } - } - - webResourceBuilder.header("X-ECOMP-RequestID",org.slf4j.MDC.get("X-ECOMP-RequestID")); - - ClientResponse response = webResourceBuilder.method(p.httpMethod.toString(), ClientResponse.class, request); - - r.code = response.getStatus(); - r.headers = response.getHeaders(); - EntityTag etag = response.getEntityTag(); - if (etag != null) - r.message = etag.getValue(); - if (response.hasEntity() && r.code != 204) - r.body = response.getEntity(String.class); - } - - long t2 = System.currentTimeMillis(); - log.info("Response received. Time: " + (t2 - t1)); - log.info("HTTP response code: " + r.code); - log.info("HTTP response message: " + r.message); - logHeaders(r.headers); - log.info("HTTP response: " + r.body); - - return r; - } - - protected SSLContext createSSLContext(Parameters p) { - try { - System.setProperty("jsse.enableSNIExtension", "false"); - System.setProperty("javax.net.ssl.trustStore", p.trustStoreFileName); - System.setProperty("javax.net.ssl.trustStorePassword", p.trustStorePassword); - - HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { - - @Override - public boolean verify(String string, SSLSession ssls) { - return true; - } - }); - - KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); - FileInputStream in = new FileInputStream(p.keyStoreFileName); - KeyStore ks = KeyStore.getInstance("PKCS12"); - char[] pwd = p.keyStorePassword.toCharArray(); - ks.load(in, pwd); - kmf.init(ks, pwd); - - SSLContext ctx = SSLContext.getInstance("TLS"); - ctx.init(kmf.getKeyManagers(), null, null); - return ctx; - } catch (Exception e) { - log.error("Error creating SSLContext: " + e.getMessage(), e); - } - return null; - } - - protected void setFailureResponseStatus(SvcLogicContext ctx, String prefix, String errorMessage, HttpResponse r) { - r = new HttpResponse(); - r.code = 500; - r.message = errorMessage; - String pp = prefix != null ? prefix + '.' : ""; - ctx.setAttribute(pp + "response-code", String.valueOf(r.code)); - ctx.setAttribute(pp + "response-message", r.message); - } - - protected void setResponseStatus(SvcLogicContext ctx, String prefix, HttpResponse r) { - String pp = prefix != null ? prefix + '.' : ""; - ctx.setAttribute(pp + "response-code", String.valueOf(r.code)); - ctx.setAttribute(pp + "response-message", r.message); - } - - public void sendFile(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { - HttpResponse r = null; - try { - FileParam p = getFileParameters(paramMap); - byte[] data = Files.readAllBytes(Paths.get(p.fileName)); - - r = sendHttpData(data, p); - setResponseStatus(ctx, p.responsePrefix, r); - - } catch (Exception e) { - log.error("Error sending the request: " + e.getMessage(), e); - - r = new HttpResponse(); - r.code = 500; - r.message = e.getMessage(); - String prefix = parseParam(paramMap, "responsePrefix", false, null); - setResponseStatus(ctx, prefix, r); - } - - if (r != null && r.code >= 300) - throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); - } - - private static class FileParam { - - public String fileName; - public String url; - public String user; - public String password; - public HttpMethod httpMethod; - public String responsePrefix; - public boolean skipSending; - } - - private FileParam getFileParameters(Map paramMap) throws SvcLogicException { - FileParam p = new FileParam(); - p.fileName = parseParam(paramMap, "fileName", true, null); - p.url = parseParam(paramMap, "url", true, null); - p.user = parseParam(paramMap, "user", false, null); - p.password = parseParam(paramMap, "password", false, null); - p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post")); - p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); - String skipSendingStr = paramMap.get("skipSending"); - p.skipSending = skipSendingStr != null && skipSendingStr.equalsIgnoreCase("true"); - return p; - } - - protected HttpResponse sendHttpData(byte[] data, FileParam p) { - Client client = Client.create(); - client.setConnectTimeout(5000); - client.setFollowRedirects(true); - if (p.user != null) - client.addFilter(new HTTPBasicAuthFilter(p.user, p.password)); - WebResource webResource = client.resource(p.url); - - log.info("Sending file"); - long t1 = System.currentTimeMillis(); - - HttpResponse r = new HttpResponse(); - r.code = 200; - - if (!p.skipSending) { - String tt = "application/octet-stream"; - - ClientResponse response = null; - if (p.httpMethod == HttpMethod.POST) - response = webResource.accept(tt).type(tt).post(ClientResponse.class, data); - else if (p.httpMethod == HttpMethod.PUT) - response = webResource.accept(tt).type(tt).put(ClientResponse.class, data); - - r.code = response.getStatus(); - r.headers = response.getHeaders(); - EntityTag etag = response.getEntityTag(); - if (etag != null) - r.message = etag.getValue(); - if (response.hasEntity() && r.code != 204) - r.body = response.getEntity(String.class); - - if (r.code == 301) { - String newUrl = response.getHeaders().getFirst("Location"); - - log.info("Got response code 301. Sending same request to URL: " + newUrl); - - webResource = client.resource(newUrl); - - if (p.httpMethod == HttpMethod.POST) - response = webResource.accept(tt).type(tt).post(ClientResponse.class, data); - else if (p.httpMethod == HttpMethod.PUT) - response = webResource.accept(tt).type(tt).put(ClientResponse.class, data); - - r.code = response.getStatus(); - etag = response.getEntityTag(); - if (etag != null) - r.message = etag.getValue(); - if (response.hasEntity() && r.code != 204) - r.body = response.getEntity(String.class); - } - } - - long t2 = System.currentTimeMillis(); - log.info("Response received. Time: " + (t2 - t1)); - log.info("HTTP response code: " + r.code); - log.info("HTTP response message: " + r.message); - logHeaders(r.headers); - log.info("HTTP response: " + r.body); - - return r; - } - - public void postMessageOnUeb(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { - HttpResponse r = null; - try { - UebParam p = getUebParameters(paramMap); - - String pp = p.responsePrefix != null ? p.responsePrefix + '.' : ""; - - String req = null; - - if (p.templateFileName == null) { - log.info("No template file name specified. Using default UEB template: " + defaultUebTemplateFileName); - p.templateFileName = defaultUebTemplateFileName; - } - - String reqTemplate = readFile(p.templateFileName); - reqTemplate = reqTemplate.replaceAll("rootVarName", p.rootVarName); - req = buildXmlJsonRequest(ctx, reqTemplate, Format.JSON); - - r = postOnUeb(req, p); - setResponseStatus(ctx, p.responsePrefix, r); - if (r.body != null) - ctx.setAttribute(pp + "httpResponse", r.body); - - } catch (Exception e) { - log.error("Error sending the request: " + e.getMessage(), e); - - r = new HttpResponse(); - r.code = 500; - r.message = e.getMessage(); - String prefix = parseParam(paramMap, "responsePrefix", false, null); - setResponseStatus(ctx, prefix, r); - } - - if (r != null && r.code >= 300) - throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); - } - - private static class UebParam { - - public String topic; - public String templateFileName; - public String rootVarName; - public String responsePrefix; - public boolean skipSending; - } - - private UebParam getUebParameters(Map paramMap) throws SvcLogicException { - UebParam p = new UebParam(); - p.topic = parseParam(paramMap, "topic", true, null); - p.templateFileName = parseParam(paramMap, "templateFileName", false, null); - p.rootVarName = parseParam(paramMap, "rootVarName", false, null); - p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); - String skipSendingStr = paramMap.get("skipSending"); - p.skipSending = skipSendingStr != null && skipSendingStr.equalsIgnoreCase("true"); - return p; - } - - protected HttpResponse postOnUeb(String request, UebParam p) throws Exception { - String[] urls = uebServers.split(" "); - for (int i = 0; i < urls.length; i++) { - if (!urls[i].endsWith("/")) - urls[i] += "/"; - urls[i] += "events/" + p.topic; - } - - Client client = Client.create(); - client.setConnectTimeout(5000); - WebResource webResource = client.resource(urls[0]); - - log.info("UEB URL: " + urls[0]); - log.info("Sending request:"); - log.info(request); - long t1 = System.currentTimeMillis(); - - HttpResponse r = new HttpResponse(); - r.code = 200; - - if (!p.skipSending) { - String tt = "application/json"; - String tt1 = tt + ";charset=UTF-8"; - - ClientResponse response = webResource.accept(tt).type(tt1).post(ClientResponse.class, request); - - r.code = response.getStatus(); - r.headers = response.getHeaders(); - if (response.hasEntity()) - r.body = response.getEntity(String.class); - } - - long t2 = System.currentTimeMillis(); - log.info("Response received. Time: " + (t2 - t1)); - log.info("HTTP response code: " + r.code); - logHeaders(r.headers); - log.info("HTTP response:\n" + r.body); - - return r; - } - - protected void logProperties(Map mm) { - List 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 + ": " + String.valueOf(mm.get(name))); - } - - protected void logHeaders(MultivaluedMap mm) { - log.info("HTTP response headers:"); - - if (mm == null) - return; - - List ll = new ArrayList<>(); - for (Object o : mm.keySet()) - ll.add((String) o); - Collections.sort(ll); - - for (String name : ll) - log.info("--- " + name + ": " + String.valueOf(mm.get(name))); - } - - public void setUebServers(String uebServers) { - this.uebServers = uebServers; - } - - public void setDefaultUebTemplateFileName(String defaultUebTemplateFileName) { - this.defaultUebTemplateFileName = defaultUebTemplateFileName; - } -} diff --git a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryException.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryException.java deleted file mode 100644 index bf6ccc056..000000000 --- a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryException.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 ONAP 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.restapicall; - -public class RetryException extends Exception { - - public RetryException(String message) { - super(message); - } - -} diff --git a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryPolicy.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryPolicy.java deleted file mode 100644 index 2a27a1d02..000000000 --- a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryPolicy.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 ONAP 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.restapicall; - -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/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryPolicyStore.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryPolicyStore.java deleted file mode 100644 index baf60d2e8..000000000 --- a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/RetryPolicyStore.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 ONAP 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.restapicall; - -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 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/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/XmlJsonUtil.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/XmlJsonUtil.java deleted file mode 100644 index 66bf08b3d..000000000 --- a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/XmlJsonUtil.java +++ /dev/null @@ -1,372 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 ONAP 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.restapicall; - -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 class XmlJsonUtil { - - private static final Logger log = LoggerFactory.getLogger(XmlJsonUtil.class); - - public static String getXml(Map 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 varmap, String var) { - boolean escape = true; - if (var.startsWith("'")) { - var = var.substring(1); - escape = false; - } - - Object o = createStructure(varmap, var); - return generateJson(o, escape); - } - - private static Object createStructure(Map flatmap, String var) { - if (flatmap.containsKey(var)) { - if (var.endsWith("_length") || var.endsWith("].key")) - return null; - return flatmap.get(var); - } - - Map 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 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 " + var + "_length:" + lengthStr); - } - } - - 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 mm = (Map) o; - for (String k : mm.keySet()) { - Object v = mm.get(k); - if (v instanceof String) { - String s = escape ? escapeXml((String) v) : (String) v; - ss.append(pad(indent)).append('<').append(k).append('>'); - ss.append(s); - ss.append("').append('\n'); - } else if (v instanceof Map) { - ss.append(pad(indent)).append('<').append(k).append('>').append('\n'); - ss.append(generateXml(v, indent + 1, escape)); - ss.append(pad(indent)).append("').append('\n'); - } else if (v instanceof List) { - List ll = (List) v; - for (Object o1 : ll) { - ss.append(pad(indent)).append('<').append(k).append('>').append('\n'); - ss.append(generateXml(o1, indent + 1, escape)); - ss.append(pad(indent)).append("').append('\n'); - } - } - } - return ss.toString(); - } - - return null; - } - - private static String generateJson(Object o, boolean escape) { - if (o == null) - return null; - - StringBuilder ss = new StringBuilder(); - generateJson(ss, o, 0, false, escape); - return ss.toString(); - } - - @SuppressWarnings("unchecked") - private static void generateJson(StringBuilder ss, Object o, int indent, boolean padFirst, boolean escape) { - if (o instanceof String) { - String s = escape ? escapeJson((String) o) : (String) o; - if (padFirst) - ss.append(pad(indent)); - ss.append('"').append(s).append('"'); - return; - } - - if (o instanceof Map) { - Map mm = (Map) o; - - if (padFirst) - ss.append(pad(indent)); - ss.append("{\n"); - - boolean first = true; - for (String k : mm.keySet()) { - if (!first) - ss.append(",\n"); - first = false; - - Object v = mm.get(k); - ss.append(pad(indent + 1)).append('"').append(k).append("\": "); - generateJson(ss, v, indent + 1, false, escape); - } - - ss.append("\n"); - ss.append(pad(indent)).append('}'); - - return; - } - - if (o instanceof List) { - List ll = (List) 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); - } - - 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 = " 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("&", "&"); - s = s.replaceAll("<", "<"); - s = s.replaceAll("'", "'"); - s = s.replaceAll("\"", """); - s = s.replaceAll(">", ">"); - return s; - } - - private static String escapeJson(String v) { - String s = v.replaceAll("\\\\", "\\\\\\\\"); - s = s.replaceAll("\"", "\\\\\""); - return s; - } - - private static String pad(int n) { - String s = ""; - for (int i = 0; i < n; i++) - s += '\t'; - return s; - } -} diff --git a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/XmlParser.java b/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/XmlParser.java deleted file mode 100644 index e90a44fb8..000000000 --- a/restapi-call-node/provider/src/main/java/org/openecomp/sdnc/restapicall/XmlParser.java +++ /dev/null @@ -1,160 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 ONAP 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.restapicall; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -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 class XmlParser { - - private static final Logger log = LoggerFactory.getLogger(XmlParser.class); - - public static Map convertToProperties(String s, Set listNameList) { - 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 (Exception e) { - e.printStackTrace(); - } - - return handler.getProperties(); - } - - private static class Handler extends DefaultHandler { - - private Set listNameList; - - private Map properties = new HashMap<>(); - - public Map getProperties() { - return properties; - } - - public Handler(Set listNameList) { - super(); - this.listNameList = listNameList; - if (this.listNameList == null) - this.listNameList = new HashSet(); - } - - String currentName = ""; - String currentValue = ""; - - @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 += '.'; - currentName += name; - - String listName = removeIndexes(currentName); - - if (listNameList.contains(listName)) { - int len = getInt(properties, currentName + "_length"); - properties.put(currentName + "_length", String.valueOf(len + 1)); - currentName += "[" + len + "]"; - } - } - - @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); - - if (currentValue.trim().length() > 0) { - currentValue = currentValue.trim(); - properties.put(currentName, currentValue); - - log.info("Added property: " + currentName + ": " + currentValue); - - currentValue = ""; - } - - int i1 = currentName.lastIndexOf("." + name); - if (i1 <= 0) - currentName = ""; - else - currentName = 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 += value; - } - - private static int getInt(Map mm, String name) { - String s = mm.get(name); - if (s == null) - return 0; - return Integer.parseInt(s); - } - - private String removeIndexes(String currentName) { - String s = ""; - 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) - s += c; - } - return s; - } - } -} diff --git a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml index a7b1a8923..583563bc0 100644 --- a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml +++ b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml @@ -38,12 +38,12 @@ - + - + diff --git a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml index 09e3de783..7b74a899f 100644 --- a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml +++ b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml @@ -27,6 +27,6 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - + diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java new file mode 100644 index 000000000..a32b2f286 --- /dev/null +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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 jtest.org.onap.ccsdk.sli.plugins.restapicall; + +import java.io.BufferedReader; +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.plugins.restapicall.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 Exception { + BufferedReader in = new BufferedReader(new InputStreamReader(ClassLoader.getSystemResourceAsStream("test.json"))); + String ss = ""; + String line = null; + while ((line = in.readLine()) != null) + ss += line + '\n'; + + Map mm = JsonParser.convertToProperties(ss); + + logProperties(mm); + + in.close(); + } + + private void logProperties(Map mm) { + List 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/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java new file mode 100644 index 000000000..318a0a248 --- /dev/null +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -0,0 +1,92 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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 jtest.org.onap.ccsdk.sli.plugins.restapicall; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestRestapiCallNode { + + private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class); + + + @Test + public void testDelete() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "pwd1"); + p.put("httpMethod", "delete"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testJsonTemplate() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "3"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].clci", "clci"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].clci", "clci"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } +} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java new file mode 100644 index 000000000..0346690a2 --- /dev/null +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java @@ -0,0 +1,215 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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 jtest.org.onap.ccsdk.sli.plugins.restapicall; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.ccsdk.sli.plugins.restapicall.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 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); + } + + @Test + public void testRemoveEmptyStructXml() { + String xmlin = "" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " blah\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " blah blah\n" + + "\n"; + + String xmloutexpected = "" + + "\n" + + " \n" + + " blah\n" + + " \n" + + " blah blah\n" + + "\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/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java new file mode 100644 index 000000000..a6d3d59ef --- /dev/null +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 ONAP 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 jtest.org.onap.ccsdk.sli.plugins.restapicall; + +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.plugins.restapicall.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"))); + String ss = ""; + String line = null; + while ((line = in.readLine()) != null) + ss += line + '\n'; + + Set listNameList = new HashSet(); + 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 mm = XmlParser.convertToProperties(ss, listNameList); + + logProperties(mm); + + in.close(); + } + + private void logProperties(Map mm) { + List 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/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestJsonParser.java b/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestJsonParser.java deleted file mode 100644 index 16fa68594..000000000 --- a/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestJsonParser.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 ONAP 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 jtest.org.openecomp.sdnc.restapicall; - -import java.io.BufferedReader; -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.openecomp.sdnc.restapicall.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 Exception { - BufferedReader in = new BufferedReader(new InputStreamReader(ClassLoader.getSystemResourceAsStream("test.json"))); - String ss = ""; - String line = null; - while ((line = in.readLine()) != null) - ss += line + '\n'; - - Map mm = JsonParser.convertToProperties(ss); - - logProperties(mm); - - in.close(); - } - - private void logProperties(Map mm) { - List 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/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestRestapiCallNode.java deleted file mode 100644 index e0e58ad50..000000000 --- a/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestRestapiCallNode.java +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 ONAP 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 jtest.org.openecomp.sdnc.restapicall; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.openecomp.sdnc.restapicall.RestapiCallNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestRestapiCallNode { - - private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class); - - - @Test - public void testDelete() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "pwd1"); - p.put("httpMethod", "delete"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testJsonTemplate() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.sdn-circuit-req-row_length", "3"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].clci", "clci"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].clci", "clci"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/test-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } -} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestXmlJsonUtil.java b/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestXmlJsonUtil.java deleted file mode 100644 index dbcf98a98..000000000 --- a/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestXmlJsonUtil.java +++ /dev/null @@ -1,215 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 ONAP 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 jtest.org.openecomp.sdnc.restapicall; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Assert; -import org.junit.Test; -import org.openecomp.sdnc.restapicall.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 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); - } - - @Test - public void testRemoveEmptyStructXml() { - String xmlin = "" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " blah\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " blah blah\n" + - "\n"; - - String xmloutexpected = "" + - "\n" + - " \n" + - " blah\n" + - " \n" + - " blah blah\n" + - "\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/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestXmlParser.java b/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestXmlParser.java deleted file mode 100644 index 980eded4e..000000000 --- a/restapi-call-node/provider/src/test/java/jtest/org/openecomp/sdnc/restapicall/TestXmlParser.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 ONAP 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 jtest.org.openecomp.sdnc.restapicall; - -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.openecomp.sdnc.restapicall.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"))); - String ss = ""; - String line = null; - while ((line = in.readLine()) != null) - ss += line + '\n'; - - Set listNameList = new HashSet(); - 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 mm = XmlParser.convertToProperties(ss, listNameList); - - logProperties(mm); - - in.close(); - } - - private void logProperties(Map mm) { - List 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/restapi-call-node/provider/src/test/resources/test.xml b/restapi-call-node/provider/src/test/resources/test.xml index 76205ddec..330064eab 100644 --- a/restapi-call-node/provider/src/test/resources/test.xml +++ b/restapi-call-node/provider/src/test/resources/test.xml @@ -23,7 +23,7 @@ 4.0.0 - org.openecomp.sdnctl + org.onap.ccsdk.sli.plugins restapi-call-node 6.0.0-SNAPSHOT @@ -47,12 +47,12 @@ test - org.openecomp.sdnctl + org.onap.ccsdk.sli sli-common compile - org.openecomp.sdnctl + org.onap.ccsdk.sli sli-provider compile @@ -99,7 +99,7 @@ com.brocade.developer providermodule-plugin - org.openecomp.sdnctl + org.onap.ccsdk.sli.plugins restapi-call-node @@ -119,8 +119,8 @@ true - org.openecomp.sdnc.restapicall - org.openecomp.sdnc.restapicall + org.onap.ccsdk.sli.plugins.restapicall + org.onap.ccsdk.sli.plugins.restapicall * diff --git a/restapi-call-node/provider/src/test/resources/test3.xml b/restapi-call-node/provider/src/test/resources/test3.xml index 2bf3be356..921161639 100644 --- a/restapi-call-node/provider/src/test/resources/test3.xml +++ b/restapi-call-node/provider/src/test/resources/test3.xml @@ -20,8 +20,8 @@ ============LICENSE_END========================================================= --> - + ICOREPVC-81114561 -- cgit From 0c7f2223a42ae9f1a9ac8954e9b9194e929b72f6 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 15 Aug 2017 10:18:56 -0400 Subject: Port sli/plugins to Carbon Updated sli/plugins to compile against OpenDaylight Carbon SR1 Change-Id: I5ca937a5a9b51cb0dadd3648c71fe2c5dcefdcf1 Issue-ID: CCSDK-26 Signed-off-by: Dan Timoney --- pom.xml | 4 ++-- properties-node/features/pom.xml | 4 ++-- properties-node/features/src/main/resources/features.xml | 4 ++-- properties-node/installer/pom.xml | 2 +- properties-node/installer/src/assembly/assemble_installer_zip.xml | 4 ++-- properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml | 4 ++-- .../installer/src/main/resources/scripts/install-feature.sh | 4 ++-- properties-node/pom.xml | 4 ++-- properties-node/provider/pom.xml | 4 ++-- .../src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java | 4 ++-- .../src/main/resources/META-INF/spring/properties-node-context.xml | 4 ++-- .../main/resources/META-INF/spring/properties-node-osgi-context.xml | 4 ++-- restapi-call-node/features/pom.xml | 4 ++-- restapi-call-node/features/src/main/resources/features.xml | 4 ++-- restapi-call-node/installer/pom.xml | 2 +- restapi-call-node/installer/src/assembly/assemble_installer_zip.xml | 4 ++-- restapi-call-node/installer/src/assembly/assemble_mvnrepo_zip.xml | 4 ++-- .../installer/src/main/resources/scripts/install-feature.sh | 4 ++-- restapi-call-node/pom.xml | 4 ++-- restapi-call-node/provider/pom.xml | 4 ++-- .../src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java | 4 ++-- .../main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpMethod.java | 4 ++-- .../java/org/onap/ccsdk/sli/plugins/restapicall/HttpResponse.java | 4 ++-- .../main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java | 4 ++-- .../main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java | 4 ++-- .../java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java | 4 ++-- .../java/org/onap/ccsdk/sli/plugins/restapicall/RetryException.java | 4 ++-- .../main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java | 4 ++-- .../java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java | 4 ++-- .../main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java | 4 ++-- .../main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java | 4 ++-- .../src/main/resources/META-INF/spring/restapi-call-node-context.xml | 4 ++-- .../main/resources/META-INF/spring/restapi-call-node-osgi-context.xml | 4 ++-- .../provider/src/main/resources/northbound-api-template.xml | 4 ++-- .../jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java | 4 ++-- .../org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java | 4 ++-- .../jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java | 4 ++-- .../jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java | 4 ++-- restapi-call-node/provider/src/test/resources/test.xml | 4 ++-- restapi-call-node/provider/src/test/resources/test3.xml | 4 ++-- 40 files changed, 78 insertions(+), 78 deletions(-) diff --git a/pom.xml b/pom.xml index 215f173fd..4af5fb508 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent - odlparent-boron-sr3 + odlparent-carbon-sr1 0.0.1-SNAPSHOT @@ -112,7 +112,7 @@ AT&T - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 159ac4740..d23d9979c 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -4,10 +4,10 @@ properties-node org.onap.ccsdk.sli.plugins - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT org.onap.ccsdk.sli.plugins - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT properties-node-features Properties Node - Features diff --git a/properties-node/features/src/main/resources/features.xml b/properties-node/features/src/main/resources/features.xml index 2ed98a124..5f0d7b55d 100644 --- a/properties-node/features/src/main/resources/features.xml +++ b/properties-node/features/src/main/resources/features.xml @@ -3,8 +3,8 @@ ============LICENSE_START======================================================= openECOMP : SDN-C ================================================================================ - Copyright (C) 2017 ONAP Intellectual Property. All rights - reserved. + 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. diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 5749a9b99..7e6ae1740 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,7 +5,7 @@ properties-node org.onap.ccsdk.sli.plugins - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT properties-node-installer Properties node - Karaf Installer diff --git a/properties-node/installer/src/assembly/assemble_installer_zip.xml b/properties-node/installer/src/assembly/assemble_installer_zip.xml index e278872a1..3bed4b5ef 100644 --- a/properties-node/installer/src/assembly/assemble_installer_zip.xml +++ b/properties-node/installer/src/assembly/assemble_installer_zip.xml @@ -2,8 +2,8 @@ ============LICENSE_START======================================================= openECOMP : SDN-C ================================================================================ - Copyright (C) 2017 ONAP Intellectual Property. All rights - reserved. + 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. diff --git a/properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml b/properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml index 1edacdb6d..cb56f2cd4 100644 --- a/properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml +++ b/properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -2,8 +2,8 @@ ============LICENSE_START======================================================= openECOMP : SDN-C ================================================================================ - Copyright (C) 2017 ONAP Intellectual Property. All rights - reserved. + 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. diff --git a/properties-node/installer/src/main/resources/scripts/install-feature.sh b/properties-node/installer/src/main/resources/scripts/install-feature.sh index 9a47d2225..e986764b9 100644 --- a/properties-node/installer/src/main/resources/scripts/install-feature.sh +++ b/properties-node/installer/src/main/resources/scripts/install-feature.sh @@ -4,8 +4,8 @@ # ============LICENSE_START======================================================= # openECOMP : SDN-C # ================================================================================ -# Copyright (C) 2017 ONAP Intellectual Property. All rights -# reserved. +# 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. diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 8d6af7c57..44d89f924 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -3,7 +3,7 @@ org.onap.ccsdk.sli.plugins sdnc-plugins - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT 4.0.0 @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins properties-node - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT Properties Node This is an implementation of DG Execute Node that reads property file and diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 43369adf7..1c5eff74c 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -4,10 +4,10 @@ org.onap.ccsdk.sli.plugins properties-node - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT org.onap.ccsdk.sli.plugins - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT properties-node-provider bundle Properties Node - Provider diff --git a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java index aa5663066..165b706be 100644 --- a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java +++ b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * 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. diff --git a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml index 048acc4aa..fd7ace8a5 100644 --- a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml +++ b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml @@ -3,8 +3,8 @@ ============LICENSE_START======================================================= openECOMP : SDN-C ================================================================================ - Copyright (C) 2017 ONAP Intellectual Property. All rights - reserved. + 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. diff --git a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml index ce17a4611..19275fc9d 100644 --- a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml +++ b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml @@ -3,8 +3,8 @@ ============LICENSE_START======================================================= openECOMP : SDN-C ================================================================================ - Copyright (C) 2017 ONAP Intellectual Property. All rights - reserved. + 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. diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index cf9473383..93ee00373 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -4,10 +4,10 @@ restapi-call-node org.onap.ccsdk.sli.plugins - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT org.onap.ccsdk.sli.plugins - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT restapi-call-node-features RESTAPI Call Node - Features diff --git a/restapi-call-node/features/src/main/resources/features.xml b/restapi-call-node/features/src/main/resources/features.xml index dbbe1b1c1..5a7f1f497 100644 --- a/restapi-call-node/features/src/main/resources/features.xml +++ b/restapi-call-node/features/src/main/resources/features.xml @@ -3,8 +3,8 @@ ============LICENSE_START======================================================= openECOMP : SDN-C ================================================================================ - Copyright (C) 2017 ONAP Intellectual Property. All rights - reserved. + 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. diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index db0aae60d..9fa4496a1 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ restapi-call-node org.onap.ccsdk.sli.plugins - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT restapi-call-node-installer Properties node - Karaf Installer diff --git a/restapi-call-node/installer/src/assembly/assemble_installer_zip.xml b/restapi-call-node/installer/src/assembly/assemble_installer_zip.xml index e278872a1..3bed4b5ef 100644 --- a/restapi-call-node/installer/src/assembly/assemble_installer_zip.xml +++ b/restapi-call-node/installer/src/assembly/assemble_installer_zip.xml @@ -2,8 +2,8 @@ ============LICENSE_START======================================================= openECOMP : SDN-C ================================================================================ - Copyright (C) 2017 ONAP Intellectual Property. All rights - reserved. + 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. diff --git a/restapi-call-node/installer/src/assembly/assemble_mvnrepo_zip.xml b/restapi-call-node/installer/src/assembly/assemble_mvnrepo_zip.xml index 1edacdb6d..cb56f2cd4 100644 --- a/restapi-call-node/installer/src/assembly/assemble_mvnrepo_zip.xml +++ b/restapi-call-node/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -2,8 +2,8 @@ ============LICENSE_START======================================================= openECOMP : SDN-C ================================================================================ - Copyright (C) 2017 ONAP Intellectual Property. All rights - reserved. + 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. diff --git a/restapi-call-node/installer/src/main/resources/scripts/install-feature.sh b/restapi-call-node/installer/src/main/resources/scripts/install-feature.sh index 9a47d2225..e986764b9 100644 --- a/restapi-call-node/installer/src/main/resources/scripts/install-feature.sh +++ b/restapi-call-node/installer/src/main/resources/scripts/install-feature.sh @@ -4,8 +4,8 @@ # ============LICENSE_START======================================================= # openECOMP : SDN-C # ================================================================================ -# Copyright (C) 2017 ONAP Intellectual Property. All rights -# reserved. +# 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. diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 86a27bb0d..e201c2708 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -3,7 +3,7 @@ org.onap.ccsdk.sli.plugins sdnc-plugins - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT 4.0.0 @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins restapi-call-node - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT RESTAPI Call Node This is an implementation of DG Execute Node that makes a call to an external REST API diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 4b328d3d0..0d695bb26 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -4,11 +4,11 @@ org.onap.ccsdk.sli.plugins restapi-call-node - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT bundle RESTAPI Call Node - Provider http://maven.apache.org diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java index 249378a06..573c85f78 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * 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. diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpMethod.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpMethod.java index e991a72b3..40dfa3714 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpMethod.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpMethod.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * 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. diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpResponse.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpResponse.java index 9fe449c75..66993aabc 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpResponse.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpResponse.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * 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. diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java index 2a9716079..f22aa0b39 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * 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. diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java index 8d1335cc5..1eed09e90 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * 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. diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 9de11fb0a..ef3145552 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * 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. diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryException.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryException.java index 2a8002819..03078c652 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryException.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryException.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * 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. diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java index 3059a4457..69334a969 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * 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. diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java index 18ec2fb76..b139da279 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * 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. diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java index 5131c8745..2fa3fa541 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * 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. diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java index 7a3243762..8f3febcaf 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * 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. diff --git a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml index 583563bc0..25ce0120a 100644 --- a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml +++ b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml @@ -3,8 +3,8 @@ ============LICENSE_START======================================================= openECOMP : SDN-C ================================================================================ - Copyright (C) 2017 ONAP Intellectual Property. All rights - reserved. + 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. diff --git a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml index 7b74a899f..8f34005d5 100644 --- a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml +++ b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml @@ -3,8 +3,8 @@ ============LICENSE_START======================================================= openECOMP : SDN-C ================================================================================ - Copyright (C) 2017 ONAP Intellectual Property. All rights - reserved. + 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. diff --git a/restapi-call-node/provider/src/main/resources/northbound-api-template.xml b/restapi-call-node/provider/src/main/resources/northbound-api-template.xml index 03530a729..5c2b9ad9a 100644 --- a/restapi-call-node/provider/src/main/resources/northbound-api-template.xml +++ b/restapi-call-node/provider/src/main/resources/northbound-api-template.xml @@ -2,8 +2,8 @@ ============LICENSE_START======================================================= openECOMP : SDN-C ================================================================================ - Copyright (C) 2017 ONAP Intellectual Property. All rights - reserved. + 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. diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java index a32b2f286..107e8c88e 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * 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. diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index 318a0a248..5b03bff47 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * 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. diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java index 0346690a2..ad1c34e90 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * 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. diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java index a6d3d59ef..6d506ccec 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * Copyright (C) 2017 ONAP Intellectual Property. All rights - * reserved. + * 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. diff --git a/restapi-call-node/provider/src/test/resources/test.xml b/restapi-call-node/provider/src/test/resources/test.xml index 330064eab..391c9b3e0 100644 --- a/restapi-call-node/provider/src/test/resources/test.xml +++ b/restapi-call-node/provider/src/test/resources/test.xml @@ -3,8 +3,8 @@ ============LICENSE_START======================================================= openECOMP : SDN-C ================================================================================ - Copyright (C) 2017 ONAP Intellectual Property. All rights - reserved. + 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. diff --git a/restapi-call-node/provider/src/test/resources/test3.xml b/restapi-call-node/provider/src/test/resources/test3.xml index 921161639..809a208eb 100644 --- a/restapi-call-node/provider/src/test/resources/test3.xml +++ b/restapi-call-node/provider/src/test/resources/test3.xml @@ -3,8 +3,8 @@ ============LICENSE_START======================================================= openECOMP : SDN-C ================================================================================ - Copyright (C) 2017 ONAP Intellectual Property. All rights - reserved. + 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. -- cgit From 3785e7ac4f5bd4c3bae2b066fddc640209f86e1d Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Wed, 23 Aug 2017 11:20:07 -0700 Subject: Remove obsolete settings.xml files Issue-Id: CCSDK-1 Change-Id: I73a814f27ca83a3a78e35cea34a7516b705c5961 Signed-off-by: Marcus G K Williams --- example-settings.xml | 163 ------------------------------------------------- jenkins-settings.xml | 168 --------------------------------------------------- 2 files changed, 331 deletions(-) delete mode 100644 example-settings.xml delete mode 100644 jenkins-settings.xml diff --git a/example-settings.xml b/example-settings.xml deleted file mode 100644 index 06c84eb6d..000000000 --- a/example-settings.xml +++ /dev/null @@ -1,163 +0,0 @@ - - - - - - - - onap-release - - - onap-release - onap-release - https://ecomp-nexus:8443/repository/maven-releases/ - - true - never - - - false - - - - - - onap-release - onap-release - https://ecomp-nexus:8443/repository/maven-releases/ - - true - never - - - false - - - - - - - onap-snapshots - - - onap-snapshot - onap-snapshot - https://ecomp-nexus:8443/repository/maven-snapshots/ - - false - - - true - - - - - - onap-snapshot - onap-snapshot - https://ecomp-nexus:8443/repository/maven-snapshots/ - - false - - - true - - - - - - opendaylight-release - - - opendaylight-mirror - opendaylight-mirror - https://nexus.opendaylight.org/content/repositories/public/ - - true - never - - - false - - - - - - opendaylight-mirror - opendaylight-mirror - https://nexus.opendaylight.org/content/repositories/public/ - - true - never - - - false - - - - - - - opendaylight-snapshots - - - opendaylight-snapshot - opendaylight-snapshot - https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ - - false - - - true - - - - - - opendaylight-snapshot - opendaylight-snapshot - https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ - - false - - - true - - - - - - - - onap-release - onap-snapshots - opendaylight-release - opendaylight-snapshots - - - - - nexus - USERNAME - PASSWORD - - - onap-release - USERNAME - PASSWORD - - - onap-snapshot - USERNAME - PASSWORD - - - diff --git a/jenkins-settings.xml b/jenkins-settings.xml deleted file mode 100644 index 88f9805f1..000000000 --- a/jenkins-settings.xml +++ /dev/null @@ -1,168 +0,0 @@ - - - - - - - - onap-release - - - onap-release - onap-release - https://ecomp-nexus:8443/repository/maven-releases/ - - true - never - - - false - - - - - - onap-release - onap-release - https://ecomp-nexus:8443/repository/maven-releases/ - - true - never - - - false - - - - - - - onap-snapshots - - - onap-snapshot - onap-snapshot - https://ecomp-nexus:8443/repository/maven-snapshots/ - - false - - - true - - - - - - onap-snapshot - onap-snapshot - https://ecomp-nexus:8443/repository/maven-snapshots/ - - false - - - true - - - - - - opendaylight-release - - - opendaylight-mirror - opendaylight-mirror - https://nexus.opendaylight.org/content/repositories/public/ - - true - never - - - false - - - - - - opendaylight-mirror - opendaylight-mirror - https://nexus.opendaylight.org/content/repositories/public/ - - true - never - - - false - - - - - - - opendaylight-snapshots - - - opendaylight-snapshot - opendaylight-snapshot - https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ - - false - - - true - - - - - - opendaylight-snapshot - opendaylight-snapshot - https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ - - false - - - true - - - - - - - - onap-release - onap-snapshots - opendaylight-release - opendaylight-snapshots - - - - - nexus - ${ecomp.nexus.user} - ${ecomp.nexus.password} - - - onap-release - ${ecomp.nexus.user} - ${ecomp.nexus.password} - - - onap-snapshot - ${ecomp.nexus.user} - ${ecomp.nexus.password} - - - sdnc-javadoc - ${ecomp.nexus.user} - ${ecomp.nexus.password} - - - -- cgit From 9042880234791fbe2e0ef033091ba93cb7f088f5 Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Wed, 23 Aug 2017 11:47:08 -0700 Subject: Conform ccsdk/sli/plugins to ONAP Style Per ONAP Style Guide: 1. Convert tabs to 4 spaces. 2. Break lines to be less than 120 characters 3. Clean ecomp references 4. Remove extraneous spaces Issue-Id: CCSDK-1 Change-Id: I5638326170aa3ab26774b373ab573643840e97ab Signed-off-by: Marcus G K Williams --- README.md | 4 +- pom.xml | 226 ++-- properties-node/features/pom.xml | 238 ++-- .../features/src/main/resources/features.xml | 22 +- properties-node/installer/pom.xml | 254 ++-- .../src/assembly/assemble_installer_zip.xml | 58 +- .../src/assembly/assemble_mvnrepo_zip.xml | 38 +- .../src/main/resources/scripts/install-feature.sh | 6 +- properties-node/pom.xml | 68 +- properties-node/provider/pom.xml | 152 +-- .../ccsdk/sli/plugins/prop/PropertiesNode.java | 100 +- .../META-INF/spring/properties-node-context.xml | 4 +- .../spring/properties-node-osgi-context.xml | 8 +- restapi-call-node/pom.xml | 66 +- restapi-call-node/provider/pom.xml | 176 +-- .../ccsdk/sli/plugins/restapicall/JsonParser.java | 96 +- .../sli/plugins/restapicall/RestapiCallNode.java | 1297 ++++++++++---------- .../ccsdk/sli/plugins/restapicall/RetryPolicy.java | 3 +- .../ccsdk/sli/plugins/restapicall/XmlJsonUtil.java | 676 +++++----- .../ccsdk/sli/plugins/restapicall/XmlParser.java | 236 ++-- .../META-INF/spring/restapi-call-node-context.xml | 30 +- .../spring/restapi-call-node-osgi-context.xml | 8 +- .../src/main/resources/default-ueb-message.json | 12 +- .../main/resources/northbound-api-template.json | 42 +- .../src/main/resources/northbound-api-template.xml | 2 +- .../sli/plugins/restapicall/TestJsonParser.java | 44 +- .../plugins/restapicall/TestRestapiCallNode.java | 100 +- .../sli/plugins/restapicall/TestXmlJsonUtil.java | 115 +- .../sli/plugins/restapicall/TestXmlParser.java | 58 +- .../provider/src/test/resources/test.json | 50 +- .../provider/src/test/resources/test.xml | 280 ++--- .../provider/src/test/resources/test3.xml | 116 +- 32 files changed, 2316 insertions(+), 2269 deletions(-) diff --git a/README.md b/README.md index 4e733caff..3ad2eae11 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -This source repository contains the code for the SDN Controller plugins. +This source repository contains the code for the CCSDK plugins. To compile this code: -1. Make sure your local Maven settings file ($HOME/.m2/settings.xml) contains references to the OpenECOMP repositories and OpenDaylight repositories. See example-settings.xml for an example. +1. Make sure your local Maven settings file ($HOME/.m2/settings.xml) contains references to the ONAP repositories and OpenDaylight repositories. See example-settings.xml for an example. 2. To compile, run "mvn clean install". diff --git a/pom.xml b/pom.xml index 4af5fb508..71303b796 100755 --- a/pom.xml +++ b/pom.xml @@ -1,118 +1,118 @@ - - - org.onap.ccsdk.parent - odlparent-carbon-sr1 - 0.0.1-SNAPSHOT - - - 4.0.0 - pom - org.onap.ccsdk.sli.plugins - sdnc-plugins - - SDN-C Java Plugins - https://wiki.onap.org - The SDN-C core components contains the SLI, dblib and root pom - - - - JIRA - https://jira.onap.org/ - - - - - scm:git:ssh://git@${onap.git.host}/ccsdk/sli/plugins.git - scm:git:ssh://${onap.git.host}:${onap.git.port}/${onap.git.project}/ccsdk/sli/plugins.git - ${onap.git.protocol}://${onap.git.host}/projects/${onap.git.project}/repos/ccsdk/sli/plugins/browse - HEAD - - - - Jenkins - https://jenkins.onap.org - - - - - - sdnc-javadoc - dav:https://${onap.nexus.host}/content/sites/site/org/onap/sdnc/plugins/${project.artifactId}/${project.version} - - - - - - blackduck - - - blackduck-scan - - - - - - com.blackducksoftware.integration - hub-maven-plugin - 1.4.0 - false - - ${project.name} - ${project.basedir} - - - - create-bdio-file - package - - createHubOutput - - - - - - - - - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.17 - - true - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - https://${onap.nexus.host} - ${onap.nexus.staging.profile-id} - ${onap.nexus.staging.server-id} - - - - - - - properties-node - restapi-call-node - - - AT&T - - 0.1.0-SNAPSHOT + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + + org.onap.ccsdk.parent + odlparent-carbon-sr1 + 0.0.1-SNAPSHOT + + + 4.0.0 + pom + org.onap.ccsdk.sli.plugins + sdnc-plugins + + SDN-C Java Plugins + https://wiki.onap.org + The SDN-C core components contains the SLI, dblib and root pom + + + + JIRA + https://jira.onap.org/ + + + + + scm:git:ssh://git@${onap.git.host}/ccsdk/sli/plugins.git + scm:git:ssh://${onap.git.host}:${onap.git.port}/${onap.git.project}/ccsdk/sli/plugins.git + ${onap.git.protocol}://${onap.git.host}/projects/${onap.git.project}/repos/ccsdk/sli/plugins/browse + HEAD + + + + Jenkins + https://jenkins.onap.org + + + + + + sdnc-javadoc + dav:https://${onap.nexus.host}/content/sites/site/org/onap/sdnc/plugins/${project.artifactId}/${project.version} + + + + + + blackduck + + + blackduck-scan + + + + + + com.blackducksoftware.integration + hub-maven-plugin + 1.4.0 + false + + ${project.name} + ${project.basedir} + + + + create-bdio-file + package + + createHubOutput + + + + + + + + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.17 + + true + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + https://${onap.nexus.host} + ${onap.nexus.staging.profile-id} + ${onap.nexus.staging.server-id} + + + + + + + properties-node + restapi-call-node + + + AT&T + + 0.1.0-SNAPSHOT diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index d23d9979c..5573d1e7a 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -1,135 +1,135 @@ - 4.0.0 - - properties-node - org.onap.ccsdk.sli.plugins - 0.1.0-SNAPSHOT - - org.onap.ccsdk.sli.plugins - 0.1.0-SNAPSHOT - properties-node-features - Properties Node - Features + 4.0.0 + + properties-node + org.onap.ccsdk.sli.plugins + 0.1.0-SNAPSHOT + + org.onap.ccsdk.sli.plugins + 0.1.0-SNAPSHOT + properties-node-features + Properties Node - Features - jar + jar - + - - org.onap.ccsdk.sli.plugins - properties-node-provider - ${project.version} - + + org.onap.ccsdk.sli.plugins + properties-node-provider + ${project.version} + - - commons-lang - commons-lang - 2.6 - compile - + + commons-lang + commons-lang + 2.6 + compile + - - org.opendaylight.mdsal - features-mdsal - ${odl.mdsal.features.version} - features - xml + + org.opendaylight.mdsal + features-mdsal + ${odl.mdsal.features.version} + features + xml - runtime - + runtime + - - - org.opendaylight.controller - opendaylight-karaf-empty - ${odl.karaf.empty.distro.version} - zip - + + + org.opendaylight.controller + opendaylight-karaf-empty + ${odl.karaf.empty.distro.version} + zip + - - - org.opendaylight.odlparent - features-test - ${odl.commons.opendaylight.version} - test - + + + org.opendaylight.odlparent + features-test + ${odl.commons.opendaylight.version} + test + - - org.opendaylight.yangtools - features-yangtools - ${odl.yangtools.version} - features - xml - runtime - - + + org.opendaylight.yangtools + features-yangtools + ${odl.yangtools.version} + features + xml + runtime + + - - - - true - src/main/resources - - - - - org.apache.maven.plugins - maven-resources-plugin - - - filter - - resources - - generate-resources - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/${features.file} - xml - features - - - - - - - - + org.apache.maven.plugins + maven-surefire-plugin + 2.16 + + + org.opendaylight.controller + opendaylight-karaf-empty + ${odl.karaf.empty.distro.version} + + + org.opendaylight.yangtools:features-test + + + + --> + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + diff --git a/properties-node/features/src/main/resources/features.xml b/properties-node/features/src/main/resources/features.xml index 5f0d7b55d..96f37a9e0 100644 --- a/properties-node/features/src/main/resources/features.xml +++ b/properties-node/features/src/main/resources/features.xml @@ -22,18 +22,18 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0"> - mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features + mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features - - sdnc-sli - spring - spring-dm - mvn:org.onap.ccsdk.sli.plugins/properties-node-provider/${project.version} - - + + sdnc-sli + spring + spring-dm + mvn:org.onap.ccsdk.sli.plugins/properties-node-provider/${project.version} + + diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 7e6ae1740..570eced79 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -1,139 +1,139 @@ - 4.0.0 - - properties-node - org.onap.ccsdk.sli.plugins - 0.1.0-SNAPSHOT - - properties-node-installer - Properties node - Karaf Installer - pom + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + properties-node + org.onap.ccsdk.sli.plugins + 0.1.0-SNAPSHOT + + properties-node-installer + Properties node - Karaf Installer + pom - - sdnc-properties-node - sdnc-properties-node - mvn:org.onap.ccsdk.sli.plugins/properties-node-features/${project.version}/xml/features - false - + + sdnc-properties-node + sdnc-properties-node + mvn:org.onap.ccsdk.sli.plugins/properties-node-features/${project.version}/xml/features + false + - + - - org.onap.ccsdk.sli.plugins - properties-node-features - ${project.version} - features - xml - - - * - * - - - + + org.onap.ccsdk.sli.plugins + properties-node-features + ${project.version} + features + xml + + + * + * + + + - - org.onap.ccsdk.sli.plugins - properties-node-provider - ${project.version} - + + org.onap.ccsdk.sli.plugins + properties-node-provider + ${project.version} + - + - - - - maven-assembly-plugin - 2.6 - - - maven-repo-zip - - single - - package - - false - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - false - - - - installer-zip - - single - - package - - true - ${application.name}-${project.version}-installer - - src/assembly/assemble_installer_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - false - ${project.build.directory}/assembly/system - false - true - true - true - false - false - org.onap.ccsdk.sli - sli-common,sli-provider,dblib-provider - provided - - - - - - maven-resources-plugin - 2.6 - - - copy-version - - copy-resources - - validate - - ${basedir}/target/stage - - - src/main/resources/scripts - - install-feature.sh - - true - - - - + + + + maven-assembly-plugin + 2.6 + + + maven-repo-zip + + single + + package + + false + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + false + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli + sli-common,sli-provider,dblib-provider + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + - - + + - - + + diff --git a/properties-node/installer/src/assembly/assemble_installer_zip.xml b/properties-node/installer/src/assembly/assemble_installer_zip.xml index 3bed4b5ef..b6fd65582 100644 --- a/properties-node/installer/src/assembly/assemble_installer_zip.xml +++ b/properties-node/installer/src/assembly/assemble_installer_zip.xml @@ -22,37 +22,37 @@ - installer_zip - - zip - + xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> + installer_zip + + zip + - - false + + false - - - target/stage/ - ${application.name} - 755 - - *.sh - - - - target/stage/ - ${application.name} - 644 - - *.sh - - - + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + diff --git a/properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml b/properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml index cb56f2cd4..2ee224477 100644 --- a/properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml +++ b/properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -22,27 +22,27 @@ - mvnrepo_zip - - zip - + xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> + mvnrepo_zip + + zip + - - false + + false - - - target/assembly/ - . - - - - + + + target/assembly/ + . + + + + diff --git a/properties-node/installer/src/main/resources/scripts/install-feature.sh b/properties-node/installer/src/main/resources/scripts/install-feature.sh index e986764b9..df03392c8 100644 --- a/properties-node/installer/src/main/resources/scripts/install-feature.sh +++ b/properties-node/installer/src/main/resources/scripts/install-feature.sh @@ -30,10 +30,10 @@ REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip if [ -f ${REPOZIP} ] then - unzip -d ${ODL_HOME} ${REPOZIP} + unzip -d ${ODL_HOME} ${REPOZIP} else - echo "ERROR : repo zip ($REPOZIP) not found" - exit 1 + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 fi ${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 44d89f924..066db5e08 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -1,43 +1,43 @@ - - org.onap.ccsdk.sli.plugins - sdnc-plugins - 0.1.0-SNAPSHOT - + + org.onap.ccsdk.sli.plugins + sdnc-plugins + 0.1.0-SNAPSHOT + - 4.0.0 - pom + 4.0.0 + pom - org.onap.ccsdk.sli.plugins - properties-node - 0.1.0-SNAPSHOT + org.onap.ccsdk.sli.plugins + properties-node + 0.1.0-SNAPSHOT - Properties Node - This is an implementation of DG Execute Node that reads property file and - puts the properties in the DG context + Properties Node + This is an implementation of DG Execute Node that reads property file and + puts the properties in the DG context - - - - org.onap.ccsdk.sli.plugins - properties-node-features - features - xml - ${project.version} - - - org.onap.ccsdk.sli.plugins - properties-node-provider - ${project.version} - - - + + + + org.onap.ccsdk.sli.plugins + properties-node-features + features + xml + ${project.version} + + + org.onap.ccsdk.sli.plugins + properties-node-provider + ${project.version} + + + - - provider - features - installer - + + provider + features + installer + diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 1c5eff74c..a5249d98b 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -1,89 +1,89 @@ - 4.0.0 - - org.onap.ccsdk.sli.plugins - properties-node - 0.1.0-SNAPSHOT - - org.onap.ccsdk.sli.plugins - 0.1.0-SNAPSHOT - properties-node-provider - bundle - Properties Node - Provider - http://maven.apache.org - - UTF-8 - - - - junit - junit - test - - - org.springframework - spring-test - ${spring.version} - test - - - org.onap.ccsdk.sli.core - sli-common - ${sdnctl.sli.version} - compile - - - org.onap.ccsdk.sli.core - sli-provider - ${sdnctl.sli.version} - compile - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.slf4j - jcl-over-slf4j - ${slf4j.version} - - - org.springframework - spring-beans - ${spring.version} - - - org.springframework - spring-context - ${spring.version} - - + 4.0.0 + + org.onap.ccsdk.sli.plugins + properties-node + 0.1.0-SNAPSHOT + + org.onap.ccsdk.sli.plugins + 0.1.0-SNAPSHOT + properties-node-provider + bundle + Properties Node - Provider + http://maven.apache.org + + UTF-8 + + + + junit + junit + test + + + org.springframework + spring-test + ${spring.version} + test + + + org.onap.ccsdk.sli.core + sli-common + ${sdnctl.sli.version} + compile + + + org.onap.ccsdk.sli.core + sli-provider + ${sdnctl.sli.version} + compile + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + org.springframework + spring-beans + ${spring.version} + + + org.springframework + spring-context + ${spring.version} + + - - + + - - org.apache.felix - maven-bundle-plugin - true - - - org.onap.ccsdk.sli.prop - org.onap.ccsdk.sli.prop - * - + + org.apache.felix + maven-bundle-plugin + true + + + org.onap.ccsdk.sli.prop + org.onap.ccsdk.sli.prop + * + - + - + - + - + diff --git a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java index 165b706be..b4886d552 100644 --- a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java +++ b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java @@ -35,63 +35,63 @@ import org.slf4j.LoggerFactory; public class PropertiesNode implements SvcLogicJavaPlugin { - private static final Logger log = LoggerFactory.getLogger(PropertiesNode.class); + private static final Logger log = LoggerFactory.getLogger(PropertiesNode.class); - public void readProperties(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { - String fileName = parseParam(paramMap, "fileName", true, null); - String contextPrefix = parseParam(paramMap, "contextPrefix", false, null); + public void readProperties(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { + String fileName = parseParam(paramMap, "fileName", true, null); + String contextPrefix = parseParam(paramMap, "contextPrefix", false, null); - try { - Properties pp = new Properties(); - InputStream in = new FileInputStream(fileName); - pp.load(in); - for (Object key : pp.keySet()) { - String pfx = contextPrefix != null ? contextPrefix + '.' : ""; - String name = (String) key; - String value = pp.getProperty(name); - if (value != null && value.trim().length() > 0) { - ctx.setAttribute(pfx + name, value.trim()); - log.info("+++ " + pfx + name + ": [" + value + "]"); - } - } - } catch (IOException e) { - throw new SvcLogicException("Cannot read property file: " + fileName + ": " + e.getMessage(), e); - } - } + try { + Properties pp = new Properties(); + InputStream in = new FileInputStream(fileName); + pp.load(in); + for (Object key : pp.keySet()) { + String pfx = contextPrefix != null ? contextPrefix + '.' : ""; + String name = (String) key; + String value = pp.getProperty(name); + if (value != null && value.trim().length() > 0) { + ctx.setAttribute(pfx + name, value.trim()); + log.info("+++ " + pfx + name + ": [" + value + "]"); + } + } + } catch (IOException e) { + throw new SvcLogicException("Cannot read property file: " + fileName + ": " + e.getMessage(), e); + } + } - private String parseParam(Map paramMap, String name, boolean required, String def) - throws SvcLogicException { - String s = paramMap.get(name); + private String parseParam(Map paramMap, String name, boolean required, String def) + throws SvcLogicException { + String s = paramMap.get(name); - if (s == null || s.trim().length() == 0) { - if (!required) - return def; - throw new SvcLogicException("Parameter " + name + " is required in PropertiesNode"); - } + if (s == null || s.trim().length() == 0) { + if (!required) + return def; + throw new SvcLogicException("Parameter " + name + " is required in PropertiesNode"); + } - s = s.trim(); - String value = ""; - int i = 0; - int i1 = s.indexOf('%'); - while (i1 >= 0) { - int i2 = s.indexOf('%', i1 + 1); - if (i2 < 0) - throw new SvcLogicException("Cannot parse parameter " + name + ": " + s + ": no matching %"); + s = s.trim(); + String value = ""; + int i = 0; + int i1 = s.indexOf('%'); + while (i1 >= 0) { + int i2 = s.indexOf('%', i1 + 1); + if (i2 < 0) + throw new SvcLogicException("Cannot parse parameter " + name + ": " + s + ": no matching %"); - String varName = s.substring(i1 + 1, i2); - String varValue = System.getenv(varName); - if (varValue == null) - varValue = ""; + String varName = s.substring(i1 + 1, i2); + String varValue = System.getenv(varName); + if (varValue == null) + varValue = ""; - value += s.substring(i, i1); - value += varValue; + value += s.substring(i, i1); + value += varValue; - i = i2 + 1; - i1 = s.indexOf('%', i); - } - value += s.substring(i); + i = i2 + 1; + i1 = s.indexOf('%', i); + } + value += s.substring(i); - log.info("Parameter " + name + ": " + value); - return value; - } + log.info("Parameter " + name + ": " + value); + return value; + } } diff --git a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml index fd7ace8a5..52d1cd96a 100644 --- a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml +++ b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml @@ -26,7 +26,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - - + + diff --git a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml index 19275fc9d..a46e37c7b 100644 --- a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml +++ b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml @@ -21,12 +21,12 @@ --> - + diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index e201c2708..7e1886f43 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -1,42 +1,42 @@ - - org.onap.ccsdk.sli.plugins - sdnc-plugins - 0.1.0-SNAPSHOT - + + org.onap.ccsdk.sli.plugins + sdnc-plugins + 0.1.0-SNAPSHOT + - 4.0.0 - pom + 4.0.0 + pom - org.onap.ccsdk.sli.plugins - restapi-call-node - 0.1.0-SNAPSHOT + org.onap.ccsdk.sli.plugins + restapi-call-node + 0.1.0-SNAPSHOT - RESTAPI Call Node - This is an implementation of DG Execute Node that makes a call to an external REST API + RESTAPI Call Node + This is an implementation of DG Execute Node that makes a call to an external REST API - - - - org.onap.ccsdk.sli.plugins - restapi-call-node-features - features - xml - ${project.version} - - - org.onap.ccsdk.sli.plugins - restapi-call-node-provider - ${project.version} - - - + + + + org.onap.ccsdk.sli.plugins + restapi-call-node-features + features + xml + ${project.version} + + + org.onap.ccsdk.sli.plugins + restapi-call-node-provider + ${project.version} + + + - - provider - features - installer - + + provider + features + installer + diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 0d695bb26..ca3f004a0 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -1,101 +1,101 @@ - 4.0.0 - - org.onap.ccsdk.sli.plugins - restapi-call-node - 0.1.0-SNAPSHOT - - org.onap.ccsdk.sli.plugins - restapi-call-node-provider - 0.1.0-SNAPSHOT - bundle - RESTAPI Call Node - Provider - http://maven.apache.org - - UTF-8 - - - - junit - junit - test - - - org.springframework - spring-test - ${spring.version} - test - - - org.onap.ccsdk.sli.core - sli-common - ${sdnctl.sli.version} - compile - - - org.onap.ccsdk.sli.core - sli-provider - ${sdnctl.sli.version} - compile - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.slf4j - jcl-over-slf4j - ${slf4j.version} - - - org.springframework - spring-beans - ${spring.version} - - - org.springframework - spring-context - ${spring.version} - - - com.sun.jersey - jersey-client - ${jersey.version} - provided - - - org.codehaus.jettison - jettison - ${jettison.version} - provided - - + 4.0.0 + + org.onap.ccsdk.sli.plugins + restapi-call-node + 0.1.0-SNAPSHOT + + org.onap.ccsdk.sli.plugins + restapi-call-node-provider + 0.1.0-SNAPSHOT + bundle + RESTAPI Call Node - Provider + http://maven.apache.org + + UTF-8 + + + + junit + junit + test + + + org.springframework + spring-test + ${spring.version} + test + + + org.onap.ccsdk.sli.core + sli-common + ${sdnctl.sli.version} + compile + + + org.onap.ccsdk.sli.core + sli-provider + ${sdnctl.sli.version} + compile + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + org.springframework + spring-beans + ${spring.version} + + + org.springframework + spring-context + ${spring.version} + + + com.sun.jersey + jersey-client + ${jersey.version} + provided + + + org.codehaus.jettison + jettison + ${jettison.version} + provided + + - - + + - - org.apache.felix - maven-bundle-plugin - true - - - org.onap.ccsdk.sli.restapicall - org.onap.ccsdk.sli.plugins.restapicall - * - + + org.apache.felix + maven-bundle-plugin + true + + + org.onap.ccsdk.sli.restapicall + org.onap.ccsdk.sli.plugins.restapicall + * + - + - + - + - + diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java index f22aa0b39..4de4a34d7 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java @@ -34,52 +34,52 @@ import org.slf4j.LoggerFactory; public class JsonParser { - private static final Logger log = LoggerFactory.getLogger(JsonParser.class); - - @SuppressWarnings("unchecked") - public static Map convertToProperties(String s) throws JSONException { - JSONObject json = new JSONObject(s); - - Map wm = new HashMap(); - Iterator ii = json.keys(); - while (ii.hasNext()) { - String key1 = ii.next(); - wm.put(key1, json.get(key1)); - } - - Map 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 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: " + key + "_length" + ": " + String.valueOf(ja.length())); - - for (int i = 0; i < ja.length(); i++) - wm.put(key + '[' + i + ']', ja.get(i)); - } - } - - return mm; - } + private static final Logger log = LoggerFactory.getLogger(JsonParser.class); + + @SuppressWarnings("unchecked") + public static Map convertToProperties(String s) throws JSONException { + JSONObject json = new JSONObject(s); + + Map wm = new HashMap(); + Iterator ii = json.keys(); + while (ii.hasNext()) { + String key1 = ii.next(); + wm.put(key1, json.get(key1)); + } + + Map 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 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: " + key + "_length" + ": " + String.valueOf(ja.length())); + + for (int i = 0; i < ja.length(); i++) + wm.put(key + '[' + i + ']', ja.get(i)); + } + } + + return mm; + } } diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index ef3145552..fb7722686 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -61,25 +61,25 @@ import com.sun.jersey.client.urlconnection.HTTPSProperties; public class RestapiCallNode implements SvcLogicJavaPlugin { - private static final Logger log = LoggerFactory.getLogger(RestapiCallNode.class); + private static final Logger log = LoggerFactory.getLogger(RestapiCallNode.class); - private String uebServers; - private String defaultUebTemplateFileName = "/opt/bvc/restapi/templates/default-ueb-message.json"; - protected RetryPolicyStore retryPolicyStore; + private String uebServers; + private String defaultUebTemplateFileName = "/opt/bvc/restapi/templates/default-ueb-message.json"; + protected RetryPolicyStore retryPolicyStore; - protected RetryPolicyStore getRetryPolicyStore() { - return retryPolicyStore; - } + protected RetryPolicyStore getRetryPolicyStore() { + return retryPolicyStore; + } - public void setRetryPolicyStore(RetryPolicyStore retryPolicyStore) { - this.retryPolicyStore = retryPolicyStore; - } + public void setRetryPolicyStore(RetryPolicyStore retryPolicyStore) { + this.retryPolicyStore = retryPolicyStore; + } - public RestapiCallNode() { + public RestapiCallNode() { - } + } - /** + /** * Allows Directed Graphs the ability to interact with REST APIs. * @param parameters HashMap of parameters passed by the DG to this function * @@ -106,654 +106,655 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { * @since 11.0.2 * @see String#split(String, int) */ - public void sendRequest(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { - sendRequest(paramMap, ctx, null); - } - - public void sendRequest(Map paramMap, SvcLogicContext ctx, Integer retryCount) - throws SvcLogicException { - - RetryPolicy retryPolicy = null; - HttpResponse r = null; - try { - Parameters p = getParameters(paramMap); - if (p.partner != null) { - retryPolicy = retryPolicyStore.getRetryPolicy(p.partner); - } - String pp = p.responsePrefix != null ? p.responsePrefix + '.' : ""; - - String req = null; - if (p.templateFileName != null) { - String reqTemplate = readFile(p.templateFileName); - req = buildXmlJsonRequest(ctx, reqTemplate, p.format); - } - r = sendHttpRequest(req, p); - setResponseStatus(ctx, p.responsePrefix, r); - - if (p.dumpHeaders && r.headers != null) { + public void sendRequest(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { + sendRequest(paramMap, ctx, null); + } + + public void sendRequest(Map paramMap, SvcLogicContext ctx, Integer retryCount) + throws SvcLogicException { + + RetryPolicy retryPolicy = null; + HttpResponse r = null; + try { + Parameters p = getParameters(paramMap); + if (p.partner != null) { + retryPolicy = retryPolicyStore.getRetryPolicy(p.partner); + } + String pp = p.responsePrefix != null ? p.responsePrefix + '.' : ""; + + String req = null; + if (p.templateFileName != null) { + String reqTemplate = readFile(p.templateFileName); + req = buildXmlJsonRequest(ctx, reqTemplate, p.format); + } + r = sendHttpRequest(req, p); + setResponseStatus(ctx, p.responsePrefix, r); + + if (p.dumpHeaders && r.headers != null) { for (Entry> a : r.headers.entrySet()) { ctx.setAttribute(pp + "header." + a.getKey(), StringUtils.join(a.getValue(), ",")); } } - if (r.body != null && r.body.trim().length() > 0) { - ctx.setAttribute(pp + "httpResponse", r.body); - - if (p.convertResponse) { - Map mm = null; - if (p.format == Format.XML) - mm = XmlParser.convertToProperties(r.body, p.listNameList); - else if (p.format == Format.JSON) - mm = JsonParser.convertToProperties(r.body); - - if (mm != null) - for (String key : mm.keySet()) - ctx.setAttribute(pp + key, mm.get(key)); - } - } - } catch (Exception e) { - boolean shouldRetry = false; - if (e.getCause() instanceof java.net.SocketException) { - shouldRetry = true; - } - - log.error("Error sending the request: " + e.getMessage(), e); - String prefix = parseParam(paramMap, "responsePrefix", false, null); - if (retryPolicy == null || shouldRetry == false) { - setFailureResponseStatus(ctx, prefix, e.getMessage(), r); - } else { - if (retryCount == null) { - retryCount = 0; - } - String retryMessage = retryCount + " attempts were made out of " + retryPolicy.getMaximumRetries() + - " maximum retries."; - log.debug(retryMessage); - try { - retryCount = retryCount + 1; - if (retryCount < retryPolicy.getMaximumRetries() + 1) { - URI uri = new URI(paramMap.get("restapiUrl")); - String hostname = uri.getHost(); - String retryString = retryPolicy.getNextHostName((uri.toString())); - URI uriTwo = new URI(retryString); - URI retryUri = UriBuilder.fromUri(uri).host(uriTwo.getHost()).port(uriTwo.getPort()).scheme( - uriTwo.getScheme()).build(); - paramMap.put("restapiUrl", retryUri.toString()); - log.debug("URL was set to " + retryUri.toString()); - log.debug("Failed to communicate with host " + hostname + - ". Request will be re-attempted using the host " + retryString + "."); - log.debug("This is retry attempt " + retryCount + " out of " + retryPolicy.getMaximumRetries()); - sendRequest(paramMap, ctx, retryCount); - } else { - log.debug("Maximum retries reached, calling setFailureResponseStatus."); - setFailureResponseStatus(ctx, prefix, e.getMessage(), r); - } - } catch (Exception ex) { - log.error("Could not attempt retry.", ex); - String retryErrorMessage = - "Retry attempt has failed. No further retry shall be attempted, calling setFailureResponseStatus."; - setFailureResponseStatus(ctx, prefix, retryErrorMessage, r); - } - } - } - - if (r != null && r.code >= 300) - throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); - } - - protected Parameters getParameters(Map paramMap) throws SvcLogicException { - Parameters p = new Parameters(); - p.templateFileName = parseParam(paramMap, "templateFileName", false, null); - p.restapiUrl = parseParam(paramMap, "restapiUrl", true, null); - p.restapiUser = parseParam(paramMap, "restapiUser", false, null); - p.restapiPassword = parseParam(paramMap, "restapiPassword", false, null); - p.contentType = parseParam(paramMap, "contentType", false, null); - p.format = Format.fromString(parseParam(paramMap, "format", false, "json")); - p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post")); - p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); - p.listNameList = getListNameList(paramMap); - String skipSendingStr = paramMap.get("skipSending"); - p.skipSending = skipSendingStr != null && skipSendingStr.equalsIgnoreCase("true"); - p.convertResponse = Boolean.valueOf(parseParam(paramMap, "convertResponse", false, "true")); - p.trustStoreFileName = parseParam(paramMap, "trustStoreFileName", false, null); - p.trustStorePassword = parseParam(paramMap, "trustStorePassword", false, null); - p.keyStoreFileName = parseParam(paramMap, "keyStoreFileName", false, null); - p.keyStorePassword = parseParam(paramMap, "keyStorePassword", false, null); - p.ssl = p.trustStoreFileName != null && p.trustStorePassword != null && p.keyStoreFileName != null && - p.keyStorePassword != null; - p.customHttpHeaders = parseParam(paramMap, "customHttpHeaders", false, null); - p.partner = parseParam(paramMap, "partner", false, null); - p.dumpHeaders = Boolean.valueOf(parseParam(paramMap, "dumpHeaders", false, null)); - return p; - } - - protected Set getListNameList(Map paramMap) { - Set ll = new HashSet(); - for (String key : paramMap.keySet()) - if (key.startsWith("listName")) - ll.add(paramMap.get(key)); - return ll; - } - - protected String parseParam(Map paramMap, String name, boolean required, String def) - throws SvcLogicException { - String s = paramMap.get(name); - - if (s == null || s.trim().length() == 0) { - if (!required) - return def; - throw new SvcLogicException("Parameter " + name + " is required in RestapiCallNode"); - } - - s = s.trim(); - String value = ""; - int i = 0; - int i1 = s.indexOf('%'); - while (i1 >= 0) { - int i2 = s.indexOf('%', i1 + 1); - if (i2 < 0) - break; - - String varName = s.substring(i1 + 1, i2); - String varValue = System.getenv(varName); - if (varValue == null) - varValue = "%" + varName + "%"; - - value += s.substring(i, i1); - value += varValue; - - i = i2 + 1; - i1 = s.indexOf('%', i); - } - value += s.substring(i); - - log.info("Parameter " + name + ": [" + value + "]"); - return value; - } - - protected String buildXmlJsonRequest(SvcLogicContext ctx, String template, Format format) { - log.info("Building " + format + " started"); - long t1 = System.currentTimeMillis(); - - template = expandRepeats(ctx, template, 1); - - Map mm = new HashMap<>(); - for (String s : ctx.getAttributeKeySet()) - mm.put(s, ctx.getAttribute(s)); - - StringBuilder ss = new StringBuilder(); - int i = 0; - while (i < template.length()) { - int i1 = template.indexOf("${", i); - if (i1 < 0) { - ss.append(template.substring(i)); - break; - } - - int i2 = template.indexOf('}', i1 + 2); - if (i2 < 0) - throw new RuntimeException("Template error: Matching } not found"); - - String var1 = template.substring(i1 + 2, i2); - String value1 = format == Format.XML ? XmlJsonUtil.getXml(mm, var1) : XmlJsonUtil.getJson(mm, var1); - // log.info(" " + var1 + ": " + value1); - if (value1 == null || value1.trim().length() == 0) { - // delete the whole element (line) - int i3 = template.lastIndexOf('\n', i1); - if (i3 < 0) - i3 = 0; - int i4 = template.indexOf('\n', i1); - if (i4 < 0) - i4 = template.length(); - - if (i < i3) - ss.append(template.substring(i, i3)); - i = i4; - } else { - ss.append(template.substring(i, i1)).append(value1); - i = i2 + 1; - } - } - - String req = format == Format.XML - ? XmlJsonUtil.removeEmptyStructXml(ss.toString()) : XmlJsonUtil.removeEmptyStructJson(ss.toString()); - - if (format == Format.JSON) - req = XmlJsonUtil.removeLastCommaJson(req); - - long t2 = System.currentTimeMillis(); - log.info("Building " + format + " completed. Time: " + (t2 - t1)); - - return req; - } - - protected String expandRepeats(SvcLogicContext ctx, String template, int level) { - StringBuilder newTemplate = new StringBuilder(); - int k = 0; - while (k < template.length()) { - int i1 = template.indexOf("${repeat:", k); - if (i1 < 0) { - newTemplate.append(template.substring(k)); - break; - } - - int i2 = template.indexOf(':', i1 + 9); - if (i2 < 0) - throw new RuntimeException( - "Template error: Context variable name followed by : is required after repeat"); - - // Find the closing }, store in i3 - int nn = 1; - int i3 = -1; - int i = i2; - while (nn > 0 && i < template.length()) { - i3 = template.indexOf('}', i); - if (i3 < 0) - throw new RuntimeException("Template error: Matching } not found"); - int i32 = template.indexOf('{', i); - if (i32 >= 0 && i32 < i3) { - nn++; - i = i32 + 1; - } else { - nn--; - i = i3 + 1; - } - } - - String var1 = template.substring(i1 + 9, i2); - String value1 = ctx.getAttribute(var1); - log.info(" " + var1 + ": " + value1); - int n = 0; - try { - n = Integer.parseInt(value1); - } catch (Exception e) { - n = 0; - } - - newTemplate.append(template.substring(k, i1)); - - String rpt = template.substring(i2 + 1, i3); - - for (int ii = 0; ii < n; ii++) { - String ss = rpt.replaceAll("\\[\\$\\{" + level + "\\}\\]", "[" + ii + "]"); - if (ii == n - 1 && ss.trim().endsWith(",")) { - int i4 = ss.lastIndexOf(','); - if (i4 > 0) - ss = ss.substring(0, i4) + ss.substring(i4 + 1); - } - newTemplate.append(ss); - } - - k = i3 + 1; - } - - if (k == 0) - return newTemplate.toString(); - - return expandRepeats(ctx, newTemplate.toString(), level + 1); - } - - protected String readFile(String fileName) throws Exception { - byte[] encoded = Files.readAllBytes(Paths.get(fileName)); - return new String(encoded, "UTF-8"); - } - - protected HttpResponse sendHttpRequest(String request, Parameters p) throws Exception { - ClientConfig config = new DefaultClientConfig(); - SSLContext ssl = null; - if (p.ssl && p.restapiUrl.startsWith("https")) - ssl = createSSLContext(p); - if (ssl != null) { - HostnameVerifier hostnameVerifier = new HostnameVerifier() { - - @Override - public boolean verify(String hostname, SSLSession session) { - return true; - } - }; - - config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, - new HTTPSProperties(hostnameVerifier, ssl)); - } - - logProperties(config.getProperties()); - - Client client = Client.create(config); - client.setConnectTimeout(5000); - if (p.restapiUser != null) - client.addFilter(new HTTPBasicAuthFilter(p.restapiUser, p.restapiPassword)); - WebResource webResource = client.resource(p.restapiUrl); - - log.info("Sending request:"); - log.info(request); - long t1 = System.currentTimeMillis(); - - HttpResponse r = new HttpResponse(); - r.code = 200; - - if (!p.skipSending) { - String tt = p.format == Format.XML ? "application/xml" : "application/json"; - String tt1 = tt + ";charset=UTF-8"; - if (p.contentType != null) { - tt = p.contentType; - tt1 = p.contentType; - } - - WebResource.Builder webResourceBuilder = webResource.accept(tt).type(tt1); + if (r.body != null && r.body.trim().length() > 0) { + ctx.setAttribute(pp + "httpResponse", r.body); + + if (p.convertResponse) { + Map mm = null; + if (p.format == Format.XML) + mm = XmlParser.convertToProperties(r.body, p.listNameList); + else if (p.format == Format.JSON) + mm = JsonParser.convertToProperties(r.body); + + if (mm != null) + for (String key : mm.keySet()) + ctx.setAttribute(pp + key, mm.get(key)); + } + } + } catch (Exception e) { + boolean shouldRetry = false; + if (e.getCause() instanceof java.net.SocketException) { + shouldRetry = true; + } + + log.error("Error sending the request: " + e.getMessage(), e); + String prefix = parseParam(paramMap, "responsePrefix", false, null); + if (retryPolicy == null || shouldRetry == false) { + setFailureResponseStatus(ctx, prefix, e.getMessage(), r); + } else { + if (retryCount == null) { + retryCount = 0; + } + String retryMessage = retryCount + " attempts were made out of " + retryPolicy.getMaximumRetries() + + " maximum retries."; + log.debug(retryMessage); + try { + retryCount = retryCount + 1; + if (retryCount < retryPolicy.getMaximumRetries() + 1) { + URI uri = new URI(paramMap.get("restapiUrl")); + String hostname = uri.getHost(); + String retryString = retryPolicy.getNextHostName((uri.toString())); + URI uriTwo = new URI(retryString); + URI retryUri = UriBuilder.fromUri(uri).host(uriTwo.getHost()).port(uriTwo.getPort()).scheme( + uriTwo.getScheme()).build(); + paramMap.put("restapiUrl", retryUri.toString()); + log.debug("URL was set to " + retryUri.toString()); + log.debug("Failed to communicate with host " + hostname + + ". Request will be re-attempted using the host " + retryString + "."); + log.debug("This is retry attempt " + retryCount + " out of " + retryPolicy.getMaximumRetries()); + sendRequest(paramMap, ctx, retryCount); + } else { + log.debug("Maximum retries reached, calling setFailureResponseStatus."); + setFailureResponseStatus(ctx, prefix, e.getMessage(), r); + } + } catch (Exception ex) { + log.error("Could not attempt retry.", ex); + String retryErrorMessage = + "Retry attempt has failed. No further retry shall be attempted, calling setFailureResponseStatus."; + setFailureResponseStatus(ctx, prefix, retryErrorMessage, r); + } + } + } + + if (r != null && r.code >= 300) + throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); + } + + protected Parameters getParameters(Map paramMap) throws SvcLogicException { + Parameters p = new Parameters(); + p.templateFileName = parseParam(paramMap, "templateFileName", false, null); + p.restapiUrl = parseParam(paramMap, "restapiUrl", true, null); + p.restapiUser = parseParam(paramMap, "restapiUser", false, null); + p.restapiPassword = parseParam(paramMap, "restapiPassword", false, null); + p.contentType = parseParam(paramMap, "contentType", false, null); + p.format = Format.fromString(parseParam(paramMap, "format", false, "json")); + p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post")); + p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); + p.listNameList = getListNameList(paramMap); + String skipSendingStr = paramMap.get("skipSending"); + p.skipSending = skipSendingStr != null && skipSendingStr.equalsIgnoreCase("true"); + p.convertResponse = Boolean.valueOf(parseParam(paramMap, "convertResponse", false, "true")); + p.trustStoreFileName = parseParam(paramMap, "trustStoreFileName", false, null); + p.trustStorePassword = parseParam(paramMap, "trustStorePassword", false, null); + p.keyStoreFileName = parseParam(paramMap, "keyStoreFileName", false, null); + p.keyStorePassword = parseParam(paramMap, "keyStorePassword", false, null); + p.ssl = p.trustStoreFileName != null && p.trustStorePassword != null && p.keyStoreFileName != null && + p.keyStorePassword != null; + p.customHttpHeaders = parseParam(paramMap, "customHttpHeaders", false, null); + p.partner = parseParam(paramMap, "partner", false, null); + p.dumpHeaders = Boolean.valueOf(parseParam(paramMap, "dumpHeaders", false, null)); + return p; + } + + protected Set getListNameList(Map paramMap) { + Set ll = new HashSet(); + for (String key : paramMap.keySet()) + if (key.startsWith("listName")) + ll.add(paramMap.get(key)); + return ll; + } + + protected String parseParam(Map paramMap, String name, boolean required, String def) + throws SvcLogicException { + String s = paramMap.get(name); + + if (s == null || s.trim().length() == 0) { + if (!required) + return def; + throw new SvcLogicException("Parameter " + name + " is required in RestapiCallNode"); + } + + s = s.trim(); + String value = ""; + int i = 0; + int i1 = s.indexOf('%'); + while (i1 >= 0) { + int i2 = s.indexOf('%', i1 + 1); + if (i2 < 0) + break; + + String varName = s.substring(i1 + 1, i2); + String varValue = System.getenv(varName); + if (varValue == null) + varValue = "%" + varName + "%"; + + value += s.substring(i, i1); + value += varValue; + + i = i2 + 1; + i1 = s.indexOf('%', i); + } + value += s.substring(i); + + log.info("Parameter " + name + ": [" + value + "]"); + return value; + } + + protected String buildXmlJsonRequest(SvcLogicContext ctx, String template, Format format) { + log.info("Building " + format + " started"); + long t1 = System.currentTimeMillis(); + + template = expandRepeats(ctx, template, 1); + + Map mm = new HashMap<>(); + for (String s : ctx.getAttributeKeySet()) + mm.put(s, ctx.getAttribute(s)); + + StringBuilder ss = new StringBuilder(); + int i = 0; + while (i < template.length()) { + int i1 = template.indexOf("${", i); + if (i1 < 0) { + ss.append(template.substring(i)); + break; + } + + int i2 = template.indexOf('}', i1 + 2); + if (i2 < 0) + throw new RuntimeException("Template error: Matching } not found"); + + String var1 = template.substring(i1 + 2, i2); + String value1 = format == Format.XML ? XmlJsonUtil.getXml(mm, var1) : XmlJsonUtil.getJson(mm, var1); + // log.info(" " + var1 + ": " + value1); + if (value1 == null || value1.trim().length() == 0) { + // delete the whole element (line) + int i3 = template.lastIndexOf('\n', i1); + if (i3 < 0) + i3 = 0; + int i4 = template.indexOf('\n', i1); + if (i4 < 0) + i4 = template.length(); + + if (i < i3) + ss.append(template.substring(i, i3)); + i = i4; + } else { + ss.append(template.substring(i, i1)).append(value1); + i = i2 + 1; + } + } + + String req = format == Format.XML + ? XmlJsonUtil.removeEmptyStructXml(ss.toString()) : XmlJsonUtil.removeEmptyStructJson(ss.toString()); + + if (format == Format.JSON) + req = XmlJsonUtil.removeLastCommaJson(req); + + long t2 = System.currentTimeMillis(); + log.info("Building " + format + " completed. Time: " + (t2 - t1)); + + return req; + } + + protected String expandRepeats(SvcLogicContext ctx, String template, int level) { + StringBuilder newTemplate = new StringBuilder(); + int k = 0; + while (k < template.length()) { + int i1 = template.indexOf("${repeat:", k); + if (i1 < 0) { + newTemplate.append(template.substring(k)); + break; + } + + int i2 = template.indexOf(':', i1 + 9); + if (i2 < 0) + throw new RuntimeException( + "Template error: Context variable name followed by : is required after repeat"); + + // Find the closing }, store in i3 + int nn = 1; + int i3 = -1; + int i = i2; + while (nn > 0 && i < template.length()) { + i3 = template.indexOf('}', i); + if (i3 < 0) + throw new RuntimeException("Template error: Matching } not found"); + int i32 = template.indexOf('{', i); + if (i32 >= 0 && i32 < i3) { + nn++; + i = i32 + 1; + } else { + nn--; + i = i3 + 1; + } + } + + String var1 = template.substring(i1 + 9, i2); + String value1 = ctx.getAttribute(var1); + log.info(" " + var1 + ": " + value1); + int n = 0; + try { + n = Integer.parseInt(value1); + } catch (Exception e) { + n = 0; + } + + newTemplate.append(template.substring(k, i1)); + + String rpt = template.substring(i2 + 1, i3); + + for (int ii = 0; ii < n; ii++) { + String ss = rpt.replaceAll("\\[\\$\\{" + level + "\\}\\]", "[" + ii + "]"); + if (ii == n - 1 && ss.trim().endsWith(",")) { + int i4 = ss.lastIndexOf(','); + if (i4 > 0) + ss = ss.substring(0, i4) + ss.substring(i4 + 1); + } + newTemplate.append(ss); + } + + k = i3 + 1; + } + + if (k == 0) + return newTemplate.toString(); + + return expandRepeats(ctx, newTemplate.toString(), level + 1); + } + + protected String readFile(String fileName) throws Exception { + byte[] encoded = Files.readAllBytes(Paths.get(fileName)); + return new String(encoded, "UTF-8"); + } + + protected HttpResponse sendHttpRequest(String request, Parameters p) throws Exception { + ClientConfig config = new DefaultClientConfig(); + SSLContext ssl = null; + if (p.ssl && p.restapiUrl.startsWith("https")) + ssl = createSSLContext(p); + if (ssl != null) { + HostnameVerifier hostnameVerifier = new HostnameVerifier() { + + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + }; + + config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, + new HTTPSProperties(hostnameVerifier, ssl)); + } + + logProperties(config.getProperties()); + + Client client = Client.create(config); + client.setConnectTimeout(5000); + if (p.restapiUser != null) + client.addFilter(new HTTPBasicAuthFilter(p.restapiUser, p.restapiPassword)); + WebResource webResource = client.resource(p.restapiUrl); + + log.info("Sending request:"); + log.info(request); + long t1 = System.currentTimeMillis(); + + HttpResponse r = new HttpResponse(); + r.code = 200; + + if (!p.skipSending) { + String tt = p.format == Format.XML ? "application/xml" : "application/json"; + String tt1 = tt + ";charset=UTF-8"; + if (p.contentType != null) { + tt = p.contentType; + tt1 = p.contentType; + } + + WebResource.Builder webResourceBuilder = webResource.accept(tt).type(tt1); if (p.customHttpHeaders != null && p.customHttpHeaders.length() > 0) { String[] keyValuePairs = p.customHttpHeaders.split(","); for (String singlePair : keyValuePairs) { int equalPosition = singlePair.indexOf('='); - webResourceBuilder.header(singlePair.substring(0, equalPosition), singlePair.substring(equalPosition + 1, singlePair.length())); + webResourceBuilder.header(singlePair.substring(0, equalPosition), + singlePair.substring(equalPosition + 1, singlePair.length())); } } webResourceBuilder.header("X-ECOMP-RequestID",org.slf4j.MDC.get("X-ECOMP-RequestID")); - ClientResponse response = webResourceBuilder.method(p.httpMethod.toString(), ClientResponse.class, request); - - r.code = response.getStatus(); - r.headers = response.getHeaders(); - EntityTag etag = response.getEntityTag(); - if (etag != null) - r.message = etag.getValue(); - if (response.hasEntity() && r.code != 204) - r.body = response.getEntity(String.class); - } - - long t2 = System.currentTimeMillis(); - log.info("Response received. Time: " + (t2 - t1)); - log.info("HTTP response code: " + r.code); - log.info("HTTP response message: " + r.message); - logHeaders(r.headers); - log.info("HTTP response: " + r.body); - - return r; - } - - protected SSLContext createSSLContext(Parameters p) { - try { - System.setProperty("jsse.enableSNIExtension", "false"); - System.setProperty("javax.net.ssl.trustStore", p.trustStoreFileName); - System.setProperty("javax.net.ssl.trustStorePassword", p.trustStorePassword); - - HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { - - @Override - public boolean verify(String string, SSLSession ssls) { - return true; - } - }); - - KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); - FileInputStream in = new FileInputStream(p.keyStoreFileName); - KeyStore ks = KeyStore.getInstance("PKCS12"); - char[] pwd = p.keyStorePassword.toCharArray(); - ks.load(in, pwd); - kmf.init(ks, pwd); - - SSLContext ctx = SSLContext.getInstance("TLS"); - ctx.init(kmf.getKeyManagers(), null, null); - return ctx; - } catch (Exception e) { - log.error("Error creating SSLContext: " + e.getMessage(), e); - } - return null; - } - - protected void setFailureResponseStatus(SvcLogicContext ctx, String prefix, String errorMessage, HttpResponse r) { - r = new HttpResponse(); - r.code = 500; - r.message = errorMessage; - String pp = prefix != null ? prefix + '.' : ""; - ctx.setAttribute(pp + "response-code", String.valueOf(r.code)); - ctx.setAttribute(pp + "response-message", r.message); - } - - protected void setResponseStatus(SvcLogicContext ctx, String prefix, HttpResponse r) { - String pp = prefix != null ? prefix + '.' : ""; - ctx.setAttribute(pp + "response-code", String.valueOf(r.code)); - ctx.setAttribute(pp + "response-message", r.message); - } - - public void sendFile(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { - HttpResponse r = null; - try { - FileParam p = getFileParameters(paramMap); - byte[] data = Files.readAllBytes(Paths.get(p.fileName)); - - r = sendHttpData(data, p); - setResponseStatus(ctx, p.responsePrefix, r); - - } catch (Exception e) { - log.error("Error sending the request: " + e.getMessage(), e); - - r = new HttpResponse(); - r.code = 500; - r.message = e.getMessage(); - String prefix = parseParam(paramMap, "responsePrefix", false, null); - setResponseStatus(ctx, prefix, r); - } - - if (r != null && r.code >= 300) - throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); - } - - private static class FileParam { - - public String fileName; - public String url; - public String user; - public String password; - public HttpMethod httpMethod; - public String responsePrefix; - public boolean skipSending; - } - - private FileParam getFileParameters(Map paramMap) throws SvcLogicException { - FileParam p = new FileParam(); - p.fileName = parseParam(paramMap, "fileName", true, null); - p.url = parseParam(paramMap, "url", true, null); - p.user = parseParam(paramMap, "user", false, null); - p.password = parseParam(paramMap, "password", false, null); - p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post")); - p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); - String skipSendingStr = paramMap.get("skipSending"); - p.skipSending = skipSendingStr != null && skipSendingStr.equalsIgnoreCase("true"); - return p; - } - - protected HttpResponse sendHttpData(byte[] data, FileParam p) { - Client client = Client.create(); - client.setConnectTimeout(5000); - client.setFollowRedirects(true); - if (p.user != null) - client.addFilter(new HTTPBasicAuthFilter(p.user, p.password)); - WebResource webResource = client.resource(p.url); - - log.info("Sending file"); - long t1 = System.currentTimeMillis(); - - HttpResponse r = new HttpResponse(); - r.code = 200; - - if (!p.skipSending) { - String tt = "application/octet-stream"; - - ClientResponse response = null; - if (p.httpMethod == HttpMethod.POST) - response = webResource.accept(tt).type(tt).post(ClientResponse.class, data); - else if (p.httpMethod == HttpMethod.PUT) - response = webResource.accept(tt).type(tt).put(ClientResponse.class, data); - - r.code = response.getStatus(); - r.headers = response.getHeaders(); - EntityTag etag = response.getEntityTag(); - if (etag != null) - r.message = etag.getValue(); - if (response.hasEntity() && r.code != 204) - r.body = response.getEntity(String.class); - - if (r.code == 301) { - String newUrl = response.getHeaders().getFirst("Location"); - - log.info("Got response code 301. Sending same request to URL: " + newUrl); - - webResource = client.resource(newUrl); - - if (p.httpMethod == HttpMethod.POST) - response = webResource.accept(tt).type(tt).post(ClientResponse.class, data); - else if (p.httpMethod == HttpMethod.PUT) - response = webResource.accept(tt).type(tt).put(ClientResponse.class, data); - - r.code = response.getStatus(); - etag = response.getEntityTag(); - if (etag != null) - r.message = etag.getValue(); - if (response.hasEntity() && r.code != 204) - r.body = response.getEntity(String.class); - } - } - - long t2 = System.currentTimeMillis(); - log.info("Response received. Time: " + (t2 - t1)); - log.info("HTTP response code: " + r.code); - log.info("HTTP response message: " + r.message); - logHeaders(r.headers); - log.info("HTTP response: " + r.body); - - return r; - } - - public void postMessageOnUeb(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { - HttpResponse r = null; - try { - UebParam p = getUebParameters(paramMap); - - String pp = p.responsePrefix != null ? p.responsePrefix + '.' : ""; - - String req = null; - - if (p.templateFileName == null) { - log.info("No template file name specified. Using default UEB template: " + defaultUebTemplateFileName); - p.templateFileName = defaultUebTemplateFileName; - } - - String reqTemplate = readFile(p.templateFileName); - reqTemplate = reqTemplate.replaceAll("rootVarName", p.rootVarName); - req = buildXmlJsonRequest(ctx, reqTemplate, Format.JSON); - - r = postOnUeb(req, p); - setResponseStatus(ctx, p.responsePrefix, r); - if (r.body != null) - ctx.setAttribute(pp + "httpResponse", r.body); - - } catch (Exception e) { - log.error("Error sending the request: " + e.getMessage(), e); - - r = new HttpResponse(); - r.code = 500; - r.message = e.getMessage(); - String prefix = parseParam(paramMap, "responsePrefix", false, null); - setResponseStatus(ctx, prefix, r); - } - - if (r != null && r.code >= 300) - throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); - } - - private static class UebParam { - - public String topic; - public String templateFileName; - public String rootVarName; - public String responsePrefix; - public boolean skipSending; - } - - private UebParam getUebParameters(Map paramMap) throws SvcLogicException { - UebParam p = new UebParam(); - p.topic = parseParam(paramMap, "topic", true, null); - p.templateFileName = parseParam(paramMap, "templateFileName", false, null); - p.rootVarName = parseParam(paramMap, "rootVarName", false, null); - p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); - String skipSendingStr = paramMap.get("skipSending"); - p.skipSending = skipSendingStr != null && skipSendingStr.equalsIgnoreCase("true"); - return p; - } - - protected HttpResponse postOnUeb(String request, UebParam p) throws Exception { - String[] urls = uebServers.split(" "); - for (int i = 0; i < urls.length; i++) { - if (!urls[i].endsWith("/")) - urls[i] += "/"; - urls[i] += "events/" + p.topic; - } - - Client client = Client.create(); - client.setConnectTimeout(5000); - WebResource webResource = client.resource(urls[0]); - - log.info("UEB URL: " + urls[0]); - log.info("Sending request:"); - log.info(request); - long t1 = System.currentTimeMillis(); - - HttpResponse r = new HttpResponse(); - r.code = 200; - - if (!p.skipSending) { - String tt = "application/json"; - String tt1 = tt + ";charset=UTF-8"; - - ClientResponse response = webResource.accept(tt).type(tt1).post(ClientResponse.class, request); - - r.code = response.getStatus(); - r.headers = response.getHeaders(); - if (response.hasEntity()) - r.body = response.getEntity(String.class); - } - - long t2 = System.currentTimeMillis(); - log.info("Response received. Time: " + (t2 - t1)); - log.info("HTTP response code: " + r.code); - logHeaders(r.headers); - log.info("HTTP response:\n" + r.body); - - return r; - } - - protected void logProperties(Map mm) { - List 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 + ": " + String.valueOf(mm.get(name))); - } - - protected void logHeaders(MultivaluedMap mm) { - log.info("HTTP response headers:"); - - if (mm == null) - return; - - List ll = new ArrayList<>(); - for (Object o : mm.keySet()) - ll.add((String) o); - Collections.sort(ll); - - for (String name : ll) - log.info("--- " + name + ": " + String.valueOf(mm.get(name))); - } - - public void setUebServers(String uebServers) { - this.uebServers = uebServers; - } - - public void setDefaultUebTemplateFileName(String defaultUebTemplateFileName) { - this.defaultUebTemplateFileName = defaultUebTemplateFileName; - } + ClientResponse response = webResourceBuilder.method(p.httpMethod.toString(), ClientResponse.class, request); + + r.code = response.getStatus(); + r.headers = response.getHeaders(); + EntityTag etag = response.getEntityTag(); + if (etag != null) + r.message = etag.getValue(); + if (response.hasEntity() && r.code != 204) + r.body = response.getEntity(String.class); + } + + long t2 = System.currentTimeMillis(); + log.info("Response received. Time: " + (t2 - t1)); + log.info("HTTP response code: " + r.code); + log.info("HTTP response message: " + r.message); + logHeaders(r.headers); + log.info("HTTP response: " + r.body); + + return r; + } + + protected SSLContext createSSLContext(Parameters p) { + try { + System.setProperty("jsse.enableSNIExtension", "false"); + System.setProperty("javax.net.ssl.trustStore", p.trustStoreFileName); + System.setProperty("javax.net.ssl.trustStorePassword", p.trustStorePassword); + + HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { + + @Override + public boolean verify(String string, SSLSession ssls) { + return true; + } + }); + + KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); + FileInputStream in = new FileInputStream(p.keyStoreFileName); + KeyStore ks = KeyStore.getInstance("PKCS12"); + char[] pwd = p.keyStorePassword.toCharArray(); + ks.load(in, pwd); + kmf.init(ks, pwd); + + SSLContext ctx = SSLContext.getInstance("TLS"); + ctx.init(kmf.getKeyManagers(), null, null); + return ctx; + } catch (Exception e) { + log.error("Error creating SSLContext: " + e.getMessage(), e); + } + return null; + } + + protected void setFailureResponseStatus(SvcLogicContext ctx, String prefix, String errorMessage, HttpResponse r) { + r = new HttpResponse(); + r.code = 500; + r.message = errorMessage; + String pp = prefix != null ? prefix + '.' : ""; + ctx.setAttribute(pp + "response-code", String.valueOf(r.code)); + ctx.setAttribute(pp + "response-message", r.message); + } + + protected void setResponseStatus(SvcLogicContext ctx, String prefix, HttpResponse r) { + String pp = prefix != null ? prefix + '.' : ""; + ctx.setAttribute(pp + "response-code", String.valueOf(r.code)); + ctx.setAttribute(pp + "response-message", r.message); + } + + public void sendFile(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { + HttpResponse r = null; + try { + FileParam p = getFileParameters(paramMap); + byte[] data = Files.readAllBytes(Paths.get(p.fileName)); + + r = sendHttpData(data, p); + setResponseStatus(ctx, p.responsePrefix, r); + + } catch (Exception e) { + log.error("Error sending the request: " + e.getMessage(), e); + + r = new HttpResponse(); + r.code = 500; + r.message = e.getMessage(); + String prefix = parseParam(paramMap, "responsePrefix", false, null); + setResponseStatus(ctx, prefix, r); + } + + if (r != null && r.code >= 300) + throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); + } + + private static class FileParam { + + public String fileName; + public String url; + public String user; + public String password; + public HttpMethod httpMethod; + public String responsePrefix; + public boolean skipSending; + } + + private FileParam getFileParameters(Map paramMap) throws SvcLogicException { + FileParam p = new FileParam(); + p.fileName = parseParam(paramMap, "fileName", true, null); + p.url = parseParam(paramMap, "url", true, null); + p.user = parseParam(paramMap, "user", false, null); + p.password = parseParam(paramMap, "password", false, null); + p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post")); + p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); + String skipSendingStr = paramMap.get("skipSending"); + p.skipSending = skipSendingStr != null && skipSendingStr.equalsIgnoreCase("true"); + return p; + } + + protected HttpResponse sendHttpData(byte[] data, FileParam p) { + Client client = Client.create(); + client.setConnectTimeout(5000); + client.setFollowRedirects(true); + if (p.user != null) + client.addFilter(new HTTPBasicAuthFilter(p.user, p.password)); + WebResource webResource = client.resource(p.url); + + log.info("Sending file"); + long t1 = System.currentTimeMillis(); + + HttpResponse r = new HttpResponse(); + r.code = 200; + + if (!p.skipSending) { + String tt = "application/octet-stream"; + + ClientResponse response = null; + if (p.httpMethod == HttpMethod.POST) + response = webResource.accept(tt).type(tt).post(ClientResponse.class, data); + else if (p.httpMethod == HttpMethod.PUT) + response = webResource.accept(tt).type(tt).put(ClientResponse.class, data); + + r.code = response.getStatus(); + r.headers = response.getHeaders(); + EntityTag etag = response.getEntityTag(); + if (etag != null) + r.message = etag.getValue(); + if (response.hasEntity() && r.code != 204) + r.body = response.getEntity(String.class); + + if (r.code == 301) { + String newUrl = response.getHeaders().getFirst("Location"); + + log.info("Got response code 301. Sending same request to URL: " + newUrl); + + webResource = client.resource(newUrl); + + if (p.httpMethod == HttpMethod.POST) + response = webResource.accept(tt).type(tt).post(ClientResponse.class, data); + else if (p.httpMethod == HttpMethod.PUT) + response = webResource.accept(tt).type(tt).put(ClientResponse.class, data); + + r.code = response.getStatus(); + etag = response.getEntityTag(); + if (etag != null) + r.message = etag.getValue(); + if (response.hasEntity() && r.code != 204) + r.body = response.getEntity(String.class); + } + } + + long t2 = System.currentTimeMillis(); + log.info("Response received. Time: " + (t2 - t1)); + log.info("HTTP response code: " + r.code); + log.info("HTTP response message: " + r.message); + logHeaders(r.headers); + log.info("HTTP response: " + r.body); + + return r; + } + + public void postMessageOnUeb(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { + HttpResponse r = null; + try { + UebParam p = getUebParameters(paramMap); + + String pp = p.responsePrefix != null ? p.responsePrefix + '.' : ""; + + String req = null; + + if (p.templateFileName == null) { + log.info("No template file name specified. Using default UEB template: " + defaultUebTemplateFileName); + p.templateFileName = defaultUebTemplateFileName; + } + + String reqTemplate = readFile(p.templateFileName); + reqTemplate = reqTemplate.replaceAll("rootVarName", p.rootVarName); + req = buildXmlJsonRequest(ctx, reqTemplate, Format.JSON); + + r = postOnUeb(req, p); + setResponseStatus(ctx, p.responsePrefix, r); + if (r.body != null) + ctx.setAttribute(pp + "httpResponse", r.body); + + } catch (Exception e) { + log.error("Error sending the request: " + e.getMessage(), e); + + r = new HttpResponse(); + r.code = 500; + r.message = e.getMessage(); + String prefix = parseParam(paramMap, "responsePrefix", false, null); + setResponseStatus(ctx, prefix, r); + } + + if (r != null && r.code >= 300) + throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); + } + + private static class UebParam { + + public String topic; + public String templateFileName; + public String rootVarName; + public String responsePrefix; + public boolean skipSending; + } + + private UebParam getUebParameters(Map paramMap) throws SvcLogicException { + UebParam p = new UebParam(); + p.topic = parseParam(paramMap, "topic", true, null); + p.templateFileName = parseParam(paramMap, "templateFileName", false, null); + p.rootVarName = parseParam(paramMap, "rootVarName", false, null); + p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); + String skipSendingStr = paramMap.get("skipSending"); + p.skipSending = skipSendingStr != null && skipSendingStr.equalsIgnoreCase("true"); + return p; + } + + protected HttpResponse postOnUeb(String request, UebParam p) throws Exception { + String[] urls = uebServers.split(" "); + for (int i = 0; i < urls.length; i++) { + if (!urls[i].endsWith("/")) + urls[i] += "/"; + urls[i] += "events/" + p.topic; + } + + Client client = Client.create(); + client.setConnectTimeout(5000); + WebResource webResource = client.resource(urls[0]); + + log.info("UEB URL: " + urls[0]); + log.info("Sending request:"); + log.info(request); + long t1 = System.currentTimeMillis(); + + HttpResponse r = new HttpResponse(); + r.code = 200; + + if (!p.skipSending) { + String tt = "application/json"; + String tt1 = tt + ";charset=UTF-8"; + + ClientResponse response = webResource.accept(tt).type(tt1).post(ClientResponse.class, request); + + r.code = response.getStatus(); + r.headers = response.getHeaders(); + if (response.hasEntity()) + r.body = response.getEntity(String.class); + } + + long t2 = System.currentTimeMillis(); + log.info("Response received. Time: " + (t2 - t1)); + log.info("HTTP response code: " + r.code); + logHeaders(r.headers); + log.info("HTTP response:\n" + r.body); + + return r; + } + + protected void logProperties(Map mm) { + List 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 + ": " + String.valueOf(mm.get(name))); + } + + protected void logHeaders(MultivaluedMap mm) { + log.info("HTTP response headers:"); + + if (mm == null) + return; + + List ll = new ArrayList<>(); + for (Object o : mm.keySet()) + ll.add((String) o); + Collections.sort(ll); + + for (String name : ll) + log.info("--- " + name + ": " + String.valueOf(mm.get(name))); + } + + public void setUebServers(String uebServers) { + this.uebServers = uebServers; + } + + public void setDefaultUebTemplateFileName(String defaultUebTemplateFileName) { + this.defaultUebTemplateFileName = defaultUebTemplateFileName; + } } diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java index 69334a969..5cee07791 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java @@ -40,7 +40,8 @@ public class RetryPolicy { } if(position == null){ - throw new RetryException("No match found for the provided uri[" + uri + "] so the next host name could not be retreived"); + throw new RetryException("No match found for the provided uri[" + uri + "] " + + "so the next host name could not be retreived"); } position++; diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java index 2fa3fa541..16b9f519f 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java @@ -31,342 +31,342 @@ import org.slf4j.LoggerFactory; public class XmlJsonUtil { - private static final Logger log = LoggerFactory.getLogger(XmlJsonUtil.class); - - public static String getXml(Map 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 varmap, String var) { - boolean escape = true; - if (var.startsWith("'")) { - var = var.substring(1); - escape = false; - } - - Object o = createStructure(varmap, var); - return generateJson(o, escape); - } - - private static Object createStructure(Map flatmap, String var) { - if (flatmap.containsKey(var)) { - if (var.endsWith("_length") || var.endsWith("].key")) - return null; - return flatmap.get(var); - } - - Map 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 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 " + var + "_length:" + lengthStr); - } - } - - 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 mm = (Map) o; - for (String k : mm.keySet()) { - Object v = mm.get(k); - if (v instanceof String) { - String s = escape ? escapeXml((String) v) : (String) v; - ss.append(pad(indent)).append('<').append(k).append('>'); - ss.append(s); - ss.append("').append('\n'); - } else if (v instanceof Map) { - ss.append(pad(indent)).append('<').append(k).append('>').append('\n'); - ss.append(generateXml(v, indent + 1, escape)); - ss.append(pad(indent)).append("').append('\n'); - } else if (v instanceof List) { - List ll = (List) v; - for (Object o1 : ll) { - ss.append(pad(indent)).append('<').append(k).append('>').append('\n'); - ss.append(generateXml(o1, indent + 1, escape)); - ss.append(pad(indent)).append("').append('\n'); - } - } - } - return ss.toString(); - } - - return null; - } - - private static String generateJson(Object o, boolean escape) { - if (o == null) - return null; - - StringBuilder ss = new StringBuilder(); - generateJson(ss, o, 0, false, escape); - return ss.toString(); - } - - @SuppressWarnings("unchecked") - private static void generateJson(StringBuilder ss, Object o, int indent, boolean padFirst, boolean escape) { - if (o instanceof String) { - String s = escape ? escapeJson((String) o) : (String) o; - if (padFirst) - ss.append(pad(indent)); - ss.append('"').append(s).append('"'); - return; - } - - if (o instanceof Map) { - Map mm = (Map) o; - - if (padFirst) - ss.append(pad(indent)); - ss.append("{\n"); - - boolean first = true; - for (String k : mm.keySet()) { - if (!first) - ss.append(",\n"); - first = false; - - Object v = mm.get(k); - ss.append(pad(indent + 1)).append('"').append(k).append("\": "); - generateJson(ss, v, indent + 1, false, escape); - } - - ss.append("\n"); - ss.append(pad(indent)).append('}'); - - return; - } - - if (o instanceof List) { - List ll = (List) 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); - } - - 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 = " 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("&", "&"); - s = s.replaceAll("<", "<"); - s = s.replaceAll("'", "'"); - s = s.replaceAll("\"", """); - s = s.replaceAll(">", ">"); - return s; - } - - private static String escapeJson(String v) { - String s = v.replaceAll("\\\\", "\\\\\\\\"); - s = s.replaceAll("\"", "\\\\\""); - return s; - } - - private static String pad(int n) { - String s = ""; - for (int i = 0; i < n; i++) - s += '\t'; - return s; - } + private static final Logger log = LoggerFactory.getLogger(XmlJsonUtil.class); + + public static String getXml(Map 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 varmap, String var) { + boolean escape = true; + if (var.startsWith("'")) { + var = var.substring(1); + escape = false; + } + + Object o = createStructure(varmap, var); + return generateJson(o, escape); + } + + private static Object createStructure(Map flatmap, String var) { + if (flatmap.containsKey(var)) { + if (var.endsWith("_length") || var.endsWith("].key")) + return null; + return flatmap.get(var); + } + + Map 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 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 " + var + "_length:" + lengthStr); + } + } + + 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 mm = (Map) o; + for (String k : mm.keySet()) { + Object v = mm.get(k); + if (v instanceof String) { + String s = escape ? escapeXml((String) v) : (String) v; + ss.append(pad(indent)).append('<').append(k).append('>'); + ss.append(s); + ss.append("').append('\n'); + } else if (v instanceof Map) { + ss.append(pad(indent)).append('<').append(k).append('>').append('\n'); + ss.append(generateXml(v, indent + 1, escape)); + ss.append(pad(indent)).append("').append('\n'); + } else if (v instanceof List) { + List ll = (List) v; + for (Object o1 : ll) { + ss.append(pad(indent)).append('<').append(k).append('>').append('\n'); + ss.append(generateXml(o1, indent + 1, escape)); + ss.append(pad(indent)).append("').append('\n'); + } + } + } + return ss.toString(); + } + + return null; + } + + private static String generateJson(Object o, boolean escape) { + if (o == null) + return null; + + StringBuilder ss = new StringBuilder(); + generateJson(ss, o, 0, false, escape); + return ss.toString(); + } + + @SuppressWarnings("unchecked") + private static void generateJson(StringBuilder ss, Object o, int indent, boolean padFirst, boolean escape) { + if (o instanceof String) { + String s = escape ? escapeJson((String) o) : (String) o; + if (padFirst) + ss.append(pad(indent)); + ss.append('"').append(s).append('"'); + return; + } + + if (o instanceof Map) { + Map mm = (Map) o; + + if (padFirst) + ss.append(pad(indent)); + ss.append("{\n"); + + boolean first = true; + for (String k : mm.keySet()) { + if (!first) + ss.append(",\n"); + first = false; + + Object v = mm.get(k); + ss.append(pad(indent + 1)).append('"').append(k).append("\": "); + generateJson(ss, v, indent + 1, false, escape); + } + + ss.append("\n"); + ss.append(pad(indent)).append('}'); + + return; + } + + if (o instanceof List) { + List ll = (List) 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); + } + + 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 = " 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("&", "&"); + s = s.replaceAll("<", "<"); + s = s.replaceAll("'", "'"); + s = s.replaceAll("\"", """); + s = s.replaceAll(">", ">"); + return s; + } + + private static String escapeJson(String v) { + String s = v.replaceAll("\\\\", "\\\\\\\\"); + s = s.replaceAll("\"", "\\\\\""); + return s; + } + + private static String pad(int n) { + String s = ""; + for (int i = 0; i < n; i++) + s += '\t'; + return s; + } } diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java index 8f3febcaf..85c9dc018 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java @@ -39,122 +39,122 @@ import org.xml.sax.helpers.DefaultHandler; public class XmlParser { - private static final Logger log = LoggerFactory.getLogger(XmlParser.class); - - public static Map convertToProperties(String s, Set listNameList) { - 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 (Exception e) { - e.printStackTrace(); - } - - return handler.getProperties(); - } - - private static class Handler extends DefaultHandler { - - private Set listNameList; - - private Map properties = new HashMap<>(); - - public Map getProperties() { - return properties; - } - - public Handler(Set listNameList) { - super(); - this.listNameList = listNameList; - if (this.listNameList == null) - this.listNameList = new HashSet(); - } - - String currentName = ""; - String currentValue = ""; - - @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 += '.'; - currentName += name; - - String listName = removeIndexes(currentName); - - if (listNameList.contains(listName)) { - int len = getInt(properties, currentName + "_length"); - properties.put(currentName + "_length", String.valueOf(len + 1)); - currentName += "[" + len + "]"; - } - } - - @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); - - if (currentValue.trim().length() > 0) { - currentValue = currentValue.trim(); - properties.put(currentName, currentValue); - - log.info("Added property: " + currentName + ": " + currentValue); - - currentValue = ""; - } - - int i1 = currentName.lastIndexOf("." + name); - if (i1 <= 0) - currentName = ""; - else - currentName = 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 += value; - } - - private static int getInt(Map mm, String name) { - String s = mm.get(name); - if (s == null) - return 0; - return Integer.parseInt(s); - } - - private String removeIndexes(String currentName) { - String s = ""; - 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) - s += c; - } - return s; - } - } + private static final Logger log = LoggerFactory.getLogger(XmlParser.class); + + public static Map convertToProperties(String s, Set listNameList) { + 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 (Exception e) { + e.printStackTrace(); + } + + return handler.getProperties(); + } + + private static class Handler extends DefaultHandler { + + private Set listNameList; + + private Map properties = new HashMap<>(); + + public Map getProperties() { + return properties; + } + + public Handler(Set listNameList) { + super(); + this.listNameList = listNameList; + if (this.listNameList == null) + this.listNameList = new HashSet(); + } + + String currentName = ""; + String currentValue = ""; + + @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 += '.'; + currentName += name; + + String listName = removeIndexes(currentName); + + if (listNameList.contains(listName)) { + int len = getInt(properties, currentName + "_length"); + properties.put(currentName + "_length", String.valueOf(len + 1)); + currentName += "[" + len + "]"; + } + } + + @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); + + if (currentValue.trim().length() > 0) { + currentValue = currentValue.trim(); + properties.put(currentName, currentValue); + + log.info("Added property: " + currentName + ": " + currentValue); + + currentValue = ""; + } + + int i1 = currentName.lastIndexOf("." + name); + if (i1 <= 0) + currentName = ""; + else + currentName = 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 += value; + } + + private static int getInt(Map mm, String name) { + String s = mm.get(name); + if (s == null) + return 0; + return Integer.parseInt(s); + } + + private String removeIndexes(String currentName) { + String s = ""; + 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) + s += c; + } + return s; + } + } } diff --git a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml index 25ce0120a..87850624c 100644 --- a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml +++ b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml @@ -24,26 +24,26 @@ 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"> - - - + + + file:${SDNC_CONFIG_DIR}/ueb.properties file:${SDNC_CONFIG_DIR}/dme2.properties - - - - + + + + - + - - - - + + + + - - - + + + diff --git a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml index 8f34005d5..2f1e4dbde 100644 --- a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml +++ b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml @@ -21,12 +21,12 @@ --> - + diff --git a/restapi-call-node/provider/src/main/resources/default-ueb-message.json b/restapi-call-node/provider/src/main/resources/default-ueb-message.json index 4b1aa0386..6ef6be7f6 100644 --- a/restapi-call-node/provider/src/main/resources/default-ueb-message.json +++ b/restapi-call-node/provider/src/main/resources/default-ueb-message.json @@ -20,13 +20,13 @@ */ { - "event":{ - "header":{ - "eventSource":"sdn-c" - }, - "body": + "event":{ + "header":{ + "eventSource":"sdn-c" + }, + "body": ${rootVarName} - } + } } diff --git a/restapi-call-node/provider/src/main/resources/northbound-api-template.json b/restapi-call-node/provider/src/main/resources/northbound-api-template.json index d48c41ce9..73a61b636 100644 --- a/restapi-call-node/provider/src/main/resources/northbound-api-template.json +++ b/restapi-call-node/provider/src/main/resources/northbound-api-template.json @@ -19,25 +19,25 @@ * ============LICENSE_END========================================================= */ -{ -"input": - { - "sdnc-request-header":{ - "svc-request-id": ${service-topology-operation-input.sdnc-request-header.svc-request-id}, - "svc-notification-url": ${service-topology-operation-input.sdnc-request-header.svc-notification-url} - }, - "request-information":{ - "request-id": ${service-topology-operation-input.request-information.request-id}, - "request-action": ${service-topology-operation-input.request-information.request-action}, - "request-sub-action": ${service-topology-operation-input.request-information.request-sub-action}, - "source": ${service-topology-operation-input.request-information.source}, - "notification-url": ${service-topology-operation-input.request-information.notification-url} - }, - "service-information":{ - "service-type": ${service-topology-operation-input.service-information.service-type}, - "service-instance-id": ${service-topology-operation-input.service-information.service-instance-id}, - "subscriber-name": ${service-topology-operation-input.service-information.subscriber-name}, - "subscriber-global-id": ${service-topology-operation-input.service-information.subscriber-global-id} - } +{ +"input": + { + "sdnc-request-header":{ + "svc-request-id": ${service-topology-operation-input.sdnc-request-header.svc-request-id}, + "svc-notification-url": ${service-topology-operation-input.sdnc-request-header.svc-notification-url} + }, + "request-information":{ + "request-id": ${service-topology-operation-input.request-information.request-id}, + "request-action": ${service-topology-operation-input.request-information.request-action}, + "request-sub-action": ${service-topology-operation-input.request-information.request-sub-action}, + "source": ${service-topology-operation-input.request-information.source}, + "notification-url": ${service-topology-operation-input.request-information.notification-url} + }, + "service-information":{ + "service-type": ${service-topology-operation-input.service-information.service-type}, + "service-instance-id": ${service-topology-operation-input.service-information.service-instance-id}, + "subscriber-name": ${service-topology-operation-input.service-information.subscriber-name}, + "subscriber-global-id": ${service-topology-operation-input.service-information.subscriber-global-id} + } } - + diff --git a/restapi-call-node/provider/src/main/resources/northbound-api-template.xml b/restapi-call-node/provider/src/main/resources/northbound-api-template.xml index 5c2b9ad9a..aea0625c1 100644 --- a/restapi-call-node/provider/src/main/resources/northbound-api-template.xml +++ b/restapi-call-node/provider/src/main/resources/northbound-api-template.xml @@ -37,7 +37,7 @@ ${service-topology-operation-input.service-information.service-type} ${service-topology-operation-input.service-information.subscriber-global-id} ${service-topology-operation-input.service-information.subscriber-name} - + ${'northbound-anyData} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java index 107e8c88e..dbca5ad7b 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java @@ -35,31 +35,33 @@ import org.slf4j.LoggerFactory; public class TestJsonParser { - private static final Logger log = LoggerFactory.getLogger(TestJsonParser.class); + private static final Logger log = LoggerFactory.getLogger(TestJsonParser.class); - @Test - public void test() throws Exception { - BufferedReader in = new BufferedReader(new InputStreamReader(ClassLoader.getSystemResourceAsStream("test.json"))); - String ss = ""; - String line = null; - while ((line = in.readLine()) != null) - ss += line + '\n'; + @Test + public void test() throws Exception { + BufferedReader in = new BufferedReader( + new InputStreamReader(ClassLoader.getSystemResourceAsStream("test.json")) + ); + String ss = ""; + String line = null; + while ((line = in.readLine()) != null) + ss += line + '\n'; - Map mm = JsonParser.convertToProperties(ss); + Map mm = JsonParser.convertToProperties(ss); - logProperties(mm); + logProperties(mm); - in.close(); - } + in.close(); + } - private void logProperties(Map mm) { - List ll = new ArrayList<>(); - for (Object o : mm.keySet()) - ll.add((String) o); - Collections.sort(ll); + private void logProperties(Map mm) { + List 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)); - } + log.info("Properties:"); + for (String name : ll) + log.info("--- " + name + ": " + mm.get(name)); + } } diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index 5b03bff47..ff9714809 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -32,61 +32,61 @@ import org.slf4j.LoggerFactory; public class TestRestapiCallNode { - private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class); + private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class); - @Test - public void testDelete() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); + @Test + public void testDelete() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "pwd1"); - p.put("httpMethod", "delete"); - p.put("skipSending", "true"); + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "pwd1"); + p.put("httpMethod", "delete"); + p.put("skipSending", "true"); - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } - @Test - public void testJsonTemplate() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.sdn-circuit-req-row_length", "3"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].clci", "clci"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].clci", "clci"); + @Test + public void testJsonTemplate() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "3"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].clci", "clci"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].clci", "clci"); - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/test-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } } diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java index ad1c34e90..579d194d5 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java @@ -40,57 +40,98 @@ public class TestXmlJsonUtil { Map 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].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[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[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[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].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_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].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.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 &"); + 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); diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java index 6d506ccec..544d259e0 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java @@ -37,39 +37,41 @@ import org.slf4j.LoggerFactory; public class TestXmlParser { - private static final Logger log = LoggerFactory.getLogger(TestXmlParser.class); + 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"))); - String ss = ""; - String line = null; - while ((line = in.readLine()) != null) - ss += line + '\n'; + @Test + public void test() throws Exception { + BufferedReader in = new BufferedReader( + new InputStreamReader(ClassLoader.getSystemResourceAsStream("test3.xml")) + ); + String ss = ""; + String line = null; + while ((line = in.readLine()) != null) + ss += line + '\n'; - Set listNameList = new HashSet(); - 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"); + Set listNameList = new HashSet(); + 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 mm = XmlParser.convertToProperties(ss, listNameList); + Map mm = XmlParser.convertToProperties(ss, listNameList); - logProperties(mm); + logProperties(mm); - in.close(); - } + in.close(); + } - private void logProperties(Map mm) { - List ll = new ArrayList<>(); - for (Object o : mm.keySet()) - ll.add((String) o); - Collections.sort(ll); + private void logProperties(Map mm) { + List 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)); - } + log.info("Properties:"); + for (String name : ll) + log.info("--- " + name + ": " + mm.get(name)); + } } diff --git a/restapi-call-node/provider/src/test/resources/test.json b/restapi-call-node/provider/src/test/resources/test.json index 885e66028..a34f7e2a0 100644 --- a/restapi-call-node/provider/src/test/resources/test.json +++ b/restapi-call-node/provider/src/test/resources/test.json @@ -20,29 +20,29 @@ */ { - "equipment-data": [ - { - "server-count": "4", - "max-server-speed": "1600000", - "number-primary-servers": "2", - "equipment-id": "Server1", - "server-model": "Unknown", - "server-id": "Server1" - } - ], - "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." + "equipment-data": [ + { + "server-count": "4", + "max-server-speed": "1600000", + "number-primary-servers": "2", + "equipment-id": "Server1", + "server-model": "Unknown", + "server-id": "Server1" + } + ], + "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/restapi-call-node/provider/src/test/resources/test.xml b/restapi-call-node/provider/src/test/resources/test.xml index 391c9b3e0..b60b5356e 100644 --- a/restapi-call-node/provider/src/test/resources/test.xml +++ b/restapi-call-node/provider/src/test/resources/test.xml @@ -21,152 +21,152 @@ --> - 4.0.0 - - org.onap.ccsdk.sli.plugins - restapi-call-node - 6.0.0-SNAPSHOT - - restapi-call-node-provider - bundle - RESTAPI Call Node - Provider - http://maven.apache.org - - UTF-8 - - - - junit - junit - test - - - org.springframework - spring-test - 3.1.4.RELEASE - test - - - org.onap.ccsdk.sli - sli-common - compile - - - org.onap.ccsdk.sli - sli-provider - compile - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.slf4j - jcl-over-slf4j - ${slf4j.version} - - - org.springframework - spring-beans - 3.1.4.RELEASE - - - org.springframework - spring-context - 3.1.4.RELEASE - - - xerces - xerces - 2.4.0 - provided - - - com.sun.jersey - jersey-client - 1.17 - - - commons-codec - commons-codec - - + 4.0.0 + + org.onap.ccsdk.sli.plugins + restapi-call-node + 6.0.0-SNAPSHOT + + restapi-call-node-provider + bundle + RESTAPI Call Node - Provider + http://maven.apache.org + + UTF-8 + + + + junit + junit + test + + + org.springframework + spring-test + 3.1.4.RELEASE + test + + + org.onap.ccsdk.sli + sli-common + compile + + + org.onap.ccsdk.sli + sli-provider + compile + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + org.springframework + spring-beans + 3.1.4.RELEASE + + + org.springframework + spring-context + 3.1.4.RELEASE + + + xerces + xerces + 2.4.0 + provided + + + com.sun.jersey + jersey-client + 1.17 + + + commons-codec + commons-codec + + - - - - com.brocade.developer - providermodule-plugin - - org.onap.ccsdk.sli.plugins - restapi-call-node - - - - process-sources - - process - - - - + + + + com.brocade.developer + providermodule-plugin + + org.onap.ccsdk.sli.plugins + restapi-call-node + + + + process-sources + + process + + + + - - org.apache.felix - maven-bundle-plugin - true - - - org.onap.ccsdk.sli.plugins.restapicall - org.onap.ccsdk.sli.plugins.restapicall - * - + + org.apache.felix + maven-bundle-plugin + true + + + org.onap.ccsdk.sli.plugins.restapicall + org.onap.ccsdk.sli.plugins.restapicall + * + - ${project.basedir}/src/main/resources/META-INF + ${project.basedir}/src/main/resources/META-INF - + - + - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - - com.brocade.developer - - - providermodule-plugin - - - [1.2.0.100-SNAPSHOT,) - - - process - - - - - - - - - - - - - + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + com.brocade.developer + + + providermodule-plugin + + + [1.2.0.100-SNAPSHOT,) + + + process + + + + + + + + + + + + + diff --git a/restapi-call-node/provider/src/test/resources/test3.xml b/restapi-call-node/provider/src/test/resources/test3.xml index 809a208eb..ade412681 100644 --- a/restapi-call-node/provider/src/test/resources/test3.xml +++ b/restapi-call-node/provider/src/test/resources/test3.xml @@ -21,62 +21,62 @@ --> - - ICOREPVC-81114561 - - VPNL811182 - 811182 - 21302:811182 - SET_BVOIP_IN - SET6_BVOIP_IN - SET6_DSU - SET_DSU - SET6_MANAGED - SET_MANAGED - SET_LOVRF_COMMUNITY - SET_RESET_LP - - AG_MAX_MCASTROUTES - - - - BGP4_PROTOCOL - v4 - gp_21302:811182 - - AG_L3VPN_EBGP - - - AG_MAX_PREFIX - - - AG_BGP_UNMANAGED - - - AG_BFD_BGP_3000 - - - - BGP4_PROTOCOL - v6 - gp6_21302:811182 - - AG6_L3VPN_EBGP - - - AG6_MAX_PREFIX - - - AG6_BGP_UNMANAGED - - - AG6_BFD_BGP_3000 - - - - 200 - Success - Y + xmlns:ns2="http://onap.org/prov/vpn/schema/v2"> + + ICOREPVC-81114561 + + VPNL811182 + 811182 + 21302:811182 + SET_BVOIP_IN + SET6_BVOIP_IN + SET6_DSU + SET_DSU + SET6_MANAGED + SET_MANAGED + SET_LOVRF_COMMUNITY + SET_RESET_LP + + AG_MAX_MCASTROUTES + + + + BGP4_PROTOCOL + v4 + gp_21302:811182 + + AG_L3VPN_EBGP + + + AG_MAX_PREFIX + + + AG_BGP_UNMANAGED + + + AG_BFD_BGP_3000 + + + + BGP4_PROTOCOL + v6 + gp6_21302:811182 + + AG6_L3VPN_EBGP + + + AG6_MAX_PREFIX + + + AG6_BGP_UNMANAGED + + + AG6_BFD_BGP_3000 + + + + 200 + Success + Y - + -- cgit From e1f7195bdbfc8146823cc29e7b6eb8e40e9a31c0 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 29 Aug 2017 08:57:00 -0400 Subject: Cleanup artifactId for ccsdk/sli/plugins ArtifactId for ccsdk/sli/plugins pom.xml should not be identical to that for sdnc/plugins, otherwise import to Eclipse of both will be confusing Updated parent artifactId in each module pom.xml under ccsdk/sli/plugins Change-Id: I13d0d09c9c6f125011942bfe700f6a2b3d1c271b Issue-ID: CCSDK-70 Signed-off-by: Dan Timoney --- pom.xml | 2 +- properties-node/pom.xml | 2 +- restapi-call-node/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 71303b796..b0973220d 100755 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ 4.0.0 pom org.onap.ccsdk.sli.plugins - sdnc-plugins + ccsdk-sli-plugins SDN-C Java Plugins https://wiki.onap.org diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 066db5e08..1f860b70e 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -2,7 +2,7 @@ org.onap.ccsdk.sli.plugins - sdnc-plugins + ccsdk-sli-plugins 0.1.0-SNAPSHOT diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 7e1886f43..b819e47e9 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -2,7 +2,7 @@ org.onap.ccsdk.sli.plugins - sdnc-plugins + ccsdk-sli-plugins 0.1.0-SNAPSHOT -- cgit From 69fec3e3ac7b14b17dcc827683caf9b07f4eb842 Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Fri, 1 Sep 2017 15:56:15 -0700 Subject: Enable surefire unit testing Issue-Id: CCSDK-67 Change-Id: I428e0b03f94559929095c7a3fbf2af55e6567f6b Signed-off-by: Marcus G K Williams --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index b0973220d..90fefcdfc 100755 --- a/pom.xml +++ b/pom.xml @@ -13,9 +13,9 @@ org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - SDN-C Java Plugins + CCSDK Java Plugins https://wiki.onap.org - The SDN-C core components contains the SLI, dblib and root pom + CCSDK Java Plugins @@ -88,7 +88,7 @@ maven-surefire-plugin 2.17 - true + false -- cgit From ac453f1bde56bf95b263113fd475ceee80ac9117 Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Thu, 7 Sep 2017 18:40:47 +0530 Subject: Fix sonar issues for ccsdk plugin few major issues https://sonar.onap.org/dashboard/index?id=org.onap.ccsdk.sli.plugins%3Arestapi-call-node-provider%3Asrc%2Fmain%2Fjava%2Forg%2Fonap%2Fccsdk%2Fsli%2Fplugins%2Frestapicall%2FRestapiCallNode.java Issue-ID: SDNC-75 Change-Id: Ida6ea182545bf57513bcd958519e3b50dfa004b2 Signed-off-by: surya-huawei --- .../sli/plugins/restapicall/RestapiCallNode.java | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index fb7722686..7ddeb4269 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -173,7 +173,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { if (retryCount < retryPolicy.getMaximumRetries() + 1) { URI uri = new URI(paramMap.get("restapiUrl")); String hostname = uri.getHost(); - String retryString = retryPolicy.getNextHostName((uri.toString())); + String retryString = retryPolicy.getNextHostName(uri.toString()); URI uriTwo = new URI(retryString); URI retryUri = UriBuilder.fromUri(uri).host(uriTwo.getHost()).port(uriTwo.getPort()).scheme( uriTwo.getScheme()).build(); @@ -212,7 +212,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); p.listNameList = getListNameList(paramMap); String skipSendingStr = paramMap.get("skipSending"); - p.skipSending = skipSendingStr != null && skipSendingStr.equalsIgnoreCase("true"); + p.skipSending = "true".equalsIgnoreCase(skipSendingStr); p.convertResponse = Boolean.valueOf(parseParam(paramMap, "convertResponse", false, "true")); p.trustStoreFileName = parseParam(paramMap, "trustStoreFileName", false, null); p.trustStorePassword = parseParam(paramMap, "trustStorePassword", false, null); @@ -228,9 +228,9 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { protected Set getListNameList(Map paramMap) { Set ll = new HashSet(); - for (String key : paramMap.keySet()) - if (key.startsWith("listName")) - ll.add(paramMap.get(key)); + for (Map.Entry entry : paramMap.entrySet()) + if (entry.getKey().startsWith("listName")) + ll.add(entry.getValue()); return ll; } @@ -503,12 +503,12 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } protected void setFailureResponseStatus(SvcLogicContext ctx, String prefix, String errorMessage, HttpResponse r) { - r = new HttpResponse(); - r.code = 500; - r.message = errorMessage; + HttpResponse resp = new HttpResponse(); + resp.code = 500; + resp.message = errorMessage; String pp = prefix != null ? prefix + '.' : ""; - ctx.setAttribute(pp + "response-code", String.valueOf(r.code)); - ctx.setAttribute(pp + "response-message", r.message); + ctx.setAttribute(pp + "response-code", String.valueOf(resp.code)); + ctx.setAttribute(pp + "response-message", resp.message); } protected void setResponseStatus(SvcLogicContext ctx, String prefix, HttpResponse r) { @@ -633,7 +633,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { String pp = p.responsePrefix != null ? p.responsePrefix + '.' : ""; - String req = null; + String req; if (p.templateFileName == null) { log.info("No template file name specified. Using default UEB template: " + defaultUebTemplateFileName); @@ -679,7 +679,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { p.rootVarName = parseParam(paramMap, "rootVarName", false, null); p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); String skipSendingStr = paramMap.get("skipSending"); - p.skipSending = skipSendingStr != null && skipSendingStr.equalsIgnoreCase("true"); + p.skipSending = "true".equalsIgnoreCase(skipSendingStr); return p; } -- cgit From 4892ec15aadfddd266daa91ccef4d47085a04202 Mon Sep 17 00:00:00 2001 From: shashikanth Date: Fri, 8 Sep 2017 18:46:42 +0530 Subject: Fix Blocker/Critical sonar issues Fix Blocker/Critical sonar issues in vnfapi module https://sonar.onap.org/component_issues?id=org.onap.ccsdk.sli.plugins%3Accsdk-sli-plugins#resolved=false|severities=BLOCKER Issue-Id: CCSDK-67 Change-Id: I6393ebbaf4bd6dc2dea4a325f2a7d106ba20dd81 Signed-off-by: shashikanth.vh --- .../java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 7ddeb4269..13295741c 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -627,7 +627,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } public void postMessageOnUeb(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { - HttpResponse r = null; + HttpResponse r; try { UebParam p = getUebParameters(paramMap); @@ -659,7 +659,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { setResponseStatus(ctx, prefix, r); } - if (r != null && r.code >= 300) + if (r.code >= 300) throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); } -- cgit From 6f48bb92c2a6464a2807bde665aa1d1486f769f9 Mon Sep 17 00:00:00 2001 From: Jessica Wagantall Date: Fri, 8 Sep 2017 11:53:50 -0700 Subject: Cleanup project's name in Sonar The name parameter in the root pom.xml should match the project name in gerrit to reflect consistency in Sonar. Change-Id: I5ea954dd39d9ca8e083978b1130393001b3e36be Issue-id: CIMAN-65 Signed-off-by: Jessica Wagantall --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 90fefcdfc..d2a761b11 100755 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - CCSDK Java Plugins + ccsdk-sli-plugins https://wiki.onap.org CCSDK Java Plugins -- cgit From 322886522453c65818199d3575e34d554d3b28ee Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Mon, 11 Sep 2017 17:51:24 +0530 Subject: Fix Sonar Issues Few major issues in Restapi call node Issue-Id: CCSDK-87 Change-Id: Ieb733fcf178cecb9983b5135be8d7737cb42a1f3 Signed-off-by: surya-huawei --- .../org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java | 2 +- .../java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java | 2 +- .../main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java index b139da279..775137fff 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java @@ -44,7 +44,7 @@ public class RetryPolicyStore { } public RetryPolicyStore() { - retryPolicies = new HashMap(); + retryPolicies = new HashMap<>(); } public RetryPolicy getRetryPolicy(String policyName) { diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java index 16b9f519f..e80ca5081 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java @@ -366,7 +366,7 @@ public class XmlJsonUtil { private static String pad(int n) { String s = ""; for (int i = 0; i < n; i++) - s += '\t'; + s += Character.toString('\t'); return s; } } diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java index 85c9dc018..61b0e31d4 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java @@ -69,7 +69,7 @@ public class XmlParser { super(); this.listNameList = listNameList; if (this.listNameList == null) - this.listNameList = new HashSet(); + this.listNameList = new HashSet<>(); } String currentName = ""; @@ -88,7 +88,7 @@ public class XmlParser { name = name.substring(i2 + 1); if (currentName.length() > 0) - currentName += '.'; + currentName += Character.toString('.'); currentName += name; String listName = removeIndexes(currentName); @@ -152,7 +152,7 @@ public class XmlParser { else if (c == ']') add = true; else if (add) - s += c; + s += Character.toString(c); } return s; } -- cgit From d20f5326f744399c9e741c306043b500991953c8 Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Thu, 14 Sep 2017 16:42:27 +0530 Subject: Fix Sonar Issues few critical/major issues in sli/plugins module Issue-Id: CCSDK-87 Change-Id: I4fc33df4ed782670252c9b550349f45b6618c77c Signed-off-by: surya-huawei --- .../java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java | 4 ++-- .../org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java index 4de4a34d7..f2867f5a3 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java @@ -40,14 +40,14 @@ public class JsonParser { public static Map convertToProperties(String s) throws JSONException { JSONObject json = new JSONObject(s); - Map wm = new HashMap(); + Map wm = new HashMap<>(); Iterator ii = json.keys(); while (ii.hasNext()) { String key1 = ii.next(); wm.put(key1, json.get(key1)); } - Map mm = new HashMap(); + Map mm = new HashMap<>(); while (!wm.isEmpty()) for (String key : new ArrayList<>(wm.keySet())) { diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 13295741c..4984d1bce 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -147,8 +147,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { mm = JsonParser.convertToProperties(r.body); if (mm != null) - for (String key : mm.keySet()) - ctx.setAttribute(pp + key, mm.get(key)); + for (Map.Entry entry : mm.entrySet()) + ctx.setAttribute(pp + entry.getKey(), entry.getValue()); } } } catch (Exception e) { @@ -227,7 +227,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } protected Set getListNameList(Map paramMap) { - Set ll = new HashSet(); + Set ll = new HashSet<>(); for (Map.Entry entry : paramMap.entrySet()) if (entry.getKey().startsWith("listName")) ll.add(entry.getValue()); @@ -473,7 +473,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } protected SSLContext createSSLContext(Parameters p) { - try { + try (FileInputStream in = new FileInputStream(p.keyStoreFileName)) { System.setProperty("jsse.enableSNIExtension", "false"); System.setProperty("javax.net.ssl.trustStore", p.trustStoreFileName); System.setProperty("javax.net.ssl.trustStorePassword", p.trustStorePassword); @@ -487,7 +487,6 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { }); KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); - FileInputStream in = new FileInputStream(p.keyStoreFileName); KeyStore ks = KeyStore.getInstance("PKCS12"); char[] pwd = p.keyStorePassword.toCharArray(); ks.load(in, pwd); -- cgit From 9342e92c2557dfc7df213b37e3957f282342b2eb Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 14 Sep 2017 16:02:25 -0400 Subject: Use oparent-odlparent in sli/plugins Update sli/plugins to use oparent-odlparent, used by latest version of ccsdk odlparent-carbon-sr1 parent. Change-Id: I315d3e0762f86d1a994c6b0d5c35b2f681b7e538 Issue-ID: CCSDK-43 Signed-off-by: Dan Timoney --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d2a761b11..fa0838dec 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-carbon-sr1 - 0.0.1-SNAPSHOT + 0.0.2-SNAPSHOT 4.0.0 -- cgit From 342453d02784a1bd791848db8af9e3f927710ec0 Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Sun, 17 Sep 2017 23:25:14 +0530 Subject: Fix Sonar Issue in sli/plugins module One major issue * move string literal to left side of string comparison Issue-Id: CCSDK-87 Change-Id: I1277c4c5515bd45ad6854c63cf6160f17b7725d0 Signed-off-by: surya-huawei --- .../java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 4984d1bce..ca227c722 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -559,7 +559,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post")); p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); String skipSendingStr = paramMap.get("skipSending"); - p.skipSending = skipSendingStr != null && skipSendingStr.equalsIgnoreCase("true"); + p.skipSending = "true".equalsIgnoreCase(skipSendingStr); return p; } -- cgit From 4318ad160fa6ee1d75c395f4409e209f5da36f53 Mon Sep 17 00:00:00 2001 From: "Arun S. Yerra" Date: Mon, 11 Sep 2017 18:57:40 -0700 Subject: Implement framework to process REST notifications Global SDNC controller needs information about network Devices (mostly PNFs) so as to instantiate/configure service. Domain Controllers control/manage the network devices within the fabric. This task is to implement RESTCONF notification processing framework, so that Global SDNC controller can process notifications from Domain controllers. Change-Id: Ia5edb5006ac3fd4ec71e55f92a05e79e40ce76d2 Issue-Id: CCSDK-88 Signed-off-by: Arun S. Yerra --- fabric-discovery-plugin/.gitignore | 19 +++ fabric-discovery-plugin/features/pom.xml | 135 ++++++++++++++++++++ .../features/src/main/resources/features.xml | 40 ++++++ fabric-discovery-plugin/installer/pom.xml | 139 +++++++++++++++++++++ .../src/assembly/assemble_installer_zip.xml | 59 +++++++++ .../src/assembly/assemble_mvnrepo_zip.xml | 49 ++++++++ .../src/main/resources/scripts/install-feature.sh | 40 ++++++ fabric-discovery-plugin/pom.xml | 42 +++++++ fabric-discovery-plugin/provider/pom.xml | 126 +++++++++++++++++++ .../fabricdiscovery/ClientMessageCallback.java | 20 +++ .../fabricdiscovery/FabricDiscoveryPlugin.java | 129 +++++++++++++++++++ .../fabricdiscovery/IClientMessageCallback.java | 16 +++ .../fabricdiscovery/IFabricDiscoveryService.java | 17 +++ .../plugins/fabricdiscovery/WebSocketClient.java | 96 ++++++++++++++ .../fabricdiscovery/WebSocketClientHandler.java | 92 ++++++++++++++ .../blueprint/fabricdiscoveryplugin-blueprint.xml | 10 ++ pom.xml | 6 +- 17 files changed, 1032 insertions(+), 3 deletions(-) create mode 100644 fabric-discovery-plugin/.gitignore create mode 100755 fabric-discovery-plugin/features/pom.xml create mode 100644 fabric-discovery-plugin/features/src/main/resources/features.xml create mode 100755 fabric-discovery-plugin/installer/pom.xml create mode 100644 fabric-discovery-plugin/installer/src/assembly/assemble_installer_zip.xml create mode 100644 fabric-discovery-plugin/installer/src/assembly/assemble_mvnrepo_zip.xml create mode 100644 fabric-discovery-plugin/installer/src/main/resources/scripts/install-feature.sh create mode 100755 fabric-discovery-plugin/pom.xml create mode 100755 fabric-discovery-plugin/provider/pom.xml create mode 100644 fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/ClientMessageCallback.java create mode 100644 fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/FabricDiscoveryPlugin.java create mode 100644 fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/IClientMessageCallback.java create mode 100644 fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/IFabricDiscoveryService.java create mode 100644 fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClient.java create mode 100644 fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClientHandler.java create mode 100644 fabric-discovery-plugin/provider/src/main/resources/org/opendaylight/blueprint/fabricdiscoveryplugin-blueprint.xml diff --git a/fabric-discovery-plugin/.gitignore b/fabric-discovery-plugin/.gitignore new file mode 100644 index 000000000..4213c2168 --- /dev/null +++ b/fabric-discovery-plugin/.gitignore @@ -0,0 +1,19 @@ +*.class +**/target +bin/ +dist +**/logs +*~ +target +target-ide +.classpath +.project +.settings +.idea +xtend-gen +yang-gen-config +yang-gen-sal +classes +.DS_STORE +.metadata +.gitreview diff --git a/fabric-discovery-plugin/features/pom.xml b/fabric-discovery-plugin/features/pom.xml new file mode 100755 index 000000000..2e0b0d94e --- /dev/null +++ b/fabric-discovery-plugin/features/pom.xml @@ -0,0 +1,135 @@ + + + 4.0.0 + + fabric-discovery-plugin + org.onap.ccsdk.sli.plugins + 0.1.0-SNAPSHOT + + org.onap.ccsdk.sli.plugins + 0.1.0-SNAPSHOT + fabric-discovery-plugin-features + Fabric Discovery Plugin - Features + + jar + + + + + org.onap.ccsdk.sli.plugins + fabric-discovery-plugin-provider + ${project.version} + + + + commons-lang + commons-lang + 2.6 + compile + + + + org.opendaylight.mdsal + features-mdsal + ${odl.mdsal.features.version} + features + xml + + runtime + + + + + + org.opendaylight.controller + opendaylight-karaf-empty + ${odl.karaf.empty.distro.version} + zip + + + + + + org.opendaylight.odlparent + features-test + ${odl.commons.opendaylight.version} + test + + + + org.opendaylight.yangtools + features-yangtools + ${odl.yangtools.version} + features + xml + runtime + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + diff --git a/fabric-discovery-plugin/features/src/main/resources/features.xml b/fabric-discovery-plugin/features/src/main/resources/features.xml new file mode 100644 index 000000000..0750c4384 --- /dev/null +++ b/fabric-discovery-plugin/features/src/main/resources/features.xml @@ -0,0 +1,40 @@ + + + + + + + mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features + + + sdnc-sli + spring + spring-dm + mvn:com.sun.jersey/jersey-client/${jersey.version} + mvn:org.codehaus.jettison/jettison/${jettison.version} + mvn:org.onap.ccsdk.sli.plugins/fabric-discovery-plugin-provider/${project.version} + + + diff --git a/fabric-discovery-plugin/installer/pom.xml b/fabric-discovery-plugin/installer/pom.xml new file mode 100755 index 000000000..1f4299019 --- /dev/null +++ b/fabric-discovery-plugin/installer/pom.xml @@ -0,0 +1,139 @@ + + + 4.0.0 + + fabric-discovery-plugin + org.onap.ccsdk.sli.plugins + 0.1.0-SNAPSHOT + + fabric-discovery-plugin-installer + Properties node - Karaf Installer + pom + + + sdnc-fabric-discovery-plugin + sdnc-fabric-discovery-plugin + mvn:org.onap.ccsdk.sli.plugins/fabric-discovery-plugin-features/${project.version}/xml/features + false + + + + + + org.onap.ccsdk.sli.plugins + fabric-discovery-plugin-features + ${project.version} + features + xml + + + * + * + + + + + + org.onap.ccsdk.sli.plugins + fabric-discovery-plugin-provider + ${project.version} + + + + + + + + maven-assembly-plugin + 2.6 + + + maven-repo-zip + + single + + package + + false + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + false + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli + sli-common,sli-provider,dblib-provider + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + + + + diff --git a/fabric-discovery-plugin/installer/src/assembly/assemble_installer_zip.xml b/fabric-discovery-plugin/installer/src/assembly/assemble_installer_zip.xml new file mode 100644 index 000000000..3bed4b5ef --- /dev/null +++ b/fabric-discovery-plugin/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,59 @@ + + + + + + installer_zip + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + + + + diff --git a/fabric-discovery-plugin/installer/src/assembly/assemble_mvnrepo_zip.xml b/fabric-discovery-plugin/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100644 index 000000000..cb56f2cd4 --- /dev/null +++ b/fabric-discovery-plugin/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,49 @@ + + + + + + mvnrepo_zip + + zip + + + + false + + + + target/assembly/ + . + + + + + + + + diff --git a/fabric-discovery-plugin/installer/src/main/resources/scripts/install-feature.sh b/fabric-discovery-plugin/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..e986764b9 --- /dev/null +++ b/fabric-discovery-plugin/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,40 @@ +#!/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========================================================= +### + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} diff --git a/fabric-discovery-plugin/pom.xml b/fabric-discovery-plugin/pom.xml new file mode 100755 index 000000000..f22fb695d --- /dev/null +++ b/fabric-discovery-plugin/pom.xml @@ -0,0 +1,42 @@ + + + + org.onap.ccsdk.sli.plugins + ccsdk-sli-plugins + 0.1.0-SNAPSHOT + + + 4.0.0 + pom + + org.onap.ccsdk.sli.plugins + fabric-discovery-plugin + 0.1.0-SNAPSHOT + + Fabric Discovery Plugin + This plugin will populate information about the devices within network fabric into SDNC database + + + + + org.onap.ccsdk.sli.plugins + fabric-discovery-plugin-features + features + xml + ${project.version} + + + org.onap.ccsdk.sli.plugins + fabric-discovery-plugin-provider + ${project.version} + + + + + + provider + features + installer + + + diff --git a/fabric-discovery-plugin/provider/pom.xml b/fabric-discovery-plugin/provider/pom.xml new file mode 100755 index 000000000..c38acb1b8 --- /dev/null +++ b/fabric-discovery-plugin/provider/pom.xml @@ -0,0 +1,126 @@ + + + 4.0.0 + + org.onap.ccsdk.sli.plugins + fabric-discovery-plugin + 0.1.0-SNAPSHOT + + org.onap.ccsdk.sli.plugins + fabric-discovery-plugin-provider + 0.1.0-SNAPSHOT + bundle + Fabric Discovery Plugin - Provider + http://maven.apache.org + + UTF-8 + + + + + io.netty + netty + 3.10.6.Final + + + + io.netty + netty-buffer + 4.0.26.Final + + + + io.netty + netty-transport + 4.0.4.Final + + + + io.netty + netty-codec-http + 4.0.15.Final + + + junit + junit + test + + + org.springframework + spring-test + ${spring.version} + test + + + org.onap.ccsdk.sli.core + sli-common + ${sdnctl.sli.version} + compile + + + org.onap.ccsdk.sli.core + sli-provider + ${sdnctl.sli.version} + compile + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + org.springframework + spring-beans + ${spring.version} + + + org.springframework + spring-context + ${spring.version} + + + com.sun.jersey + jersey-client + ${jersey.version} + provided + + + org.codehaus.jettison + jettison + ${jettison.version} + provided + + + org.onap.ccsdk.sli.core + sli-common + ${sdnctl.sli.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${sdnctl.sli.version} + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + org.onap.ccsdk.sli.plugins.fabricdiscovery + org.onap.ccsdk.sli.plugins.fabricdiscovery + * + + + + + + diff --git a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/ClientMessageCallback.java b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/ClientMessageCallback.java new file mode 100644 index 000000000..0a8ba9e75 --- /dev/null +++ b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/ClientMessageCallback.java @@ -0,0 +1,20 @@ +package org.onap.ccsdk.sli.plugins.fabricdiscovery; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; + +/** + * Created by arun on 9/9/17. + */ +public class ClientMessageCallback implements IClientMessageCallback { + private static final Logger LOG = LoggerFactory.getLogger(ClientMessageCallback.class); + + @Override + public void onMessageReceived(final Object message) { + if (message instanceof TextWebSocketFrame) { + LOG.info("received message {}" + ((TextWebSocketFrame) message).text()); + } + } + +} diff --git a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/FabricDiscoveryPlugin.java b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/FabricDiscoveryPlugin.java new file mode 100644 index 000000000..7a0c68f41 --- /dev/null +++ b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/FabricDiscoveryPlugin.java @@ -0,0 +1,129 @@ +/*- + * ============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.fabricdiscovery; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class FabricDiscoveryPlugin implements SvcLogicJavaPlugin, IFabricDiscoveryService { + + private ExecutorService service; + private Map streamMap; + private static final Logger LOG = LoggerFactory.getLogger(FabricDiscoveryPlugin.class); + + public FabricDiscoveryPlugin() { + service = Executors.newFixedThreadPool(10); + streamMap = new ConcurrentHashMap (); + } + + @Override + public void processDcNotificationStream (Map paramMap, SvcLogicContext ctx) throws SvcLogicException { + boolean enable = Boolean.parseBoolean(parseParam(paramMap, "enable", true, null)); + String stream = parseParam(paramMap, "stream", true, null); + + LOG.info("{} monitoring notification stream: {}", (enable) ? "START" : "STOP", stream); + try { + service.execute(new Runnable () { + public void run () { + try { + URI uri = new URI(stream); + if (enable) { + if (streamMap.get(stream) != null) { + LOG.info("Notification Stream: {} is already being monitoried", stream); + return; + } + IClientMessageCallback messageCallback = new ClientMessageCallback(); + WebSocketClient wcClient = new WebSocketClient(uri, messageCallback); + streamMap.put(stream, wcClient); + wcClient.initialize(); + try { + wcClient.connect(); + } catch (InterruptedException e) { + LOG.info("Web Socket Client throws Exception: ", e.getMessage()); + } + } else { + WebSocketClient wc = streamMap.get(stream); + if (wc != null) { + try { + wc.close("Closing"); + } catch (InterruptedException e) { + LOG.info("Web Socket Client throws Exception: ", e.getMessage()); + } + } + } + } catch (URISyntaxException e) { + LOG.info("Exception converting stream to URI with: ", e.getMessage()); + } + } + }); + } catch (Exception e) { + LOG.info("Web Socket client connection throws an exception: ", e.getMessage()); + } + } + + private String parseParam(Map paramMap, String name, boolean required, String def) + throws SvcLogicException { + String s = paramMap.get(name); + + if (s == null || s.trim().length() == 0) { + if (!required) + return def; + throw new SvcLogicException("Parameter " + name + " is required in PropertiesNode"); + } + + s = s.trim(); + String value = ""; + int i = 0; + int i1 = s.indexOf('%'); + while (i1 >= 0) { + int i2 = s.indexOf('%', i1 + 1); + if (i2 < 0) + throw new SvcLogicException("Cannot parse parameter " + name + ": " + s + ": no matching %"); + + String varName = s.substring(i1 + 1, i2); + String varValue = System.getenv(varName); + if (varValue == null) + varValue = ""; + + value = (new StringBuilder()).append(value) + .append(s.substring(i, i1)) + .append(varValue).toString(); + i = i2 + 1; + i1 = s.indexOf('%', i); + } + value = (new StringBuilder()).append(value) + .append(s.substring(i)).toString(); + + LOG.info("Parameter {}: {}", name, value); + return value; + } +} diff --git a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/IClientMessageCallback.java b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/IClientMessageCallback.java new file mode 100644 index 000000000..e555d3382 --- /dev/null +++ b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/IClientMessageCallback.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.onap.ccsdk.sli.plugins.fabricdiscovery; + +/** + * Created by mbobak on 1/22/14. + */ +public interface IClientMessageCallback { + + void onMessageReceived(Object message); +} diff --git a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/IFabricDiscoveryService.java b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/IFabricDiscoveryService.java new file mode 100644 index 000000000..857d75a99 --- /dev/null +++ b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/IFabricDiscoveryService.java @@ -0,0 +1,17 @@ +package org.onap.ccsdk.sli.plugins.fabricdiscovery; + +import java.util.Map; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + +/** + * Created by arun on 9/10/17. + */ +public interface IFabricDiscoveryService { + + /* (non-Javadoc) + * @see void#processDcNotificationStream(java.lang.String, java.lang.Integer, java.lang.String, java.lang.Boolean) + */ + void processDcNotificationStream (Map paramMap, SvcLogicContext ctx) throws SvcLogicException; + +} diff --git a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClient.java b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClient.java new file mode 100644 index 000000000..bdecdc742 --- /dev/null +++ b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClient.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.onap.ccsdk.sli.plugins.fabricdiscovery; + +import io.netty.bootstrap.Bootstrap; +import io.netty.buffer.Unpooled; +import io.netty.channel.Channel; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelPipeline; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.SocketChannel; +import io.netty.channel.socket.nio.NioSocketChannel; +import io.netty.handler.codec.http.HttpClientCodec; +import io.netty.handler.codec.http.HttpObjectAggregator; +import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame; +import io.netty.handler.codec.http.websocketx.PingWebSocketFrame; +import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; +import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory; +import io.netty.handler.codec.http.websocketx.WebSocketVersion; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class WebSocketClient { + + private static final Logger LOG = LoggerFactory.getLogger(WebSocketClient.class); + + private final URI uri; + private final Bootstrap bootstrap = new Bootstrap(); + private final WebSocketClientHandler clientHandler; + private Channel clientChannel; + private final EventLoopGroup group = new NioEventLoopGroup(); + + public WebSocketClient(final URI uri, final IClientMessageCallback clientMessageCallback) { + this.uri = uri; + clientHandler = new WebSocketClientHandler(WebSocketClientHandshakerFactory.newHandshaker(uri, + WebSocketVersion.V13, null, false, null), clientMessageCallback); + // last null could be replaced with DefaultHttpHeaders + initialize(); + } + + public void initialize() { + + String protocol = uri.getScheme(); + if (!"ws".equals(protocol)) { + throw new IllegalArgumentException("Unsupported protocol: " + protocol); + } + + bootstrap.group(group).channel(NioSocketChannel.class).handler(new ChannelInitializer() { + @Override + public void initChannel(final SocketChannel ch) throws Exception { + ChannelPipeline pipeline = ch.pipeline(); + pipeline.addLast("http-codec", new HttpClientCodec()); + pipeline.addLast("aggregator", new HttpObjectAggregator(8192)); + pipeline.addLast("ws-handler", clientHandler); + } + }); + } + + public void connect() throws InterruptedException { + LOG.info("WebSocket Client connecting"); + clientChannel = bootstrap.connect(uri.getHost(), uri.getPort()).sync().channel(); + clientHandler.handshakeFuture().sync(); + } + + public void writeAndFlush(final String message) { + clientChannel.writeAndFlush(new TextWebSocketFrame(message)); + } + + public void writeAndFlush(final Object message) { + clientChannel.writeAndFlush(message); + } + + public void ping() { + clientChannel.writeAndFlush(new PingWebSocketFrame(Unpooled.copiedBuffer(new byte[] { 1, 2, 3, 4, 5, 6 }))); + } + + public void close(final String reasonText) throws InterruptedException { + CloseWebSocketFrame closeWebSocketFrame = new CloseWebSocketFrame(1000, reasonText); + clientChannel.writeAndFlush(closeWebSocketFrame); + + // WebSocketClientHandler will close the connection when the server + // responds to the CloseWebSocketFrame. + clientChannel.closeFuture().sync(); + group.shutdownGracefully(); + } +} diff --git a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClientHandler.java b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClientHandler.java new file mode 100644 index 000000000..c1c5dc30f --- /dev/null +++ b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClientHandler.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.onap.ccsdk.sli.plugins.fabricdiscovery; + +import io.netty.channel.Channel; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelPromise; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.handler.codec.http.FullHttpResponse; +import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame; +import io.netty.handler.codec.http.websocketx.PongWebSocketFrame; +import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; +import io.netty.handler.codec.http.websocketx.WebSocketFrame; +import io.netty.util.CharsetUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class WebSocketClientHandler extends SimpleChannelInboundHandler { + + private static final Logger LOG = LoggerFactory.getLogger(WebSocketClientHandler.class.toString()); + private final WebSocketClientHandshaker handshaker; + private ChannelPromise handshakeFuture; + private final IClientMessageCallback messageListener; + + public WebSocketClientHandler(WebSocketClientHandshaker handshaker, IClientMessageCallback listener) { + this.handshaker = handshaker; + this.messageListener = listener; + } + + public ChannelFuture handshakeFuture() { + return handshakeFuture; + } + + @Override + public void handlerAdded(ChannelHandlerContext ctx) throws Exception { + handshakeFuture = ctx.newPromise(); + } + + @Override + public void channelActive(ChannelHandlerContext ctx) throws Exception { + handshaker.handshake(ctx.channel()); + } + + @Override + public void channelInactive(ChannelHandlerContext ctx) throws Exception { + LOG.info("WebSocket Client disconnected!"); + } + + @Override + public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { + Channel ch = ctx.channel(); + if (!handshaker.isHandshakeComplete()) { + handshaker.finishHandshake(ch, (FullHttpResponse) msg); + LOG.info("WebSocket Client connected!"); + handshakeFuture.setSuccess(); + return; + } + + if (msg instanceof FullHttpResponse) { + FullHttpResponse response = (FullHttpResponse) msg; + throw new Exception("Unexpected FullHttpResponse (getStatus=" + response.getStatus() + ", content=" + + response.content().toString(CharsetUtil.UTF_8) + ')'); + } + + messageListener.onMessageReceived(msg); + WebSocketFrame frame = (WebSocketFrame) msg; + + if (frame instanceof PongWebSocketFrame) { + LOG.info("WebSocket Client received pong"); + } else if (frame instanceof CloseWebSocketFrame) { + LOG.info("WebSocket Client received closing"); + ch.close(); + } + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + LOG.info("Cause: {} .", cause.toString()); + + if (!handshakeFuture.isDone()) { + handshakeFuture.setFailure(cause); + } + + ctx.close(); + } +} diff --git a/fabric-discovery-plugin/provider/src/main/resources/org/opendaylight/blueprint/fabricdiscoveryplugin-blueprint.xml b/fabric-discovery-plugin/provider/src/main/resources/org/opendaylight/blueprint/fabricdiscoveryplugin-blueprint.xml new file mode 100644 index 000000000..43137bb89 --- /dev/null +++ b/fabric-discovery-plugin/provider/src/main/resources/org/opendaylight/blueprint/fabricdiscoveryplugin-blueprint.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/pom.xml b/pom.xml index d2a761b11..4f1ac54ea 100755 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,5 @@ - + org.onap.ccsdk.parent @@ -108,7 +107,8 @@ properties-node restapi-call-node - + fabric-discovery-plugin + AT&T -- cgit From da4d77a5a127b3297fe15ecf012d05df721a90c7 Mon Sep 17 00:00:00 2001 From: "Arun S. Yerra" Date: Mon, 18 Sep 2017 23:23:54 -0700 Subject: Implement fabric discovery DG parameter validation Directed Graph to establish notification stream session with local domain controller passes the REST notification server address. It also passes a a boolean parameter to to either start or stop the session. This change adds logic to validate these input parameters, Issue-Id: CCSDK-88 Change-Id: I3fa05f5badeafbaa15e5ae89a3a60b8e237f212b Signed-off-by: Arun S. Yerra --- .../fabricdiscovery/FabricDiscoveryPlugin.java | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/FabricDiscoveryPlugin.java b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/FabricDiscoveryPlugin.java index 7a0c68f41..66452758d 100644 --- a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/FabricDiscoveryPlugin.java +++ b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/FabricDiscoveryPlugin.java @@ -39,6 +39,8 @@ public class FabricDiscoveryPlugin implements SvcLogicJavaPlugin, IFabricDiscove private ExecutorService service; private Map streamMap; private static final Logger LOG = LoggerFactory.getLogger(FabricDiscoveryPlugin.class); + private static final String STREAM_PREFIX = "ws://"; + private static final String FB_DISCOVERY_STATUS = "fb-response"; public FabricDiscoveryPlugin() { service = Executors.newFixedThreadPool(10); @@ -47,10 +49,29 @@ public class FabricDiscoveryPlugin implements SvcLogicJavaPlugin, IFabricDiscove @Override public void processDcNotificationStream (Map paramMap, SvcLogicContext ctx) throws SvcLogicException { - boolean enable = Boolean.parseBoolean(parseParam(paramMap, "enable", true, null)); + boolean enable; String stream = parseParam(paramMap, "stream", true, null); + String prefix = parseParam(paramMap, "contextPrefix", false, null); + String enableStr = parseParam(paramMap, "enable", true, null); + // Validate the input parameters + String pfx = (prefix != null) ? prefix + '.' : ""; + if ("true".equalsIgnoreCase(enableStr)) { + enable = true; + } else if ("false".equalsIgnoreCase(enableStr)) { + enable = false; + } else { + ctx.setAttribute(pfx + FB_DISCOVERY_STATUS, "Failure"); + throw new SvcLogicException("Incorrect parameter: enable. Valid values are ['true', 'false']"); + } + if (!STREAM_PREFIX.equalsIgnoreCase(stream.substring(0, 5))) { + ctx.setAttribute(pfx + FB_DISCOVERY_STATUS, "Failure"); + throw new SvcLogicException("Incorrect parameter: stream, Input is not a web socket address"); + } + + ctx.setAttribute(pfx + FB_DISCOVERY_STATUS, "Success"); LOG.info("{} monitoring notification stream: {}", (enable) ? "START" : "STOP", stream); + try { service.execute(new Runnable () { public void run () { -- cgit From b75cf562ffd37a99eb171cb3ce03f90f1dd08d19 Mon Sep 17 00:00:00 2001 From: "Arun S. Yerra" Date: Tue, 19 Sep 2017 00:38:58 -0700 Subject: Implement test case for Fabric Discovery Plugin Fabric Discovery plugin implements framework to connect to fabric update notifications from local domain controllers. This task is to implement unit test case for this module. Issue-Id: CCSDK-96 Change-Id: I3387f248e693a7da6b4817bc27f87dbc86aea806 Signed-off-by: Arun S. Yerra --- .../fabricdiscovery/TestFabricDiscoveryPlugin.java | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 fabric-discovery-plugin/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/fabricdiscovery/TestFabricDiscoveryPlugin.java diff --git a/fabric-discovery-plugin/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/fabricdiscovery/TestFabricDiscoveryPlugin.java b/fabric-discovery-plugin/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/fabricdiscovery/TestFabricDiscoveryPlugin.java new file mode 100644 index 000000000..f5dc7cbc0 --- /dev/null +++ b/fabric-discovery-plugin/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/fabricdiscovery/TestFabricDiscoveryPlugin.java @@ -0,0 +1,35 @@ +package jtest.org.onap.ccsdk.sli.plugins.fabricdiscovery; + +import java.util.HashMap; +import java.util.Map; +import org.junit.Assert; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.plugins.fabricdiscovery.FabricDiscoveryPlugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Created by arun on 9/18/17. + */ + +public class TestFabricDiscoveryPlugin { + private static final Logger LOG = LoggerFactory.getLogger(TestFabricDiscoveryPlugin.class); + private static final String C_STREAM = + "ws://localhost:8185/data-change-event-subscription/network-topology:network-topology/datastore=CONFIGURATION/scope=BASE"; + private final String FB_DISCOVERY_STATUS = "fb-response"; + + @Test + public void connectToNotificationServerSuccess() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + String stream = C_STREAM; + + Map p = new HashMap(); + p.put("stream", stream); + p.put("enable", "true"); + + FabricDiscoveryPlugin fdp = new FabricDiscoveryPlugin(); + fdp.processDcNotificationStream(p, ctx); + Assert.assertEquals("Success", ctx.getAttribute(FB_DISCOVERY_STATUS)); + } +} -- cgit From e1b367fbb12a2b36371842491e4b92a6464fb3c3 Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Tue, 19 Sep 2017 15:48:21 +0530 Subject: Fix Sonar Issue One major issue in sli/plugins module *Making anonymous inner class a lambda for better code readabilty Issue-Id: CCSDK-87 Change-Id: Ib650546c4c2c86411744379fe5beae828403453d Signed-off-by: surya-huawei --- .../ccsdk/sli/plugins/restapicall/RestapiCallNode.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index ca227c722..cfd02edd0 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -403,13 +403,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { if (p.ssl && p.restapiUrl.startsWith("https")) ssl = createSSLContext(p); if (ssl != null) { - HostnameVerifier hostnameVerifier = new HostnameVerifier() { - - @Override - public boolean verify(String hostname, SSLSession session) { - return true; - } - }; + HostnameVerifier hostnameVerifier = (hostname, session) -> true; config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(hostnameVerifier, ssl)); @@ -478,13 +472,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { System.setProperty("javax.net.ssl.trustStore", p.trustStoreFileName); System.setProperty("javax.net.ssl.trustStorePassword", p.trustStorePassword); - HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { - - @Override - public boolean verify(String string, SSLSession ssls) { - return true; - } - }); + HttpsURLConnection.setDefaultHostnameVerifier((string, ssls) -> true); KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); KeyStore ks = KeyStore.getInstance("PKCS12"); -- cgit From 671fbfeca691227bde901595e46cbc3a46ba7429 Mon Sep 17 00:00:00 2001 From: Gaurav Agrawal Date: Tue, 19 Sep 2017 15:38:32 +0530 Subject: Using specific exceptions in RestApiCallNode Changes includes 1) Sonar critical fixes stating use of specific exceptions instead of generic one 2) Throw exception for invalid input of repeat times. 3) Added testcases https://sonar.onap.org/component_issues/index?id=org.onap.ccsdk.sli.plugins%3Accsdk-sli-plugins#resolved=false|severities=CRITICAL Change-Id: I2633f857e161bf7068c51ef835b7c2cd5eb5aa62 Issue-Id: CCSDK-67 Signed-off-by: Gaurav Agrawal --- .../sli/plugins/restapicall/RestapiCallNode.java | 105 ++++++++++++++------- .../plugins/restapicall/TestRestapiCallNode.java | 83 +++++++++++++++- 2 files changed, 154 insertions(+), 34 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index ca227c722..4bdbd00a8 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -21,7 +21,11 @@ package org.onap.ccsdk.sli.plugins.restapicall; +import com.sun.jersey.api.client.ClientHandlerException; +import com.sun.jersey.api.client.UniformInterfaceException; import java.io.FileInputStream; +import java.io.IOException; +import java.net.SocketException; import java.net.URI; import java.nio.file.Files; import java.nio.file.Paths; @@ -45,6 +49,7 @@ import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.UriBuilder; import org.apache.commons.lang3.StringUtils; +import org.codehaus.jettison.json.JSONException; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; @@ -114,7 +119,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { throws SvcLogicException { RetryPolicy retryPolicy = null; - HttpResponse r = null; + HttpResponse r = new HttpResponse(); try { Parameters p = getParameters(paramMap); if (p.partner != null) { @@ -151,9 +156,9 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { ctx.setAttribute(pp + entry.getKey(), entry.getValue()); } } - } catch (Exception e) { + } catch (SvcLogicException | JSONException e) { boolean shouldRetry = false; - if (e.getCause() instanceof java.net.SocketException) { + if (e.getCause().getCause() instanceof SocketException) { shouldRetry = true; } @@ -190,7 +195,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } catch (Exception ex) { log.error("Could not attempt retry.", ex); String retryErrorMessage = - "Retry attempt has failed. No further retry shall be attempted, calling setFailureResponseStatus."; + "Retry attempt has failed. No further retry shall be attempted, calling " + + "setFailureResponseStatus."; setFailureResponseStatus(ctx, prefix, retryErrorMessage, r); } } @@ -270,7 +276,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { return value; } - protected String buildXmlJsonRequest(SvcLogicContext ctx, String template, Format format) { + protected String buildXmlJsonRequest(SvcLogicContext ctx, String template, Format format) + throws SvcLogicException { log.info("Building " + format + " started"); long t1 = System.currentTimeMillis(); @@ -291,7 +298,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { int i2 = template.indexOf('}', i1 + 2); if (i2 < 0) - throw new RuntimeException("Template error: Matching } not found"); + throw new SvcLogicException("Template error: Matching } not found"); String var1 = template.substring(i1 + 2, i2); String value1 = format == Format.XML ? XmlJsonUtil.getXml(mm, var1) : XmlJsonUtil.getJson(mm, var1); @@ -326,7 +333,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { return req; } - protected String expandRepeats(SvcLogicContext ctx, String template, int level) { + protected String expandRepeats(SvcLogicContext ctx, String template, int level) throws SvcLogicException { StringBuilder newTemplate = new StringBuilder(); int k = 0; while (k < template.length()) { @@ -338,7 +345,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { int i2 = template.indexOf(':', i1 + 9); if (i2 < 0) - throw new RuntimeException( + throw new SvcLogicException( "Template error: Context variable name followed by : is required after repeat"); // Find the closing }, store in i3 @@ -348,7 +355,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { while (nn > 0 && i < template.length()) { i3 = template.indexOf('}', i); if (i3 < 0) - throw new RuntimeException("Template error: Matching } not found"); + throw new SvcLogicException("Template error: Matching } not found"); int i32 = template.indexOf('{', i); if (i32 >= 0 && i32 < i3) { nn++; @@ -365,8 +372,9 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { int n = 0; try { n = Integer.parseInt(value1); - } catch (Exception e) { - n = 0; + } catch (NumberFormatException e) { + throw new SvcLogicException("Invalid input of repeat interval, should be an integer value " + + e.getLocalizedMessage(), e); } newTemplate.append(template.substring(k, i1)); @@ -392,12 +400,17 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { return expandRepeats(ctx, newTemplate.toString(), level + 1); } - protected String readFile(String fileName) throws Exception { - byte[] encoded = Files.readAllBytes(Paths.get(fileName)); - return new String(encoded, "UTF-8"); + protected String readFile(String fileName) throws SvcLogicException { + try { + byte[] encoded = Files.readAllBytes(Paths.get(fileName)); + return new String(encoded, "UTF-8"); + } catch (IOException | SecurityException e) { + throw new SvcLogicException("Unable to read file " + fileName + e.getLocalizedMessage(), e); + } } - protected HttpResponse sendHttpRequest(String request, Parameters p) throws Exception { + protected HttpResponse sendHttpRequest(String request, Parameters p) throws SvcLogicException { + ClientConfig config = new DefaultClientConfig(); SSLContext ssl = null; if (p.ssl && p.restapiUrl.startsWith("https")) @@ -451,7 +464,14 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { webResourceBuilder.header("X-ECOMP-RequestID",org.slf4j.MDC.get("X-ECOMP-RequestID")); - ClientResponse response = webResourceBuilder.method(p.httpMethod.toString(), ClientResponse.class, request); + ClientResponse response; + + try { + response = webResourceBuilder.method(p.httpMethod.toString(), ClientResponse.class, request); + } catch (UniformInterfaceException | ClientHandlerException e) { + throw new SvcLogicException("Exception while sending http request to client " + + e.getLocalizedMessage(), e); + } r.code = response.getStatus(); r.headers = response.getHeaders(); @@ -501,8 +521,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { return null; } - protected void setFailureResponseStatus(SvcLogicContext ctx, String prefix, String errorMessage, HttpResponse r) { - HttpResponse resp = new HttpResponse(); + protected void setFailureResponseStatus(SvcLogicContext ctx, String prefix, String errorMessage, + HttpResponse resp) { resp.code = 500; resp.message = errorMessage; String pp = prefix != null ? prefix + '.' : ""; @@ -525,7 +545,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { r = sendHttpData(data, p); setResponseStatus(ctx, p.responsePrefix, r); - } catch (Exception e) { + } catch (SvcLogicException | IOException e) { log.error("Error sending the request: " + e.getMessage(), e); r = new HttpResponse(); @@ -563,7 +583,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { return p; } - protected HttpResponse sendHttpData(byte[] data, FileParam p) { + protected HttpResponse sendHttpData(byte[] data, FileParam p) throws SvcLogicException { Client client = Client.create(); client.setConnectTimeout(5000); client.setFollowRedirects(true); @@ -580,11 +600,18 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { if (!p.skipSending) { String tt = "application/octet-stream"; - ClientResponse response = null; - if (p.httpMethod == HttpMethod.POST) - response = webResource.accept(tt).type(tt).post(ClientResponse.class, data); - else if (p.httpMethod == HttpMethod.PUT) - response = webResource.accept(tt).type(tt).put(ClientResponse.class, data); + ClientResponse response; + try { + if (p.httpMethod == HttpMethod.POST) + response = webResource.accept(tt).type(tt).post(ClientResponse.class, data); + else if (p.httpMethod == HttpMethod.PUT) + response = webResource.accept(tt).type(tt).put(ClientResponse.class, data); + else + throw new SvcLogicException("Http operation" + p.httpMethod + "not supported"); + } catch (UniformInterfaceException | ClientHandlerException e) { + throw new SvcLogicException("Exception while sending http request to client " + + e.getLocalizedMessage(), e); + } r.code = response.getStatus(); r.headers = response.getHeaders(); @@ -601,10 +628,17 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { webResource = client.resource(newUrl); - if (p.httpMethod == HttpMethod.POST) - response = webResource.accept(tt).type(tt).post(ClientResponse.class, data); - else if (p.httpMethod == HttpMethod.PUT) - response = webResource.accept(tt).type(tt).put(ClientResponse.class, data); + try { + if (p.httpMethod == HttpMethod.POST) + response = webResource.accept(tt).type(tt).post(ClientResponse.class, data); + else if (p.httpMethod == HttpMethod.PUT) + response = webResource.accept(tt).type(tt).put(ClientResponse.class, data); + else + throw new SvcLogicException("Http operation" + p.httpMethod + "not supported"); + } catch (UniformInterfaceException | ClientHandlerException e) { + throw new SvcLogicException("Exception while sending http request to client " + + e.getLocalizedMessage(), e); + } r.code = response.getStatus(); etag = response.getEntityTag(); @@ -648,7 +682,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { if (r.body != null) ctx.setAttribute(pp + "httpResponse", r.body); - } catch (Exception e) { + } catch (SvcLogicException e) { log.error("Error sending the request: " + e.getMessage(), e); r = new HttpResponse(); @@ -682,7 +716,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { return p; } - protected HttpResponse postOnUeb(String request, UebParam p) throws Exception { + protected HttpResponse postOnUeb(String request, UebParam p) throws SvcLogicException { String[] urls = uebServers.split(" "); for (int i = 0; i < urls.length; i++) { if (!urls[i].endsWith("/")) @@ -706,7 +740,14 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { String tt = "application/json"; String tt1 = tt + ";charset=UTF-8"; - ClientResponse response = webResource.accept(tt).type(tt1).post(ClientResponse.class, request); + ClientResponse response; + + try { + response = webResource.accept(tt).type(tt1).post(ClientResponse.class, request); + } catch (UniformInterfaceException | ClientHandlerException e) { + throw new SvcLogicException("Exception while posting http request to client " + + e.getLocalizedMessage(), e); + } r.code = response.getStatus(); r.headers = response.getHeaders(); diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index ff9714809..51c394783 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -26,6 +26,7 @@ import java.util.Map; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,7 +37,7 @@ public class TestRestapiCallNode { @Test - public void testDelete() throws Exception { + public void testDelete() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); Map p = new HashMap(); @@ -51,7 +52,7 @@ public class TestRestapiCallNode { } @Test - public void testJsonTemplate() throws Exception { + public void testJsonTemplate() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); ctx.setAttribute("tmp.sdn-circuit-req-row_length", "3"); ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); @@ -89,4 +90,82 @@ public class TestRestapiCallNode { RestapiCallNode rcn = new RestapiCallNode(); rcn.sendRequest(p, ctx); } + + @Test(expected = SvcLogicException.class) + public void testInvalidRepeatTimes() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "a"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testInvalidTemplatePath() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resourcess/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testWithoutSkipSending() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "false"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } } -- cgit From 02e1594ffee2231523d0486a5d8b590ff09581df Mon Sep 17 00:00:00 2001 From: Gaurav Agrawal Date: Tue, 19 Sep 2017 17:40:54 +0530 Subject: Refinements to RestApiCall plugin Changes includes: 1) Check for null in JsonParser.convertToProperties() which can otherwise result in null pointer exception 2) Use logger built-in string formatting rather then string concatenation 3) Use StringBuilder for multiple string concatenations 4) Making utility classes final and defines private constructor for them 5) Added testcases/testpoints https://sonar.onap.org/component_issues/index?id=org.onap.ccsdk.sli.plugins%3Accsdk-sli-plugins#resolved=false|severities=CRITICAL Change-Id: Ic047b6d0369827a38a98c52e8365f1fe7266840f Issue-Id: CCSDK-67 Signed-off-by: Gaurav Agrawal --- .../ccsdk/sli/plugins/restapicall/JsonParser.java | 85 ++++++++++++---------- .../ccsdk/sli/plugins/restapicall/XmlJsonUtil.java | 14 ++-- .../ccsdk/sli/plugins/restapicall/XmlParser.java | 62 +++++++++------- .../sli/plugins/restapicall/TestJsonParser.java | 20 +++-- .../sli/plugins/restapicall/TestXmlParser.java | 10 +-- .../provider/src/test/resources/test.json | 5 +- 6 files changed, 114 insertions(+), 82 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java index f2867f5a3..4a1dfef50 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java @@ -21,6 +21,8 @@ package org.onap.ccsdk.sli.plugins.restapicall; +import static com.google.common.base.Preconditions.checkNotNull; + import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -29,57 +31,64 @@ 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 class JsonParser { +public final class JsonParser { private static final Logger log = LoggerFactory.getLogger(JsonParser.class); - @SuppressWarnings("unchecked") - public static Map convertToProperties(String s) throws JSONException { - JSONObject json = new JSONObject(s); - - Map wm = new HashMap<>(); - Iterator ii = json.keys(); - while (ii.hasNext()) { - String key1 = ii.next(); - wm.put(key1, json.get(key1)); - } - - Map mm = new HashMap<>(); + private JsonParser() { + // Preventing instantiation of the same. + } - while (!wm.isEmpty()) - for (String key : new ArrayList<>(wm.keySet())) { - Object o = wm.get(key); - wm.remove(key); + @SuppressWarnings("unchecked") + public static Map convertToProperties(String s) + throws SvcLogicException { + + checkNotNull(s, "Input should not be null."); + + try { + JSONObject json = new JSONObject(s); + Map wm = new HashMap<>(); + Iterator ii = json.keys(); + while (ii.hasNext()) { + String key1 = ii.next(); + wm.put(key1, json.get(key1)); + } - if (o instanceof Boolean || o instanceof Number || o instanceof String) { - mm.put(key, o.toString()); + Map mm = new HashMap<>(); - log.info("Added property: " + key + ": " + o.toString()); - } + while (!wm.isEmpty()) + for (String key : new ArrayList<>(wm.keySet())) { + Object o = wm.get(key); + wm.remove(key); - else if (o instanceof JSONObject) { - JSONObject jo = (JSONObject) o; - Iterator i = jo.keys(); - while (i.hasNext()) { - String key1 = i.next(); - wm.put(key + "." + key1, jo.get(key1)); - } - } + if (o instanceof Boolean || o instanceof Number || o instanceof String) { + mm.put(key, o.toString()); - else if (o instanceof JSONArray) { - JSONArray ja = (JSONArray) o; - mm.put(key + "_length", String.valueOf(ja.length())); + log.info("Added property: {} : {}", key, o.toString()); + } else if (o instanceof JSONObject) { + JSONObject jo = (JSONObject) o; + Iterator 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: " + 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)); + for (int i = 0; i < ja.length(); i++) + wm.put(key + '[' + i + ']', ja.get(i)); + } } - } - - return mm; + return mm; + } catch (JSONException e) { + throw new SvcLogicException("Unable to convert JSON to properties" + e.getLocalizedMessage(), e); + } } } diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java index e80ca5081..b94f0a638 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java @@ -29,10 +29,14 @@ import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class XmlJsonUtil { +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 varmap, String var) { boolean escape = true; if (var.startsWith("'")) { @@ -99,7 +103,7 @@ public class XmlJsonUtil { try { length = Integer.parseInt(lengthStr); } catch (Exception e) { - log.warn("Invalid number for " + var + "_length:" + lengthStr); + log.warn("Invalid number for {}_length:{}", var, lengthStr); } } @@ -364,9 +368,9 @@ public class XmlJsonUtil { } private static String pad(int n) { - String s = ""; + StringBuilder s = new StringBuilder(); for (int i = 0; i < n; i++) - s += Character.toString('\t'); - return s; + s.append(Character.toString('\t')); + return s.toString(); } } diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java index 61b0e31d4..7ef776da1 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java @@ -21,37 +21,49 @@ package org.onap.ccsdk.sli.plugins.restapicall; +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 class XmlParser { +public final class XmlParser { private static final Logger log = LoggerFactory.getLogger(XmlParser.class); - public static Map convertToProperties(String s, Set listNameList) { + private XmlParser() { + // Preventing instantiation of the same. + } + + public static Map convertToProperties(String s, Set 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 (Exception e) { - e.printStackTrace(); + } catch (ParserConfigurationException | IOException | SAXException e) { + throw new SvcLogicException("Unable to convert XML to properties" + e.getLocalizedMessage(), e); } - return handler.getProperties(); } @@ -72,8 +84,8 @@ public class XmlParser { this.listNameList = new HashSet<>(); } - String currentName = ""; - String currentValue = ""; + StringBuilder currentName = new StringBuilder(); + StringBuilder currentValue = new StringBuilder(); @Override public void startElement(String uri, String localName, String qName, Attributes attributes) @@ -88,15 +100,16 @@ public class XmlParser { name = name.substring(i2 + 1); if (currentName.length() > 0) - currentName += Character.toString('.'); - currentName += name; + currentName.append(Character.toString('.')); + currentName.append(name); - String listName = removeIndexes(currentName); + String listName = removeIndexes(currentName.toString()); if (listNameList.contains(listName)) { - int len = getInt(properties, currentName + "_length"); - properties.put(currentName + "_length", String.valueOf(len + 1)); - currentName += "[" + len + "]"; + String n = currentName.toString() + "_length"; + int len = getInt(properties, n); + properties.put(n, String.valueOf(len + 1)); + currentName.append("[").append(len).append("]"); } } @@ -111,20 +124,19 @@ public class XmlParser { if (i2 >= 0) name = name.substring(i2 + 1); - if (currentValue.trim().length() > 0) { - currentValue = currentValue.trim(); - properties.put(currentName, currentValue); - - log.info("Added property: " + currentName + ": " + currentValue); + String s = currentValue.toString().trim(); + if (s.length() > 0) { + properties.put(currentName.toString(), s); - currentValue = ""; + log.info("Added property: {} : {}", currentName, s); + currentValue = new StringBuilder(); } int i1 = currentName.lastIndexOf("." + name); if (i1 <= 0) - currentName = ""; + currentName = new StringBuilder(); else - currentName = currentName.substring(0, i1); + currentName = new StringBuilder(currentName.substring(0, i1)); } @Override @@ -132,7 +144,7 @@ public class XmlParser { super.characters(ch, start, length); String value = new String(ch, start, length); - currentValue += value; + currentValue.append(value); } private static int getInt(Map mm, String name) { @@ -143,7 +155,7 @@ public class XmlParser { } private String removeIndexes(String currentName) { - String s = ""; + StringBuilder b = new StringBuilder(); boolean add = true; for (int i = 0; i < currentName.length(); i++) { char c = currentName.charAt(i); @@ -152,9 +164,9 @@ public class XmlParser { else if (c == ']') add = true; else if (add) - s += Character.toString(c); + b.append(Character.toString(c)); } - return s; + return b.toString(); } } } diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java index dbca5ad7b..5526be81f 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java @@ -22,6 +22,7 @@ package jtest.org.onap.ccsdk.sli.plugins.restapicall; import java.io.BufferedReader; +import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; @@ -29,6 +30,7 @@ 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.restapicall.JsonParser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,30 +40,34 @@ public class TestJsonParser { private static final Logger log = LoggerFactory.getLogger(TestJsonParser.class); @Test - public void test() throws Exception { + public void test() throws SvcLogicException, IOException { BufferedReader in = new BufferedReader( new InputStreamReader(ClassLoader.getSystemResourceAsStream("test.json")) ); - String ss = ""; - String line = null; + StringBuilder b = new StringBuilder(); + String line; while ((line = in.readLine()) != null) - ss += line + '\n'; + b.append(line).append('\n'); - Map mm = JsonParser.convertToProperties(ss); + Map 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 mm) { List 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)); + log.info("--- {}: {}", name, mm.get(name)); } } diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java index 544d259e0..e8567d591 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java @@ -44,10 +44,10 @@ public class TestXmlParser { BufferedReader in = new BufferedReader( new InputStreamReader(ClassLoader.getSystemResourceAsStream("test3.xml")) ); - String ss = ""; - String line = null; + StringBuilder b = new StringBuilder(); + String line; while ((line = in.readLine()) != null) - ss += line + '\n'; + b.append(line).append('\n'); Set listNameList = new HashSet(); listNameList.add("project.dependencies.dependency"); @@ -57,10 +57,8 @@ public class TestXmlParser { listNameList.add("project.build.pluginManagement." + "plugins.plugin.configuration.lifecycleMappingMetadata.pluginExecutions.pluginExecution"); - Map mm = XmlParser.convertToProperties(ss, listNameList); - + Map mm = XmlParser.convertToProperties(b.toString(), listNameList); logProperties(mm); - in.close(); } diff --git a/restapi-call-node/provider/src/test/resources/test.json b/restapi-call-node/provider/src/test/resources/test.json index a34f7e2a0..b48eb6b43 100644 --- a/restapi-call-node/provider/src/test/resources/test.json +++ b/restapi-call-node/provider/src/test/resources/test.json @@ -27,7 +27,10 @@ "number-primary-servers": "2", "equipment-id": "Server1", "server-model": "Unknown", - "server-id": "Server1" + "server-id": "Server1", + "test-node" : { + "test-inner-node" : "Test-Value" + } } ], "resource-state": { -- cgit From f8d60223f0cdd676a89cad12f0f8c0a8e97819d6 Mon Sep 17 00:00:00 2001 From: Brian Freeman Date: Tue, 19 Sep 2017 16:53:20 +0000 Subject: Fix sli dependency Issue-ID: SDNC-86 Change-Id: I4b6a4ab0ba8532802486f18804421dc76fc4c862 Signed-off-by: Brian Freeman --- fabric-discovery-plugin/features/src/main/resources/features.xml | 2 +- properties-node/features/src/main/resources/features.xml | 2 +- restapi-call-node/features/src/main/resources/features.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fabric-discovery-plugin/features/src/main/resources/features.xml b/fabric-discovery-plugin/features/src/main/resources/features.xml index 0750c4384..34ddebb99 100644 --- a/fabric-discovery-plugin/features/src/main/resources/features.xml +++ b/fabric-discovery-plugin/features/src/main/resources/features.xml @@ -29,7 +29,7 @@ - sdnc-sli + sdnc-sli spring spring-dm mvn:com.sun.jersey/jersey-client/${jersey.version} diff --git a/properties-node/features/src/main/resources/features.xml b/properties-node/features/src/main/resources/features.xml index 96f37a9e0..9abacf0b8 100644 --- a/properties-node/features/src/main/resources/features.xml +++ b/properties-node/features/src/main/resources/features.xml @@ -29,7 +29,7 @@ - sdnc-sli + sdnc-sli spring spring-dm mvn:org.onap.ccsdk.sli.plugins/properties-node-provider/${project.version} diff --git a/restapi-call-node/features/src/main/resources/features.xml b/restapi-call-node/features/src/main/resources/features.xml index 5a7f1f497..da9266f9e 100644 --- a/restapi-call-node/features/src/main/resources/features.xml +++ b/restapi-call-node/features/src/main/resources/features.xml @@ -29,7 +29,7 @@ - sdnc-sli + sdnc-sli spring spring-dm mvn:com.sun.jersey/jersey-client/${jersey.version} -- cgit From ba209b4de55c56e5c427e3389518966f2c896661 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 19 Sep 2017 20:48:48 -0400 Subject: Remove unthrown exception Merge build fails because catch statement is trying to catch JSONException which is not thrown in body of try Change-Id: I9e29e1698e04f8135799440ca4859aa418d1c54d Issue-ID: CCSDK-99 Signed-off-by: Dan Timoney --- .../org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 60697a423..20c13daac 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -8,9 +8,9 @@ * 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. @@ -156,7 +156,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { ctx.setAttribute(pp + entry.getKey(), entry.getValue()); } } - } catch (SvcLogicException | JSONException e) { + } catch (SvcLogicException e) { boolean shouldRetry = false; if (e.getCause().getCause() instanceof SocketException) { shouldRetry = true; -- cgit From 33bfbaf4a7c2c33fc0b0b5ab18a5553dd8884cf7 Mon Sep 17 00:00:00 2001 From: Gaurav Agrawal Date: Wed, 20 Sep 2017 11:48:54 +0530 Subject: Changes to RestApiCall plugin Changes includes 1. Perform validation of URL syntax during parameter parsing phase. 2. StringBuilder to replace string concatenation within loop. 3. Testcase addition. 4. Sonar critical issue fix for XmlJsonUtil 5) Use logger built-in string formatting rather then string concatenation https://sonar.onap.org/component_issues/index?id=org.onap.ccsdk.sli.plugins%3Accsdk-sli-plugins#resolved=false|severities=CRITICAL Change-Id: I884af51023bbd4983c43707aca97c398d24fc9de Issue-Id: CCSDK-67 Signed-off-by: Gaurav Agrawal --- .../sli/plugins/restapicall/RestapiCallNode.java | 73 ++++++++++++---------- .../ccsdk/sli/plugins/restapicall/XmlJsonUtil.java | 2 +- .../plugins/restapicall/TestRestapiCallNode.java | 27 ++++++++ 3 files changed, 69 insertions(+), 33 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 20c13daac..c4ad4c55b 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -183,10 +183,10 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { URI retryUri = UriBuilder.fromUri(uri).host(uriTwo.getHost()).port(uriTwo.getPort()).scheme( uriTwo.getScheme()).build(); paramMap.put("restapiUrl", retryUri.toString()); - log.debug("URL was set to " + retryUri.toString()); - log.debug("Failed to communicate with host " + hostname + - ". Request will be re-attempted using the host " + retryString + "."); - log.debug("This is retry attempt " + retryCount + " out of " + retryPolicy.getMaximumRetries()); + log.debug("URL was set to {}", retryUri.toString()); + log.debug("Failed to communicate with host {}. Request will be re-attempted using the host {}.", + hostname, retryString); + log.debug("This is retry attempt {} out of {}", retryCount, retryPolicy.getMaximumRetries()); sendRequest(paramMap, ctx, retryCount); } else { log.debug("Maximum retries reached, calling setFailureResponseStatus."); @@ -210,6 +210,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { Parameters p = new Parameters(); p.templateFileName = parseParam(paramMap, "templateFileName", false, null); p.restapiUrl = parseParam(paramMap, "restapiUrl", true, null); + validateUrl(p.restapiUrl); p.restapiUser = parseParam(paramMap, "restapiUser", false, null); p.restapiPassword = parseParam(paramMap, "restapiPassword", false, null); p.contentType = parseParam(paramMap, "contentType", false, null); @@ -232,6 +233,14 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { return p; } + private void validateUrl(String restapiUrl) throws SvcLogicException { + try { + URI.create(restapiUrl); + } catch (IllegalArgumentException e) { + throw new SvcLogicException("Invalid input of url " + e.getLocalizedMessage(), e); + } + } + protected Set getListNameList(Map paramMap) { Set ll = new HashSet<>(); for (Map.Entry entry : paramMap.entrySet()) @@ -251,7 +260,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } s = s.trim(); - String value = ""; + StringBuilder value = new StringBuilder(); int i = 0; int i1 = s.indexOf('%'); while (i1 >= 0) { @@ -264,21 +273,21 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { if (varValue == null) varValue = "%" + varName + "%"; - value += s.substring(i, i1); - value += varValue; + value.append(s.substring(i, i1)); + value.append(varValue); i = i2 + 1; i1 = s.indexOf('%', i); } - value += s.substring(i); + value.append(s.substring(i)); - log.info("Parameter " + name + ": [" + value + "]"); - return value; + log.info("Parameter {}: [{}]", name, value); + return value.toString(); } protected String buildXmlJsonRequest(SvcLogicContext ctx, String template, Format format) throws SvcLogicException { - log.info("Building " + format + " started"); + log.info("Building {} started", format); long t1 = System.currentTimeMillis(); template = expandRepeats(ctx, template, 1); @@ -328,7 +337,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { req = XmlJsonUtil.removeLastCommaJson(req); long t2 = System.currentTimeMillis(); - log.info("Building " + format + " completed. Time: " + (t2 - t1)); + log.info("Building {} completed. Time: {}", format, (t2 - t1)); return req; } @@ -368,7 +377,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { String var1 = template.substring(i1 + 9, i2); String value1 = ctx.getAttribute(var1); - log.info(" " + var1 + ": " + value1); + log.info(" {}:{}", var1, value1); int n = 0; try { n = Integer.parseInt(value1); @@ -477,11 +486,11 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } long t2 = System.currentTimeMillis(); - log.info("Response received. Time: " + (t2 - t1)); - log.info("HTTP response code: " + r.code); - log.info("HTTP response message: " + r.message); + log.info("Response received. Time: {}", (t2 - t1)); + log.info("HTTP response code: {}", r.code); + log.info("HTTP response message: {}", r.message); logHeaders(r.headers); - log.info("HTTP response: " + r.body); + log.info("HTTP response: {}", r.body); return r; } @@ -504,7 +513,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { ctx.init(kmf.getKeyManagers(), null, null); return ctx; } catch (Exception e) { - log.error("Error creating SSLContext: " + e.getMessage(), e); + log.error("Error creating SSLContext: {}", e.getMessage(), e); } return null; } @@ -534,7 +543,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { setResponseStatus(ctx, p.responsePrefix, r); } catch (SvcLogicException | IOException e) { - log.error("Error sending the request: " + e.getMessage(), e); + log.error("Error sending the request: {}", e.getMessage(), e); r = new HttpResponse(); r.code = 500; @@ -612,7 +621,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { if (r.code == 301) { String newUrl = response.getHeaders().getFirst("Location"); - log.info("Got response code 301. Sending same request to URL: " + newUrl); + log.info("Got response code 301. Sending same request to URL: {}", newUrl); webResource = client.resource(newUrl); @@ -638,11 +647,11 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } long t2 = System.currentTimeMillis(); - log.info("Response received. Time: " + (t2 - t1)); - log.info("HTTP response code: " + r.code); - log.info("HTTP response message: " + r.message); + log.info("Response received. Time: {}", (t2 - t1)); + log.info("HTTP response code: {}", r.code); + log.info("HTTP response message: {}", r.message); logHeaders(r.headers); - log.info("HTTP response: " + r.body); + log.info("HTTP response: {}", r.body); return r; } @@ -657,7 +666,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { String req; if (p.templateFileName == null) { - log.info("No template file name specified. Using default UEB template: " + defaultUebTemplateFileName); + log.info("No template file name specified. Using default UEB template: {}", defaultUebTemplateFileName); p.templateFileName = defaultUebTemplateFileName; } @@ -671,7 +680,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { ctx.setAttribute(pp + "httpResponse", r.body); } catch (SvcLogicException e) { - log.error("Error sending the request: " + e.getMessage(), e); + log.error("Error sending the request: {}", e.getMessage(), e); r = new HttpResponse(); r.code = 500; @@ -716,7 +725,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { client.setConnectTimeout(5000); WebResource webResource = client.resource(urls[0]); - log.info("UEB URL: " + urls[0]); + log.info("UEB URL: {}", urls[0]); log.info("Sending request:"); log.info(request); long t1 = System.currentTimeMillis(); @@ -744,10 +753,10 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } long t2 = System.currentTimeMillis(); - log.info("Response received. Time: " + (t2 - t1)); - log.info("HTTP response code: " + r.code); + log.info("Response received. Time: {}", (t2 - t1)); + log.info("HTTP response code: {}", r.code); logHeaders(r.headers); - log.info("HTTP response:\n" + r.body); + log.info("HTTP response:\n {}", r.body); return r; } @@ -760,7 +769,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { log.info("Properties:"); for (String name : ll) - log.info("--- " + name + ": " + String.valueOf(mm.get(name))); + log.info("--- {}:{}", name, String.valueOf(mm.get(name))); } protected void logHeaders(MultivaluedMap mm) { @@ -775,7 +784,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { Collections.sort(ll); for (String name : ll) - log.info("--- " + name + ": " + String.valueOf(mm.get(name))); + log.info("--- {}:{}", name, String.valueOf(mm.get(name))); } public void setUebServers(String uebServers) { diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java index b94f0a638..359501fc4 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java @@ -103,7 +103,7 @@ public final class XmlJsonUtil { try { length = Integer.parseInt(lengthStr); } catch (Exception e) { - log.warn("Invalid number for {}_length:{}", var, lengthStr); + log.warn("Invalid number for {}_length:{}", var, lengthStr, e); } } diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index 51c394783..118d97d31 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -168,4 +168,31 @@ public class TestRestapiCallNode { RestapiCallNode rcn = new RestapiCallNode(); rcn.sendRequest(p, ctx); } + + + @Test(expected = SvcLogicException.class) + public void testWithInvalidURI() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo. getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "false"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } } -- cgit From 72e394582ceeb86e35d2c5cb34b244b38ae5659f Mon Sep 17 00:00:00 2001 From: Gaurav Agrawal Date: Wed, 20 Sep 2017 12:43:42 +0530 Subject: Refinements and test additions to XmlParser Changes includes 1) Added validation for invalid length 2) Added testcases to test length Change-Id: Iefd56ca470382be139f185fdf84b6c0de0fa99f6 Issue-Id: CCSDK-100 Signed-off-by: Gaurav Agrawal --- .../ccsdk/sli/plugins/restapicall/XmlParser.java | 2 +- .../sli/plugins/restapicall/TestXmlParser.java | 46 ++++++++++++++++++++ .../provider/src/test/resources/invalidlength.xml | 49 ++++++++++++++++++++++ 3 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 restapi-call-node/provider/src/test/resources/invalidlength.xml diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java index 7ef776da1..9aede5b7e 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java @@ -61,7 +61,7 @@ public final class XmlParser { SAXParser saxParser = factory.newSAXParser(); InputStream in = new ByteArrayInputStream(s.getBytes()); saxParser.parse(in, handler); - } catch (ParserConfigurationException | IOException | SAXException e) { + } catch (ParserConfigurationException | IOException | SAXException | NumberFormatException e) { throw new SvcLogicException("Unable to convert XML to properties" + e.getLocalizedMessage(), e); } return handler.getProperties(); diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java index e8567d591..c6bf4a8b9 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java @@ -21,6 +21,9 @@ package jtest.org.onap.ccsdk.sli.plugins.restapicall; +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; @@ -31,6 +34,7 @@ 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.restapicall.XmlParser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,6 +66,48 @@ public class TestXmlParser { 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 listNameList = new HashSet(); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); + + Map 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 listNameList = new HashSet(); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); + + Map mm = XmlParser.convertToProperties(b.toString(), listNameList); + logProperties(mm); + in.close(); + } + private void logProperties(Map mm) { List ll = new ArrayList<>(); for (Object o : mm.keySet()) diff --git a/restapi-call-node/provider/src/test/resources/invalidlength.xml b/restapi-call-node/provider/src/test/resources/invalidlength.xml new file mode 100644 index 000000000..c086d564e --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/invalidlength.xml @@ -0,0 +1,49 @@ + + + + + + ICOREPVC-81114561 + + VPNL811182 + 811182 + 21302:811182 + SET_BVOIP_IN + SET6_BVOIP_IN + a + SET6_DSU + SET_DSU + SET6_MANAGED + SET_MANAGED + SET_LOVRF_COMMUNITY + SET_RESET_LP + + AG_MAX_MCASTROUTES + + + + 200 + Success + Y + + -- cgit From ff9dfa14ecc880d13dfc1ce4648fc4baee9f7d99 Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Wed, 20 Sep 2017 16:50:20 +0530 Subject: Use entrySet instead of keySet *Iterating over map entries with entrySet This is done because both key and value are needed and iterating over entryset is more efficient than keyset Issue-Id: CCSDK-87 Change-Id: I31d14239c8f7300ff2d3a629683e00b42e61ad86 Signed-off-by: surya-huawei --- .../ccsdk/sli/plugins/restapicall/XmlJsonUtil.java | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java index b94f0a638..4a04d97d7 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java @@ -132,23 +132,24 @@ public final class XmlJsonUtil { if (o instanceof Map) { StringBuilder ss = new StringBuilder(); Map mm = (Map) o; - for (String k : mm.keySet()) { - Object v = mm.get(k); + for (Map.Entry 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(k).append('>'); + ss.append(pad(indent)).append('<').append(key).append('>'); ss.append(s); - ss.append("').append('\n'); + ss.append("').append('\n'); } else if (v instanceof Map) { - ss.append(pad(indent)).append('<').append(k).append('>').append('\n'); + ss.append(pad(indent)).append('<').append(key).append('>').append('\n'); ss.append(generateXml(v, indent + 1, escape)); - ss.append(pad(indent)).append("').append('\n'); + ss.append(pad(indent)).append("').append('\n'); } else if (v instanceof List) { List ll = (List) v; for (Object o1 : ll) { - ss.append(pad(indent)).append('<').append(k).append('>').append('\n'); + ss.append(pad(indent)).append('<').append(key).append('>').append('\n'); ss.append(generateXml(o1, indent + 1, escape)); - ss.append(pad(indent)).append("').append('\n'); + ss.append(pad(indent)).append("').append('\n'); } } } @@ -185,13 +186,13 @@ public final class XmlJsonUtil { ss.append("{\n"); boolean first = true; - for (String k : mm.keySet()) { + for (Map.Entry entry : mm.entrySet()) { if (!first) ss.append(",\n"); first = false; - - Object v = mm.get(k); - ss.append(pad(indent + 1)).append('"').append(k).append("\": "); + Object v = entry.getValue(); + String key = entry.getKey(); + ss.append(pad(indent + 1)).append('"').append(key).append("\": "); generateJson(ss, v, indent + 1, false, escape); } -- cgit From 23fc985b7163470ed5f2a1d7cbf2e3f0431a8c8a Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Thu, 21 Sep 2017 16:47:19 +0530 Subject: Replace type specification with diamond operator Major issue in sli/plugins module *Used diamond operator to reduce verbosity of generics code *Removed unnecessary parantheses as they can be misleading sometimes Issue-Id: CCSDK-87 Change-Id: I81c0b566f5beb81d3733549a2f9de81b50d6814c Signed-off-by: surya-huawei --- .../onap/ccsdk/sli/plugins/fabricdiscovery/FabricDiscoveryPlugin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/FabricDiscoveryPlugin.java b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/FabricDiscoveryPlugin.java index 66452758d..99e171f6e 100644 --- a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/FabricDiscoveryPlugin.java +++ b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/FabricDiscoveryPlugin.java @@ -44,7 +44,7 @@ public class FabricDiscoveryPlugin implements SvcLogicJavaPlugin, IFabricDiscove public FabricDiscoveryPlugin() { service = Executors.newFixedThreadPool(10); - streamMap = new ConcurrentHashMap (); + streamMap = new ConcurrentHashMap<>(); } @Override @@ -70,7 +70,7 @@ public class FabricDiscoveryPlugin implements SvcLogicJavaPlugin, IFabricDiscove } ctx.setAttribute(pfx + FB_DISCOVERY_STATUS, "Success"); - LOG.info("{} monitoring notification stream: {}", (enable) ? "START" : "STOP", stream); + LOG.info("{} monitoring notification stream: {}", enable ? "START" : "STOP", stream); try { service.execute(new Runnable () { -- cgit From bb5be2989a75d48a56877e1bf5135a0bec68f43e Mon Sep 17 00:00:00 2001 From: "Arun S. Yerra" Date: Fri, 22 Sep 2017 15:20:32 -0700 Subject: Implement test cases for fabric discovery plugin This change adds a negative test case to test input from directed graph to start listening to domain controller notifications. Issue-id: CCSDK-96 Change-Id: I2dd1a4d2264df4c142362e242e04bf9495e0351a Signed-off-by: Arun S. Yerra --- .../fabricdiscovery/TestFabricDiscoveryPlugin.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/fabric-discovery-plugin/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/fabricdiscovery/TestFabricDiscoveryPlugin.java b/fabric-discovery-plugin/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/fabricdiscovery/TestFabricDiscoveryPlugin.java index f5dc7cbc0..ac0461889 100644 --- a/fabric-discovery-plugin/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/fabricdiscovery/TestFabricDiscoveryPlugin.java +++ b/fabric-discovery-plugin/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/fabricdiscovery/TestFabricDiscoveryPlugin.java @@ -17,6 +17,8 @@ public class TestFabricDiscoveryPlugin { private static final Logger LOG = LoggerFactory.getLogger(TestFabricDiscoveryPlugin.class); private static final String C_STREAM = "ws://localhost:8185/data-change-event-subscription/network-topology:network-topology/datastore=CONFIGURATION/scope=BASE"; + private static final String W_STREAM = + "get://localhost:8185/data-change-event-subscription/network-topology:network/datastore=CONFIGURATION/scope=BASE"; private final String FB_DISCOVERY_STATUS = "fb-response"; @Test @@ -32,4 +34,25 @@ public class TestFabricDiscoveryPlugin { fdp.processDcNotificationStream(p, ctx); Assert.assertEquals("Success", ctx.getAttribute(FB_DISCOVERY_STATUS)); } + + @Test + public void connectToNotificationServerFailure() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + String stream = W_STREAM; + + Map p = new HashMap<>(); + p.put("stream", stream); + p.put("enable", "true"); + + FabricDiscoveryPlugin fdp = new FabricDiscoveryPlugin(); + try { + fdp.processDcNotificationStream(p, ctx); + LOG.info("Connection to Stream:{} succeeded.", stream); + } catch (Exception e) { + LOG.info("Received Exception while connecting to Fabric Discovery notification server: {}", e.getMessage()); + } finally { + Assert.assertEquals("Failure", ctx.getAttribute(FB_DISCOVERY_STATUS)); + } + } + } -- cgit From a12faac8e7133f354050cf9b7990f8b35d022d01 Mon Sep 17 00:00:00 2001 From: "Arun S. Yerra" Date: Sun, 24 Sep 2017 21:42:08 -0700 Subject: Implement test cases for fabric discovery plugin This change adds a negative test case to test input from directed graph to specify whether to start or stop listening to domain controller notifications. Issue-id: CCSDK-96 Change-Id: I19e904c39e58e81d39079e233c68383496d8bc59 Signed-off-by: Arun S. Yerra --- .../fabricdiscovery/TestFabricDiscoveryPlugin.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/fabric-discovery-plugin/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/fabricdiscovery/TestFabricDiscoveryPlugin.java b/fabric-discovery-plugin/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/fabricdiscovery/TestFabricDiscoveryPlugin.java index ac0461889..7a25e77be 100644 --- a/fabric-discovery-plugin/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/fabricdiscovery/TestFabricDiscoveryPlugin.java +++ b/fabric-discovery-plugin/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/fabricdiscovery/TestFabricDiscoveryPlugin.java @@ -55,4 +55,25 @@ public class TestFabricDiscoveryPlugin { } } + @Test + public void validateParameterEnableFailure() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + String stream = C_STREAM; + final String W_ENABLE_STR = "bad enable parameter"; + + Map p = new HashMap<>(); + p.put("stream", stream); + p.put("enable", W_ENABLE_STR); + + FabricDiscoveryPlugin fdp = new FabricDiscoveryPlugin(); + try { + fdp.processDcNotificationStream(p, ctx); + LOG.info("Connection to Stream:{} succeeded.", stream); + } catch (Exception e) { + LOG.info("Received Exception while connecting to Fabric Discovery notification server: {}", e.getMessage()); + } finally { + Assert.assertEquals("Failure", ctx.getAttribute(FB_DISCOVERY_STATUS)); + } + } + } -- cgit From dbcacd2b6361252e4de5c4b114f29274f7ce9652 Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Fri, 22 Sep 2017 18:44:07 +0530 Subject: Remove unused imports Removed unused imports to increase the code's readability Issue-Id: CCSDK-87 Change-Id: Ib8f9dbe1e0a05567c75f7fcd46ab024f5b433fef Signed-off-by: surya-huawei --- .../org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClient.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClient.java b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClient.java index bdecdc742..d5bab386e 100644 --- a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClient.java +++ b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClient.java @@ -23,9 +23,6 @@ import io.netty.handler.codec.http.websocketx.PingWebSocketFrame; import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory; import io.netty.handler.codec.http.websocketx.WebSocketVersion; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; import java.net.URI; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -- cgit From 68607dc808655310f2b62f9fd0228980cb4c2325 Mon Sep 17 00:00:00 2001 From: "ramu.n" Date: Wed, 27 Sep 2017 18:44:14 +0530 Subject: Add underlay JSON template validation Add UT test cases to validate the JSON template used to communicate with 3rd party controller of IP WAN Network Change-Id: I251f5cabecdd7e4f02d0be3bb27d7af4a355c077 Issue-Id: SDNC-90 Signed-off-by: Ramu N --- .../plugins/restapicall/TestRestapiCallNode.java | 64 +++++++- .../src/test/resources/l3smsitetemplate.json | 164 +++++++++++++++++++++ .../src/test/resources/l3smvpntemplate.json | 28 ++++ 3 files changed, 254 insertions(+), 2 deletions(-) create mode 100644 restapi-call-node/provider/src/test/resources/l3smsitetemplate.json create mode 100644 restapi-call-node/provider/src/test/resources/l3smvpntemplate.json diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index 118d97d31..2d3b40105 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -8,9 +8,9 @@ * 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. @@ -195,4 +195,64 @@ public class TestRestapiCallNode { RestapiCallNode rcn = new RestapiCallNode(); rcn.sendRequest(p, ctx); } + + @Test + public void testVpnJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testSiteJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + ctx.setAttribute("prop.l3vpn.site1_name", "10000000-0000-0000-0000-000000000002"); + ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003"); + ctx.setAttribute("prop.l3vpn.entry1-id", "1"); + ctx.setAttribute("prop.l3vpn.sna1_name", "10000000-0000-0000-0000-000000000004"); + ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e"); + ctx.setAttribute("prop.l3vpn.ac1_id", "a8098c1a-f86e-11da-bd1a-00112444be1b"); + ctx.setAttribute("prop.l3vpn.ac1-peer-ip", "192.168.1.1"); + ctx.setAttribute("prop.l3vpn.ac1-ip", "192.168.1.2"); + ctx.setAttribute("prop.l3vpn.sna1-route", "192.168.1.4/24"); + + ctx.setAttribute("prop.l3vpn.site2_name", "10000000-0000-0000-0000-000000000005"); + ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006"); + ctx.setAttribute("prop.l3vpn.entry2-id", "1"); + ctx.setAttribute("prop.l3vpn.sna2_name", "10000000-0000-0000-0000-000000000007"); + ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a"); + ctx.setAttribute("prop.l3vpn.ac2_id", "a8098c1a-f86e-11da-bd1a-00112444be1c"); + ctx.setAttribute("prop.l3vpn.ac2-peer-ip", "192.168.1.5"); + ctx.setAttribute("prop.l3vpn.ac2-ip", "192.168.1.5"); + ctx.setAttribute("prop.l3vpn.sna2-route", "192.168.1.8/24"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/l3smsitetemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/sites"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } } diff --git a/restapi-call-node/provider/src/test/resources/l3smsitetemplate.json b/restapi-call-node/provider/src/test/resources/l3smsitetemplate.json new file mode 100644 index 000000000..e7b569289 --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/l3smsitetemplate.json @@ -0,0 +1,164 @@ +/*- + * ============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========================================================= + */ + +[ + { + "site-id": ${prop.l3vpn.site1_name}, + "vpn-policies": { + "vpn-policy": [ + { + "vpn-policy-id": ${prop.l3vpn.vpn-policy1-id}, + "entries": [ + { + "id": ${prop.l3vpn.entry1-id}, + "vpn": { + "vpn-id": ${prop.l3vpn.name}, + "site-role": "huawei-ac-net-l3vpn-svc:any-to-any-role" + } + } + ] + } + ] + }, + "site-network-accesses": { + "site-network-access": [ + { + "site-network-access-id": ${prop.l3vpn.sna1_name}, + "bearer": { + "appointed-access": { + "ne-id": ${prop.l3vpn.pe1_id}, + "ltp-id": ${prop.l3vpn.ac1_id}, + "vlan": { + "type": "huawei-ac-net-l3vpn-svc:vlan-dot1q", + "vlan-id": ${prop.l3vpn.sna1_svlan} + } + } + }, + "ip-connection": { + "ipv4": { + "address-allocation-type": "huawei-ac-net-l3vpn-svc:static-address", + "addresses": { + "provider-address": ${prop.l3vpn.ac1-peer-ip}, + "customer-address": ${prop.l3vpn.ac1-ip}, + "mask": "24" + } + } + }, + "service": { + "mtu": "1500" + }, + "routing-protocols": { + "routing-protocol": [ + { + "type": "huawei-ac-net-l3vpn-svc:static", + "static": { + "cascaded-lan-prefixes": [ + { + "ipv4-lan-prefixes": [ + { + "ip-prefix": ${prop.l3vpn.sna1-route}, + "next-hop": ${prop.l3vpn.sna1-route} + } + ] + } + ] + } + } + ] + }, + "vpn-attachment": { + "vpn-policy-id": ${prop.l3vpn.name} + } + } + ] + }, + { + "site-id": ${prop.l3vpn.site2_name}, + "vpn-policies": { + "vpn-policy": [ + { + "vpn-policy-id": ${prop.l3vpn.vpn-policy2-id}, + "entries": [ + { + "id": ${prop.l3vpn.entry2-id}, + "vpn": { + "vpn-id": ${prop.l3vpn.name}, + "site-role": "huawei-ac-net-l3vpn-svc:any-to-any-role" + } + } + ] + } + ] + }, + "site-network-accesses": { + "site-network-access": [ + { + "site-network-access-id": ${prop.l3vpn.sna2_name}, + "bearer": { + "appointed-access": { + "ne-id": ${prop.l3vpn.pe2_id}, + "ltp-id": ${prop.l3vpn.ac2_id}, + "vlan": { + "type": "huawei-ac-net-l3vpn-svc:vlan-dot1q", + "vlan-id": ${prop.l3vpn.sna2_svlan} + } + } + }, + "ip-connection": { + "ipv4": { + "address-allocation-type": "huawei-ac-net-l3vpn-svc:static-address", + "addresses": { + "provider-address": ${prop.l3vpn.ac2-peer-ip}, + "customer-address": ${prop.l3vpn.ac2-ip}, + "mask": "24" + } + } + }, + "service": { + "mtu": "1500" + }, + "routing-protocols": { + "routing-protocol": [ + { + "type": "huawei-ac-net-l3vpn-svc:static", + "static": { + "cascaded-lan-prefixes": [ + { + "ipv4-lan-prefixes": [ + { + "ip-prefix": ${prop.l3vpn.sna2-route}, + "next-hop": ${prop.l3vpn.sna2-route} + } + ] + } + ] + } + } + ] + }, + "vpn-attachment": { + "vpn-policy-id": ${prop.l3vpn.name} + } + } + ] + } +] + diff --git a/restapi-call-node/provider/src/test/resources/l3smvpntemplate.json b/restapi-call-node/provider/src/test/resources/l3smvpntemplate.json new file mode 100644 index 000000000..c0a7c1922 --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/l3smvpntemplate.json @@ -0,0 +1,28 @@ +/*- + * ============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========================================================= + */ + +{ + "vpn-id": ${prop.l3vpn.name}, + "customer-name": "huawei", + "vpn-service-topology": ${prop.l3vpn.topology}, + "route-exchange-policy": "huawei-ac-net-l3vpn-svc:vpnv4-way" +} + -- cgit From 1f4c154ba6ae1ed672637ab1083e91d4de1d1c75 Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Wed, 27 Sep 2017 10:12:50 -0700 Subject: Add VoLTE Overlay Json template Issue-Id: SDNC-43 Change-Id: I9569f853a722dd43ef8723d2ed16077b5b02a1ff Signed-off-by: Marcus G K Williams --- .../main/resources/l3-dci-connects-template.json | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 restapi-call-node/provider/src/main/resources/l3-dci-connects-template.json diff --git a/restapi-call-node/provider/src/main/resources/l3-dci-connects-template.json b/restapi-call-node/provider/src/main/resources/l3-dci-connects-template.json new file mode 100644 index 000000000..3f0e20304 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/l3-dci-connects-template.json @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : SDN-C + * ================================================================================ + * Copyright (C) 2017 Intel Corp. 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========================================================= + */ + +{ + "l3-dci-connect": { + "id": "${prop.l3-dci-connects.id}", + "name": "${prop.l3-dci-connects.name}", + "description": "${prop.l3-dci-connects.description}", + "router_id": "${prop.l3-dci-connects.router_id}", + "firewall_enable": false, + "local_networks": ["${prop.l3-dci-connects.local_networks}"], + "local_network_all": false, + "evpn_irts": ["${prop.l3-dci-connects.evpn_irts}"], + "evpn_erts": ["${prop.l3-dci-connects.evpn_erts}"], + "l3_vni": "${prop.l3-dci-connects.l3_vni}" + } +} -- cgit From 1a6f50f6de487545dbb1e2c713bdf558ce889827 Mon Sep 17 00:00:00 2001 From: "ramu.n" Date: Thu, 28 Sep 2017 08:45:27 +0530 Subject: Add VoLTE underlay JSON template Add VoLTE underlay JSON template used to communicate with 3rd party controller of IP WAN Network Change-Id: Icc93da198c7a1f3d9ed462e178571e316fde3f83 Issue-Id: SDNC-90 Signed-off-by: Ramu N --- .../src/main/resources/l3smsitetemplate.json | 164 +++++++++++++++++++++ .../src/main/resources/l3smvpntemplate.json | 28 ++++ 2 files changed, 192 insertions(+) create mode 100644 restapi-call-node/provider/src/main/resources/l3smsitetemplate.json create mode 100644 restapi-call-node/provider/src/main/resources/l3smvpntemplate.json diff --git a/restapi-call-node/provider/src/main/resources/l3smsitetemplate.json b/restapi-call-node/provider/src/main/resources/l3smsitetemplate.json new file mode 100644 index 000000000..e7b569289 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/l3smsitetemplate.json @@ -0,0 +1,164 @@ +/*- + * ============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========================================================= + */ + +[ + { + "site-id": ${prop.l3vpn.site1_name}, + "vpn-policies": { + "vpn-policy": [ + { + "vpn-policy-id": ${prop.l3vpn.vpn-policy1-id}, + "entries": [ + { + "id": ${prop.l3vpn.entry1-id}, + "vpn": { + "vpn-id": ${prop.l3vpn.name}, + "site-role": "huawei-ac-net-l3vpn-svc:any-to-any-role" + } + } + ] + } + ] + }, + "site-network-accesses": { + "site-network-access": [ + { + "site-network-access-id": ${prop.l3vpn.sna1_name}, + "bearer": { + "appointed-access": { + "ne-id": ${prop.l3vpn.pe1_id}, + "ltp-id": ${prop.l3vpn.ac1_id}, + "vlan": { + "type": "huawei-ac-net-l3vpn-svc:vlan-dot1q", + "vlan-id": ${prop.l3vpn.sna1_svlan} + } + } + }, + "ip-connection": { + "ipv4": { + "address-allocation-type": "huawei-ac-net-l3vpn-svc:static-address", + "addresses": { + "provider-address": ${prop.l3vpn.ac1-peer-ip}, + "customer-address": ${prop.l3vpn.ac1-ip}, + "mask": "24" + } + } + }, + "service": { + "mtu": "1500" + }, + "routing-protocols": { + "routing-protocol": [ + { + "type": "huawei-ac-net-l3vpn-svc:static", + "static": { + "cascaded-lan-prefixes": [ + { + "ipv4-lan-prefixes": [ + { + "ip-prefix": ${prop.l3vpn.sna1-route}, + "next-hop": ${prop.l3vpn.sna1-route} + } + ] + } + ] + } + } + ] + }, + "vpn-attachment": { + "vpn-policy-id": ${prop.l3vpn.name} + } + } + ] + }, + { + "site-id": ${prop.l3vpn.site2_name}, + "vpn-policies": { + "vpn-policy": [ + { + "vpn-policy-id": ${prop.l3vpn.vpn-policy2-id}, + "entries": [ + { + "id": ${prop.l3vpn.entry2-id}, + "vpn": { + "vpn-id": ${prop.l3vpn.name}, + "site-role": "huawei-ac-net-l3vpn-svc:any-to-any-role" + } + } + ] + } + ] + }, + "site-network-accesses": { + "site-network-access": [ + { + "site-network-access-id": ${prop.l3vpn.sna2_name}, + "bearer": { + "appointed-access": { + "ne-id": ${prop.l3vpn.pe2_id}, + "ltp-id": ${prop.l3vpn.ac2_id}, + "vlan": { + "type": "huawei-ac-net-l3vpn-svc:vlan-dot1q", + "vlan-id": ${prop.l3vpn.sna2_svlan} + } + } + }, + "ip-connection": { + "ipv4": { + "address-allocation-type": "huawei-ac-net-l3vpn-svc:static-address", + "addresses": { + "provider-address": ${prop.l3vpn.ac2-peer-ip}, + "customer-address": ${prop.l3vpn.ac2-ip}, + "mask": "24" + } + } + }, + "service": { + "mtu": "1500" + }, + "routing-protocols": { + "routing-protocol": [ + { + "type": "huawei-ac-net-l3vpn-svc:static", + "static": { + "cascaded-lan-prefixes": [ + { + "ipv4-lan-prefixes": [ + { + "ip-prefix": ${prop.l3vpn.sna2-route}, + "next-hop": ${prop.l3vpn.sna2-route} + } + ] + } + ] + } + } + ] + }, + "vpn-attachment": { + "vpn-policy-id": ${prop.l3vpn.name} + } + } + ] + } +] + diff --git a/restapi-call-node/provider/src/main/resources/l3smvpntemplate.json b/restapi-call-node/provider/src/main/resources/l3smvpntemplate.json new file mode 100644 index 000000000..c0a7c1922 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/l3smvpntemplate.json @@ -0,0 +1,28 @@ +/*- + * ============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========================================================= + */ + +{ + "vpn-id": ${prop.l3vpn.name}, + "customer-name": "huawei", + "vpn-service-topology": ${prop.l3vpn.topology}, + "route-exchange-policy": "huawei-ac-net-l3vpn-svc:vpnv4-way" +} + -- cgit From ebd6ab052a5fcd84522f3daff88b197e46a068c8 Mon Sep 17 00:00:00 2001 From: 黄卓垚10112215 Date: Thu, 28 Sep 2017 14:34:15 +0800 Subject: SPTN l3vpn template Change-Id: I3349a43e2dbd8948fbc5573a6c064c45e7a443de Issue-ID: SDNC-91 Signed-off-by: Zhuoyao Huang <10112215@zte.com.cn> --- .../src/main/resources/sptn-l3vpn-template.json | 180 +++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 restapi-call-node/provider/src/main/resources/sptn-l3vpn-template.json diff --git a/restapi-call-node/provider/src/main/resources/sptn-l3vpn-template.json b/restapi-call-node/provider/src/main/resources/sptn-l3vpn-template.json new file mode 100644 index 000000000..9e1e92068 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/sptn-l3vpn-template.json @@ -0,0 +1,180 @@ +/*- + * ============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========================================================= + */ + +{ + "snc-l3vpn": { + "-xmlns": "urn:chinamobile:l3vpn", + "operate-status": "operate-up", + "traffic-class": "BE", + "acs": { + "l3-acs": [ + { + "id": "0", + "ne-id": ${prop.l3vpn.pe1_id}, + "ltp-id": ${prop.l3vpn.ac1_id}, + "ip-addr": ${prop.l3vpn.ac1_ip.value}, + "ip-mask": ${prop.l3vpn.ac1_ip.mask}, + "access-type": "Sub-interface", + "vlan": ${prop.l3vpn.ac1_svlan}, + "qos": { + "belonged-id": ${prop.l3vpn.ac1_id}, + "tunnel-mode": "pipeline", + "cac-mode": "1", + "convg-mode": "0", + "traffic-adj-mode": "0", + "a2z-policing": "1", + "z2a-policing": "1", + "a2z-cir": "5000", + "z2a-cir": "5000", + "a2z-pir": "1000000", + "z2a-pir": "1000000", + "a2z-cbs": "1024", + "z2a-cbs": "1024", + "a2z-pbs": "1024", + "z2a-pbs": "1024", + "a2z-color-mode": "0", + "z2a-color-mode": "0", + "traffic-class": "CS7" + }, + "protocol-list": { + "protocols": { + "protocol-type": "static", + "static-route-list": { + "static-routes": [ + { + "id": "0", + "dest-ip": ${prop.l3vpn.ac1_peer_ip.value}, + "dest-mask": ${prop.l3vpn.ac1_peer_ip.mask}, + "route-type": "direct-route", + "out-inf": ${prop.l3vpn.ac1_id}, + "route-weight": "3", + "route-status": "up" + } + ] + } + } + } + }, + { + "id": "1", + "ne-id": ${prop.l3vpn.pe2_id}, + "ltp-id": ${prop.l3vpn.ac2_id}, + "ip-addr": ${prop.l3vpn.ac2_ip.value}, + "ip-mask": ${prop.l3vpn.ac2_ip.mask}, + "access-type": "Sub-interface", + "vlan": ${prop.l3vpn.ac1_svlan}, + "qos": { + "belonged-id": ${prop.l3vpn.ac2_id}, + "tunnel-mode": "pipeline", + "cac-mode": "1", + "convg-mode": "0", + "traffic-adj-mode": "0", + "a2z-policing": "1", + "z2a-policing": "1", + "a2z-cir": "5000", + "z2a-cir": "5000", + "a2z-pir": "1000000", + "z2a-pir": "1000000", + "a2z-cbs": "1024", + "z2a-cbs": "1024", + "a2z-pbs": "1024", + "z2a-pbs": "1024", + "a2z-color-mode": "0", + "z2a-color-mode": "0", + "traffic-class": "CS7" + }, + "protocol-list": { + "protocols": { + "protocol-type": "static", + "static-route-list": { + "static-routes": [ + { + "id": "0", + "dest-ip": ${prop.l3vpn.ac2_peer_ip.value}, + "dest-mask": ${prop.l3vpn.ac2_peer_ip.mask}, + "route-type": "direct-route", + "out-inf": ${prop.l3vpn.ac2_id}, + "route-weight": "4", + "route-status": "up" + } + ] + } + } + } + } + ] + }, + "user-label": ${prop.l3vpn.name}, + "topo-mode": "any-to-any", + "admin-status": "admin-up", + "tunnel-create-policy": { + "user-label": "tunnel", + "tenant-id": "tunnel", + "direction": "bidirection", + "type": "1", + "admin-status": "admin-up", + "qos": { + "tunnel-mode": "pipeline", + "cac-mode": "1", + "convg-mode": "0", + "traffic-adj-mode": "0", + "a2z-policing": "0", + "a2z-cir": "500", + "a2z-pir": "1000000", + "a2z-cbs": "1024", + "a2z-pbs": "1024", + "a2z-color-mode": "0", + "z2a-policing": "0", + "z2a-cir": "500", + "z2a-pir": "1000000", + "z2a-cbs": "1024", + "z2a-pbs": "1024", + "z2a-color-mode": "0", + "traffic-class": "CS7" + }, + "snc-switch": { + "layer-rate": "LSP", + "linear-protection-type": "path-protection-1-to-1", + "linear-protection-protocol": "APS", + "switch-mode": "double-end-switch", + "revertive-mode": "revertive", + "wtr": "60", + "hold-off-time": "0", + "reroute-revertive-mode": "revertive", + "reroute-wtr": "50" + }, + "lsp-oam": { + "cc-allow": "true", + "cc-exp": "CS7", + "cc-interval": "3.3", + "lm-mode": "preactive", + "dm-mode": "preactive", + "meps": { + "mep": [ + { "id": "1" }, + { "id": "2" } + ] + } + } + } + } +} + -- cgit From 59f762556c4cecf8f59e780f6dd5072d85ccabfe Mon Sep 17 00:00:00 2001 From: Gaurav Agrawal Date: Thu, 28 Sep 2017 15:20:37 +0530 Subject: Added l2-dci json template and updated l3-dci Following changes are included: 1) Added l2-dci template 2) Updated l3-dci template to handle paramaters generically for l2 and l3 3) Leaf-List handling 4) Added testcases for l2 and l3 template. Change-Id: I3142ae35286ea3c55927bedf5a071aaff5b15401 Issue-Id: SDNC-103 Signed-off-by: Gaurav Agrawal --- .../main/resources/l2-dci-connects-template.json | 29 +++++++++++ .../main/resources/l3-dci-connects-template.json | 16 +++--- .../plugins/restapicall/TestRestapiCallNode.java | 57 +++++++++++++++++++++- .../test/resources/l2-dci-connects-template.json | 29 +++++++++++ .../test/resources/l3-dci-connects-template.json | 34 +++++++++++++ 5 files changed, 156 insertions(+), 9 deletions(-) create mode 100644 restapi-call-node/provider/src/main/resources/l2-dci-connects-template.json create mode 100644 restapi-call-node/provider/src/test/resources/l2-dci-connects-template.json create mode 100644 restapi-call-node/provider/src/test/resources/l3-dci-connects-template.json diff --git a/restapi-call-node/provider/src/main/resources/l2-dci-connects-template.json b/restapi-call-node/provider/src/main/resources/l2-dci-connects-template.json new file mode 100644 index 000000000..f18075686 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/l2-dci-connects-template.json @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : SDN-C + * ================================================================================ + * 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========================================================= + */ + +{ + "l2-dci-connect": { + "id": ${prop.dci-connects.id}, + "name": ${prop.dci-connects.name}, + "description": ${prop.dci-connects.description}, + "network_id": ${prop.dci-connects.local_networks[0]}, + "evpn_irts": ${prop.dci-connects.evpn_irts}, + "evpn_erts": ${prop.dci-connects.evpn_erts}, + "vni": ${prop.dci-connects.vni} + } +} diff --git a/restapi-call-node/provider/src/main/resources/l3-dci-connects-template.json b/restapi-call-node/provider/src/main/resources/l3-dci-connects-template.json index 3f0e20304..c011b077b 100644 --- a/restapi-call-node/provider/src/main/resources/l3-dci-connects-template.json +++ b/restapi-call-node/provider/src/main/resources/l3-dci-connects-template.json @@ -20,15 +20,15 @@ { "l3-dci-connect": { - "id": "${prop.l3-dci-connects.id}", - "name": "${prop.l3-dci-connects.name}", - "description": "${prop.l3-dci-connects.description}", - "router_id": "${prop.l3-dci-connects.router_id}", + "id": ${prop.dci-connects.id}, + "name": ${prop.dci-connects.name}, + "description": ${prop.dci-connects.description}, + "router_id": ${prop.dci-connects.router_id}, "firewall_enable": false, - "local_networks": ["${prop.l3-dci-connects.local_networks}"], + "local_networks": ${prop.dci-connects.local_networks}, "local_network_all": false, - "evpn_irts": ["${prop.l3-dci-connects.evpn_irts}"], - "evpn_erts": ["${prop.l3-dci-connects.evpn_erts}"], - "l3_vni": "${prop.l3-dci-connects.l3_vni}" + "evpn_irts": ${prop.dci-connects.evpn_irts}, + "evpn_erts": ${prop.dci-connects.evpn_erts}, + "l3_vni": ${prop.dci-connects.vni} } } diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index 2d3b40105..1dcc97bca 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -23,7 +23,6 @@ package jtest.org.onap.ccsdk.sli.plugins.restapicall; import java.util.HashMap; import java.util.Map; - import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; @@ -255,4 +254,60 @@ public class TestRestapiCallNode { RestapiCallNode rcn = new RestapiCallNode(); rcn.sendRequest(p, ctx); } + + @Test + public void testL2DciTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.dci-connects.id", "Id1"); + ctx.setAttribute("prop.dci-connects.name", "Name1"); + ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1"); + ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2"); + ctx.setAttribute("prop.dci-connects.vni", "1"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/l2-dci-connects-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testL3DciTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.dci-connects.id", "Id1"); + ctx.setAttribute("prop.dci-connects.name", "Name1"); + ctx.setAttribute("prop.dci-connects.local_networks_length", "2"); + ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1"); + ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2"); + ctx.setAttribute("prop.dci-connects.vni", "1"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/l3-dci-connects-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + + } } diff --git a/restapi-call-node/provider/src/test/resources/l2-dci-connects-template.json b/restapi-call-node/provider/src/test/resources/l2-dci-connects-template.json new file mode 100644 index 000000000..f18075686 --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/l2-dci-connects-template.json @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : SDN-C + * ================================================================================ + * 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========================================================= + */ + +{ + "l2-dci-connect": { + "id": ${prop.dci-connects.id}, + "name": ${prop.dci-connects.name}, + "description": ${prop.dci-connects.description}, + "network_id": ${prop.dci-connects.local_networks[0]}, + "evpn_irts": ${prop.dci-connects.evpn_irts}, + "evpn_erts": ${prop.dci-connects.evpn_erts}, + "vni": ${prop.dci-connects.vni} + } +} diff --git a/restapi-call-node/provider/src/test/resources/l3-dci-connects-template.json b/restapi-call-node/provider/src/test/resources/l3-dci-connects-template.json new file mode 100644 index 000000000..c011b077b --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/l3-dci-connects-template.json @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : SDN-C + * ================================================================================ + * Copyright (C) 2017 Intel Corp. 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========================================================= + */ + +{ + "l3-dci-connect": { + "id": ${prop.dci-connects.id}, + "name": ${prop.dci-connects.name}, + "description": ${prop.dci-connects.description}, + "router_id": ${prop.dci-connects.router_id}, + "firewall_enable": false, + "local_networks": ${prop.dci-connects.local_networks}, + "local_network_all": false, + "evpn_irts": ${prop.dci-connects.evpn_irts}, + "evpn_erts": ${prop.dci-connects.evpn_erts}, + "l3_vni": ${prop.dci-connects.vni} + } +} -- cgit From a4dcbc1613a91c21381ff5d485509148970d1684 Mon Sep 17 00:00:00 2001 From: Brian Freeman Date: Thu, 28 Sep 2017 12:05:43 +0000 Subject: Setup ReadTheDocs Issue-ID: CCSDK-107 Change-Id: I8b0715d07c50734217806ac24e5610b5f478ce04 Signed-off-by: Brian Freeman --- docs/index.rst | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 docs/index.rst diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 000000000..833e1aa96 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,8 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. + +TODO Add files to toctree and delete this header +------------------------------------------------ +.. toctree:: + :maxdepth: 1 + + -- cgit From 02c63c550acb82bee8d360c01bb1723b10f8df9a Mon Sep 17 00:00:00 2001 From: "ramu.n" Date: Fri, 29 Sep 2017 06:32:52 +0530 Subject: Update VoLTE underlay JSON template *Add vrf-attribute configuration *Add BGP protocol type for ac Change-Id: I6deb5b4ec6d71b18e8d6b67aadaba18b7a27c47b Issue-Id: SDNC-108 Signed-off-by: Ramu N --- .../src/main/resources/l3smsitetemplate.json | 31 ++++++++++++++----- .../src/main/resources/l3smvpntemplate.json | 15 ++++++---- .../src/main/resources/l3smvrftemplate.json | 35 ++++++++++++++++++++++ .../plugins/restapicall/TestRestapiCallNode.java | 33 ++++++++++++++++++-- .../src/test/resources/l3smsitetemplate.json | 31 ++++++++++++++----- .../src/test/resources/l3smvpntemplate.json | 15 ++++++---- .../src/test/resources/l3smvrftemplate.json | 35 ++++++++++++++++++++++ 7 files changed, 167 insertions(+), 28 deletions(-) create mode 100644 restapi-call-node/provider/src/main/resources/l3smvrftemplate.json create mode 100644 restapi-call-node/provider/src/test/resources/l3smvrftemplate.json diff --git a/restapi-call-node/provider/src/main/resources/l3smsitetemplate.json b/restapi-call-node/provider/src/main/resources/l3smsitetemplate.json index e7b569289..3aa426be7 100644 --- a/restapi-call-node/provider/src/main/resources/l3smsitetemplate.json +++ b/restapi-call-node/provider/src/main/resources/l3smsitetemplate.json @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * openECOMP : SDN-C + * ONAP : SDN-C * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. @@ -68,19 +68,28 @@ "routing-protocols": { "routing-protocol": [ { - "type": "huawei-ac-net-l3vpn-svc:static", + "type": ${prop.l3vpn.ac1_protocol}, "static": { "cascaded-lan-prefixes": [ { "ipv4-lan-prefixes": [ { - "ip-prefix": ${prop.l3vpn.sna1-route}, - "next-hop": ${prop.l3vpn.sna1-route} + "ip-prefix": ${prop.l3vpn.sna1-route.ip-prefix}, + "next-hop": ${prop.l3vpn.sna1-route.next-hop} } ] } ] } + "bgp": { + "peers": [ + { + "peer-ip": ${prop.l3vpn.peer1-ip}, + "remote-as": ${prop.l3vpn.ac1_protocol_bgp_as} + } + ] + } + } } ] }, @@ -138,19 +147,27 @@ "routing-protocols": { "routing-protocol": [ { - "type": "huawei-ac-net-l3vpn-svc:static", + "type": ${prop.l3vpn.ac2_protocol}, "static": { "cascaded-lan-prefixes": [ { "ipv4-lan-prefixes": [ { - "ip-prefix": ${prop.l3vpn.sna2-route}, - "next-hop": ${prop.l3vpn.sna2-route} + "ip-prefix": ${prop.l3vpn.sna2-route.ip-prefix}, + "next-hop": ${prop.l3vpn.sna2-route.next-hop} } ] } ] } + "bgp": { + "peers": [ + { + "peer-ip": ${prop.l3vpn.peer2-ip}, + "remote-as": ${prop.l3vpn.ac2_protocol_bgp_as} + } + ] + } } ] }, diff --git a/restapi-call-node/provider/src/main/resources/l3smvpntemplate.json b/restapi-call-node/provider/src/main/resources/l3smvpntemplate.json index c0a7c1922..c0d135310 100644 --- a/restapi-call-node/provider/src/main/resources/l3smvpntemplate.json +++ b/restapi-call-node/provider/src/main/resources/l3smvpntemplate.json @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * openECOMP : SDN-C + * ONAP : SDN-C * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. @@ -20,9 +20,12 @@ */ { - "vpn-id": ${prop.l3vpn.name}, - "customer-name": "huawei", - "vpn-service-topology": ${prop.l3vpn.topology}, - "route-exchange-policy": "huawei-ac-net-l3vpn-svc:vpnv4-way" + "vpn-service": [ + { + "vpn-id": ${prop.l3vpn.name, + "customer-name": "huawei", + "vpn-service-topology": ${prop.l3vpn.topology, + "route-exchange-policy": "huawei-ac-net-l3vpn-svc:vpnv4-way" + } + ] } - diff --git a/restapi-call-node/provider/src/main/resources/l3smvrftemplate.json b/restapi-call-node/provider/src/main/resources/l3smvrftemplate.json new file mode 100644 index 000000000..732af278c --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/l3smvrftemplate.json @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : 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========================================================= + */ + +{ + "vrf-attribute": [ + { + "vrf-attribute-id": ${prop.l3vpn.vrf1-id}, + "ne-id": ${prop.l3vpn.pe1_id}, + "vpn-policy-id": ${prop.l3vpn.vpn-policy1-id} + }, + { + "vrf-attribute-id": ${prop.l3vpn.vrf2-id}, + "ne-id": ${prop.l3vpn.pe2_id}, + "vpn-policy-id": ${prop.l3vpn.vpn-policy2-id} + } + ] +} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index 1dcc97bca..2c2bde0f4 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -23,6 +23,7 @@ package jtest.org.onap.ccsdk.sli.plugins.restapicall; import java.util.HashMap; import java.util.Map; + import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; @@ -229,7 +230,9 @@ public class TestRestapiCallNode { ctx.setAttribute("prop.l3vpn.ac1_id", "a8098c1a-f86e-11da-bd1a-00112444be1b"); ctx.setAttribute("prop.l3vpn.ac1-peer-ip", "192.168.1.1"); ctx.setAttribute("prop.l3vpn.ac1-ip", "192.168.1.2"); - ctx.setAttribute("prop.l3vpn.sna1-route", "192.168.1.4/24"); + ctx.setAttribute("prop.l3vpn.ac1_protocol", "static"); + ctx.setAttribute("prop.l3vpn.sna1-route.ip-prefix", "192.168.1.1/24"); + ctx.setAttribute("prop.l3vpn.sna1-route.next-hop", "192.168.1.4"); ctx.setAttribute("prop.l3vpn.site2_name", "10000000-0000-0000-0000-000000000005"); ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006"); @@ -239,7 +242,9 @@ public class TestRestapiCallNode { ctx.setAttribute("prop.l3vpn.ac2_id", "a8098c1a-f86e-11da-bd1a-00112444be1c"); ctx.setAttribute("prop.l3vpn.ac2-peer-ip", "192.168.1.5"); ctx.setAttribute("prop.l3vpn.ac2-ip", "192.168.1.5"); - ctx.setAttribute("prop.l3vpn.sna2-route", "192.168.1.8/24"); + ctx.setAttribute("prop.l3vpn.ac2_protocol", "bgp"); + ctx.setAttribute("prop.l3vpn.peer2-ip", "192.168.1.5"); + ctx.setAttribute("prop.l3vpn.ac2_protocol_bgp_as", "200"); Map p = new HashMap(); p.put("templateFileName", "src/test/resources/l3smsitetemplate.json"); @@ -255,6 +260,30 @@ public class TestRestapiCallNode { rcn.sendRequest(p, ctx); } + @Test + public void testVrfJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.vrf1-id", "10000000-0000-0000-0000-000000000007"); + ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003"); + ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e"); + ctx.setAttribute("prop.l3vpn.vrf2-id", "10000000-0000-0000-0000-000000000009"); + ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006"); + ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/l3smvrftemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vrf-attributes"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + @Test public void testL2DciTemplate() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); diff --git a/restapi-call-node/provider/src/test/resources/l3smsitetemplate.json b/restapi-call-node/provider/src/test/resources/l3smsitetemplate.json index e7b569289..3aa426be7 100644 --- a/restapi-call-node/provider/src/test/resources/l3smsitetemplate.json +++ b/restapi-call-node/provider/src/test/resources/l3smsitetemplate.json @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * openECOMP : SDN-C + * ONAP : SDN-C * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. @@ -68,19 +68,28 @@ "routing-protocols": { "routing-protocol": [ { - "type": "huawei-ac-net-l3vpn-svc:static", + "type": ${prop.l3vpn.ac1_protocol}, "static": { "cascaded-lan-prefixes": [ { "ipv4-lan-prefixes": [ { - "ip-prefix": ${prop.l3vpn.sna1-route}, - "next-hop": ${prop.l3vpn.sna1-route} + "ip-prefix": ${prop.l3vpn.sna1-route.ip-prefix}, + "next-hop": ${prop.l3vpn.sna1-route.next-hop} } ] } ] } + "bgp": { + "peers": [ + { + "peer-ip": ${prop.l3vpn.peer1-ip}, + "remote-as": ${prop.l3vpn.ac1_protocol_bgp_as} + } + ] + } + } } ] }, @@ -138,19 +147,27 @@ "routing-protocols": { "routing-protocol": [ { - "type": "huawei-ac-net-l3vpn-svc:static", + "type": ${prop.l3vpn.ac2_protocol}, "static": { "cascaded-lan-prefixes": [ { "ipv4-lan-prefixes": [ { - "ip-prefix": ${prop.l3vpn.sna2-route}, - "next-hop": ${prop.l3vpn.sna2-route} + "ip-prefix": ${prop.l3vpn.sna2-route.ip-prefix}, + "next-hop": ${prop.l3vpn.sna2-route.next-hop} } ] } ] } + "bgp": { + "peers": [ + { + "peer-ip": ${prop.l3vpn.peer2-ip}, + "remote-as": ${prop.l3vpn.ac2_protocol_bgp_as} + } + ] + } } ] }, diff --git a/restapi-call-node/provider/src/test/resources/l3smvpntemplate.json b/restapi-call-node/provider/src/test/resources/l3smvpntemplate.json index c0a7c1922..c0d135310 100644 --- a/restapi-call-node/provider/src/test/resources/l3smvpntemplate.json +++ b/restapi-call-node/provider/src/test/resources/l3smvpntemplate.json @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * openECOMP : SDN-C + * ONAP : SDN-C * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. @@ -20,9 +20,12 @@ */ { - "vpn-id": ${prop.l3vpn.name}, - "customer-name": "huawei", - "vpn-service-topology": ${prop.l3vpn.topology}, - "route-exchange-policy": "huawei-ac-net-l3vpn-svc:vpnv4-way" + "vpn-service": [ + { + "vpn-id": ${prop.l3vpn.name, + "customer-name": "huawei", + "vpn-service-topology": ${prop.l3vpn.topology, + "route-exchange-policy": "huawei-ac-net-l3vpn-svc:vpnv4-way" + } + ] } - diff --git a/restapi-call-node/provider/src/test/resources/l3smvrftemplate.json b/restapi-call-node/provider/src/test/resources/l3smvrftemplate.json new file mode 100644 index 000000000..732af278c --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/l3smvrftemplate.json @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : 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========================================================= + */ + +{ + "vrf-attribute": [ + { + "vrf-attribute-id": ${prop.l3vpn.vrf1-id}, + "ne-id": ${prop.l3vpn.pe1_id}, + "vpn-policy-id": ${prop.l3vpn.vpn-policy1-id} + }, + { + "vrf-attribute-id": ${prop.l3vpn.vrf2-id}, + "ne-id": ${prop.l3vpn.pe2_id}, + "vpn-policy-id": ${prop.l3vpn.vpn-policy2-id} + } + ] +} -- cgit From 2f8f9b58913ad1aa11838680857a1148a8b72bb3 Mon Sep 17 00:00:00 2001 From: "ramu.n" Date: Wed, 11 Oct 2017 14:35:39 +0530 Subject: Update underlay JSON template for VoLTE use case Fix closing braces in l3smvpntemplate.json file Change-Id: I1c891d46591f184a9cc89ca3d15b3046932ab05f Issue-Id: SDNC-108 Signed-off-by: Ramu N --- restapi-call-node/provider/src/main/resources/l3smvpntemplate.json | 4 ++-- restapi-call-node/provider/src/test/resources/l3smvpntemplate.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/restapi-call-node/provider/src/main/resources/l3smvpntemplate.json b/restapi-call-node/provider/src/main/resources/l3smvpntemplate.json index c0d135310..67f127ce9 100644 --- a/restapi-call-node/provider/src/main/resources/l3smvpntemplate.json +++ b/restapi-call-node/provider/src/main/resources/l3smvpntemplate.json @@ -22,9 +22,9 @@ { "vpn-service": [ { - "vpn-id": ${prop.l3vpn.name, + "vpn-id": ${prop.l3vpn.name}, "customer-name": "huawei", - "vpn-service-topology": ${prop.l3vpn.topology, + "vpn-service-topology": ${prop.l3vpn.topology}, "route-exchange-policy": "huawei-ac-net-l3vpn-svc:vpnv4-way" } ] diff --git a/restapi-call-node/provider/src/test/resources/l3smvpntemplate.json b/restapi-call-node/provider/src/test/resources/l3smvpntemplate.json index c0d135310..67f127ce9 100644 --- a/restapi-call-node/provider/src/test/resources/l3smvpntemplate.json +++ b/restapi-call-node/provider/src/test/resources/l3smvpntemplate.json @@ -22,9 +22,9 @@ { "vpn-service": [ { - "vpn-id": ${prop.l3vpn.name, + "vpn-id": ${prop.l3vpn.name}, "customer-name": "huawei", - "vpn-service-topology": ${prop.l3vpn.topology, + "vpn-service-topology": ${prop.l3vpn.topology}, "route-exchange-policy": "huawei-ac-net-l3vpn-svc:vpnv4-way" } ] -- cgit From e83bb3719c410e1f3d5b9d1fa345672dec9f7f43 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 11 Oct 2017 11:58:11 -0400 Subject: Add readthedocs sections for sli/plugins Add readthedocs sections for sli/plugins Change-Id: Ic5292d16f9fd4f07cadba775aac80d6fea10e647 Issue-ID: CCSDK-107 Signed-off-by: Dan Timoney --- docs/architecture.rst | 27 +++++++++++++++++++++++++++ docs/build.rst | 18 ++++++++++++++++++ docs/index.rst | 10 +++++++--- docs/logging.rst | 14 ++++++++++++++ docs/offeredapis.rst | 6 ++++++ docs/release-notes.rst | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 docs/architecture.rst create mode 100644 docs/build.rst create mode 100644 docs/logging.rst create mode 100644 docs/offeredapis.rst create mode 100644 docs/release-notes.rst diff --git a/docs/architecture.rst b/docs/architecture.rst new file mode 100644 index 000000000..8daa0d3bc --- /dev/null +++ b/docs/architecture.rst @@ -0,0 +1,27 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 + +Architecture +============ + +.. note:: + * This section is used to describe a software component from a high level + view of capability, common usage scenarios, and interactions with other + components required in the usage scenarios. + + * The architecture section is typically: provided in a platform-component + and sdk collections; and referenced from developer and user guides. + + * This note must be removed after content has been added. + + +Capabilities +------------ + + +Usage Scenarios +--------------- + + +Interactions +------------ diff --git a/docs/build.rst b/docs/build.rst new file mode 100644 index 000000000..0a4c308e6 --- /dev/null +++ b/docs/build.rst @@ -0,0 +1,18 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 + +Build +===== + + +Environment +----------- +Requires maven release 3.3 or greater + +Steps +----- +To compile this code: + +1. Make sure your local Maven settings file ($HOME/.m2/settings.xml) contains references to the ONAP repositories and OpenDaylight repositories. + +2. To compile, run "mvn clean install". \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index 833e1aa96..83bb78a8d 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,8 +1,12 @@ .. This work is licensed under a Creative Commons Attribution 4.0 International License. -TODO Add files to toctree and delete this header ------------------------------------------------- +CCSDK Service Logic Interpretor Plugins +---------------------------------------- .. toctree:: :maxdepth: 1 - + architecture.rst + offeredapis.rst + logging.rst + build.rst + release-notes.rst diff --git a/docs/logging.rst b/docs/logging.rst new file mode 100644 index 000000000..187eb03b7 --- /dev/null +++ b/docs/logging.rst @@ -0,0 +1,14 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 + +Logging +======= +CCSDK uses slf4j to log messages to the standard OpenDaylight karaf.log +log file. + +Where to Access Information +--------------------------- +Logs are found within the SDNC docker container, in the directory +/opt/opendaylight/current/data/logs. + + diff --git a/docs/offeredapis.rst b/docs/offeredapis.rst new file mode 100644 index 000000000..e20c786cc --- /dev/null +++ b/docs/offeredapis.rst @@ -0,0 +1,6 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 + +Offered APIs +============ + diff --git a/docs/release-notes.rst b/docs/release-notes.rst new file mode 100644 index 000000000..b45165706 --- /dev/null +++ b/docs/release-notes.rst @@ -0,0 +1,46 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. + +Release Notes +============= + +.. note:: + * This Release Notes must be updated each time the team decides to Release new artifacts. + * The scope of this Release Notes is for this particular component. In other words, each ONAP component has its Release Notes. + * This Release Notes is cumulative, the most recently Released artifact is made visible in the top of this Release Notes. + * Except the date and the version number, all the other sections are optional but there must be at least one section describing the purpose of this new release. + * This note must be removed after content has been added. + + +Version: x.y.z +-------------- + + +:Release Date: yyyy-mm-dd + + + +**New Features** + +One or two sentences explaining the purpose of this Release. + +**Bug Fixes** + - `CIMAN-65 `_ and a sentence explaining what this defect is addressing. +**Known Issues** + - `CIMAN-65 `_ and two, three sentences. + One sentences explaining what is the issue. + + Another sentence explaining the impact of the issue. + + And an optional sentence providing a workaround. + +**Security Issues** + You may want to include a reference to CVE (Common Vulnerabilities and Exposures) `CVE `_ + + +**Upgrade Notes** + +**Deprecation Notes** + +**Other** + +=========== \ No newline at end of file -- cgit From 3cc6cc194791d9eedfe87fd671ee0db3e8e72897 Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Thu, 12 Oct 2017 13:40:39 +0530 Subject: Remove null check *Move string literal to the left side of comparison Null check is performed by String.equalsIgnorecase hence removed Issue-Id: CCSDK-117 Change-Id: I48c8815f9f20a1c6e86c8b4af8966c9945d5b0c7 Signed-off-by: surya-huawei --- .../main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java index 573c85f78..776485afa 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java @@ -25,11 +25,9 @@ public enum Format { JSON, XML; public static Format fromString(String s) { - if (s == null) - return null; - if (s.equalsIgnoreCase("json")) + if ("json".equalsIgnoreCase(s)) return JSON; - if (s.equalsIgnoreCase("xml")) + if ("xml".equalsIgnoreCase(s)) return XML; throw new IllegalArgumentException("Invalid value for format: " + s); } -- cgit From 85e0df60352d2ffa7e63a5a5e570f12cb0b081f4 Mon Sep 17 00:00:00 2001 From: "ramu.n" Date: Fri, 13 Oct 2017 16:18:50 +0530 Subject: Update VoLTE underlay JSON template *Fix missing site element in l3smsitetemplate.json file *Add UT test case delete L3VPN Change-Id: Iee56d30746328e8f094a5c45c6e2e577b6989bf9 Issue-Id: SDNC-108 Signed-off-by: Ramu N --- .../src/main/resources/l3smsitetemplate.json | 6 ++++-- .../plugins/restapicall/TestRestapiCallNode.java | 23 +++++++++++++++++++++- .../src/test/resources/l3smsitetemplate.json | 6 ++++-- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/restapi-call-node/provider/src/main/resources/l3smsitetemplate.json b/restapi-call-node/provider/src/main/resources/l3smsitetemplate.json index 3aa426be7..016879c3c 100644 --- a/restapi-call-node/provider/src/main/resources/l3smsitetemplate.json +++ b/restapi-call-node/provider/src/main/resources/l3smsitetemplate.json @@ -19,7 +19,8 @@ * ============LICENSE_END========================================================= */ -[ +{ + "site":[ { "site-id": ${prop.l3vpn.site1_name}, "vpn-policies": { @@ -177,5 +178,6 @@ } ] } -] + ] +} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index 2c2bde0f4..a84d1509e 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -283,7 +283,28 @@ public class TestRestapiCallNode { RestapiCallNode rcn = new RestapiCallNode(); rcn.sendRequest(p, ctx); } - + + @Test + public void testDeleteVpnJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + Map p = new HashMap(); + //p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services" + + "/vpnservice=10000000-0000-0000-0000-000000000001"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "delete"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + @Test public void testL2DciTemplate() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); diff --git a/restapi-call-node/provider/src/test/resources/l3smsitetemplate.json b/restapi-call-node/provider/src/test/resources/l3smsitetemplate.json index 3aa426be7..016879c3c 100644 --- a/restapi-call-node/provider/src/test/resources/l3smsitetemplate.json +++ b/restapi-call-node/provider/src/test/resources/l3smsitetemplate.json @@ -19,7 +19,8 @@ * ============LICENSE_END========================================================= */ -[ +{ + "site":[ { "site-id": ${prop.l3vpn.site1_name}, "vpn-policies": { @@ -177,5 +178,6 @@ } ] } -] + ] +} -- cgit From ba4ef5baf9a3661aa4c55d06a38b62b8bb0a00b4 Mon Sep 17 00:00:00 2001 From: "ramu.n" Date: Tue, 17 Oct 2017 21:08:02 +0530 Subject: Add JSON template for VoLTE use case *For ipwan controller first need to get authentication token and add to customHttpHeaders Change-Id: I7be6e75f9712bc2214ee4a1804189162675c8a25 Issue-Id: SDNC-131 Signed-off-by: Ramu N --- .../src/main/resources/actokentemplate.json | 25 ++++++++++++++++++++++ .../plugins/restapicall/TestRestapiCallNode.java | 24 +++++++++++++++++++-- .../src/test/resources/actokentemplate.json | 25 ++++++++++++++++++++++ 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 restapi-call-node/provider/src/main/resources/actokentemplate.json create mode 100644 restapi-call-node/provider/src/test/resources/actokentemplate.json diff --git a/restapi-call-node/provider/src/main/resources/actokentemplate.json b/restapi-call-node/provider/src/main/resources/actokentemplate.json new file mode 100644 index 000000000..31bf0ee2b --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/actokentemplate.json @@ -0,0 +1,25 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : 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========================================================= + */ + +{ + "userName": ${prop.sdncRestApi.thirdpartySdnc.user}, + "password": ${prop.sdncRestApi.thirdpartySdnc.password} +} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index a84d1509e..2da5b2c83 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -230,6 +230,7 @@ public class TestRestapiCallNode { ctx.setAttribute("prop.l3vpn.ac1_id", "a8098c1a-f86e-11da-bd1a-00112444be1b"); ctx.setAttribute("prop.l3vpn.ac1-peer-ip", "192.168.1.1"); ctx.setAttribute("prop.l3vpn.ac1-ip", "192.168.1.2"); + ctx.setAttribute("prop.l3vpn.sna1_svlan", "100"); ctx.setAttribute("prop.l3vpn.ac1_protocol", "static"); ctx.setAttribute("prop.l3vpn.sna1-route.ip-prefix", "192.168.1.1/24"); ctx.setAttribute("prop.l3vpn.sna1-route.next-hop", "192.168.1.4"); @@ -240,10 +241,11 @@ public class TestRestapiCallNode { ctx.setAttribute("prop.l3vpn.sna2_name", "10000000-0000-0000-0000-000000000007"); ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a"); ctx.setAttribute("prop.l3vpn.ac2_id", "a8098c1a-f86e-11da-bd1a-00112444be1c"); - ctx.setAttribute("prop.l3vpn.ac2-peer-ip", "192.168.1.5"); + ctx.setAttribute("prop.l3vpn.ac2-peer-ip", "192.168.1.6"); ctx.setAttribute("prop.l3vpn.ac2-ip", "192.168.1.5"); + ctx.setAttribute("prop.l3vpn.sna2_svlan", "200"); ctx.setAttribute("prop.l3vpn.ac2_protocol", "bgp"); - ctx.setAttribute("prop.l3vpn.peer2-ip", "192.168.1.5"); + ctx.setAttribute("prop.l3vpn.peer2-ip", "192.168.1.7"); ctx.setAttribute("prop.l3vpn.ac2_protocol_bgp_as", "200"); Map p = new HashMap(); @@ -360,4 +362,22 @@ public class TestRestapiCallNode { rcn.sendRequest(p, ctx); } + + @Test + public void testControllerTokenTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.user", "admin"); + ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.password", "admin123"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/actokentemplate.json"); + p.put("restapiUrl", "https://ipwan:18002/controller/v2/tokens"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } } diff --git a/restapi-call-node/provider/src/test/resources/actokentemplate.json b/restapi-call-node/provider/src/test/resources/actokentemplate.json new file mode 100644 index 000000000..31bf0ee2b --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/actokentemplate.json @@ -0,0 +1,25 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : 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========================================================= + */ + +{ + "userName": ${prop.sdncRestApi.thirdpartySdnc.user}, + "password": ${prop.sdncRestApi.thirdpartySdnc.password} +} -- cgit From 9c6ec0e0a2f3439cef2d7891f5121c51ce236ab0 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 25 Oct 2017 16:55:57 -0400 Subject: Use version 0.1.0 of parent Update to use version 0.1.0 (released version) of parent pom Change-Id: I79234c02f70837da35045f97ceafdd6d176daa7f Issue-ID: CCSDK-80 Signed-off-by: Dan Timoney --- pom.xml | 2 +- version.properties | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 8abd76132..2067e13a7 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent odlparent-carbon-sr1 - 0.0.2-SNAPSHOT + 0.1.0 4.0.0 diff --git a/version.properties b/version.properties index 256546630..a9acb2876 100644 --- a/version.properties +++ b/version.properties @@ -5,9 +5,9 @@ # Comment -release_name=1 +release_name=0 sprint_number=1 -feature_revision=2 +feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit From 5abb631c6cb327eb420c6a61c0b98270c673f730 Mon Sep 17 00:00:00 2001 From: "Arun S. Yerra" Date: Mon, 6 Nov 2017 14:56:45 -0800 Subject: Purging Fabric discovery plugin code Two files in Fabric Discovery plugin has license issue. Purging this feature for R1 release, as this feature is not being used in R1 release and will be reworked in R2 release. Change-Id: If92d9c96c01e250e59c2bf99a12b95a9d37b197c Issue-Id: CCSDK-138 Signed-off-by: Arun S. Yerra --- fabric-discovery-plugin/.gitignore | 19 --- fabric-discovery-plugin/features/pom.xml | 135 ------------------- .../features/src/main/resources/features.xml | 40 ------ fabric-discovery-plugin/installer/pom.xml | 139 ------------------- .../src/assembly/assemble_installer_zip.xml | 59 -------- .../src/assembly/assemble_mvnrepo_zip.xml | 49 ------- .../src/main/resources/scripts/install-feature.sh | 40 ------ fabric-discovery-plugin/pom.xml | 42 ------ fabric-discovery-plugin/provider/pom.xml | 126 ----------------- .../fabricdiscovery/ClientMessageCallback.java | 20 --- .../fabricdiscovery/FabricDiscoveryPlugin.java | 150 --------------------- .../fabricdiscovery/IClientMessageCallback.java | 16 --- .../fabricdiscovery/IFabricDiscoveryService.java | 17 --- .../plugins/fabricdiscovery/WebSocketClient.java | 93 ------------- .../fabricdiscovery/WebSocketClientHandler.java | 92 ------------- .../blueprint/fabricdiscoveryplugin-blueprint.xml | 10 -- .../fabricdiscovery/TestFabricDiscoveryPlugin.java | 79 ----------- pom.xml | 1 - 18 files changed, 1127 deletions(-) delete mode 100644 fabric-discovery-plugin/.gitignore delete mode 100755 fabric-discovery-plugin/features/pom.xml delete mode 100644 fabric-discovery-plugin/features/src/main/resources/features.xml delete mode 100755 fabric-discovery-plugin/installer/pom.xml delete mode 100644 fabric-discovery-plugin/installer/src/assembly/assemble_installer_zip.xml delete mode 100644 fabric-discovery-plugin/installer/src/assembly/assemble_mvnrepo_zip.xml delete mode 100644 fabric-discovery-plugin/installer/src/main/resources/scripts/install-feature.sh delete mode 100755 fabric-discovery-plugin/pom.xml delete mode 100755 fabric-discovery-plugin/provider/pom.xml delete mode 100644 fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/ClientMessageCallback.java delete mode 100644 fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/FabricDiscoveryPlugin.java delete mode 100644 fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/IClientMessageCallback.java delete mode 100644 fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/IFabricDiscoveryService.java delete mode 100644 fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClient.java delete mode 100644 fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClientHandler.java delete mode 100644 fabric-discovery-plugin/provider/src/main/resources/org/opendaylight/blueprint/fabricdiscoveryplugin-blueprint.xml delete mode 100644 fabric-discovery-plugin/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/fabricdiscovery/TestFabricDiscoveryPlugin.java diff --git a/fabric-discovery-plugin/.gitignore b/fabric-discovery-plugin/.gitignore deleted file mode 100644 index 4213c2168..000000000 --- a/fabric-discovery-plugin/.gitignore +++ /dev/null @@ -1,19 +0,0 @@ -*.class -**/target -bin/ -dist -**/logs -*~ -target -target-ide -.classpath -.project -.settings -.idea -xtend-gen -yang-gen-config -yang-gen-sal -classes -.DS_STORE -.metadata -.gitreview diff --git a/fabric-discovery-plugin/features/pom.xml b/fabric-discovery-plugin/features/pom.xml deleted file mode 100755 index 2e0b0d94e..000000000 --- a/fabric-discovery-plugin/features/pom.xml +++ /dev/null @@ -1,135 +0,0 @@ - - - 4.0.0 - - fabric-discovery-plugin - org.onap.ccsdk.sli.plugins - 0.1.0-SNAPSHOT - - org.onap.ccsdk.sli.plugins - 0.1.0-SNAPSHOT - fabric-discovery-plugin-features - Fabric Discovery Plugin - Features - - jar - - - - - org.onap.ccsdk.sli.plugins - fabric-discovery-plugin-provider - ${project.version} - - - - commons-lang - commons-lang - 2.6 - compile - - - - org.opendaylight.mdsal - features-mdsal - ${odl.mdsal.features.version} - features - xml - - runtime - - - - - - org.opendaylight.controller - opendaylight-karaf-empty - ${odl.karaf.empty.distro.version} - zip - - - - - - org.opendaylight.odlparent - features-test - ${odl.commons.opendaylight.version} - test - - - - org.opendaylight.yangtools - features-yangtools - ${odl.yangtools.version} - features - xml - runtime - - - - - - - true - src/main/resources - - - - - org.apache.maven.plugins - maven-resources-plugin - - - filter - - resources - - generate-resources - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/${features.file} - xml - features - - - - - - - - - diff --git a/fabric-discovery-plugin/features/src/main/resources/features.xml b/fabric-discovery-plugin/features/src/main/resources/features.xml deleted file mode 100644 index 34ddebb99..000000000 --- a/fabric-discovery-plugin/features/src/main/resources/features.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features - - - sdnc-sli - spring - spring-dm - mvn:com.sun.jersey/jersey-client/${jersey.version} - mvn:org.codehaus.jettison/jettison/${jettison.version} - mvn:org.onap.ccsdk.sli.plugins/fabric-discovery-plugin-provider/${project.version} - - - diff --git a/fabric-discovery-plugin/installer/pom.xml b/fabric-discovery-plugin/installer/pom.xml deleted file mode 100755 index 1f4299019..000000000 --- a/fabric-discovery-plugin/installer/pom.xml +++ /dev/null @@ -1,139 +0,0 @@ - - - 4.0.0 - - fabric-discovery-plugin - org.onap.ccsdk.sli.plugins - 0.1.0-SNAPSHOT - - fabric-discovery-plugin-installer - Properties node - Karaf Installer - pom - - - sdnc-fabric-discovery-plugin - sdnc-fabric-discovery-plugin - mvn:org.onap.ccsdk.sli.plugins/fabric-discovery-plugin-features/${project.version}/xml/features - false - - - - - - org.onap.ccsdk.sli.plugins - fabric-discovery-plugin-features - ${project.version} - features - xml - - - * - * - - - - - - org.onap.ccsdk.sli.plugins - fabric-discovery-plugin-provider - ${project.version} - - - - - - - - maven-assembly-plugin - 2.6 - - - maven-repo-zip - - single - - package - - false - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - false - - - - installer-zip - - single - - package - - true - ${application.name}-${project.version}-installer - - src/assembly/assemble_installer_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - false - ${project.build.directory}/assembly/system - false - true - true - true - false - false - org.onap.ccsdk.sli - sli-common,sli-provider,dblib-provider - provided - - - - - - maven-resources-plugin - 2.6 - - - copy-version - - copy-resources - - validate - - ${basedir}/target/stage - - - src/main/resources/scripts - - install-feature.sh - - true - - - - - - - - - - - - diff --git a/fabric-discovery-plugin/installer/src/assembly/assemble_installer_zip.xml b/fabric-discovery-plugin/installer/src/assembly/assemble_installer_zip.xml deleted file mode 100644 index 3bed4b5ef..000000000 --- a/fabric-discovery-plugin/installer/src/assembly/assemble_installer_zip.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - installer_zip - - zip - - - - false - - - - target/stage/ - ${application.name} - 755 - - *.sh - - - - target/stage/ - ${application.name} - 644 - - *.sh - - - - - - - diff --git a/fabric-discovery-plugin/installer/src/assembly/assemble_mvnrepo_zip.xml b/fabric-discovery-plugin/installer/src/assembly/assemble_mvnrepo_zip.xml deleted file mode 100644 index cb56f2cd4..000000000 --- a/fabric-discovery-plugin/installer/src/assembly/assemble_mvnrepo_zip.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - mvnrepo_zip - - zip - - - - false - - - - target/assembly/ - . - - - - - - - - diff --git a/fabric-discovery-plugin/installer/src/main/resources/scripts/install-feature.sh b/fabric-discovery-plugin/installer/src/main/resources/scripts/install-feature.sh deleted file mode 100644 index e986764b9..000000000 --- a/fabric-discovery-plugin/installer/src/main/resources/scripts/install-feature.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/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========================================================= -### - -ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} -ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} -ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} -INSTALLERDIR=$(dirname $0) - -REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip - -if [ -f ${REPOZIP} ] -then - unzip -d ${ODL_HOME} ${REPOZIP} -else - echo "ERROR : repo zip ($REPOZIP) not found" - exit 1 -fi - -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} diff --git a/fabric-discovery-plugin/pom.xml b/fabric-discovery-plugin/pom.xml deleted file mode 100755 index f22fb695d..000000000 --- a/fabric-discovery-plugin/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - org.onap.ccsdk.sli.plugins - ccsdk-sli-plugins - 0.1.0-SNAPSHOT - - - 4.0.0 - pom - - org.onap.ccsdk.sli.plugins - fabric-discovery-plugin - 0.1.0-SNAPSHOT - - Fabric Discovery Plugin - This plugin will populate information about the devices within network fabric into SDNC database - - - - - org.onap.ccsdk.sli.plugins - fabric-discovery-plugin-features - features - xml - ${project.version} - - - org.onap.ccsdk.sli.plugins - fabric-discovery-plugin-provider - ${project.version} - - - - - - provider - features - installer - - - diff --git a/fabric-discovery-plugin/provider/pom.xml b/fabric-discovery-plugin/provider/pom.xml deleted file mode 100755 index c38acb1b8..000000000 --- a/fabric-discovery-plugin/provider/pom.xml +++ /dev/null @@ -1,126 +0,0 @@ - - - 4.0.0 - - org.onap.ccsdk.sli.plugins - fabric-discovery-plugin - 0.1.0-SNAPSHOT - - org.onap.ccsdk.sli.plugins - fabric-discovery-plugin-provider - 0.1.0-SNAPSHOT - bundle - Fabric Discovery Plugin - Provider - http://maven.apache.org - - UTF-8 - - - - - io.netty - netty - 3.10.6.Final - - - - io.netty - netty-buffer - 4.0.26.Final - - - - io.netty - netty-transport - 4.0.4.Final - - - - io.netty - netty-codec-http - 4.0.15.Final - - - junit - junit - test - - - org.springframework - spring-test - ${spring.version} - test - - - org.onap.ccsdk.sli.core - sli-common - ${sdnctl.sli.version} - compile - - - org.onap.ccsdk.sli.core - sli-provider - ${sdnctl.sli.version} - compile - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.slf4j - jcl-over-slf4j - ${slf4j.version} - - - org.springframework - spring-beans - ${spring.version} - - - org.springframework - spring-context - ${spring.version} - - - com.sun.jersey - jersey-client - ${jersey.version} - provided - - - org.codehaus.jettison - jettison - ${jettison.version} - provided - - - org.onap.ccsdk.sli.core - sli-common - ${sdnctl.sli.version} - - - org.onap.ccsdk.sli.core - sli-provider - ${sdnctl.sli.version} - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - org.onap.ccsdk.sli.plugins.fabricdiscovery - org.onap.ccsdk.sli.plugins.fabricdiscovery - * - - - - - - diff --git a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/ClientMessageCallback.java b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/ClientMessageCallback.java deleted file mode 100644 index 0a8ba9e75..000000000 --- a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/ClientMessageCallback.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.onap.ccsdk.sli.plugins.fabricdiscovery; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; - -/** - * Created by arun on 9/9/17. - */ -public class ClientMessageCallback implements IClientMessageCallback { - private static final Logger LOG = LoggerFactory.getLogger(ClientMessageCallback.class); - - @Override - public void onMessageReceived(final Object message) { - if (message instanceof TextWebSocketFrame) { - LOG.info("received message {}" + ((TextWebSocketFrame) message).text()); - } - } - -} diff --git a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/FabricDiscoveryPlugin.java b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/FabricDiscoveryPlugin.java deleted file mode 100644 index 99e171f6e..000000000 --- a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/FabricDiscoveryPlugin.java +++ /dev/null @@ -1,150 +0,0 @@ -/*- - * ============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.fabricdiscovery; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class FabricDiscoveryPlugin implements SvcLogicJavaPlugin, IFabricDiscoveryService { - - private ExecutorService service; - private Map streamMap; - private static final Logger LOG = LoggerFactory.getLogger(FabricDiscoveryPlugin.class); - private static final String STREAM_PREFIX = "ws://"; - private static final String FB_DISCOVERY_STATUS = "fb-response"; - - public FabricDiscoveryPlugin() { - service = Executors.newFixedThreadPool(10); - streamMap = new ConcurrentHashMap<>(); - } - - @Override - public void processDcNotificationStream (Map paramMap, SvcLogicContext ctx) throws SvcLogicException { - boolean enable; - String stream = parseParam(paramMap, "stream", true, null); - String prefix = parseParam(paramMap, "contextPrefix", false, null); - String enableStr = parseParam(paramMap, "enable", true, null); - - // Validate the input parameters - String pfx = (prefix != null) ? prefix + '.' : ""; - if ("true".equalsIgnoreCase(enableStr)) { - enable = true; - } else if ("false".equalsIgnoreCase(enableStr)) { - enable = false; - } else { - ctx.setAttribute(pfx + FB_DISCOVERY_STATUS, "Failure"); - throw new SvcLogicException("Incorrect parameter: enable. Valid values are ['true', 'false']"); - } - if (!STREAM_PREFIX.equalsIgnoreCase(stream.substring(0, 5))) { - ctx.setAttribute(pfx + FB_DISCOVERY_STATUS, "Failure"); - throw new SvcLogicException("Incorrect parameter: stream, Input is not a web socket address"); - } - - ctx.setAttribute(pfx + FB_DISCOVERY_STATUS, "Success"); - LOG.info("{} monitoring notification stream: {}", enable ? "START" : "STOP", stream); - - try { - service.execute(new Runnable () { - public void run () { - try { - URI uri = new URI(stream); - if (enable) { - if (streamMap.get(stream) != null) { - LOG.info("Notification Stream: {} is already being monitoried", stream); - return; - } - IClientMessageCallback messageCallback = new ClientMessageCallback(); - WebSocketClient wcClient = new WebSocketClient(uri, messageCallback); - streamMap.put(stream, wcClient); - wcClient.initialize(); - try { - wcClient.connect(); - } catch (InterruptedException e) { - LOG.info("Web Socket Client throws Exception: ", e.getMessage()); - } - } else { - WebSocketClient wc = streamMap.get(stream); - if (wc != null) { - try { - wc.close("Closing"); - } catch (InterruptedException e) { - LOG.info("Web Socket Client throws Exception: ", e.getMessage()); - } - } - } - } catch (URISyntaxException e) { - LOG.info("Exception converting stream to URI with: ", e.getMessage()); - } - } - }); - } catch (Exception e) { - LOG.info("Web Socket client connection throws an exception: ", e.getMessage()); - } - } - - private String parseParam(Map paramMap, String name, boolean required, String def) - throws SvcLogicException { - String s = paramMap.get(name); - - if (s == null || s.trim().length() == 0) { - if (!required) - return def; - throw new SvcLogicException("Parameter " + name + " is required in PropertiesNode"); - } - - s = s.trim(); - String value = ""; - int i = 0; - int i1 = s.indexOf('%'); - while (i1 >= 0) { - int i2 = s.indexOf('%', i1 + 1); - if (i2 < 0) - throw new SvcLogicException("Cannot parse parameter " + name + ": " + s + ": no matching %"); - - String varName = s.substring(i1 + 1, i2); - String varValue = System.getenv(varName); - if (varValue == null) - varValue = ""; - - value = (new StringBuilder()).append(value) - .append(s.substring(i, i1)) - .append(varValue).toString(); - i = i2 + 1; - i1 = s.indexOf('%', i); - } - value = (new StringBuilder()).append(value) - .append(s.substring(i)).toString(); - - LOG.info("Parameter {}: {}", name, value); - return value; - } -} diff --git a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/IClientMessageCallback.java b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/IClientMessageCallback.java deleted file mode 100644 index e555d3382..000000000 --- a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/IClientMessageCallback.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.onap.ccsdk.sli.plugins.fabricdiscovery; - -/** - * Created by mbobak on 1/22/14. - */ -public interface IClientMessageCallback { - - void onMessageReceived(Object message); -} diff --git a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/IFabricDiscoveryService.java b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/IFabricDiscoveryService.java deleted file mode 100644 index 857d75a99..000000000 --- a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/IFabricDiscoveryService.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.onap.ccsdk.sli.plugins.fabricdiscovery; - -import java.util.Map; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; - -/** - * Created by arun on 9/10/17. - */ -public interface IFabricDiscoveryService { - - /* (non-Javadoc) - * @see void#processDcNotificationStream(java.lang.String, java.lang.Integer, java.lang.String, java.lang.Boolean) - */ - void processDcNotificationStream (Map paramMap, SvcLogicContext ctx) throws SvcLogicException; - -} diff --git a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClient.java b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClient.java deleted file mode 100644 index d5bab386e..000000000 --- a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClient.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.onap.ccsdk.sli.plugins.fabricdiscovery; - -import io.netty.bootstrap.Bootstrap; -import io.netty.buffer.Unpooled; -import io.netty.channel.Channel; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelPipeline; -import io.netty.channel.EventLoopGroup; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.channel.socket.SocketChannel; -import io.netty.channel.socket.nio.NioSocketChannel; -import io.netty.handler.codec.http.HttpClientCodec; -import io.netty.handler.codec.http.HttpObjectAggregator; -import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame; -import io.netty.handler.codec.http.websocketx.PingWebSocketFrame; -import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; -import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory; -import io.netty.handler.codec.http.websocketx.WebSocketVersion; -import java.net.URI; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class WebSocketClient { - - private static final Logger LOG = LoggerFactory.getLogger(WebSocketClient.class); - - private final URI uri; - private final Bootstrap bootstrap = new Bootstrap(); - private final WebSocketClientHandler clientHandler; - private Channel clientChannel; - private final EventLoopGroup group = new NioEventLoopGroup(); - - public WebSocketClient(final URI uri, final IClientMessageCallback clientMessageCallback) { - this.uri = uri; - clientHandler = new WebSocketClientHandler(WebSocketClientHandshakerFactory.newHandshaker(uri, - WebSocketVersion.V13, null, false, null), clientMessageCallback); - // last null could be replaced with DefaultHttpHeaders - initialize(); - } - - public void initialize() { - - String protocol = uri.getScheme(); - if (!"ws".equals(protocol)) { - throw new IllegalArgumentException("Unsupported protocol: " + protocol); - } - - bootstrap.group(group).channel(NioSocketChannel.class).handler(new ChannelInitializer() { - @Override - public void initChannel(final SocketChannel ch) throws Exception { - ChannelPipeline pipeline = ch.pipeline(); - pipeline.addLast("http-codec", new HttpClientCodec()); - pipeline.addLast("aggregator", new HttpObjectAggregator(8192)); - pipeline.addLast("ws-handler", clientHandler); - } - }); - } - - public void connect() throws InterruptedException { - LOG.info("WebSocket Client connecting"); - clientChannel = bootstrap.connect(uri.getHost(), uri.getPort()).sync().channel(); - clientHandler.handshakeFuture().sync(); - } - - public void writeAndFlush(final String message) { - clientChannel.writeAndFlush(new TextWebSocketFrame(message)); - } - - public void writeAndFlush(final Object message) { - clientChannel.writeAndFlush(message); - } - - public void ping() { - clientChannel.writeAndFlush(new PingWebSocketFrame(Unpooled.copiedBuffer(new byte[] { 1, 2, 3, 4, 5, 6 }))); - } - - public void close(final String reasonText) throws InterruptedException { - CloseWebSocketFrame closeWebSocketFrame = new CloseWebSocketFrame(1000, reasonText); - clientChannel.writeAndFlush(closeWebSocketFrame); - - // WebSocketClientHandler will close the connection when the server - // responds to the CloseWebSocketFrame. - clientChannel.closeFuture().sync(); - group.shutdownGracefully(); - } -} diff --git a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClientHandler.java b/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClientHandler.java deleted file mode 100644 index c1c5dc30f..000000000 --- a/fabric-discovery-plugin/provider/src/main/java/org/onap/ccsdk/sli/plugins/fabricdiscovery/WebSocketClientHandler.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.onap.ccsdk.sli.plugins.fabricdiscovery; - -import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelPromise; -import io.netty.channel.SimpleChannelInboundHandler; -import io.netty.handler.codec.http.FullHttpResponse; -import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame; -import io.netty.handler.codec.http.websocketx.PongWebSocketFrame; -import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; -import io.netty.handler.codec.http.websocketx.WebSocketFrame; -import io.netty.util.CharsetUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class WebSocketClientHandler extends SimpleChannelInboundHandler { - - private static final Logger LOG = LoggerFactory.getLogger(WebSocketClientHandler.class.toString()); - private final WebSocketClientHandshaker handshaker; - private ChannelPromise handshakeFuture; - private final IClientMessageCallback messageListener; - - public WebSocketClientHandler(WebSocketClientHandshaker handshaker, IClientMessageCallback listener) { - this.handshaker = handshaker; - this.messageListener = listener; - } - - public ChannelFuture handshakeFuture() { - return handshakeFuture; - } - - @Override - public void handlerAdded(ChannelHandlerContext ctx) throws Exception { - handshakeFuture = ctx.newPromise(); - } - - @Override - public void channelActive(ChannelHandlerContext ctx) throws Exception { - handshaker.handshake(ctx.channel()); - } - - @Override - public void channelInactive(ChannelHandlerContext ctx) throws Exception { - LOG.info("WebSocket Client disconnected!"); - } - - @Override - public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { - Channel ch = ctx.channel(); - if (!handshaker.isHandshakeComplete()) { - handshaker.finishHandshake(ch, (FullHttpResponse) msg); - LOG.info("WebSocket Client connected!"); - handshakeFuture.setSuccess(); - return; - } - - if (msg instanceof FullHttpResponse) { - FullHttpResponse response = (FullHttpResponse) msg; - throw new Exception("Unexpected FullHttpResponse (getStatus=" + response.getStatus() + ", content=" - + response.content().toString(CharsetUtil.UTF_8) + ')'); - } - - messageListener.onMessageReceived(msg); - WebSocketFrame frame = (WebSocketFrame) msg; - - if (frame instanceof PongWebSocketFrame) { - LOG.info("WebSocket Client received pong"); - } else if (frame instanceof CloseWebSocketFrame) { - LOG.info("WebSocket Client received closing"); - ch.close(); - } - } - - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - LOG.info("Cause: {} .", cause.toString()); - - if (!handshakeFuture.isDone()) { - handshakeFuture.setFailure(cause); - } - - ctx.close(); - } -} diff --git a/fabric-discovery-plugin/provider/src/main/resources/org/opendaylight/blueprint/fabricdiscoveryplugin-blueprint.xml b/fabric-discovery-plugin/provider/src/main/resources/org/opendaylight/blueprint/fabricdiscoveryplugin-blueprint.xml deleted file mode 100644 index 43137bb89..000000000 --- a/fabric-discovery-plugin/provider/src/main/resources/org/opendaylight/blueprint/fabricdiscoveryplugin-blueprint.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - diff --git a/fabric-discovery-plugin/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/fabricdiscovery/TestFabricDiscoveryPlugin.java b/fabric-discovery-plugin/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/fabricdiscovery/TestFabricDiscoveryPlugin.java deleted file mode 100644 index 7a25e77be..000000000 --- a/fabric-discovery-plugin/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/fabricdiscovery/TestFabricDiscoveryPlugin.java +++ /dev/null @@ -1,79 +0,0 @@ -package jtest.org.onap.ccsdk.sli.plugins.fabricdiscovery; - -import java.util.HashMap; -import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.plugins.fabricdiscovery.FabricDiscoveryPlugin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Created by arun on 9/18/17. - */ - -public class TestFabricDiscoveryPlugin { - private static final Logger LOG = LoggerFactory.getLogger(TestFabricDiscoveryPlugin.class); - private static final String C_STREAM = - "ws://localhost:8185/data-change-event-subscription/network-topology:network-topology/datastore=CONFIGURATION/scope=BASE"; - private static final String W_STREAM = - "get://localhost:8185/data-change-event-subscription/network-topology:network/datastore=CONFIGURATION/scope=BASE"; - private final String FB_DISCOVERY_STATUS = "fb-response"; - - @Test - public void connectToNotificationServerSuccess() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - String stream = C_STREAM; - - Map p = new HashMap(); - p.put("stream", stream); - p.put("enable", "true"); - - FabricDiscoveryPlugin fdp = new FabricDiscoveryPlugin(); - fdp.processDcNotificationStream(p, ctx); - Assert.assertEquals("Success", ctx.getAttribute(FB_DISCOVERY_STATUS)); - } - - @Test - public void connectToNotificationServerFailure() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - String stream = W_STREAM; - - Map p = new HashMap<>(); - p.put("stream", stream); - p.put("enable", "true"); - - FabricDiscoveryPlugin fdp = new FabricDiscoveryPlugin(); - try { - fdp.processDcNotificationStream(p, ctx); - LOG.info("Connection to Stream:{} succeeded.", stream); - } catch (Exception e) { - LOG.info("Received Exception while connecting to Fabric Discovery notification server: {}", e.getMessage()); - } finally { - Assert.assertEquals("Failure", ctx.getAttribute(FB_DISCOVERY_STATUS)); - } - } - - @Test - public void validateParameterEnableFailure() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - String stream = C_STREAM; - final String W_ENABLE_STR = "bad enable parameter"; - - Map p = new HashMap<>(); - p.put("stream", stream); - p.put("enable", W_ENABLE_STR); - - FabricDiscoveryPlugin fdp = new FabricDiscoveryPlugin(); - try { - fdp.processDcNotificationStream(p, ctx); - LOG.info("Connection to Stream:{} succeeded.", stream); - } catch (Exception e) { - LOG.info("Received Exception while connecting to Fabric Discovery notification server: {}", e.getMessage()); - } finally { - Assert.assertEquals("Failure", ctx.getAttribute(FB_DISCOVERY_STATUS)); - } - } - -} diff --git a/pom.xml b/pom.xml index 2067e13a7..a5c349fcb 100755 --- a/pom.xml +++ b/pom.xml @@ -107,7 +107,6 @@ properties-node restapi-call-node - fabric-discovery-plugin AT&T -- cgit From 0b5f6324415051a44d4ad7fd5ba27d15c7cb5a27 Mon Sep 17 00:00:00 2001 From: Morgan Richomme Date: Wed, 8 Nov 2017 08:54:35 +0100 Subject: Fix doc8 errors JIRA: CCSDK-139 Change-Id: Ib509dfddad976679a03cb015dc8ac505e03046fa Signed-off-by: Morgan Richomme --- docs/release-notes.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/release-notes.rst b/docs/release-notes.rst index b45165706..dd01fc7e4 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -42,5 +42,3 @@ One or two sentences explaining the purpose of this Release. **Deprecation Notes** **Other** - -=========== \ No newline at end of file -- cgit From eff81fd8cbdcb6dabd3b9d41a1d2659ccd57f2f9 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 9 Nov 2017 07:21:42 -0500 Subject: Roll to version 0.1.1-SNAPSHOT Roll to next release version Change-Id: I3d10e4d8e35c844f4eac305332b160cdb533efc3 Issue-ID: CCSDK-141 Signed-off-by: Dan Timoney --- pom.xml | 2 +- properties-node/features/pom.xml | 4 ++-- properties-node/installer/pom.xml | 2 +- properties-node/pom.xml | 4 ++-- properties-node/provider/pom.xml | 4 ++-- restapi-call-node/features/pom.xml | 4 ++-- restapi-call-node/installer/pom.xml | 2 +- restapi-call-node/pom.xml | 4 ++-- restapi-call-node/provider/pom.xml | 4 ++-- version.properties | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index a5c349fcb..c1ed06be4 100755 --- a/pom.xml +++ b/pom.xml @@ -111,7 +111,7 @@ AT&T - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 5573d1e7a..8ed9601f8 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -4,10 +4,10 @@ properties-node org.onap.ccsdk.sli.plugins - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT properties-node-features Properties Node - Features diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 570eced79..b00a7e5a2 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,7 +5,7 @@ properties-node org.onap.ccsdk.sli.plugins - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT properties-node-installer Properties node - Karaf Installer diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 1f860b70e..c85160794 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -3,7 +3,7 @@ org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT 4.0.0 @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins properties-node - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT Properties Node This is an implementation of DG Execute Node that reads property file and diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index a5249d98b..b73456815 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -4,10 +4,10 @@ org.onap.ccsdk.sli.plugins properties-node - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT properties-node-provider bundle Properties Node - Provider diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index 93ee00373..5528bb6b1 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -4,10 +4,10 @@ restapi-call-node org.onap.ccsdk.sli.plugins - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT restapi-call-node-features RESTAPI Call Node - Features diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 9fa4496a1..724534759 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ restapi-call-node org.onap.ccsdk.sli.plugins - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT restapi-call-node-installer Properties node - Karaf Installer diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index b819e47e9..9d266cead 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -3,7 +3,7 @@ org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT 4.0.0 @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins restapi-call-node - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT RESTAPI Call Node This is an implementation of DG Execute Node that makes a call to an external REST API diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index ca3f004a0..5af32b642 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -4,11 +4,11 @@ org.onap.ccsdk.sli.plugins restapi-call-node - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT bundle RESTAPI Call Node - Provider http://maven.apache.org diff --git a/version.properties b/version.properties index a9acb2876..948004231 100644 --- a/version.properties +++ b/version.properties @@ -7,7 +7,7 @@ release_name=0 sprint_number=1 -feature_revision=0 +feature_revision=1 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit From 3f8a54594c56bd294ed74ec703a49d7f3a3571cf Mon Sep 17 00:00:00 2001 From: Rich Bennett Date: Wed, 15 Nov 2017 06:59:58 -0500 Subject: Rm docs in repo consolidated w/ ccsdk/distribution Change-Id: I2741cdfac2d387b18f6eb9bd6be37dd1598989ca Issue-ID: DOC-130 Signed-off-by: Rich Bennett --- docs/architecture.rst | 27 --------------------------- docs/build.rst | 18 ------------------ docs/index.rst | 12 ------------ docs/logging.rst | 14 -------------- docs/offeredapis.rst | 6 ------ docs/release-notes.rst | 44 -------------------------------------------- 6 files changed, 121 deletions(-) delete mode 100644 docs/architecture.rst delete mode 100644 docs/build.rst delete mode 100644 docs/index.rst delete mode 100644 docs/logging.rst delete mode 100644 docs/offeredapis.rst delete mode 100644 docs/release-notes.rst diff --git a/docs/architecture.rst b/docs/architecture.rst deleted file mode 100644 index 8daa0d3bc..000000000 --- a/docs/architecture.rst +++ /dev/null @@ -1,27 +0,0 @@ -.. This work is licensed under a Creative Commons Attribution 4.0 International License. -.. http://creativecommons.org/licenses/by/4.0 - -Architecture -============ - -.. note:: - * This section is used to describe a software component from a high level - view of capability, common usage scenarios, and interactions with other - components required in the usage scenarios. - - * The architecture section is typically: provided in a platform-component - and sdk collections; and referenced from developer and user guides. - - * This note must be removed after content has been added. - - -Capabilities ------------- - - -Usage Scenarios ---------------- - - -Interactions ------------- diff --git a/docs/build.rst b/docs/build.rst deleted file mode 100644 index 0a4c308e6..000000000 --- a/docs/build.rst +++ /dev/null @@ -1,18 +0,0 @@ -.. This work is licensed under a Creative Commons Attribution 4.0 International License. -.. http://creativecommons.org/licenses/by/4.0 - -Build -===== - - -Environment ------------ -Requires maven release 3.3 or greater - -Steps ------ -To compile this code: - -1. Make sure your local Maven settings file ($HOME/.m2/settings.xml) contains references to the ONAP repositories and OpenDaylight repositories. - -2. To compile, run "mvn clean install". \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst deleted file mode 100644 index 83bb78a8d..000000000 --- a/docs/index.rst +++ /dev/null @@ -1,12 +0,0 @@ -.. This work is licensed under a Creative Commons Attribution 4.0 International License. - -CCSDK Service Logic Interpretor Plugins ----------------------------------------- -.. toctree:: - :maxdepth: 1 - - architecture.rst - offeredapis.rst - logging.rst - build.rst - release-notes.rst diff --git a/docs/logging.rst b/docs/logging.rst deleted file mode 100644 index 187eb03b7..000000000 --- a/docs/logging.rst +++ /dev/null @@ -1,14 +0,0 @@ -.. This work is licensed under a Creative Commons Attribution 4.0 International License. -.. http://creativecommons.org/licenses/by/4.0 - -Logging -======= -CCSDK uses slf4j to log messages to the standard OpenDaylight karaf.log -log file. - -Where to Access Information ---------------------------- -Logs are found within the SDNC docker container, in the directory -/opt/opendaylight/current/data/logs. - - diff --git a/docs/offeredapis.rst b/docs/offeredapis.rst deleted file mode 100644 index e20c786cc..000000000 --- a/docs/offeredapis.rst +++ /dev/null @@ -1,6 +0,0 @@ -.. This work is licensed under a Creative Commons Attribution 4.0 International License. -.. http://creativecommons.org/licenses/by/4.0 - -Offered APIs -============ - diff --git a/docs/release-notes.rst b/docs/release-notes.rst deleted file mode 100644 index dd01fc7e4..000000000 --- a/docs/release-notes.rst +++ /dev/null @@ -1,44 +0,0 @@ -.. This work is licensed under a Creative Commons Attribution 4.0 International License. - -Release Notes -============= - -.. note:: - * This Release Notes must be updated each time the team decides to Release new artifacts. - * The scope of this Release Notes is for this particular component. In other words, each ONAP component has its Release Notes. - * This Release Notes is cumulative, the most recently Released artifact is made visible in the top of this Release Notes. - * Except the date and the version number, all the other sections are optional but there must be at least one section describing the purpose of this new release. - * This note must be removed after content has been added. - - -Version: x.y.z --------------- - - -:Release Date: yyyy-mm-dd - - - -**New Features** - -One or two sentences explaining the purpose of this Release. - -**Bug Fixes** - - `CIMAN-65 `_ and a sentence explaining what this defect is addressing. -**Known Issues** - - `CIMAN-65 `_ and two, three sentences. - One sentences explaining what is the issue. - - Another sentence explaining the impact of the issue. - - And an optional sentence providing a workaround. - -**Security Issues** - You may want to include a reference to CVE (Common Vulnerabilities and Exposures) `CVE `_ - - -**Upgrade Notes** - -**Deprecation Notes** - -**Other** -- cgit From 4a7e43e82712d200f2dd992fb4c070d7389fef50 Mon Sep 17 00:00:00 2001 From: Jessica Wagantall Date: Thu, 16 Nov 2017 23:55:07 -0800 Subject: Bump minor version Bump minor version in preparation for Amsterdam branching. Change-Id: I421e94b159e68e3371729709523f21a58dd3613f Issue-ID: CIMAN-120 Signed-off-by: Jessica Wagantall --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 948004231..92e459540 100644 --- a/version.properties +++ b/version.properties @@ -6,7 +6,7 @@ # Comment release_name=0 -sprint_number=1 +sprint_number=2 feature_revision=1 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit From 17a92cb09deea9704ca2b12beec3450ee1f89a65 Mon Sep 17 00:00:00 2001 From: Jessica Wagantall Date: Fri, 17 Nov 2017 16:59:31 -0800 Subject: Bump minor version Bump minor version in preparation for Amsterdam branching. Change-Id: I514e87be3f1291a1fa8bf9e9afb3a10066d71779 Issue-ID: CIMAN-120 Signed-off-by: Jessica Wagantall --- pom.xml | 2 +- properties-node/features/pom.xml | 4 ++-- properties-node/installer/pom.xml | 2 +- properties-node/pom.xml | 4 ++-- properties-node/provider/pom.xml | 4 ++-- restapi-call-node/features/pom.xml | 4 ++-- restapi-call-node/installer/pom.xml | 2 +- restapi-call-node/pom.xml | 4 ++-- restapi-call-node/provider/pom.xml | 4 ++-- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index c1ed06be4..cf84ab7ae 100755 --- a/pom.xml +++ b/pom.xml @@ -111,7 +111,7 @@ AT&T - 0.1.1-SNAPSHOT + 0.2.0-SNAPSHOT diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 8ed9601f8..0f1e662d9 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -4,10 +4,10 @@ properties-node org.onap.ccsdk.sli.plugins - 0.1.1-SNAPSHOT + 0.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins - 0.1.1-SNAPSHOT + 0.2.0-SNAPSHOT properties-node-features Properties Node - Features diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index b00a7e5a2..8a3330a8f 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,7 +5,7 @@ properties-node org.onap.ccsdk.sli.plugins - 0.1.1-SNAPSHOT + 0.2.0-SNAPSHOT properties-node-installer Properties node - Karaf Installer diff --git a/properties-node/pom.xml b/properties-node/pom.xml index c85160794..ea03a6423 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -3,7 +3,7 @@ org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.1.1-SNAPSHOT + 0.2.0-SNAPSHOT 4.0.0 @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins properties-node - 0.1.1-SNAPSHOT + 0.2.0-SNAPSHOT Properties Node This is an implementation of DG Execute Node that reads property file and diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index b73456815..d622e59e9 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -4,10 +4,10 @@ org.onap.ccsdk.sli.plugins properties-node - 0.1.1-SNAPSHOT + 0.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins - 0.1.1-SNAPSHOT + 0.2.0-SNAPSHOT properties-node-provider bundle Properties Node - Provider diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index 5528bb6b1..41af12507 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -4,10 +4,10 @@ restapi-call-node org.onap.ccsdk.sli.plugins - 0.1.1-SNAPSHOT + 0.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins - 0.1.1-SNAPSHOT + 0.2.0-SNAPSHOT restapi-call-node-features RESTAPI Call Node - Features diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 724534759..aedb3b705 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ restapi-call-node org.onap.ccsdk.sli.plugins - 0.1.1-SNAPSHOT + 0.2.0-SNAPSHOT restapi-call-node-installer Properties node - Karaf Installer diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 9d266cead..d48253e08 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -3,7 +3,7 @@ org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.1.1-SNAPSHOT + 0.2.0-SNAPSHOT 4.0.0 @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins restapi-call-node - 0.1.1-SNAPSHOT + 0.2.0-SNAPSHOT RESTAPI Call Node This is an implementation of DG Execute Node that makes a call to an external REST API diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 5af32b642..0d6b3fb86 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -4,11 +4,11 @@ org.onap.ccsdk.sli.plugins restapi-call-node - 0.1.1-SNAPSHOT + 0.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.1.1-SNAPSHOT + 0.2.0-SNAPSHOT bundle RESTAPI Call Node - Provider http://maven.apache.org -- cgit From e26d43acd63b27378b201400294d219c6fe8fb4d Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 21 Nov 2017 15:34:54 -0500 Subject: Fix version.properties Reset patch version to 0 in version.properties Change-Id: I08e769b75c455c94d7e989030caba313f1897fb7 Issue-ID: CIMAN-120 Signed-off-by: Dan Timoney --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 92e459540..52afe0331 100644 --- a/version.properties +++ b/version.properties @@ -7,7 +7,7 @@ release_name=0 sprint_number=2 -feature_revision=1 +feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit From ad7ea1271a5eb1bb56b48a2fb1b35d8ddfed2d12 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 27 Feb 2018 13:34:16 -0500 Subject: Nitrogen port : sli/plugins Update properties-node and restapi-call-node to compile against ODL Nitrogen Change-Id: I21f06abb008562d6e351cb780302ed4375f5d3d2 Issue-ID: CCSDK-178 Signed-off-by: Dan Timoney --- pom.xml | 115 ++++++++--------- .../features/ccsdk-properties-node/pom.xml | 44 +++++++ .../features/features-properties-node/pom.xml | 29 +++++ properties-node/features/pom.xml | 137 ++------------------ .../features/src/main/resources/features.xml | 39 ------ properties-node/installer/pom.xml | 30 +++-- .../src/main/resources/scripts/install-feature.sh | 9 +- properties-node/pom.xml | 36 ++---- properties-node/provider/pom.xml | 68 ++-------- .../META-INF/spring/properties-node-context.xml | 32 ----- .../spring/properties-node-osgi-context.xml | 32 ----- .../blueprint/properties-node-blueprint.xml | 16 +++ .../features/ccsdk-restapi-call-node/pom.xml | 53 ++++++++ .../features/features-restapi-call-node/pom.xml | 29 +++++ restapi-call-node/features/pom.xml | 143 +++------------------ restapi-call-node/installer/pom.xml | 39 +++--- .../src/main/resources/scripts/install-feature.sh | 9 +- restapi-call-node/pom.xml | 36 ++---- restapi-call-node/provider/pom.xml | 56 ++------ 19 files changed, 339 insertions(+), 613 deletions(-) create mode 100644 properties-node/features/ccsdk-properties-node/pom.xml create mode 100644 properties-node/features/features-properties-node/pom.xml delete mode 100644 properties-node/features/src/main/resources/features.xml delete mode 100644 properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml delete mode 100644 properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml create mode 100755 properties-node/provider/src/main/resources/org/opendaylight/blueprint/properties-node-blueprint.xml create mode 100644 restapi-call-node/features/ccsdk-restapi-call-node/pom.xml create mode 100644 restapi-call-node/features/features-restapi-call-node/pom.xml diff --git a/pom.xml b/pom.xml index cf84ab7ae..0a01af400 100755 --- a/pom.xml +++ b/pom.xml @@ -1,27 +1,29 @@ - + + 4.0.0 org.onap.ccsdk.parent - odlparent-carbon-sr1 - 0.1.0 + odlparent-lite + 1.0.1-SNAPSHOT - 4.0.0 - pom org.onap.ccsdk.sli.plugins ccsdk-sli-plugins + 0.2.1-SNAPSHOT + pom ccsdk-sli-plugins - https://wiki.onap.org CCSDK Java Plugins + https://wiki.onap.org + + ONAP + - - - JIRA - https://jira.onap.org/ - - + + properties-node + restapi-call-node + scm:git:ssh://git@${onap.git.host}/ccsdk/sli/plugins.git @@ -29,13 +31,14 @@ ${onap.git.protocol}://${onap.git.host}/projects/${onap.git.project}/repos/ccsdk/sli/plugins/browse HEAD - + + JIRA + https://jira.onap.org/ + Jenkins https://jenkins.onap.org - - sdnc-javadoc @@ -43,43 +46,6 @@ - - - blackduck - - - blackduck-scan - - - - - - com.blackducksoftware.integration - hub-maven-plugin - 1.4.0 - false - - ${project.name} - ${project.basedir} - - - - create-bdio-file - package - - createHubOutput - - - - - - - - - - - - @@ -102,16 +68,43 @@ - - - properties-node - restapi-call-node - - - AT&T - - 0.2.0-SNAPSHOT + + + blackduck + + + blackduck-scan + + + + + + com.blackducksoftware.integration + hub-maven-plugin + 1.4.0 + false + + ${project.name} + ${project.basedir} + + + + create-bdio-file + package + + createHubOutput + + + + + + + + + + + diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml new file mode 100644 index 000000000..992e1099b --- /dev/null +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -0,0 +1,44 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + ccsdk-properties-node + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-plugins :: properties-node :: ${project.artifactId} + + + true + + + + + org.opendaylight.controller + odl-mdsal-broker + xml + features + + + org.onap.ccsdk.sli.core + ccsdk-sli + ${ccsdk.sli.core.version} + xml + features + + + ${project.groupId} + properties-node-provider + ${project.version} + + + + diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml new file mode 100644 index 000000000..b39826221 --- /dev/null +++ b/properties-node/features/features-properties-node/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + feature-repo-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + features-properties-node + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-plugins :: properties-node :: ${project.artifactId} + + + + ${project.groupId} + ccsdk-properties-node + ${project.version} + xml + features + + + + diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 0f1e662d9..0d4476585 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -1,135 +1,22 @@ 4.0.0 + - properties-node - org.onap.ccsdk.sli.plugins - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + org.onap.ccsdk.sli.plugins - 0.2.0-SNAPSHOT properties-node-features - Properties Node - Features - - jar - - - - - org.onap.ccsdk.sli.plugins - properties-node-provider - ${project.version} - - - - commons-lang - commons-lang - 2.6 - compile - - - - org.opendaylight.mdsal - features-mdsal - ${odl.mdsal.features.version} - features - xml - - runtime - - - - - - org.opendaylight.controller - opendaylight-karaf-empty - ${odl.karaf.empty.distro.version} - zip - - - - - - org.opendaylight.odlparent - features-test - ${odl.commons.opendaylight.version} - test - - - - org.opendaylight.yangtools - features-yangtools - ${odl.yangtools.version} - features - xml - runtime - - + 0.2.1-SNAPSHOT + pom - - - - true - src/main/resources - - - - - org.apache.maven.plugins - maven-resources-plugin - - - filter - - resources - - generate-resources - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/${features.file} - xml - features - - - - - - - - + + ccsdk-properties-node + features-properties-node + diff --git a/properties-node/features/src/main/resources/features.xml b/properties-node/features/src/main/resources/features.xml deleted file mode 100644 index 9abacf0b8..000000000 --- a/properties-node/features/src/main/resources/features.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features - - - sdnc-sli - spring - spring-dm - mvn:org.onap.ccsdk.sli.plugins/properties-node-provider/${project.version} - - - - diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 8a3330a8f..359c8fb83 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -1,20 +1,24 @@ - + 4.0.0 + - properties-node - org.onap.ccsdk.sli.plugins - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + + org.onap.ccsdk.sli.plugins properties-node-installer - Properties node - Karaf Installer + 0.2.1-SNAPSHOT pom + ccsdk-sli-plugins :: properties-node :: ${project.artifactId} + - sdnc-properties-node - sdnc-properties-node - mvn:org.onap.ccsdk.sli.plugins/properties-node-features/${project.version}/xml/features + ccsdk-properties-node + ${application.name} + mvn:org.onap.ccsdk.sli.plugins/${features.boot}/${project.version}/xml/features false @@ -22,10 +26,10 @@ org.onap.ccsdk.sli.plugins - properties-node-features + ${application.name} ${project.version} - features xml + features * @@ -99,8 +103,7 @@ true false false - org.onap.ccsdk.sli - sli-common,sli-provider,dblib-provider + org.onap.ccsdk.sli.plugins provided @@ -135,5 +138,4 @@ - diff --git a/properties-node/installer/src/main/resources/scripts/install-feature.sh b/properties-node/installer/src/main/resources/scripts/install-feature.sh index df03392c8..0eab001d5 100644 --- a/properties-node/installer/src/main/resources/scripts/install-feature.sh +++ b/properties-node/installer/src/main/resources/scripts/install-feature.sh @@ -10,9 +10,9 @@ # 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. @@ -23,7 +23,6 @@ ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} -ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} INSTALLERDIR=$(dirname $0) REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip @@ -36,5 +35,5 @@ else exit 1 fi -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} +${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} feature:install ${features.boot} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index ea03a6423..8e99cf6cf 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -1,43 +1,25 @@ - + + 4.0.0 + - org.onap.ccsdk.sli.plugins - ccsdk-sli-plugins - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT - 4.0.0 - pom - org.onap.ccsdk.sli.plugins properties-node - 0.2.0-SNAPSHOT + 0.2.1-SNAPSHOT + pom - Properties Node + ccsdk-sli-plugins :: properties-node This is an implementation of DG Execute Node that reads property file and puts the properties in the DG context - - - - org.onap.ccsdk.sli.plugins - properties-node-features - features - xml - ${project.version} - - - org.onap.ccsdk.sli.plugins - properties-node-provider - ${project.version} - - - - provider features installer - diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index d622e59e9..c354dc1fc 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -1,89 +1,43 @@ 4.0.0 + - org.onap.ccsdk.sli.plugins - properties-node - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + binding-parent + 1.0.1-SNAPSHOT + org.onap.ccsdk.sli.plugins - 0.2.0-SNAPSHOT properties-node-provider + 0.2.1-SNAPSHOT bundle - Properties Node - Provider + + ccsdk-sli-plugins :: properties-node :: ${project.artifactId} http://maven.apache.org + UTF-8 + junit junit test - - org.springframework - spring-test - ${spring.version} - test - org.onap.ccsdk.sli.core sli-common - ${sdnctl.sli.version} - compile org.onap.ccsdk.sli.core sli-provider - ${sdnctl.sli.version} - compile org.slf4j slf4j-api - ${slf4j.version} - - - org.slf4j - jcl-over-slf4j - ${slf4j.version} - - - org.springframework - spring-beans - ${spring.version} - - org.springframework - spring-context - ${spring.version} - - - - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - org.onap.ccsdk.sli.prop - org.onap.ccsdk.sli.prop - * - - - - - - - - - - + diff --git a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml deleted file mode 100644 index 52d1cd96a..000000000 --- a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - diff --git a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml deleted file mode 100644 index a46e37c7b..000000000 --- a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - diff --git a/properties-node/provider/src/main/resources/org/opendaylight/blueprint/properties-node-blueprint.xml b/properties-node/provider/src/main/resources/org/opendaylight/blueprint/properties-node-blueprint.xml new file mode 100755 index 000000000..6e1d48efd --- /dev/null +++ b/properties-node/provider/src/main/resources/org/opendaylight/blueprint/properties-node-blueprint.xml @@ -0,0 +1,16 @@ + + + + + + + + + + org.onap.ccsdk.sli.plugins.prop.PropertiesNode + + + + \ No newline at end of file diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml new file mode 100644 index 000000000..aa54b4cf7 --- /dev/null +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + ccsdk-restapi-call-node + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} + + + + true + + + + + + org.opendaylight.controller + odl-mdsal-broker + xml + features + + + org.onap.ccsdk.sli.core + ccsdk-sli + ${ccsdk.sli.core.version} + xml + features + + + ${project.groupId} + restapi-call-node-provider + ${project.version} + + + com.sun.jersey + jersey-client + + + org.codehaus.jettison + jettison + + + diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml new file mode 100644 index 000000000..3347502b9 --- /dev/null +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + feature-repo-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + features-restapi-call-node + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} + + + + ${project.groupId} + ccsdk-restapi-call-node + ${project.version} + xml + features + + + + diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index 41af12507..98494089c 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -1,135 +1,22 @@ - 4.0.0 - - restapi-call-node - org.onap.ccsdk.sli.plugins - 0.2.0-SNAPSHOT - - org.onap.ccsdk.sli.plugins - 0.2.0-SNAPSHOT - restapi-call-node-features - RESTAPI Call Node - Features + 4.0.0 - jar + + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + - + org.onap.ccsdk.sli.plugins + restapi-call-node-features + 0.2.1-SNAPSHOT + pom - - org.onap.ccsdk.sli.plugins - restapi-call-node-provider - ${project.version} - + ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} - - commons-lang - commons-lang - 2.6 - compile - - - - org.opendaylight.mdsal - features-mdsal - ${odl.mdsal.features.version} - features - xml - - runtime - - - - - - org.opendaylight.controller - opendaylight-karaf-empty - ${odl.karaf.empty.distro.version} - zip - - - - - - org.opendaylight.odlparent - features-test - ${odl.commons.opendaylight.version} - test - - - - org.opendaylight.yangtools - features-yangtools - ${odl.yangtools.version} - features - xml - runtime - - - - - - - true - src/main/resources - - - - - org.apache.maven.plugins - maven-resources-plugin - - - filter - - resources - - generate-resources - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/${features.file} - xml - features - - - - - - - - + + ccsdk-restapi-call-node + features-restapi-call-node + diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index aedb3b705..68fe477d9 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -1,20 +1,24 @@ - + 4.0.0 + - restapi-call-node - org.onap.ccsdk.sli.plugins - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + + org.onap.ccsdk.sli.plugins restapi-call-node-installer - Properties node - Karaf Installer + 0.2.1-SNAPSHOT pom + ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} + - sdnc-restapi-call-node - sdnc-restapi-call-node - mvn:org.onap.ccsdk.sli.plugins/restapi-call-node-features/${project.version}/xml/features + ccsdk-restapi-call-node + ${application.name} + mvn:org.onap.ccsdk.sli.plugins/${features.boot}/${project.version}/xml/features false @@ -22,10 +26,10 @@ org.onap.ccsdk.sli.plugins - restapi-call-node-features + ${application.name} ${project.version} - features xml + features * @@ -39,7 +43,14 @@ restapi-call-node-provider ${project.version} - + + org.springframework + spring-beans + + + org.springframework + spring-context + @@ -99,8 +110,7 @@ true false false - org.onap.ccsdk.sli - sli-common,sli-provider,dblib-provider + org.onap.ccsdk.sli.core provided @@ -135,5 +145,4 @@ - diff --git a/restapi-call-node/installer/src/main/resources/scripts/install-feature.sh b/restapi-call-node/installer/src/main/resources/scripts/install-feature.sh index e986764b9..cee4a4952 100644 --- a/restapi-call-node/installer/src/main/resources/scripts/install-feature.sh +++ b/restapi-call-node/installer/src/main/resources/scripts/install-feature.sh @@ -10,9 +10,9 @@ # 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. @@ -23,7 +23,6 @@ ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} -ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} INSTALLERDIR=$(dirname $0) REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip @@ -36,5 +35,5 @@ else exit 1 fi -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} +${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} feature:install ${features.boot} diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index d48253e08..e55fd29a9 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -1,42 +1,24 @@ - + + 4.0.0 + - org.onap.ccsdk.sli.plugins - ccsdk-sli-plugins - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT - 4.0.0 - pom - org.onap.ccsdk.sli.plugins restapi-call-node - 0.2.0-SNAPSHOT + 0.2.1-SNAPSHOT + pom - RESTAPI Call Node + ccsdk-sli-plugins :: restapi-call-node This is an implementation of DG Execute Node that makes a call to an external REST API - - - - org.onap.ccsdk.sli.plugins - restapi-call-node-features - features - xml - ${project.version} - - - org.onap.ccsdk.sli.plugins - restapi-call-node-provider - ${project.version} - - - - provider features installer - diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 0d6b3fb86..aae29ead0 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -1,20 +1,25 @@ 4.0.0 + - org.onap.ccsdk.sli.plugins - restapi-call-node - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + binding-parent + 1.0.1-SNAPSHOT + org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.2.0-SNAPSHOT + 0.2.1-SNAPSHOT bundle - RESTAPI Call Node - Provider + + ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} http://maven.apache.org + UTF-8 + junit @@ -24,78 +29,37 @@ org.springframework spring-test - ${spring.version} test org.onap.ccsdk.sli.core sli-common - ${sdnctl.sli.version} - compile org.onap.ccsdk.sli.core sli-provider - ${sdnctl.sli.version} - compile org.slf4j slf4j-api - ${slf4j.version} - - - org.slf4j - jcl-over-slf4j - ${slf4j.version} org.springframework spring-beans - ${spring.version} org.springframework spring-context - ${spring.version} com.sun.jersey jersey-client - ${jersey.version} provided org.codehaus.jettison jettison - ${jettison.version} provided - - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - org.onap.ccsdk.sli.restapicall - org.onap.ccsdk.sli.plugins.restapicall - * - - - - - - - - - - - -- cgit From 3fc57645ddea0895cbd0a902c81549f0606161f7 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 7 Mar 2018 20:02:33 +0000 Subject: restore previous template behavior previously this exception was not thrown, it was caught and ignored. This restores backwards compatibility Change-Id: Ia07c409f47be1269f959134ddbd4aa2898004e7d Issue-ID: CCSDK-203 Signed-off-by: Smokowski, Kevin (ks6305) --- .../java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java | 3 +-- .../org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index c4ad4c55b..572b2042f 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -382,8 +382,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { try { n = Integer.parseInt(value1); } catch (NumberFormatException e) { - throw new SvcLogicException("Invalid input of repeat interval, should be an integer value " + - e.getLocalizedMessage(), e); + log.info("value1 not set or not a number, n will remain set at zero"); } newTemplate.append(template.substring(k, i1)); diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index 2da5b2c83..09fa8355a 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -91,7 +91,7 @@ public class TestRestapiCallNode { rcn.sendRequest(p, ctx); } - @Test(expected = SvcLogicException.class) + @Test public void testInvalidRepeatTimes() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); ctx.setAttribute("tmp.sdn-circuit-req-row_length", "a"); -- cgit From 5146216d32145407e91dee490e5d1f4ccb56e0bb Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Tue, 13 Mar 2018 19:13:19 +0000 Subject: add request body param allow request body to be passed into rest api call node Change-Id: I14a79fccb8dc3e29f2ec487bb6ba2f8021a0e498 Issue-ID: CCSDK-210 Signed-off-by: Smokowski, Kevin (ks6305) --- .../main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java | 1 + .../java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java | 3 +++ 2 files changed, 4 insertions(+) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java index 1eed09e90..47bb655f5 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java @@ -43,4 +43,5 @@ public class Parameters { public String customHttpHeaders; public String partner; public Boolean dumpHeaders; + public String requestBody; } diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 572b2042f..e5c185968 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -131,6 +131,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { if (p.templateFileName != null) { String reqTemplate = readFile(p.templateFileName); req = buildXmlJsonRequest(ctx, reqTemplate, p.format); + } else if (p.requestBody != null) { + req = p.requestBody; } r = sendHttpRequest(req, p); setResponseStatus(ctx, p.responsePrefix, r); @@ -209,6 +211,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { protected Parameters getParameters(Map paramMap) throws SvcLogicException { Parameters p = new Parameters(); p.templateFileName = parseParam(paramMap, "templateFileName", false, null); + p.requestBody = parseParam(paramMap, "requestBody", false, null); p.restapiUrl = parseParam(paramMap, "restapiUrl", true, null); validateUrl(p.restapiUrl); p.restapiUser = parseParam(paramMap, "restapiUser", false, null); -- cgit From 4aeb20ec95c4f51c9bf5090ed1d9ef647882a85e Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 15 Mar 2018 16:46:09 -0400 Subject: Fix restapi-call-node install Restapi-call-node zip includes some packages already installed in ODL distribution. Prevent it from overwriting them by unzipping with -n option. Change-Id: Ie3059465fab05a6d5bd64f93c139094a8a22828f Issue-ID: CCSDK-208 Signed-off-by: Timoney, Dan (dt5972) --- .../installer/src/main/resources/scripts/install-feature.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/restapi-call-node/installer/src/main/resources/scripts/install-feature.sh b/restapi-call-node/installer/src/main/resources/scripts/install-feature.sh index cee4a4952..6e3d4169d 100644 --- a/restapi-call-node/installer/src/main/resources/scripts/install-feature.sh +++ b/restapi-call-node/installer/src/main/resources/scripts/install-feature.sh @@ -29,7 +29,7 @@ REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip if [ -f ${REPOZIP} ] then - unzip -d ${ODL_HOME} ${REPOZIP} + unzip -nd ${ODL_HOME} ${REPOZIP} else echo "ERROR : repo zip ($REPOZIP) not found" exit 1 -- cgit From 09031e372568052390f514ad37efa919299153a4 Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Mon, 2 Apr 2018 17:29:53 +0900 Subject: RESTapiCallNode make request without content-type currently the RESTAPI adaptor doesn't make a REST request with empty Content-type, this change is to help the adaptor to make request with no Content-type, currently defaulting to application/json. This is to avoid, when some servers throw 415 Unsupported Media Type error, when they dont support JSON response. Issue-ID: CCSDK-232 Change-Id: I19fbb949f0aad4ea7ca91d6afcac06a5b7f8deed Signed-off-by: Ganesh Chandrasekaran --- .../src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java | 4 +++- .../java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java index 776485afa..1578ee320 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Format.java @@ -22,13 +22,15 @@ package org.onap.ccsdk.sli.plugins.restapicall; public enum Format { - JSON, XML; + 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/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index e5c185968..ea2d259b7 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -437,7 +437,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { Client client = Client.create(config); client.setConnectTimeout(5000); - if (p.restapiUser != null) + if (p.restapiUser != null && p.restapiPassword != null) client.addFilter(new HTTPBasicAuthFilter(p.restapiUser, p.restapiPassword)); WebResource webResource = client.resource(p.restapiUrl); @@ -457,6 +457,9 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } WebResource.Builder webResourceBuilder = webResource.accept(tt).type(tt1); + if(p.format == Format.NONE){ + webResourceBuilder = webResource.header("",""); + } if (p.customHttpHeaders != null && p.customHttpHeaders.length() > 0) { String[] keyValuePairs = p.customHttpHeaders.split(","); -- cgit From da48f72cb03bf7b5eca0be26d1d0302bb6dc8147 Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Tue, 3 Apr 2018 08:23:45 +0900 Subject: JUnit tests added Issue-ID: CCSDK-232 Change-Id: I4ee2201510b6ad43ec74d27cbc781da75f182cef Signed-off-by: Ganesh Chandrasekaran --- .../plugins/restapicall/TestRestapiCallNode.java | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index 09fa8355a..4809ca7c0 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -380,4 +380,41 @@ public class TestRestapiCallNode { RestapiCallNode rcn = new RestapiCallNode(); rcn.sendRequest(p, ctx); } + + + @Test + public void testDeleteNoneAsContentType() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "pwd1"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testPostNoneAsContentType() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "none"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } } -- cgit From b988799b56244d7920cefc0ec1abe14b4deb2d15 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 18 Apr 2018 02:26:13 -0400 Subject: Fix release version Fix release version in version.properties Change-Id: Ie8e3226e40e78a989a9cb142dd8da4825a3e4e1a Issue-ID: CCSDK-242 Signed-off-by: Timoney, Dan (dt5972) --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 52afe0331..92e459540 100644 --- a/version.properties +++ b/version.properties @@ -7,7 +7,7 @@ release_name=0 sprint_number=2 -feature_revision=0 +feature_revision=1 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit From 5809abef574106cda283c4a33999adee43a59542 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Sun, 29 Apr 2018 19:23:36 -0400 Subject: Roll versions step 5 : sli/plugins poms Roll versions for next release candidate. Change-Id: I0492be8c774aa23f1e0ff2bb1944eae2e818e183 Issue-ID: CCSDK-257 Signed-off-by: Timoney, Dan (dt5972) --- pom.xml | 4 ++-- properties-node/features/ccsdk-properties-node/pom.xml | 4 ++-- properties-node/features/features-properties-node/pom.xml | 4 ++-- properties-node/features/pom.xml | 4 ++-- properties-node/installer/pom.xml | 4 ++-- properties-node/pom.xml | 4 ++-- properties-node/provider/pom.xml | 4 ++-- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/features-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/pom.xml | 4 ++-- restapi-call-node/installer/pom.xml | 4 ++-- restapi-call-node/pom.xml | 4 ++-- restapi-call-node/provider/pom.xml | 4 ++-- version.properties | 2 +- 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/pom.xml b/pom.xml index 0a01af400..0de6405d0 100755 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index 992e1099b..fd897b7d3 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-properties-node - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index b39826221..bd91a282d 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.plugins features-properties-node - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 0d4476585..81ce31823 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-features - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 359c8fb83..e12ab4687 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-installer - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 8e99cf6cf..0e1556a5a 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-plugins :: properties-node diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index c354dc1fc..5e042c960 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-provider - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT bundle ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index aa54b4cf7..7bcc67ad0 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restapi-call-node - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index 3347502b9..a5f12dcbc 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.plugins features-restapi-call-node - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index 98494089c..c51af4228 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-features - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 68fe477d9..2ebcabea1 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-installer - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index e55fd29a9..ba6f7d776 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index aae29ead0..fcece6900 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT bundle ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/version.properties b/version.properties index 92e459540..7862a834a 100644 --- a/version.properties +++ b/version.properties @@ -7,7 +7,7 @@ release_name=0 sprint_number=2 -feature_revision=1 +feature_revision=2 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit From b3739710de5967d5138f2e01bf1d8f8da79d7788 Mon Sep 17 00:00:00 2001 From: Jessica Wagantall Date: Thu, 3 May 2018 17:27:31 -0700 Subject: Add INFO.yaml file Add INFO.yaml to list: - Project description - Properties - PTL information - Meeting information - Committer information Change-Id: I64f9444f3661f221c8616c9d409324441d4c45b4 Issue-ID: CIMAN-134 Signed-off-by: Jessica Wagantall --- INFO.yaml | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 INFO.yaml diff --git a/INFO.yaml b/INFO.yaml new file mode 100644 index 000000000..aaea28b82 --- /dev/null +++ b/INFO.yaml @@ -0,0 +1,42 @@ +--- +project: 'ccsdk-sli-plugins' +project_creation_date: '2017-06-27' +lifecycle_state: 'Incubation' +project_lead: &onap_releng_ptl + name: 'Dan Timoney' + email: 'dtimoney@att.com' + id: 'djtimoney' + company: 'ATT' + timezone: 'America/New York' +primary_contact: *onap_releng_ptl +issue_tracking: + type: 'jira' + url: 'https://jira.onap.org/projects/CCSDK' + key: 'CCDSK' +meetings: + - type: 'zoom' + agenda: 'https://wiki.onap.org/display/DW/Common+Controller+SDK+Project' + url: 'https://wiki.onap.org/display/DW/Common+Controller+SDK+Project#CommonControllerSDKProject-MeetingMinutes' + server: 'n/a' + channel: 'n/a' + repeats: 'weekly' + time: '13:00 UTC' +committers: + - <<: *onap_releng_ptl + - name: 'Jack Lucas' + email: 'jflucas@research.att.com' + company: 'ATT' + id: 'jackl' + timezone: 'America/New York' + - name: 'Jun (Nicolas) Hu' + email: 'jh245g@att.com' + company: 'ATT' + id: 'jh245g' + timezone: 'America/New York' + - name: 'Ryan Goulding' + email: 'ryandgoulding@gmail.com' + company: 'Inocybe Technologies' + id: 'rgoulding' + timezone: 'America/New York' +tsc: + approval: 'https://lists.onap.org/pipermail/onap-tsc' -- cgit From ad31eaad93ac40d814996928873a4d1830c12fce Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 15 May 2018 15:40:54 -0400 Subject: Add blueprint for restapicallnode Restapicallnode was using spring-dm to advertise itself in Amsterdam. This no longer is supported in Karaf 4 (Nitrogen) so need to use Aries Blueprint. Change-Id: Id78811a5c8c443bcdc8c906e33e57660560ef586 Issue-ID: CCSDK-277 Signed-off-by: Timoney, Dan (dt5972) --- .../blueprint/restapi-call-node-blueprint.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 restapi-call-node/provider/src/main/resources/org/opendaylight/blueprint/restapi-call-node-blueprint.xml diff --git a/restapi-call-node/provider/src/main/resources/org/opendaylight/blueprint/restapi-call-node-blueprint.xml b/restapi-call-node/provider/src/main/resources/org/opendaylight/blueprint/restapi-call-node-blueprint.xml new file mode 100755 index 000000000..390bb0a35 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/org/opendaylight/blueprint/restapi-call-node-blueprint.xml @@ -0,0 +1,16 @@ + + + + + + + + + + org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode + + + + \ No newline at end of file -- cgit From 25db2c02240103cc1eb9c11355db97d8c3a37a42 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 17 May 2018 19:06:07 -0400 Subject: Update sli/plugins to use 1.0.2 parent Update pom.xmls to use released 1.0.2 version of parent Change-Id: I7ce1568347e217e5f9d1978dc620f3a0b52a60a0 Issue-ID: CCSDK-286 Signed-off-by: Timoney, Dan (dt5972) --- pom.xml | 2 +- properties-node/features/ccsdk-properties-node/pom.xml | 2 +- properties-node/features/features-properties-node/pom.xml | 2 +- properties-node/features/pom.xml | 2 +- properties-node/installer/pom.xml | 2 +- properties-node/pom.xml | 2 +- properties-node/provider/pom.xml | 2 +- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/features-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/pom.xml | 2 +- restapi-call-node/installer/pom.xml | 2 +- restapi-call-node/pom.xml | 2 +- restapi-call-node/provider/pom.xml | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 0de6405d0..48fdb5fcf 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 org.onap.ccsdk.sli.plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index fd897b7d3..e0124b633 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index bd91a282d..92989c968 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 81ce31823..d9c99fe13 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 org.onap.ccsdk.sli.plugins diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index e12ab4687..74e58e44b 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 org.onap.ccsdk.sli.plugins diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 0e1556a5a..527819a32 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 org.onap.ccsdk.sli.plugins diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 5e042c960..e6b2d61b0 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.2-SNAPSHOT + 1.0.2 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 7bcc67ad0..99761aa81 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index a5f12dcbc..d04af2707 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index c51af4228..a57a01276 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 2ebcabea1..55f462de7 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index ba6f7d776..c19ead71f 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index fcece6900..135ea6142 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.2-SNAPSHOT + 1.0.2 org.onap.ccsdk.sli.plugins -- cgit From 189be235f9ad5ebd92bd93ea49152b4333e879e1 Mon Sep 17 00:00:00 2001 From: "Stilwell, David (stilwelld)" Date: Wed, 23 May 2018 12:47:15 -0400 Subject: Roll to next snapshot version Roll to version 0.2.3-SNAPSHOT and update parent to 1.0.3-SNAPSHOT Change-Id: Idc86fcb6e7cd6c691db61a774a6582f574489a90 Issue-ID: CCSDK-290 Signed-off-by: Stilwell, David (stilwelld) --- pom.xml | 4 ++-- properties-node/features/ccsdk-properties-node/pom.xml | 4 ++-- properties-node/features/features-properties-node/pom.xml | 4 ++-- properties-node/features/pom.xml | 4 ++-- properties-node/installer/pom.xml | 4 ++-- properties-node/pom.xml | 4 ++-- properties-node/provider/pom.xml | 4 ++-- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/features-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/pom.xml | 4 ++-- restapi-call-node/installer/pom.xml | 4 ++-- restapi-call-node/pom.xml | 4 ++-- restapi-call-node/provider/pom.xml | 4 ++-- version.properties | 2 +- 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/pom.xml b/pom.xml index 48fdb5fcf..d4ee67455 100755 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index e0124b633..1bd3a8b98 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-properties-node - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index 92989c968..f38ad181b 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.plugins features-properties-node - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index d9c99fe13..cf4c440c7 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-features - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 74e58e44b..b9ed78ed5 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-installer - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 527819a32..c4814abd8 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-plugins :: properties-node diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index e6b2d61b0..6574cb102 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-provider - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT bundle ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 99761aa81..4c2635848 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restapi-call-node - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index d04af2707..30a22da09 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.plugins features-restapi-call-node - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index a57a01276..fedafd235 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-features - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 55f462de7..1f6fd27be 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-installer - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index c19ead71f..8ecd53335 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 135ea6142..918403922 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT bundle ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/version.properties b/version.properties index 7862a834a..66decce4b 100644 --- a/version.properties +++ b/version.properties @@ -7,7 +7,7 @@ release_name=0 sprint_number=2 -feature_revision=2 +feature_revision=3 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit From 4f5ae57e8b948d680b4c169ad2795025960649d4 Mon Sep 17 00:00:00 2001 From: "Stilwell, David (stilwelld)" Date: Wed, 23 May 2018 17:16:50 -0400 Subject: Update to release version parent 1.0.3 Update parent version to remove -SNAPSHOT (1.0.3) Change-Id: I7e790d752edfaad02780a40d3dd4802e915752a7 Issue-ID: CCSDK-290 Signed-off-by: Stilwell, David (stilwelld) --- pom.xml | 2 +- properties-node/features/ccsdk-properties-node/pom.xml | 2 +- properties-node/features/features-properties-node/pom.xml | 2 +- properties-node/features/pom.xml | 2 +- properties-node/installer/pom.xml | 2 +- properties-node/pom.xml | 2 +- properties-node/provider/pom.xml | 2 +- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/features-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/pom.xml | 2 +- restapi-call-node/installer/pom.xml | 2 +- restapi-call-node/pom.xml | 2 +- restapi-call-node/provider/pom.xml | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index d4ee67455..0386e16b1 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 org.onap.ccsdk.sli.plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index 1bd3a8b98..e724df18d 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index f38ad181b..f85243a16 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index cf4c440c7..9c2443f70 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 org.onap.ccsdk.sli.plugins diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index b9ed78ed5..e782c91ac 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 org.onap.ccsdk.sli.plugins diff --git a/properties-node/pom.xml b/properties-node/pom.xml index c4814abd8..bb4c8a2db 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 org.onap.ccsdk.sli.plugins diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 6574cb102..004cc57f1 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.3-SNAPSHOT + 1.0.3 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 4c2635848..ed6604c2d 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index 30a22da09..f3b076249 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index fedafd235..563c38fb5 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 1f6fd27be..dcccc14c2 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 8ecd53335..dd938583f 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 918403922..2411a26bc 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.3-SNAPSHOT + 1.0.3 org.onap.ccsdk.sli.plugins -- cgit From 054268fcc23260ba89bea7fdb07f6037a6fd76bc Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 30 May 2018 18:12:49 -0400 Subject: Roll version to 0.2.4 Roll version to 0.2.4-SNAPSHOT and version 1.0.4-SNAPSHOT of parent Change-Id: I3e657bba0043cc713c7ed20883fb975a058be3aa Issue-ID: CCSDK-291 Signed-off-by: Timoney, Dan (dt5972) --- pom.xml | 4 ++-- properties-node/features/ccsdk-properties-node/pom.xml | 4 ++-- properties-node/features/features-properties-node/pom.xml | 4 ++-- properties-node/features/pom.xml | 4 ++-- properties-node/installer/pom.xml | 4 ++-- properties-node/pom.xml | 4 ++-- properties-node/provider/pom.xml | 4 ++-- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/features-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/pom.xml | 4 ++-- restapi-call-node/installer/pom.xml | 4 ++-- restapi-call-node/pom.xml | 4 ++-- restapi-call-node/provider/pom.xml | 4 ++-- version.properties | 2 +- 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/pom.xml b/pom.xml index 0386e16b1..99b484ec0 100755 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index e724df18d..f3b39257d 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-properties-node - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index f85243a16..1b3f5a8b7 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.plugins features-properties-node - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 9c2443f70..f0a45571f 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-features - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index e782c91ac..179ca1c2c 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-installer - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index bb4c8a2db..57d8ecfcb 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-plugins :: properties-node diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 004cc57f1..2d648035d 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-provider - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT bundle ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index ed6604c2d..a789d96b9 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restapi-call-node - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index f3b076249..8dd62d094 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.plugins features-restapi-call-node - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index 563c38fb5..be1ef23a1 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-features - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index dcccc14c2..64151c6ad 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-installer - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index dd938583f..d34163380 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 2411a26bc..35d55cc40 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT bundle ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/version.properties b/version.properties index 66decce4b..eef7ce9c0 100644 --- a/version.properties +++ b/version.properties @@ -7,7 +7,7 @@ release_name=0 sprint_number=2 -feature_revision=3 +feature_revision=4 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit From ea26c5d881e669021c6dfc31202c9c4ff544d5dd Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 31 May 2018 14:27:07 -0400 Subject: Use released parent pom Update to use release parent pom version 1.0.4 Change-Id: I3bbcdbeb1e8d0e6b02791e9c935c6819dbc2948b Issue-ID: CCSDK-291 Signed-off-by: Timoney, Dan (dt5972) --- pom.xml | 2 +- properties-node/features/ccsdk-properties-node/pom.xml | 2 +- properties-node/features/features-properties-node/pom.xml | 2 +- properties-node/features/pom.xml | 2 +- properties-node/installer/pom.xml | 2 +- properties-node/pom.xml | 2 +- properties-node/provider/pom.xml | 2 +- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/features-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/pom.xml | 2 +- restapi-call-node/installer/pom.xml | 2 +- restapi-call-node/pom.xml | 2 +- restapi-call-node/provider/pom.xml | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 99b484ec0..d33d5debd 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 org.onap.ccsdk.sli.plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index f3b39257d..8d61c4ee1 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index 1b3f5a8b7..3861350fe 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index f0a45571f..99f0a9278 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 org.onap.ccsdk.sli.plugins diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 179ca1c2c..90fffb208 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 org.onap.ccsdk.sli.plugins diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 57d8ecfcb..833d0b102 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 org.onap.ccsdk.sli.plugins diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 2d648035d..ca7e8d6f7 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.4-SNAPSHOT + 1.0.4 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index a789d96b9..d2d571b9d 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index 8dd62d094..60e0cc7bf 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index be1ef23a1..0b317861f 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 64151c6ad..7c10a412e 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index d34163380..9ed310f73 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 35d55cc40..85340ddcb 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.4-SNAPSHOT + 1.0.4 org.onap.ccsdk.sli.plugins -- cgit From 2642a03e5aee31ce5d51719adce283f7cd96c7b9 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 6 Jun 2018 14:11:23 -0400 Subject: Roll versions for Casablanca - sli/plugins Roll to version 0.3.0-SNAPSHOT for Casablanca development Change-Id: Id71eaf1ac29d2b383e6c99710700b332974c31ef Issue-ID: CCSDK-295 Signed-off-by: Timoney, Dan (dt5972) --- pom.xml | 4 ++-- properties-node/features/ccsdk-properties-node/pom.xml | 4 ++-- properties-node/features/features-properties-node/pom.xml | 4 ++-- properties-node/features/pom.xml | 4 ++-- properties-node/installer/pom.xml | 4 ++-- properties-node/pom.xml | 4 ++-- properties-node/provider/pom.xml | 4 ++-- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/features-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/pom.xml | 4 ++-- restapi-call-node/installer/pom.xml | 4 ++-- restapi-call-node/pom.xml | 4 ++-- restapi-call-node/provider/pom.xml | 4 ++-- version.properties | 6 +++--- 14 files changed, 29 insertions(+), 29 deletions(-) diff --git a/pom.xml b/pom.xml index d33d5debd..8c1301332 100755 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index 8d61c4ee1..420ba49d9 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-properties-node - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index 3861350fe..e8f168e2b 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-properties-node - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 99f0a9278..dd0e824f0 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-features - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 90fffb208..c9a11c613 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-installer - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 833d0b102..eb7dcbb51 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-plugins :: properties-node diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index ca7e8d6f7..9dcdb9b62 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-provider - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT bundle ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index d2d571b9d..43dcc74f0 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restapi-call-node - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index 60e0cc7bf..dfcef32f4 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-restapi-call-node - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index 0b317861f..14e9ae022 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-features - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 7c10a412e..0badf58b5 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-installer - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 9ed310f73..641bcc863 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 85340ddcb..45fbdff18 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT bundle ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/version.properties b/version.properties index eef7ce9c0..53760c8c7 100644 --- a/version.properties +++ b/version.properties @@ -6,11 +6,11 @@ # Comment release_name=0 -sprint_number=2 -feature_revision=4 +sprint_number=3 +feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} -release_version=${base_version} +release_version=${base_version}-STAGING snapshot_version=${base_version}-SNAPSHOT -- cgit From 600aab4f869d5b632f055dce5cb910ce1d5a348e Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Tue, 12 Jun 2018 18:39:44 +0900 Subject: support oAuth authentication method Issue-ID: CCSDK-298 Change-Id: I16d3e15f0250c78b48886c80d9a4427838ae36b3 Signed-off-by: Ganesh Chandrasekaran --- .../features/src/main/resources/features.xml | 2 ++ restapi-call-node/provider/pom.xml | 12 ++++++++++++ .../ccsdk/sli/plugins/restapicall/Parameters.java | 4 ++++ .../sli/plugins/restapicall/RestapiCallNode.java | 22 ++++++++++++++++++++++ .../plugins/restapicall/TestRestapiCallNode.java | 18 ++++++++++++++++++ .../provider/src/test/resources/test.xml | 10 ++++++++++ 6 files changed, 68 insertions(+) diff --git a/restapi-call-node/features/src/main/resources/features.xml b/restapi-call-node/features/src/main/resources/features.xml index da9266f9e..a764aa477 100644 --- a/restapi-call-node/features/src/main/resources/features.xml +++ b/restapi-call-node/features/src/main/resources/features.xml @@ -33,6 +33,8 @@ spring spring-dm mvn:com.sun.jersey/jersey-client/${jersey.version} + mvn:com.sun.jersey.contribs.jersey-oauth/oauth-signature/${jersey.version} + mvn:com.sun.jersey.contribs.jersey-oauth/oauth-client/${jersey.version} mvn:org.codehaus.jettison/jettison/${jettison.version} mvn:org.onap.ccsdk.sli.plugins/restapi-call-node-provider/${project.version} diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 45fbdff18..4831356c3 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -56,6 +56,18 @@ jersey-client provided + + com.sun.jersey.contribs.jersey-oauth + oauth-signature + ${jersey.version} + provided + + + com.sun.jersey.contribs.jersey-oauth + oauth-client + ${jersey.version} + provided + org.codehaus.jettison jettison diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java index 47bb655f5..3a4bc76c5 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java @@ -44,4 +44,8 @@ public class Parameters { public String partner; public Boolean dumpHeaders; public String requestBody; + public String oAuthConsumerKey; + public String oAuthConsumerSecret; + public String oAuthSignatureMethod; + public String oAuthVersion; } diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index ea2d259b7..bd2fc8267 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -62,6 +62,9 @@ import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; +import com.sun.jersey.oauth.client.OAuthClientFilter; +import com.sun.jersey.oauth.signature.OAuthParameters; +import com.sun.jersey.oauth.signature.OAuthSecrets; import com.sun.jersey.client.urlconnection.HTTPSProperties; public class RestapiCallNode implements SvcLogicJavaPlugin { @@ -94,6 +97,10 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { * * * + * + * + * + * * * * @@ -216,6 +223,10 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { validateUrl(p.restapiUrl); p.restapiUser = parseParam(paramMap, "restapiUser", false, null); p.restapiPassword = parseParam(paramMap, "restapiPassword", false, null); + p.oAuthConsumerKey = parseParam(paramMap, "oAuthConsumerKey", false, null); + p.oAuthConsumerSecret = parseParam(paramMap, "oAuthConsumerSecret", false, null); + p.oAuthSignatureMethod = parseParam(paramMap, "oAuthSignatureMethod", false, null); + p.oAuthVersion = parseParam(paramMap, "oAuthVersion", false, null); p.contentType = parseParam(paramMap, "contentType", false, null); p.format = Format.fromString(parseParam(paramMap, "format", false, "json")); p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post")); @@ -439,6 +450,17 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { client.setConnectTimeout(5000); if (p.restapiUser != null && p.restapiPassword != null) client.addFilter(new HTTPBasicAuthFilter(p.restapiUser, p.restapiPassword)); + else if(p.oAuthConsumerKey != null && p.oAuthConsumerSecret != null && p.oAuthSignatureMethod != null && p.oAuthVersion != null) + { + OAuthParameters params = new OAuthParameters() + .signatureMethod(p.oAuthSignatureMethod) + .consumerKey(p.oAuthConsumerKey) + .version(p.oAuthVersion); + + OAuthSecrets secrets = new OAuthSecrets() + .consumerSecret(p.oAuthConsumerSecret); + client.addFilter(new OAuthClientFilter(client.getProviders(), params, secrets)); + } WebResource webResource = client.resource(p.restapiUrl); log.info("Sending request:"); diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index 4809ca7c0..88a1eeaeb 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -417,4 +417,22 @@ public class TestRestapiCallNode { RestapiCallNode rcn = new RestapiCallNode(); rcn.sendRequest(p, ctx); } + + @Test + public void testDeleteOAuthType() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("oAuthSignatureMethod", "plainTEXT"); + p.put("oAuthVersion", "1.0"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } } diff --git a/restapi-call-node/provider/src/test/resources/test.xml b/restapi-call-node/provider/src/test/resources/test.xml index b60b5356e..1974f688e 100644 --- a/restapi-call-node/provider/src/test/resources/test.xml +++ b/restapi-call-node/provider/src/test/resources/test.xml @@ -87,6 +87,16 @@ jersey-client 1.17 + + com.sun.jersey.contribs.jersey-oauth + oauth-signature + 1.17 + + + com.sun.jersey.contribs.jersey-oauth + oauth-client + 1.17 + commons-codec commons-codec -- cgit From a87dc9c351b0c08d20adc428c215cf3934bb79bb Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Thu, 14 Jun 2018 08:02:31 +0900 Subject: CCSDK plugin has authType param for DG to sel type Issue-ID: CCSDK-299 Change-Id: I61a56c873189ccc6ba9985c5121d50e2ad1f3f48 Signed-off-by: Ganesh Chandrasekaran --- .../ccsdk/sli/plugins/restapicall/AuthType.java | 19 +++ .../ccsdk/sli/plugins/restapicall/Parameters.java | 1 + .../sli/plugins/restapicall/RestapiCallNode.java | 92 +++++++++++--- .../plugins/restapicall/TestRestapiCallNode.java | 137 +++++++++++++++++++++ 4 files changed, 232 insertions(+), 17 deletions(-) create mode 100644 restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/AuthType.java diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/AuthType.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/AuthType.java new file mode 100644 index 000000000..851dc9cc8 --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/AuthType.java @@ -0,0 +1,19 @@ +package org.onap.ccsdk.sli.plugins.restapicall; + +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/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java index 3a4bc76c5..c170cfc7d 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java @@ -48,4 +48,5 @@ public class Parameters { public String oAuthConsumerSecret; public String oAuthSignatureMethod; public String oAuthVersion; + public AuthType authtype; } diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index bd2fc8267..d215d9092 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -62,6 +62,7 @@ import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; +import com.sun.jersey.api.client.filter.HTTPDigestAuthFilter; import com.sun.jersey.oauth.client.OAuthClientFilter; import com.sun.jersey.oauth.signature.OAuthParameters; import com.sun.jersey.oauth.signature.OAuthSecrets; @@ -229,6 +230,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { p.oAuthVersion = parseParam(paramMap, "oAuthVersion", false, null); p.contentType = parseParam(paramMap, "contentType", false, null); p.format = Format.fromString(parseParam(paramMap, "format", false, "json")); + p.authtype = AuthType.fromString(parseParam(paramMap, "authType", false, "unspecified")); p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post")); p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); p.listNameList = getListNameList(paramMap); @@ -431,6 +433,67 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } } + protected Client addAuthType(Client c, FileParam fp) throws SvcLogicException { + Parameters p = new Parameters(); + p.restapiUser = fp.user; + p.restapiPassword = fp.password; + p.oAuthConsumerKey = fp.oAuthConsumerKey; + p.oAuthVersion = fp.oAuthVersion; + p.oAuthConsumerSecret = fp.oAuthConsumerSecret; + p.oAuthSignatureMethod = fp.oAuthSignatureMethod; + p.authtype = fp.authtype; + return addAuthType(c,p); + } + + protected Client addAuthType(Client client, Parameters p) throws SvcLogicException { + if (p.authtype == AuthType.Unspecified){ + if (p.restapiUser != null && p.restapiPassword != null) + client.addFilter(new HTTPBasicAuthFilter(p.restapiUser, p.restapiPassword)); + else if(p.oAuthConsumerKey != null && p.oAuthConsumerSecret != null + && p.oAuthSignatureMethod != null) { + OAuthParameters params = new OAuthParameters() + .signatureMethod(p.oAuthSignatureMethod) + .consumerKey(p.oAuthConsumerKey) + .version(p.oAuthVersion); + + OAuthSecrets secrets = new OAuthSecrets() + .consumerSecret(p.oAuthConsumerSecret); + client.addFilter(new OAuthClientFilter(client.getProviders(), params, secrets)); + } + } else { + if (p.authtype == AuthType.DIGEST) { + if (p.restapiUser != null && p.restapiPassword != null) { + client.addFilter(new HTTPDigestAuthFilter(p.restapiUser, p.restapiPassword)); + } else { + throw new SvcLogicException("oAUTH authentication type selected but all restapiUser and restapiPassword " + + "parameters doesn't exist", new Throwable()); + } + } else if (p.authtype == AuthType.BASIC){ + if (p.restapiUser != null && p.restapiPassword != null) { + client.addFilter(new HTTPBasicAuthFilter(p.restapiUser, p.restapiPassword)); + } else { + throw new SvcLogicException("oAUTH authentication type selected but all restapiUser and restapiPassword " + + "parameters doesn't exist", new Throwable()); + } + } else if(p.authtype == AuthType.OAUTH ) { + if(p.oAuthConsumerKey != null && p.oAuthConsumerSecret != null && p.oAuthSignatureMethod != null) { + OAuthParameters params = new OAuthParameters() + .signatureMethod(p.oAuthSignatureMethod) + .consumerKey(p.oAuthConsumerKey) + .version(p.oAuthVersion); + + OAuthSecrets secrets = new OAuthSecrets() + .consumerSecret(p.oAuthConsumerSecret); + client.addFilter(new OAuthClientFilter(client.getProviders(), params, secrets)); + } else { + throw new SvcLogicException("oAUTH authentication type selected but all oAuthConsumerKey, oAuthConsumerSecret " + + "and oAuthSignatureMethod parameters doesn't exist", new Throwable()); + } + } + } + return client; + } + protected HttpResponse sendHttpRequest(String request, Parameters p) throws SvcLogicException { ClientConfig config = new DefaultClientConfig(); @@ -448,20 +511,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { Client client = Client.create(config); client.setConnectTimeout(5000); - if (p.restapiUser != null && p.restapiPassword != null) - client.addFilter(new HTTPBasicAuthFilter(p.restapiUser, p.restapiPassword)); - else if(p.oAuthConsumerKey != null && p.oAuthConsumerSecret != null && p.oAuthSignatureMethod != null && p.oAuthVersion != null) - { - OAuthParameters params = new OAuthParameters() - .signatureMethod(p.oAuthSignatureMethod) - .consumerKey(p.oAuthConsumerKey) - .version(p.oAuthVersion); - - OAuthSecrets secrets = new OAuthSecrets() - .consumerSecret(p.oAuthConsumerSecret); - client.addFilter(new OAuthClientFilter(client.getProviders(), params, secrets)); - } - WebResource webResource = client.resource(p.restapiUrl); + WebResource webResource = addAuthType(client,p).resource(p.restapiUrl); log.info("Sending request:"); log.info(request); @@ -592,6 +642,11 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { public HttpMethod httpMethod; public String responsePrefix; public boolean skipSending; + public String oAuthConsumerKey; + public String oAuthConsumerSecret; + public String oAuthSignatureMethod; + public String oAuthVersion; + public AuthType authtype; } private FileParam getFileParameters(Map paramMap) throws SvcLogicException { @@ -604,6 +659,11 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); String skipSendingStr = paramMap.get("skipSending"); p.skipSending = "true".equalsIgnoreCase(skipSendingStr); + p.oAuthConsumerKey = parseParam(paramMap, "oAuthConsumerKey", false, null); + p.oAuthVersion = parseParam(paramMap, "oAuthVersion", false, null); + p.oAuthConsumerSecret = parseParam(paramMap, "oAuthConsumerSecret", false, null); + p.oAuthSignatureMethod = parseParam(paramMap, "oAuthSignatureMethod", false, null); + p.authtype = AuthType.fromString(parseParam(paramMap, "authType", false, "unspecified")); return p; } @@ -611,9 +671,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { Client client = Client.create(); client.setConnectTimeout(5000); client.setFollowRedirects(true); - if (p.user != null) - client.addFilter(new HTTPBasicAuthFilter(p.user, p.password)); - WebResource webResource = client.resource(p.url); + WebResource webResource = addAuthType(client,p).resource(p.url); log.info("Sending file"); long t1 = System.currentTimeMillis(); diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index 88a1eeaeb..81806f6de 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -435,4 +435,141 @@ public class TestRestapiCallNode { RestapiCallNode rcn = new RestapiCallNode(); rcn.sendRequest(p, ctx); } + + @Test + public void testDeleteAuthTypeBasic() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "basic"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteAuthTypeDigest() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "digest"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteAuthTypeOAuth() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "oauth"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("oAuthSignatureMethod", "plainTEXT"); + p.put("oAuthVersion", "1.0"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteAuthTypeNoneOAuth() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("oAuthSignatureMethod", "plainTEXT"); + p.put("oAuthVersion", "1.0"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + @Test + public void testDeleteAuthTypeNoneBasic() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testInvalidDeleteAuthTypeOAuth() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "oauth"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testInvalidDeleteAuthTypeBasic() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "basic"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testInvalidDeleteAuthTypeDigest() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "digest"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } } -- cgit From b942c2091cacfe09e503e445c7a15b77080ab357 Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Fri, 15 Jun 2018 10:17:06 +0900 Subject: CCSDK PropNode can read JSON and put to ctx Issue-ID: CCSDK-304 Change-Id: I510fe73c3eedc49071e386689090104a761a03a6 CCSDK PropertyNode can now read a JSON file and put to ctx memory Change-Id: I440ae043c020a08cd869df587916799dd7e3aeea CCSDK PropertyNode can now read a JSON file and put to ctx memory Issue-ID: CCSDK-304 Change-Id: Ic06a89c2327d07b31a1f45b9cc57783d8faf370a Signed-off-by: Ganesh Chandrasekaran --- properties-node/provider/pom.xml | 11 +- .../onap/ccsdk/sli/plugins/prop/JsonParser.java | 94 ++++++++ .../onap/ccsdk/sli/plugins/prop/Parameters.java | 27 +++ .../ccsdk/sli/plugins/prop/PropertiesNode.java | 64 ++++-- .../ccsdk/sli/plugins/prop/TestJsonParser.java | 73 ++++++ .../ccsdk/sli/plugins/prop/TestPropertiesNode.java | 247 +++++++++++++++++++++ .../provider/src/test/resources/test-invalid.json | 29 +++ .../provider/src/test/resources/test.json | 30 +++ .../provider/src/test/resources/test.txt | 30 +++ 9 files changed, 590 insertions(+), 15 deletions(-) create mode 100644 properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/JsonParser.java create mode 100644 properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/Parameters.java create mode 100644 properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestJsonParser.java create mode 100644 properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java create mode 100644 properties-node/provider/src/test/resources/test-invalid.json create mode 100644 properties-node/provider/src/test/resources/test.json create mode 100644 properties-node/provider/src/test/resources/test.txt diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 9dcdb9b62..b3a1cf533 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -26,6 +26,11 @@ junit test + + org.springframework + spring-test + test + org.onap.ccsdk.sli.core sli-common @@ -38,6 +43,10 @@ org.slf4j slf4j-api - + + org.codehaus.jettison + jettison + provided + diff --git a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/JsonParser.java b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/JsonParser.java new file mode 100644 index 000000000..89243a055 --- /dev/null +++ b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/JsonParser.java @@ -0,0 +1,94 @@ +/*- + * ============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.prop; + +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; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import static com.google.common.base.Preconditions.checkNotNull; + +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 convertToProperties(String s) + throws SvcLogicException { + + checkNotNull(s, "Input should not be null."); + + try { + JSONObject json = new JSONObject(s); + Map wm = new HashMap<>(); + Iterator ii = json.keys(); + while (ii.hasNext()) { + String key1 = ii.next(); + wm.put(key1, json.get(key1)); + } + + Map 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 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/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/Parameters.java b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/Parameters.java new file mode 100644 index 000000000..e15f0822d --- /dev/null +++ b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/Parameters.java @@ -0,0 +1,27 @@ +/*- + * ============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.prop; + +public class Parameters { + public String fileName; + public String contextPrefix; +} diff --git a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java index b4886d552..63fdeded8 100644 --- a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java +++ b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java @@ -21,6 +21,7 @@ package org.onap.ccsdk.sli.plugins.prop; +import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; @@ -38,27 +39,62 @@ public class PropertiesNode implements SvcLogicJavaPlugin { private static final Logger log = LoggerFactory.getLogger(PropertiesNode.class); public void readProperties(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { - String fileName = parseParam(paramMap, "fileName", true, null); - String contextPrefix = parseParam(paramMap, "contextPrefix", false, null); - + Parameters param = getParameters(paramMap); + Properties prop = new Properties(); try { - Properties pp = new Properties(); - InputStream in = new FileInputStream(fileName); - pp.load(in); - for (Object key : pp.keySet()) { - String pfx = contextPrefix != null ? contextPrefix + '.' : ""; - String name = (String) key; - String value = pp.getProperty(name); - if (value != null && value.trim().length() > 0) { - ctx.setAttribute(pfx + name, value.trim()); - log.info("+++ " + pfx + name + ": [" + value + "]"); + File file = new File(param.fileName); + InputStream in = new FileInputStream(file); + Map mm = null; + String pfx = param.contextPrefix != null ? param.contextPrefix + '.' : ""; + if ("json".equalsIgnoreCase(getFileExtension(param.fileName))){ + byte[] data = new byte[(int) file.length()]; + in.read(data); + in.close(); + String str = new String(data, "UTF-8"); + mm = JsonParser.convertToProperties(str); + } else { + prop.load(in); + for (Object key : prop.keySet()) { + String name = (String) key; + String value = prop.getProperty(name); + if (value != null && value.trim().length() > 0) { + ctx.setAttribute(pfx + name, value.trim()); + log.info("+++ " + pfx + name + ": [" + value + "]"); + } + } + } + if (mm != null){ + for (Map.Entry entry : mm.entrySet()){ + ctx.setAttribute(pfx + entry.getKey(), entry.getValue()); + log.info("+++ " + pfx + entry.getKey() + ": [" + entry.getValue() + "]"); } } + } catch (IOException e) { - throw new SvcLogicException("Cannot read property file: " + fileName + ": " + e.getMessage(), e); + throw new SvcLogicException("Cannot read property file: " + param.fileName + ": " + e.getMessage(), e); } } + /* Getting extension has to do the following + * "" --> "" + * "name" --> "" + * "name.txt" --> "txt" + * ".htpasswd" --> "" + * "name.with.many.dots.myext" --> "myext" + */ + private static String getFileExtension(String fileName) { + if(fileName.lastIndexOf(".") != -1 && fileName.lastIndexOf(".") != 0) + return fileName.substring(fileName.lastIndexOf(".")+1); + else return ""; + } + + protected Parameters getParameters(Map paramMap) throws SvcLogicException { + Parameters p = new Parameters(); + p.fileName = parseParam(paramMap, "fileName", true, null); + p.contextPrefix = parseParam(paramMap, "contextPrefix", false, null); + return p; + } + private String parseParam(Map paramMap, String name, boolean required, String def) throws SvcLogicException { String s = paramMap.get(name); diff --git a/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestJsonParser.java b/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestJsonParser.java new file mode 100644 index 000000000..0681124d9 --- /dev/null +++ b/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestJsonParser.java @@ -0,0 +1,73 @@ +/*- + * ============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 jtest.org.onap.ccsdk.sli.plugins.prop; + +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.prop.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 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 mm) { + List 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/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java b/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java new file mode 100644 index 000000000..894eee997 --- /dev/null +++ b/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java @@ -0,0 +1,247 @@ +package jtest.org.onap.ccsdk.sli.plugins.prop; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.prop.PropertiesNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestPropertiesNode { + + private static final Logger log = LoggerFactory.getLogger(TestPropertiesNode.class); + + @Test + public void testJSONFileParsing() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.json"); + p.put("contextPrefix", "test-json"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("test-json.message"),"The provisioned access " + + "bandwidth is at or exceeds 50% of the total server capacity."); + } + + @Test + public void testJSONFileArrayParsing() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.json"); + p.put("contextPrefix", "test-json"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("test-json.equipment-data[0].max-server-speed"),"1600000"); + assertEquals(ctx.getAttribute("test-json.resource-state.used"),"1605000"); + assertEquals(ctx.getAttribute("test-json.resource-rule.service-model"),"DUMMY"); + assertEquals(ctx.getAttribute("test-json.resource-rule.endpoint-position"),"VCE-Cust"); + } + + @Test + public void testJSONFileParsingPrefixCheck() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.json"); + p.put("contextPrefix", ""); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("equipment-data[0].max-server-speed"),"1600000"); + assertEquals(ctx.getAttribute("resource-state.used"),"1605000"); + assertEquals(ctx.getAttribute("resource-rule.service-model"),"DUMMY"); + assertEquals(ctx.getAttribute("resource-rule.endpoint-position"),"VCE-Cust"); + assertEquals(ctx.getAttribute("resource-rule.hard-limit-expression"),"max-server-" + + "speed * number-primary-servers"); + } + + @Test + public void testJSONFileParsingNoPrefix() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.json"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("equipment-data[0].max-server-speed"),"1600000"); + assertEquals(ctx.getAttribute("resource-state.used"),"1605000"); + assertEquals(ctx.getAttribute("resource-rule.service-model"),"DUMMY"); + assertEquals(ctx.getAttribute("resource-rule.endpoint-position"),"VCE-Cust"); + assertEquals(ctx.getAttribute("resource-rule.hard-limit-expression"),"max-server-" + + "speed * number-primary-servers"); + } + + @Test + public void testJSONFileParsingCtxCheck() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.json"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("equipment-data[0].max-server-speed"),"1600000"); + assertEquals(ctx.getAttribute("resource-state.used"),"1605000"); + assertEquals(ctx.getAttribute("resource-rule.service-model"),"DUMMY"); + assertEquals(ctx.getAttribute("resource-rule.endpoint-position"),"VCE-Cust"); + assertEquals(ctx.getAttribute("resource-rule.hard-limit-expression"),"max-server-" + + "speed * number-primary-servers"); + assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1"); + } + + @Test(expected = SvcLogicException.class) + public void testToPropertiesInvalidJson() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test-invalid.json"); + p.put("contextPrefix", "invalid"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1"); + } + + @Test + public void testTXTFileParsing() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.txt"); + p.put("contextPrefix", "test-txt"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("test-txt.service-data.service-information.service-type"),"AVPN"); + assertEquals(ctx.getAttribute("test-txt.service-configuration-notification-input.response-code"),"0"); + assertEquals(ctx.getAttribute("test-txt.operational-data.avpn-ip-port-information.port-" + + "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED"); + assertEquals(ctx.getAttribute("test-txt.service-data.avpn-ip-port-information.avpn-" + + "access-information.l1-customer-handoff"),"_1000BASELX"); + assertEquals(ctx.getAttribute("test-txt.service-data.avpn-ip-port-information.avpn-" + + "access-information.vlan-tag-control"),"_1Q"); + } + + @Test + public void testTXTFileParsingPrefixCheck() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.txt"); + p.put("contextPrefix", ""); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN"); + assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0"); + assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" + + "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED"); + assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" + + "access-information.l1-customer-handoff"),"_1000BASELX"); + assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" + + "access-information.vlan-tag-control"),"_1Q"); + } + + @Test + public void testTXTFileParsingNoPrefix() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.txt"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN"); + assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0"); + assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" + + "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED"); + assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" + + "access-information.l1-customer-handoff"),"_1000BASELX"); + assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" + + "access-information.vlan-tag-control"),"_1Q"); + } + + @Test + public void testTXTFileParsingCtxCheck() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.txt"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN"); + assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0"); + assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" + + "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED"); + assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" + + "access-information.l1-customer-handoff"),"_1000BASELX"); + assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" + + "access-information.vlan-tag-control"),"_1Q"); + assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1"); + } + + @Test(expected = SvcLogicException.class) + public void testToPropertiesInvalidParam() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + + Map p = new HashMap(); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1"); + } + + @Test(expected = SvcLogicException.class) + public void testToPropertiesNoParam() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + + Map p = new HashMap(); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1"); + } + + @Test(expected = SvcLogicException.class) + public void testToPropertiesFilePathError() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + + Map p = new HashMap(); + p.put("fileName", "src/tests/resources/test.txt"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1"); + } +} diff --git a/properties-node/provider/src/test/resources/test-invalid.json b/properties-node/provider/src/test/resources/test-invalid.json new file mode 100644 index 000000000..21af3ac1d --- /dev/null +++ b/properties-node/provider/src/test/resources/test-invalid.json @@ -0,0 +1,29 @@ + "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/properties-node/provider/src/test/resources/test.json b/properties-node/provider/src/test/resources/test.json new file mode 100644 index 000000000..75155393c --- /dev/null +++ b/properties-node/provider/src/test/resources/test.json @@ -0,0 +1,30 @@ +{ + "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/properties-node/provider/src/test/resources/test.txt b/properties-node/provider/src/test/resources/test.txt new file mode 100644 index 000000000..79e8acff4 --- /dev/null +++ b/properties-node/provider/src/test/resources/test.txt @@ -0,0 +1,30 @@ +operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-egress-class-queueing-policing-codes.cos2v-queueing-code = P +operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-egress-class-queueing-policing-codes.cos3-queueing-code = W +operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-per-class-queueing-behaviors.cos2-queueing = WRED +operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-per-class-queueing-behaviors.cos2v-queueing = QueueLimit +operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing = WRED +operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-behaviors.cos2-shaping = Disable +operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-behaviors.cos2v-shaping = Enable +operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-behaviors.cos3-shaping = Disable +operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-codes.cos2-shaping-code = W +operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-codes.cos2v-shaping-code = P +service-configuration-notification-input.ack-final-indicator = Y +service-configuration-notification-input.response-code = 0 +service-configuration-notification-input.response-message = Plc Activation Failed: Device gblond2005me6 Sync-from Failed. Please check device IP address and NCS setup. +service-configuration-notification-input.service-information.service-instance-id = TEST7 +service-configuration-notification-input.service-information.service-type = AVPN +service-configuration-notification-input.svc-request-id = TEST7 +service-data.avpn-ip-port-information.avpn-access-information.access-circuit-id = DHEC.54831.170.ATI +service-data.avpn-ip-port-information.avpn-access-information.access-interface = _1G +service-data.avpn-ip-port-information.avpn-access-information.access-speed = 10000 +service-data.avpn-ip-port-information.avpn-access-information.access-speed-units = Kbps +service-data.avpn-ip-port-information.avpn-access-information.l1-customer-handoff = _1000BASELX +service-data.avpn-ip-port-information.avpn-access-information.managed-ce = N +service-data.avpn-ip-port-information.avpn-access-information.vlan-tag-control = _1Q +service-data.avpn-ip-port-information.clli = LONDENEH +service-data.avpn-ip-port-information.contracted-port-speed = 10000 +service-data.avpn-ip-port-information.contracted-port-speed-units = Kbps +service-data.avpn-ip-port-information.endpoint-information.bundle-id = 33 +service-data.avpn-ip-port-information.endpoint-information.interface-string = ae0 +service-data.service-information.service-instance-id = ICORESITE-2751508 +service-data.service-information.service-type = AVPN \ No newline at end of file -- cgit From 09705266013bdc54b58a8b9791de897aafdf4b8c Mon Sep 17 00:00:00 2001 From: sb5356 Date: Fri, 15 Jun 2018 16:20:12 -0400 Subject: Capability to avoid surrounding values with quotes Restapi-call-node: Give opportunity for developer to specify a variable in a JSON template, so that restapi-call-node will know it should not surround the value with quotes. Change-Id: I844a8fd68f3015cbd6f5b039b8911e903de557ea Issue-ID: CCSDK-296 Signed-off-by: Stan Bonev --- .../ccsdk/sli/plugins/restapicall/XmlJsonUtil.java | 24 +++++++++++++++------- .../sli/plugins/restapicall/TestXmlJsonUtil.java | 6 ++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java index 965d3daaa..8a0ca8d94 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java @@ -55,8 +55,14 @@ public final class XmlJsonUtil { escape = false; } + boolean quotes = true; + if (var.startsWith("\"")) { + var = var.substring(1); + quotes = false; + } + Object o = createStructure(varmap, var); - return generateJson(o, escape); + return generateJson(o, escape, quotes); } private static Object createStructure(Map flatmap, String var) { @@ -159,22 +165,26 @@ public final class XmlJsonUtil { return null; } - private static String generateJson(Object o, boolean escape) { + 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); + 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) { + 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)); - ss.append('"').append(s).append('"'); + if (quotes) { + ss.append('"').append(s).append('"'); + } else { + ss.append(s); + } return; } @@ -193,7 +203,7 @@ public final class XmlJsonUtil { Object v = entry.getValue(); String key = entry.getKey(); ss.append(pad(indent + 1)).append('"').append(key).append("\": "); - generateJson(ss, v, indent + 1, false, escape); + generateJson(ss, v, indent + 1, false, escape, true); } ss.append("\n"); @@ -215,7 +225,7 @@ public final class XmlJsonUtil { ss.append(",\n"); first = false; - generateJson(ss, o1, indent + 1, true, escape); + generateJson(ss, o1, indent + 1, true, escape, quotes); } ss.append("\n"); diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java index 579d194d5..fcbd844fc 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java @@ -144,6 +144,12 @@ public class TestXmlJsonUtil { 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 -- cgit From 7ef4659e0b07164402cf6d7aa89b45df03063669 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Mon, 18 Jun 2018 11:54:35 -0400 Subject: Update sli/plugins to ODL Oxygen Minor updates to feature pom.xmls to get clean compile with ODL Oxygen parent poms. Change-Id: I8671ad1366b8dc2e79fe206971675ba56a0e2bac Issue-ID: CCSDK-283 Signed-off-by: Timoney, Dan (dt5972) --- .../features/ccsdk-properties-node/pom.xml | 29 ++++--- .../features/ccsdk-restapi-call-node/pom.xml | 92 +++++++++++----------- restapi-call-node/provider/pom.xml | 4 - 3 files changed, 67 insertions(+), 58 deletions(-) diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index 420ba49d9..fd38cb224 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -16,17 +16,28 @@ ccsdk-sli-plugins :: properties-node :: ${project.artifactId} - - true - + + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + ${odl.mdsal.model.version} + pom + import + + + org.opendaylight.controller + mdsal-artifacts + ${odl.mdsal.version} + pom + import + + + + - - org.opendaylight.controller - odl-mdsal-broker - xml - features - + org.onap.ccsdk.sli.core ccsdk-sli diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 43dcc74f0..822a6d1e7 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -1,53 +1,55 @@ - - 4.0.0 + + 4.0.0 - - org.onap.ccsdk.parent - single-feature-parent - 1.1.0-SNAPSHOT - - + + org.onap.ccsdk.parent + single-feature-parent + 1.1.0-SNAPSHOT + + - org.onap.ccsdk.sli.plugins - ccsdk-restapi-call-node - 0.3.0-SNAPSHOT - feature + org.onap.ccsdk.sli.plugins + ccsdk-restapi-call-node + 0.3.0-SNAPSHOT + feature - ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} + ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} + + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + ${odl.mdsal.model.version} + pom + import + + + org.opendaylight.controller + mdsal-artifacts + ${odl.mdsal.version} + pom + import + + + - - true - + - - - - org.opendaylight.controller - odl-mdsal-broker - xml - features - - - org.onap.ccsdk.sli.core - ccsdk-sli - ${ccsdk.sli.core.version} - xml - features - - - ${project.groupId} - restapi-call-node-provider - ${project.version} - - - com.sun.jersey - jersey-client - - - org.codehaus.jettison - jettison - - + + org.onap.ccsdk.sli.core + ccsdk-sli + ${ccsdk.sli.core.version} + xml + features + + + ${project.groupId} + restapi-call-node-provider + ${project.version} + + diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 4831356c3..18a20cef1 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -54,24 +54,20 @@ com.sun.jersey jersey-client - provided com.sun.jersey.contribs.jersey-oauth oauth-signature ${jersey.version} - provided com.sun.jersey.contribs.jersey-oauth oauth-client ${jersey.version} - provided org.codehaus.jettison jettison - provided -- cgit From 788e651b9234fbfeb2bb4cc052fecb06a10ef70f Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Tue, 19 Jun 2018 16:01:12 +0900 Subject: CCSDK PropNode can read XML and put to ctx Issue-ID: CCSDK-303 Change-Id: I7104e7f8735d0c1496e93cdb8112e49333b016e9 Signed-off-by: Ganesh Chandrasekaran --- README.md | 11 + .../onap/ccsdk/sli/plugins/prop/Parameters.java | 4 + .../ccsdk/sli/plugins/prop/PropertiesNode.java | 52 ++- .../org/onap/ccsdk/sli/plugins/prop/XmlParser.java | 171 ++++++++++ .../ccsdk/sli/plugins/prop/TestPropertiesNode.java | 352 +++++++++++++++++++++ .../onap/ccsdk/sli/plugins/prop/TestXmlParser.java | 121 +++++++ .../provider/src/test/resources/invalidlength.xml | 49 +++ properties-node/provider/src/test/resources/test | 30 ++ .../provider/src/test/resources/test-invalid.xml | 170 ++++++++++ .../provider/src/test/resources/test.xml | 182 +++++++++++ .../provider/src/test/resources/test3.xml | 82 +++++ 11 files changed, 1212 insertions(+), 12 deletions(-) create mode 100644 properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/XmlParser.java create mode 100644 properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestXmlParser.java create mode 100644 properties-node/provider/src/test/resources/invalidlength.xml create mode 100644 properties-node/provider/src/test/resources/test create mode 100644 properties-node/provider/src/test/resources/test-invalid.xml create mode 100644 properties-node/provider/src/test/resources/test.xml create mode 100644 properties-node/provider/src/test/resources/test3.xml diff --git a/README.md b/README.md index 3ad2eae11..05e536b16 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,14 @@ To compile this code: 2. To compile, run "mvn clean install". +PropertyNode: +1) Takes any file then parses it and puts it to the context memory for Directed Graphs access. +2) Various parameters it takes: + + public String fileName; //Name of the file to put to properties + + public String contextPrefix; //Any prefix to add for your keys in the Properties context + + public Set listNameList;//only applies to XML based file parsing, you can use this to exclude a specific tree to be put to context. + + public boolean fileBasedParsing;//enable to do a file based parsing, currently supports JSON and XML. \ No newline at end of file diff --git a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/Parameters.java b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/Parameters.java index e15f0822d..99e4647d7 100644 --- a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/Parameters.java +++ b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/Parameters.java @@ -21,7 +21,11 @@ package org.onap.ccsdk.sli.plugins.prop; +import java.util.Set; + public class Parameters { public String fileName; public String contextPrefix; + public Set listNameList; + public boolean fileBasedParsing; } diff --git a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java index 63fdeded8..cefc9c23e 100644 --- a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java +++ b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java @@ -25,8 +25,10 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.util.HashSet; import java.util.Map; import java.util.Properties; +import java.util.Set; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; @@ -46,12 +48,33 @@ public class PropertiesNode implements SvcLogicJavaPlugin { InputStream in = new FileInputStream(file); Map mm = null; String pfx = param.contextPrefix != null ? param.contextPrefix + '.' : ""; - if ("json".equalsIgnoreCase(getFileExtension(param.fileName))){ + if(param.fileBasedParsing){ byte[] data = new byte[(int) file.length()]; - in.read(data); - in.close(); - String str = new String(data, "UTF-8"); - mm = JsonParser.convertToProperties(str); + if ("json".equalsIgnoreCase(getFileExtension(param.fileName))) { + in.read(data); + String str = new String(data, "UTF-8"); + mm = JsonParser.convertToProperties(str); + } else if ("xml".equalsIgnoreCase(getFileExtension(param.fileName))) { + in.read(data); + String str = new String(data, "UTF-8"); + mm = XmlParser.convertToProperties(str, param.listNameList); + } else { + prop.load(in); + for (Object key : prop.keySet()) { + String name = (String) key; + String value = prop.getProperty(name); + if (value != null && value.trim().length() > 0) { + ctx.setAttribute(pfx + name, value.trim()); + log.info("+++ " + pfx + name + ": [" + value + "]"); + } + } + } + if (mm != null){ + for (Map.Entry entry : mm.entrySet()){ + ctx.setAttribute(pfx + entry.getKey(), entry.getValue()); + log.info("+++ " + pfx + entry.getKey() + ": [" + entry.getValue() + "]"); + } + } } else { prop.load(in); for (Object key : prop.keySet()) { @@ -63,13 +86,7 @@ public class PropertiesNode implements SvcLogicJavaPlugin { } } } - if (mm != null){ - for (Map.Entry entry : mm.entrySet()){ - ctx.setAttribute(pfx + entry.getKey(), entry.getValue()); - log.info("+++ " + pfx + entry.getKey() + ": [" + entry.getValue() + "]"); - } - } - + in.close(); } catch (IOException e) { throw new SvcLogicException("Cannot read property file: " + param.fileName + ": " + e.getMessage(), e); } @@ -92,9 +109,20 @@ public class PropertiesNode implements SvcLogicJavaPlugin { Parameters p = new Parameters(); p.fileName = parseParam(paramMap, "fileName", true, null); p.contextPrefix = parseParam(paramMap, "contextPrefix", false, null); + p.listNameList = getListNameList(paramMap); + String fileBasedParsingStr = paramMap.get("fileBasedParsing"); + p.fileBasedParsing = "true".equalsIgnoreCase(fileBasedParsingStr); return p; } + protected Set getListNameList(Map paramMap) { + Set ll = new HashSet<>(); + for (Map.Entry entry : paramMap.entrySet()) + if (entry.getKey().startsWith("listName")) + ll.add(entry.getValue()); + return ll; + } + private String parseParam(Map paramMap, String name, boolean required, String def) throws SvcLogicException { String s = paramMap.get(name); diff --git a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/XmlParser.java b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/XmlParser.java new file mode 100644 index 000000000..c9581af55 --- /dev/null +++ b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/XmlParser.java @@ -0,0 +1,171 @@ +/*- + * ============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.prop; + +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; + +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +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 static com.google.common.base.Preconditions.checkNotNull; + +public final class XmlParser { + + private static final Logger log = LoggerFactory.getLogger(XmlParser.class); + + private XmlParser() { + // Preventing instantiation of the same. + } + + public static Map convertToProperties(String s, Set 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 listNameList; + + private Map properties = new HashMap<>(); + + public Map getProperties() { + return properties; + } + + public Handler(Set 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 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/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java b/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java index 894eee997..aa3f89d12 100644 --- a/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java +++ b/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java @@ -1,7 +1,9 @@ package jtest.org.onap.ccsdk.sli.plugins.prop; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -22,6 +24,7 @@ public class TestPropertiesNode { Map p = new HashMap(); p.put("fileName", "src/test/resources/test.json"); p.put("contextPrefix", "test-json"); + p.put("fileBasedParsing","true"); PropertiesNode rcn = new PropertiesNode(); rcn.readProperties(p, ctx); @@ -37,6 +40,7 @@ public class TestPropertiesNode { Map p = new HashMap(); p.put("fileName", "src/test/resources/test.json"); p.put("contextPrefix", "test-json"); + p.put("fileBasedParsing","true"); PropertiesNode rcn = new PropertiesNode(); rcn.readProperties(p, ctx); @@ -54,6 +58,7 @@ public class TestPropertiesNode { Map p = new HashMap(); p.put("fileName", "src/test/resources/test.json"); p.put("contextPrefix", ""); + p.put("fileBasedParsing","true"); PropertiesNode rcn = new PropertiesNode(); rcn.readProperties(p, ctx); @@ -72,6 +77,7 @@ public class TestPropertiesNode { Map p = new HashMap(); p.put("fileName", "src/test/resources/test.json"); + p.put("fileBasedParsing","true"); PropertiesNode rcn = new PropertiesNode(); rcn.readProperties(p, ctx); @@ -91,6 +97,7 @@ public class TestPropertiesNode { Map p = new HashMap(); p.put("fileName", "src/test/resources/test.json"); + p.put("fileBasedParsing","true"); PropertiesNode rcn = new PropertiesNode(); rcn.readProperties(p, ctx); @@ -112,6 +119,7 @@ public class TestPropertiesNode { Map p = new HashMap(); p.put("fileName", "src/test/resources/test-invalid.json"); p.put("contextPrefix", "invalid"); + p.put("fileBasedParsing","true"); PropertiesNode rcn = new PropertiesNode(); rcn.readProperties(p, ctx); @@ -126,6 +134,7 @@ public class TestPropertiesNode { Map p = new HashMap(); p.put("fileName", "src/test/resources/test.txt"); p.put("contextPrefix", "test-txt"); + p.put("fileBasedParsing","true"); PropertiesNode rcn = new PropertiesNode(); rcn.readProperties(p, ctx); @@ -147,6 +156,7 @@ public class TestPropertiesNode { Map p = new HashMap(); p.put("fileName", "src/test/resources/test.txt"); p.put("contextPrefix", ""); + p.put("fileBasedParsing","true"); PropertiesNode rcn = new PropertiesNode(); rcn.readProperties(p, ctx); @@ -167,6 +177,7 @@ public class TestPropertiesNode { Map p = new HashMap(); p.put("fileName", "src/test/resources/test.txt"); + p.put("fileBasedParsing","true"); PropertiesNode rcn = new PropertiesNode(); rcn.readProperties(p, ctx); @@ -188,6 +199,7 @@ public class TestPropertiesNode { Map p = new HashMap(); p.put("fileName", "src/test/resources/test.txt"); + p.put("fileBasedParsing","true"); PropertiesNode rcn = new PropertiesNode(); rcn.readProperties(p, ctx); @@ -211,6 +223,7 @@ public class TestPropertiesNode { Map p = new HashMap(); p.put("responsePrefix", "response"); p.put("skipSending", "true"); + p.put("fileBasedParsing","true"); PropertiesNode rcn = new PropertiesNode(); rcn.readProperties(p, ctx); @@ -224,6 +237,7 @@ public class TestPropertiesNode { ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); Map p = new HashMap(); + p.put("fileBasedParsing","true"); PropertiesNode rcn = new PropertiesNode(); rcn.readProperties(p, ctx); @@ -238,10 +252,348 @@ public class TestPropertiesNode { Map p = new HashMap(); p.put("fileName", "src/tests/resources/test.txt"); + p.put("fileBasedParsing","true"); PropertiesNode rcn = new PropertiesNode(); rcn.readProperties(p, ctx); assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1"); } + + @Test + public void testXMLFileParsing() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.xml"); + p.put("contextPrefix", "test-xml"); + p.put("listName", "project.build"); + p.put("fileBasedParsing","true"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("test-xml.project.modelVersion"),"4.0.0"); + } + + @Test + public void testXMLFileInnerParsing() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.xml"); + p.put("contextPrefix", "test-xml"); + p.put("listName", "project.modelVersion"); + p.put("fileBasedParsing","true"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("test-xml.project.properties.project.build.sourceEncoding"),"UTF-8"); + assertEquals(ctx.getAttribute("test-xml.project.dependencies.dependency.scope"),"provided"); + assertEquals(ctx.getAttribute("test-xml.project.build.pluginManagement.plugins.plugin.configuration" + + ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." + + "pluginExecutionFilter.versionRange"),"[1.2.0.100-SNAPSHOT,)"); + assertEquals(ctx.getAttribute("test-xml.project.build.plugins.plugin.configuration." + + "instructions.Import-Package"),"*"); + } + + @Test + public void testXMLFileParsingPrefixCheck() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.xml"); + p.put("contextPrefix", ""); + p.put("fileBasedParsing","true"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("project.properties.project.build.sourceEncoding"),"UTF-8"); + assertEquals(ctx.getAttribute("project.dependencies.dependency.scope"),"provided"); + assertEquals(ctx.getAttribute("project.build.pluginManagement.plugins.plugin.configuration" + + ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." + + "pluginExecutionFilter.versionRange"),"[1.2.0.100-SNAPSHOT,)"); + assertEquals(ctx.getAttribute("project.build.plugins.plugin.configuration." + + "instructions.Import-Package"),"*"); + } + + @Test + public void testXMLFileParsingNoPrefix() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.xml"); + p.put("fileBasedParsing","true"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("project.properties.project.build.sourceEncoding"),"UTF-8"); + assertEquals(ctx.getAttribute("project.dependencies.dependency.scope"),"provided"); + assertEquals(ctx.getAttribute("project.build.pluginManagement.plugins.plugin.configuration" + + ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." + + "pluginExecutionFilter.versionRange"),"[1.2.0.100-SNAPSHOT,)"); + assertEquals(ctx.getAttribute("project.build.plugins.plugin.configuration." + + "instructions.Import-Package"),"*"); + } + + @Test + public void testXMLFileParsingCtxCheck() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.xml"); + p.put("fileBasedParsing","true"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("project.properties.project.build.sourceEncoding"),"UTF-8"); + assertEquals(ctx.getAttribute("project.dependencies.dependency.scope"),"provided"); + assertEquals(ctx.getAttribute("project.build.pluginManagement.plugins.plugin.configuration" + + ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." + + "pluginExecutionFilter.versionRange"),"[1.2.0.100-SNAPSHOT,)"); + assertEquals(ctx.getAttribute("project.build.plugins.plugin.configuration." + + "instructions.Import-Package"),"*"); + assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1"); + } + + @Test(expected = SvcLogicException.class) + public void testToPropertiesInvalidXML() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test-invalid.xml"); + p.put("contextPrefix", "invalid"); + p.put("fileBasedParsing","true"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1"); + } + + @Test + public void testXMLFileParsingListName() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.xml"); + p.put("contextPrefix", "test-xml-listName"); + p.put("fileBasedParsing","true"); + p.put("listName", "project.build.pluginManagement"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("test-xml-listName.project.build." + + "pluginManagement.plugins.plugin.version"),null); + assertEquals(ctx.getAttribute("test-xml-listName.project.build." + + "plugins.plugin.groupId"),"org.apache.felix"); + } + + @Test + public void testXMLFileParsingListNameAnother() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.xml"); + p.put("contextPrefix", "test-xml-listName"); + p.put("fileBasedParsing","true"); + p.put("listName", "project.modelVersion"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("test-xml-listName.project.modelVersion"),null); + assertEquals(ctx.getAttribute("test-xml-listName.project.build." + + "plugins.plugin.groupId"),"org.apache.felix"); + } + + @Test + public void testTXTFileParsingNotFileBased() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.txt"); + p.put("contextPrefix", "test-txt"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("test-txt.service-data.service-information.service-type"),"AVPN"); + assertEquals(ctx.getAttribute("test-txt.service-configuration-notification-input.response-code"),"0"); + assertEquals(ctx.getAttribute("test-txt.operational-data.avpn-ip-port-information.port-" + + "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED"); + assertEquals(ctx.getAttribute("test-txt.service-data.avpn-ip-port-information.avpn-" + + "access-information.l1-customer-handoff"),"_1000BASELX"); + assertEquals(ctx.getAttribute("test-txt.service-data.avpn-ip-port-information.avpn-" + + "access-information.vlan-tag-control"),"_1Q"); + } + + @Test + public void testTXTFileParsingPrefixCheckNotFileBased() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.txt"); + p.put("contextPrefix", ""); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN"); + assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0"); + assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" + + "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED"); + assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" + + "access-information.l1-customer-handoff"),"_1000BASELX"); + assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" + + "access-information.vlan-tag-control"),"_1Q"); + } + + @Test + public void testTXTFileParsingNoPrefixNotFileBased() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.txt"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN"); + assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0"); + assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" + + "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED"); + assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" + + "access-information.l1-customer-handoff"),"_1000BASELX"); + assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" + + "access-information.vlan-tag-control"),"_1Q"); + } + + @Test + public void testTXTFileParsingCtxCheckNotFileBased() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.txt"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN"); + assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0"); + assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" + + "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED"); + assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" + + "access-information.l1-customer-handoff"),"_1000BASELX"); + assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" + + "access-information.vlan-tag-control"),"_1Q"); + assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1"); + } + + @Test + public void testJSONFileArrayParsingNotFileBased() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.json"); + p.put("contextPrefix", "NotFileBased"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("NotFileBased.\"limit-value\""),"\"1920000\""); + assertEquals(ctx.getAttribute("NotFileBased.\"hard-limit-expression\""),"\"max-server-speed * number-primary-servers\","); + assertEquals(ctx.getAttribute("NotFileBased.\"test-inner-node\""),"\"Test-Value\""); + } + + @Test + public void testXMLFileInnerParsingNotFileBased() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test.xml"); + p.put("contextPrefix", "NotFileBased"); + p.put("listName", "project.modelVersion"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("NotFileBased.RESTAPI"),"Call Node - Provider"); + assertEquals(ctx.getAttribute("NotFileBased."); + assertEquals(ctx.getAttribute("NotFileBased.openECOMP"),"SDN-C"); + assertEquals(ctx.getAttribute("NotFileBased."); + } + + @Test + public void testNoFileTypeNoPrefixNotFileBased() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test"); + p.put("fileBasedParsing","true"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN"); + assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0"); + assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" + + "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED"); + assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" + + "access-information.l1-customer-handoff"),"_1000BASELX"); + assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" + + "access-information.vlan-tag-control"),"_1Q"); + } + + @Test(expected = SvcLogicException.class) + public void testNoFileTypeParseReqError() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("file Name", "src/test/resources/test"); + p.put("fileBasedParsing","true"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN"); + assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0"); + assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" + + "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED"); + assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" + + "access-information.l1-customer-handoff"),"_1000BASELX"); + assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" + + "access-information.vlan-tag-control"),"_1Q"); + } + + @Test + public void testNoFileTypeParseError() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("fileName", "src/test/resources/test"); + p.put("file Based % Parsing","true"); + + PropertiesNode rcn = new PropertiesNode(); + rcn.readProperties(p, ctx); + + assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN"); + assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0"); + assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" + + "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED"); + assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" + + "access-information.l1-customer-handoff"),"_1000BASELX"); + assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" + + "access-information.vlan-tag-control"),"_1Q"); + } } diff --git a/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestXmlParser.java b/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestXmlParser.java new file mode 100644 index 000000000..7cd072ed8 --- /dev/null +++ b/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestXmlParser.java @@ -0,0 +1,121 @@ +/*- + * ============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 jtest.org.onap.ccsdk.sli.plugins.prop; + +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.prop.XmlParser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +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 static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +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 listNameList = new HashSet(); + 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 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 listNameList = new HashSet(); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); + + Map 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 listNameList = new HashSet(); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); + + Map mm = XmlParser.convertToProperties(b.toString(), listNameList); + logProperties(mm); + in.close(); + } + + private void logProperties(Map mm) { + List 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/properties-node/provider/src/test/resources/invalidlength.xml b/properties-node/provider/src/test/resources/invalidlength.xml new file mode 100644 index 000000000..c086d564e --- /dev/null +++ b/properties-node/provider/src/test/resources/invalidlength.xml @@ -0,0 +1,49 @@ + + + + + + ICOREPVC-81114561 + + VPNL811182 + 811182 + 21302:811182 + SET_BVOIP_IN + SET6_BVOIP_IN + a + SET6_DSU + SET_DSU + SET6_MANAGED + SET_MANAGED + SET_LOVRF_COMMUNITY + SET_RESET_LP + + AG_MAX_MCASTROUTES + + + + 200 + Success + Y + + diff --git a/properties-node/provider/src/test/resources/test b/properties-node/provider/src/test/resources/test new file mode 100644 index 000000000..79e8acff4 --- /dev/null +++ b/properties-node/provider/src/test/resources/test @@ -0,0 +1,30 @@ +operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-egress-class-queueing-policing-codes.cos2v-queueing-code = P +operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-egress-class-queueing-policing-codes.cos3-queueing-code = W +operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-per-class-queueing-behaviors.cos2-queueing = WRED +operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-per-class-queueing-behaviors.cos2v-queueing = QueueLimit +operational-data.avpn-ip-port-information.port-level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing = WRED +operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-behaviors.cos2-shaping = Disable +operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-behaviors.cos2v-shaping = Enable +operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-behaviors.cos3-shaping = Disable +operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-codes.cos2-shaping-code = W +operational-data.avpn-ip-port-information.port-level-cos.shaping.pe-egress-per-class-shaping-codes.cos2v-shaping-code = P +service-configuration-notification-input.ack-final-indicator = Y +service-configuration-notification-input.response-code = 0 +service-configuration-notification-input.response-message = Plc Activation Failed: Device gblond2005me6 Sync-from Failed. Please check device IP address and NCS setup. +service-configuration-notification-input.service-information.service-instance-id = TEST7 +service-configuration-notification-input.service-information.service-type = AVPN +service-configuration-notification-input.svc-request-id = TEST7 +service-data.avpn-ip-port-information.avpn-access-information.access-circuit-id = DHEC.54831.170.ATI +service-data.avpn-ip-port-information.avpn-access-information.access-interface = _1G +service-data.avpn-ip-port-information.avpn-access-information.access-speed = 10000 +service-data.avpn-ip-port-information.avpn-access-information.access-speed-units = Kbps +service-data.avpn-ip-port-information.avpn-access-information.l1-customer-handoff = _1000BASELX +service-data.avpn-ip-port-information.avpn-access-information.managed-ce = N +service-data.avpn-ip-port-information.avpn-access-information.vlan-tag-control = _1Q +service-data.avpn-ip-port-information.clli = LONDENEH +service-data.avpn-ip-port-information.contracted-port-speed = 10000 +service-data.avpn-ip-port-information.contracted-port-speed-units = Kbps +service-data.avpn-ip-port-information.endpoint-information.bundle-id = 33 +service-data.avpn-ip-port-information.endpoint-information.interface-string = ae0 +service-data.service-information.service-instance-id = ICORESITE-2751508 +service-data.service-information.service-type = AVPN \ No newline at end of file diff --git a/properties-node/provider/src/test/resources/test-invalid.xml b/properties-node/provider/src/test/resources/test-invalid.xml new file mode 100644 index 000000000..50bd0fff2 --- /dev/null +++ b/properties-node/provider/src/test/resources/test-invalid.xml @@ -0,0 +1,170 @@ + + + + + 4.0.0 + + org.onap.ccsdk.sli.plugins + restapi-call-node + 6.0.0-SNAPSHOT + + restapi-call-node-provider + bundle + RESTAPI Call Node - Provider + http://maven.apache.org + + UTF-8 + + + + junit + junit + test + + + org.springframework + spring-test + 3.1.4.RELEASE + test + + + org.onap.ccsdk.sli + sli-common + compile + + + org.onap.ccsdk.sli + sli-provider + compile + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + org.springframework + spring-beans + 3.1.4.RELEASE + + + org.springframework + spring-context + 3.1.4.RELEASE + + + xerces + xerces + 2.4.0 + provided + + + com.sun.jersey + jersey-client + 1.17 + + + com.s + + + + + + com.brocade.developer + providermodule-plugin + + org.onap.ccsdk.sli.plugins + restapi-call-node + + + + process-sources + + process + + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + org.onap.ccsdk.sli.plugins.restapicall + org.onap.ccsdk.sli.plugins.restapicall + * + + + ${project.basedir}/src/main/resources/META-INF + + + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + com.brocade.developer + + + providermodule-plugin + + + [1.2.0.100-SNAPSHOT,) + + + process + + + + + + + + + + + + + + diff --git a/properties-node/provider/src/test/resources/test.xml b/properties-node/provider/src/test/resources/test.xml new file mode 100644 index 000000000..1974f688e --- /dev/null +++ b/properties-node/provider/src/test/resources/test.xml @@ -0,0 +1,182 @@ + + + + + 4.0.0 + + org.onap.ccsdk.sli.plugins + restapi-call-node + 6.0.0-SNAPSHOT + + restapi-call-node-provider + bundle + RESTAPI Call Node - Provider + http://maven.apache.org + + UTF-8 + + + + junit + junit + test + + + org.springframework + spring-test + 3.1.4.RELEASE + test + + + org.onap.ccsdk.sli + sli-common + compile + + + org.onap.ccsdk.sli + sli-provider + compile + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + org.springframework + spring-beans + 3.1.4.RELEASE + + + org.springframework + spring-context + 3.1.4.RELEASE + + + xerces + xerces + 2.4.0 + provided + + + com.sun.jersey + jersey-client + 1.17 + + + com.sun.jersey.contribs.jersey-oauth + oauth-signature + 1.17 + + + com.sun.jersey.contribs.jersey-oauth + oauth-client + 1.17 + + + commons-codec + commons-codec + + + + + + + com.brocade.developer + providermodule-plugin + + org.onap.ccsdk.sli.plugins + restapi-call-node + + + + process-sources + + process + + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + org.onap.ccsdk.sli.plugins.restapicall + org.onap.ccsdk.sli.plugins.restapicall + * + + + ${project.basedir}/src/main/resources/META-INF + + + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + com.brocade.developer + + + providermodule-plugin + + + [1.2.0.100-SNAPSHOT,) + + + process + + + + + + + + + + + + + + diff --git a/properties-node/provider/src/test/resources/test3.xml b/properties-node/provider/src/test/resources/test3.xml new file mode 100644 index 000000000..ade412681 --- /dev/null +++ b/properties-node/provider/src/test/resources/test3.xml @@ -0,0 +1,82 @@ + + + + + + ICOREPVC-81114561 + + VPNL811182 + 811182 + 21302:811182 + SET_BVOIP_IN + SET6_BVOIP_IN + SET6_DSU + SET_DSU + SET6_MANAGED + SET_MANAGED + SET_LOVRF_COMMUNITY + SET_RESET_LP + + AG_MAX_MCASTROUTES + + + + BGP4_PROTOCOL + v4 + gp_21302:811182 + + AG_L3VPN_EBGP + + + AG_MAX_PREFIX + + + AG_BGP_UNMANAGED + + + AG_BFD_BGP_3000 + + + + BGP4_PROTOCOL + v6 + gp6_21302:811182 + + AG6_L3VPN_EBGP + + + AG6_MAX_PREFIX + + + AG6_BGP_UNMANAGED + + + AG6_BFD_BGP_3000 + + + + 200 + Success + Y + + -- cgit From e8670e23820ae4d648b88c050b46add498303a9f Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 22 Jun 2018 15:53:19 -0400 Subject: Add feature aggregator Added feature aggregator ccsdk-sli-plugins-all so that all features from sli/plugins repo can be added with one install. Change-Id: I85ff00612ee60e69937c7b10d814cf81198ed51c Issue-ID: CCSDK-283 Signed-off-by: Timoney, Dan (dt5972) --- features/ccsdk-sli-plugins-all/pom.xml | 58 +++++++++ features/features-sli-plugins/pom.xml | 29 +++++ features/installer/pom.xml | 137 +++++++++++++++++++++ .../src/assembly/assemble_installer_zip.xml | 39 ++++++ .../src/assembly/assemble_mvnrepo_zip.xml | 29 +++++ .../src/main/resources/scripts/install-feature.sh | 18 +++ features/pom.xml | 24 ++++ pom.xml | 1 + properties-node/installer/pom.xml | 4 +- .../src/assembly/assemble_mvnrepo_zip.xml | 2 +- restapi-call-node/installer/pom.xml | 4 +- .../src/assembly/assemble_mvnrepo_zip.xml | 2 +- 12 files changed, 341 insertions(+), 6 deletions(-) create mode 100644 features/ccsdk-sli-plugins-all/pom.xml create mode 100644 features/features-sli-plugins/pom.xml create mode 100755 features/installer/pom.xml create mode 100755 features/installer/src/assembly/assemble_installer_zip.xml create mode 100755 features/installer/src/assembly/assemble_mvnrepo_zip.xml create mode 100644 features/installer/src/main/resources/scripts/install-feature.sh create mode 100755 features/pom.xml diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml new file mode 100644 index 000000000..756e75902 --- /dev/null +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -0,0 +1,58 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.1.0-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + ccsdk-sli-plugins-all + 0.3.0-SNAPSHOT + feature + + ccsdk-sli-plugins :: features :: ${project.artifactId} + + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + ${odl.mdsal.model.version} + pom + import + + + org.opendaylight.controller + mdsal-artifacts + ${odl.mdsal.version} + pom + import + + + + + + + ${project.groupId} + ccsdk-properties-node + ${project.version} + xml + features + + + ${project.groupId} + ccsdk-restapi-call-node + ${project.version} + xml + features + + + + + + diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml new file mode 100644 index 000000000..0b43d1a0d --- /dev/null +++ b/features/features-sli-plugins/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + feature-repo-parent + 1.1.0-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + features-sli-plugins + 0.3.0-SNAPSHOT + feature + + ccsdk-sli-plugins :: features :: ${project.artifactId} + + + + ${project.groupId} + ccsdk-sli-plugins-all + ${project.version} + xml + features + + + + diff --git a/features/installer/pom.xml b/features/installer/pom.xml new file mode 100755 index 000000000..050d3e9d5 --- /dev/null +++ b/features/installer/pom.xml @@ -0,0 +1,137 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.1.0-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + sliplugins-features-installer + 0.3.0-SNAPSHOT + pom + + ccsdk-sli-plugins :: features :: ${project.artifactId} + + + ccsdk-sli-plugins-all + ${application.name} + mvn:org.onap.ccsdk.sli.plugins/${features.boot}/${project.version}/xml/features + false + + + + + + org.onap.ccsdk.sli.plugins + ${application.name} + ${project.version} + xml + features + + + * + * + + + + + + + + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + true + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + true + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli.plugins + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + + + diff --git a/features/installer/src/assembly/assemble_installer_zip.xml b/features/installer/src/assembly/assemble_installer_zip.xml new file mode 100755 index 000000000..a6a22a9ba --- /dev/null +++ b/features/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,39 @@ + + + + bin + + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + + + + diff --git a/features/installer/src/assembly/assemble_mvnrepo_zip.xml b/features/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100755 index 000000000..86b07f1f3 --- /dev/null +++ b/features/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,29 @@ + + + + repo + + + zip + + + + false + + + + target/assembly/ + . + + + + + + + + diff --git a/features/installer/src/main/resources/scripts/install-feature.sh b/features/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..e16e79a12 --- /dev/null +++ b/features/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} feature:install ${features.boot} diff --git a/features/pom.xml b/features/pom.xml new file mode 100755 index 000000000..3ac87bf6b --- /dev/null +++ b/features/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.1.0-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + sliplugins-feature-aggregator + 0.3.0-SNAPSHOT + pom + + ccsdk-sli-plugins :: features + + + ccsdk-sli-plugins-all + features-sli-plugins + installer + + diff --git a/pom.xml b/pom.xml index 8c1301332..b6efa94ce 100755 --- a/pom.xml +++ b/pom.xml @@ -23,6 +23,7 @@ properties-node restapi-call-node + features diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index c9a11c613..965bdbb77 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -59,12 +59,12 @@ package - false + true stage/${application.name}-${project.version} src/assembly/assemble_mvnrepo_zip.xml - false + true diff --git a/properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml b/properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml index 2ee224477..9cdc78879 100644 --- a/properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml +++ b/properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -25,7 +25,7 @@ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> - mvnrepo_zip + repo zip diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 0badf58b5..8e2f402eb 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -66,12 +66,12 @@ package - false + true stage/${application.name}-${project.version} src/assembly/assemble_mvnrepo_zip.xml - false + true diff --git a/restapi-call-node/installer/src/assembly/assemble_mvnrepo_zip.xml b/restapi-call-node/installer/src/assembly/assemble_mvnrepo_zip.xml index cb56f2cd4..35e79db18 100644 --- a/restapi-call-node/installer/src/assembly/assemble_mvnrepo_zip.xml +++ b/restapi-call-node/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -25,7 +25,7 @@ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> - mvnrepo_zip + repo zip -- cgit From 6603a6b208f454e87215047a3116ca6d40cc56c2 Mon Sep 17 00:00:00 2001 From: as005h Date: Tue, 8 May 2018 14:01:50 -0400 Subject: Share http payload of restapi-call-node Changes to save request payload to context variable based on returnRequestPayload flag Change-Id: I75069f700f34848904204049d6160251ea43578d Issue-ID: CCSDK-365 Signed-off-by: Timoney, Dan (dt5972) --- properties-node/provider/pom.xml | 1 - .../java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java | 1 + .../org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java | 6 ++++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index b3a1cf533..a9a3c94d5 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -46,7 +46,6 @@ org.codehaus.jettison jettison - provided diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java index c170cfc7d..d3fec37ee 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java @@ -49,4 +49,5 @@ public class Parameters { public String oAuthSignatureMethod; public String oAuthVersion; public AuthType authtype; + public Boolean returnRequestPayload; } diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index d215d9092..5168b3ec1 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -112,6 +112,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { * * * + * * *
restapiUrlMandatoryurl to send the request tohttps://sdncodl:8543/restconf/operations/L3VNF-API:create-update-vnf-request
restapiUserOptionaluser name to use for http basic authenticationsdnc_ws
restapiPasswordOptionalunencrypted password to use for http basic authenticationplain_password
oAuthConsumerKeyOptionalConsumer key to use for http oAuth authenticationplain_key
oAuthConsumerSecretOptionalConsumer secret to use for http oAuth authenticationplain_secret
oAuthSignatureMethodOptionalConsumer method to use for http oAuth authenticationmethod
oAuthVersionOptionalVersion http oAuth authenticationversion
contentTypeOptionalhttp content type to set in the http headerusually application/json or application/xml
formatOptionalshould match request body formatjson or xml
httpMethodOptionalhttp method to use when sending the requestget post put delete patch
customHttpHeadersOptionala list additional http headers to be passed in, follow the format in the exampleX-CSI-MessageId=messageId,headerFieldName=headerFieldValue
dumpHeadersOptionalwhen true writes http header content to context memorytrue or false
partnerOptionalneeded for DME2 callsdme2proxy
returnRequestPayloadOptionalused to return payload built in the requesttrue or false
* @param ctx Reference to context memory @@ -150,6 +151,10 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { ctx.setAttribute(pp + "header." + a.getKey(), StringUtils.join(a.getValue(), ",")); } } + + if (p.returnRequestPayload && req != null) { + ctx.setAttribute(pp + "httpRequest", req); + } if (r.body != null && r.body.trim().length() > 0) { ctx.setAttribute(pp + "httpResponse", r.body); @@ -246,6 +251,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { p.customHttpHeaders = parseParam(paramMap, "customHttpHeaders", false, null); p.partner = parseParam(paramMap, "partner", false, null); p.dumpHeaders = Boolean.valueOf(parseParam(paramMap, "dumpHeaders", false, null)); + p.returnRequestPayload = Boolean.valueOf(parseParam(paramMap, "returnRequestPayload", false, null)); return p; } -- cgit From d6a56cd8f71cc196083c6ab16e86d24c7c89f9ef Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Thu, 19 Jul 2018 11:17:06 +0900 Subject: SSHApiCallNode API definition Issue-ID: CCSDK-384 Change-Id: I558bb774081074fbd1c541512d767a9ca5d1f866 Signed-off-by: Ganesh Chandrasekaran --- pom.xml | 1 + .../sli/plugins/restapicall/TestJsonParser.java | 73 --- .../plugins/restapicall/TestRestapiCallNode.java | 575 --------------------- .../sli/plugins/restapicall/TestXmlJsonUtil.java | 262 ---------- .../sli/plugins/restapicall/TestXmlParser.java | 121 ----- .../sli/plugins/sshapicall/TestJsonParser.java | 73 +++ .../plugins/sshapicall/TestRestapiCallNode.java | 575 +++++++++++++++++++++ .../sli/plugins/sshapicall/TestXmlJsonUtil.java | 262 ++++++++++ .../sli/plugins/sshapicall/TestXmlParser.java | 121 +++++ sshapi-call-node/.gitignore | 34 ++ .../features/ccsdk-sshapi-call-node/pom.xml | 55 ++ .../features/features-sshapi-call-node/pom.xml | 31 ++ sshapi-call-node/features/pom.xml | 24 + .../features/src/main/resources/features.xml | 51 ++ sshapi-call-node/installer/pom.xml | 148 ++++++ .../src/assembly/assemble_installer_zip.xml | 59 +++ .../src/assembly/assemble_mvnrepo_zip.xml | 49 ++ .../src/main/resources/scripts/install-feature.sh | 39 ++ sshapi-call-node/pom.xml | 24 + sshapi-call-node/provider/pom.xml | 73 +++ .../sli/plugins/sshapicall/SshApiCallNode.java | 84 +++ .../sli/plugins/sshapicall/impl/AuthType.java | 19 + .../ccsdk/sli/plugins/sshapicall/impl/Format.java | 39 ++ .../sli/plugins/sshapicall/impl/Parameters.java | 42 ++ .../sshapicall/impl/SshapiCallNodeImpl.java | 43 ++ .../sli/plugins/sshapicall/model/JsonParser.java | 96 ++++ .../plugins/sshapicall/model/RetryException.java | 32 ++ .../sli/plugins/sshapicall/model/RetryPolicy.java | 62 +++ .../plugins/sshapicall/model/RetryPolicyStore.java | 56 ++ .../sli/plugins/sshapicall/model/XmlJsonUtil.java | 389 ++++++++++++++ .../sli/plugins/sshapicall/model/XmlParser.java | 174 +++++++ .../META-INF/spring/sshapi-call-node-context.xml | 51 ++ .../spring/sshapi-call-node-osgi-context.xml | 34 ++ .../blueprint/sshapi-call-node-blueprint.xml | 16 + .../sli/plugins/sshapicall/TestJsonParser.java | 75 +++ .../sli/plugins/sshapicall/TestXmlJsonUtil.java | 264 ++++++++++ .../sli/plugins/sshapicall/TestXmlParser.java | 123 +++++ .../provider/src/test/resources/invalidlength.xml | 49 ++ .../provider/src/test/resources/test-template.json | 57 ++ .../provider/src/test/resources/test.json | 51 ++ .../provider/src/test/resources/test.xml | 184 +++++++ .../provider/src/test/resources/test3.xml | 82 +++ 42 files changed, 3641 insertions(+), 1031 deletions(-) delete mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java delete mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java delete mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java delete mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java create mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java create mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestRestapiCallNode.java create mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java create mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java create mode 100755 sshapi-call-node/.gitignore create mode 100644 sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml create mode 100644 sshapi-call-node/features/features-sshapi-call-node/pom.xml create mode 100755 sshapi-call-node/features/pom.xml create mode 100644 sshapi-call-node/features/src/main/resources/features.xml create mode 100755 sshapi-call-node/installer/pom.xml create mode 100644 sshapi-call-node/installer/src/assembly/assemble_installer_zip.xml create mode 100644 sshapi-call-node/installer/src/assembly/assemble_mvnrepo_zip.xml create mode 100644 sshapi-call-node/installer/src/main/resources/scripts/install-feature.sh create mode 100755 sshapi-call-node/pom.xml create mode 100755 sshapi-call-node/provider/pom.xml create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/SshApiCallNode.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/AuthType.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Format.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Parameters.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/SshapiCallNodeImpl.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryException.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicy.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicyStore.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlJsonUtil.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java create mode 100644 sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-context.xml create mode 100644 sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-osgi-context.xml create mode 100755 sshapi-call-node/provider/src/main/resources/org/opendaylight/blueprint/sshapi-call-node-blueprint.xml create mode 100644 sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java create mode 100644 sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java create mode 100644 sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java create mode 100644 sshapi-call-node/provider/src/test/resources/invalidlength.xml create mode 100644 sshapi-call-node/provider/src/test/resources/test-template.json create mode 100644 sshapi-call-node/provider/src/test/resources/test.json create mode 100644 sshapi-call-node/provider/src/test/resources/test.xml create mode 100644 sshapi-call-node/provider/src/test/resources/test3.xml diff --git a/pom.xml b/pom.xml index b6efa94ce..ecdce6505 100755 --- a/pom.xml +++ b/pom.xml @@ -23,6 +23,7 @@ properties-node restapi-call-node + sshapi-call-node features diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java deleted file mode 100644 index 5526be81f..000000000 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============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 jtest.org.onap.ccsdk.sli.plugins.restapicall; - -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.restapicall.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 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 mm) { - List 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/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java deleted file mode 100644 index 81806f6de..000000000 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ /dev/null @@ -1,575 +0,0 @@ -/*- - * ============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 jtest.org.onap.ccsdk.sli.plugins.restapicall; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestRestapiCallNode { - - private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class); - - - @Test - public void testDelete() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "pwd1"); - p.put("httpMethod", "delete"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testJsonTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.sdn-circuit-req-row_length", "3"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].clci", "clci"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].clci", "clci"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/test-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testInvalidRepeatTimes() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.sdn-circuit-req-row_length", "a"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/test-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testInvalidTemplatePath() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resourcess/test-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testWithoutSkipSending() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/test-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "false"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - - @Test(expected = SvcLogicException.class) - public void testWithInvalidURI() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/test-template.json"); - p.put("restapiUrl", "http://echo. getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "false"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testVpnJsonTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); - ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); - p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "restapi-result"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testSiteJsonTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); - ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); - - ctx.setAttribute("prop.l3vpn.site1_name", "10000000-0000-0000-0000-000000000002"); - ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003"); - ctx.setAttribute("prop.l3vpn.entry1-id", "1"); - ctx.setAttribute("prop.l3vpn.sna1_name", "10000000-0000-0000-0000-000000000004"); - ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e"); - ctx.setAttribute("prop.l3vpn.ac1_id", "a8098c1a-f86e-11da-bd1a-00112444be1b"); - ctx.setAttribute("prop.l3vpn.ac1-peer-ip", "192.168.1.1"); - ctx.setAttribute("prop.l3vpn.ac1-ip", "192.168.1.2"); - ctx.setAttribute("prop.l3vpn.sna1_svlan", "100"); - ctx.setAttribute("prop.l3vpn.ac1_protocol", "static"); - ctx.setAttribute("prop.l3vpn.sna1-route.ip-prefix", "192.168.1.1/24"); - ctx.setAttribute("prop.l3vpn.sna1-route.next-hop", "192.168.1.4"); - - ctx.setAttribute("prop.l3vpn.site2_name", "10000000-0000-0000-0000-000000000005"); - ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006"); - ctx.setAttribute("prop.l3vpn.entry2-id", "1"); - ctx.setAttribute("prop.l3vpn.sna2_name", "10000000-0000-0000-0000-000000000007"); - ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a"); - ctx.setAttribute("prop.l3vpn.ac2_id", "a8098c1a-f86e-11da-bd1a-00112444be1c"); - ctx.setAttribute("prop.l3vpn.ac2-peer-ip", "192.168.1.6"); - ctx.setAttribute("prop.l3vpn.ac2-ip", "192.168.1.5"); - ctx.setAttribute("prop.l3vpn.sna2_svlan", "200"); - ctx.setAttribute("prop.l3vpn.ac2_protocol", "bgp"); - ctx.setAttribute("prop.l3vpn.peer2-ip", "192.168.1.7"); - ctx.setAttribute("prop.l3vpn.ac2_protocol_bgp_as", "200"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/l3smsitetemplate.json"); - p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/sites"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "restapi-result"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testVrfJsonTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.l3vpn.vrf1-id", "10000000-0000-0000-0000-000000000007"); - ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003"); - ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e"); - ctx.setAttribute("prop.l3vpn.vrf2-id", "10000000-0000-0000-0000-000000000009"); - ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006"); - ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/l3smvrftemplate.json"); - p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vrf-attributes"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "restapi-result"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteVpnJsonTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); - ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); - - Map p = new HashMap(); - //p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); - p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services" - + "/vpnservice=10000000-0000-0000-0000-000000000001"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("format", "json"); - p.put("httpMethod", "delete"); - p.put("responsePrefix", "restapi-result"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testL2DciTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.dci-connects.id", "Id1"); - ctx.setAttribute("prop.dci-connects.name", "Name1"); - ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1"); - ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2"); - ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1"); - ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2"); - ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1"); - ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2"); - ctx.setAttribute("prop.dci-connects.vni", "1"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/l2-dci-connects-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testL3DciTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.dci-connects.id", "Id1"); - ctx.setAttribute("prop.dci-connects.name", "Name1"); - ctx.setAttribute("prop.dci-connects.local_networks_length", "2"); - ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1"); - ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2"); - ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1"); - ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2"); - ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1"); - ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2"); - ctx.setAttribute("prop.dci-connects.vni", "1"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/l3-dci-connects-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - - } - - @Test - public void testControllerTokenTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.user", "admin"); - ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.password", "admin123"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/actokentemplate.json"); - p.put("restapiUrl", "https://ipwan:18002/controller/v2/tokens"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "restapi-result"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - - @Test - public void testDeleteNoneAsContentType() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "pwd1"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testPostNoneAsContentType() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); - ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); - p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("format", "none"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "restapi-result"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteOAuthType() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("oAuthSignatureMethod", "plainTEXT"); - p.put("oAuthVersion", "1.0"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteAuthTypeBasic() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "basic"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteAuthTypeDigest() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "digest"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteAuthTypeOAuth() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "oauth"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("oAuthSignatureMethod", "plainTEXT"); - p.put("oAuthVersion", "1.0"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteAuthTypeNoneOAuth() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("oAuthSignatureMethod", "plainTEXT"); - p.put("oAuthVersion", "1.0"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - @Test - public void testDeleteAuthTypeNoneBasic() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testInvalidDeleteAuthTypeOAuth() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "oauth"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testInvalidDeleteAuthTypeBasic() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "basic"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testInvalidDeleteAuthTypeDigest() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "digest"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } -} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java deleted file mode 100644 index fcbd844fc..000000000 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java +++ /dev/null @@ -1,262 +0,0 @@ -/*- - * ============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 jtest.org.onap.ccsdk.sli.plugins.restapicall; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.sli.plugins.restapicall.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 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 = "" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " blah\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " blah blah\n" + - "\n"; - - String xmloutexpected = "" + - "\n" + - " \n" + - " blah\n" + - " \n" + - " blah blah\n" + - "\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/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java deleted file mode 100644 index c6bf4a8b9..000000000 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java +++ /dev/null @@ -1,121 +0,0 @@ -/*- - * ============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 jtest.org.onap.ccsdk.sli.plugins.restapicall; - -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.restapicall.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 listNameList = new HashSet(); - 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 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 listNameList = new HashSet(); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); - - Map 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 listNameList = new HashSet(); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); - - Map mm = XmlParser.convertToProperties(b.toString(), listNameList); - logProperties(mm); - in.close(); - } - - private void logProperties(Map mm) { - List 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/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java new file mode 100644 index 000000000..0216b6675 --- /dev/null +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java @@ -0,0 +1,73 @@ +/*- + * ============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 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.restapicall.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 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 mm) { + List 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/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestRestapiCallNode.java new file mode 100644 index 000000000..5c6c4e279 --- /dev/null +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestRestapiCallNode.java @@ -0,0 +1,575 @@ +/*- + * ============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 jtest.org.onap.ccsdk.sli.plugins.sshapicall; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestRestapiCallNode { + + private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class); + + + @Test + public void testDelete() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "pwd1"); + p.put("httpMethod", "delete"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "3"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].clci", "clci"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].clci", "clci"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testInvalidRepeatTimes() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "a"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testInvalidTemplatePath() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resourcess/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testWithoutSkipSending() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "false"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + + @Test(expected = SvcLogicException.class) + public void testWithInvalidURI() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo. getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "false"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testVpnJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testSiteJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + ctx.setAttribute("prop.l3vpn.site1_name", "10000000-0000-0000-0000-000000000002"); + ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003"); + ctx.setAttribute("prop.l3vpn.entry1-id", "1"); + ctx.setAttribute("prop.l3vpn.sna1_name", "10000000-0000-0000-0000-000000000004"); + ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e"); + ctx.setAttribute("prop.l3vpn.ac1_id", "a8098c1a-f86e-11da-bd1a-00112444be1b"); + ctx.setAttribute("prop.l3vpn.ac1-peer-ip", "192.168.1.1"); + ctx.setAttribute("prop.l3vpn.ac1-ip", "192.168.1.2"); + ctx.setAttribute("prop.l3vpn.sna1_svlan", "100"); + ctx.setAttribute("prop.l3vpn.ac1_protocol", "static"); + ctx.setAttribute("prop.l3vpn.sna1-route.ip-prefix", "192.168.1.1/24"); + ctx.setAttribute("prop.l3vpn.sna1-route.next-hop", "192.168.1.4"); + + ctx.setAttribute("prop.l3vpn.site2_name", "10000000-0000-0000-0000-000000000005"); + ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006"); + ctx.setAttribute("prop.l3vpn.entry2-id", "1"); + ctx.setAttribute("prop.l3vpn.sna2_name", "10000000-0000-0000-0000-000000000007"); + ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a"); + ctx.setAttribute("prop.l3vpn.ac2_id", "a8098c1a-f86e-11da-bd1a-00112444be1c"); + ctx.setAttribute("prop.l3vpn.ac2-peer-ip", "192.168.1.6"); + ctx.setAttribute("prop.l3vpn.ac2-ip", "192.168.1.5"); + ctx.setAttribute("prop.l3vpn.sna2_svlan", "200"); + ctx.setAttribute("prop.l3vpn.ac2_protocol", "bgp"); + ctx.setAttribute("prop.l3vpn.peer2-ip", "192.168.1.7"); + ctx.setAttribute("prop.l3vpn.ac2_protocol_bgp_as", "200"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/l3smsitetemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/sites"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testVrfJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.vrf1-id", "10000000-0000-0000-0000-000000000007"); + ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003"); + ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e"); + ctx.setAttribute("prop.l3vpn.vrf2-id", "10000000-0000-0000-0000-000000000009"); + ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006"); + ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/l3smvrftemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vrf-attributes"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteVpnJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + Map p = new HashMap(); + //p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services" + + "/vpnservice=10000000-0000-0000-0000-000000000001"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "delete"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testL2DciTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.dci-connects.id", "Id1"); + ctx.setAttribute("prop.dci-connects.name", "Name1"); + ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1"); + ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2"); + ctx.setAttribute("prop.dci-connects.vni", "1"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/l2-dci-connects-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testL3DciTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.dci-connects.id", "Id1"); + ctx.setAttribute("prop.dci-connects.name", "Name1"); + ctx.setAttribute("prop.dci-connects.local_networks_length", "2"); + ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1"); + ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2"); + ctx.setAttribute("prop.dci-connects.vni", "1"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/l3-dci-connects-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + + } + + @Test + public void testControllerTokenTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.user", "admin"); + ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.password", "admin123"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/actokentemplate.json"); + p.put("restapiUrl", "https://ipwan:18002/controller/v2/tokens"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + + @Test + public void testDeleteNoneAsContentType() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "pwd1"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testPostNoneAsContentType() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "none"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteOAuthType() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("oAuthSignatureMethod", "plainTEXT"); + p.put("oAuthVersion", "1.0"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteAuthTypeBasic() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "basic"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteAuthTypeDigest() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "digest"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteAuthTypeOAuth() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "oauth"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("oAuthSignatureMethod", "plainTEXT"); + p.put("oAuthVersion", "1.0"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteAuthTypeNoneOAuth() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("oAuthSignatureMethod", "plainTEXT"); + p.put("oAuthVersion", "1.0"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + @Test + public void testDeleteAuthTypeNoneBasic() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testInvalidDeleteAuthTypeOAuth() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "oauth"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testInvalidDeleteAuthTypeBasic() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "basic"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testInvalidDeleteAuthTypeDigest() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "digest"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } +} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java new file mode 100644 index 000000000..bd9ff1c98 --- /dev/null +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java @@ -0,0 +1,262 @@ +/*- + * ============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 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.restapicall.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 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 = "" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " blah\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " blah blah\n" + + "\n"; + + String xmloutexpected = "" + + "\n" + + " \n" + + " blah\n" + + " \n" + + " blah blah\n" + + "\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/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java new file mode 100644 index 000000000..8ff0b0a3f --- /dev/null +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java @@ -0,0 +1,121 @@ +/*- + * ============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 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.restapicall.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 listNameList = new HashSet(); + 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 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 listNameList = new HashSet(); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); + + Map 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 listNameList = new HashSet(); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); + + Map mm = XmlParser.convertToProperties(b.toString(), listNameList); + logProperties(mm); + in.close(); + } + + private void logProperties(Map mm) { + List 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/.gitignore b/sshapi-call-node/.gitignore new file mode 100755 index 000000000..b73caf31e --- /dev/null +++ b/sshapi-call-node/.gitignore @@ -0,0 +1,34 @@ +#####standard .git ignore entries##### + +## IDE Specific Files ## +org.eclipse.core.resources.prefs +.classpath +.project +.settings +.idea +.externalToolBuilders +maven-eclipse.xml +workspace + +## Compilation Files ## +*.class +**/target +target +target-ide +MANIFEST.MF + +## Misc Ignores (OS specific etc) ## +bin/ +dist +*~ +*.ipr +*.iml +*.iws +classes +out/ +.DS_STORE +.metadata + +## Folders which contain auto generated source code ## +yang-gen-config +yang-gen-sal diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml new file mode 100644 index 000000000..12ec06867 --- /dev/null +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.1.0-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + ccsdk-sshapi-call-node + 0.3.0-SNAPSHOT + feature + + ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} + + + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + ${odl.mdsal.model.version} + pom + import + + + org.opendaylight.controller + mdsal-artifacts + ${odl.mdsal.version} + pom + import + + + + + + + + org.onap.ccsdk.sli.core + ccsdk-sli + ${ccsdk.sli.core.version} + xml + features + + + ${project.groupId} + sshapi-call-node-provider + ${project.version} + + + diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml new file mode 100644 index 000000000..a37ac6172 --- /dev/null +++ b/sshapi-call-node/features/features-sshapi-call-node/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + feature-repo-parent + 1.1.0-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + features-sshapi-call-node + 0.3.0-SNAPSHOT + feature + + ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} + + + + ${project.groupId} + ccsdk-sshapi-call-node + ${project.version} + xml + features + + + + diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml new file mode 100755 index 000000000..49b96e3fd --- /dev/null +++ b/sshapi-call-node/features/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.1.0-SNAPSHOT + + + org.onap.ccsdk.sli.plugins + sshapi-call-node-features + 0.3.0-SNAPSHOT + pom + + ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} + + + ccsdk-sshapi-call-node + features-sshapi-call-node + + diff --git a/sshapi-call-node/features/src/main/resources/features.xml b/sshapi-call-node/features/src/main/resources/features.xml new file mode 100644 index 000000000..573f5cb05 --- /dev/null +++ b/sshapi-call-node/features/src/main/resources/features.xml @@ -0,0 +1,51 @@ + + + + + + + + mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features + + + + sdnc-sli + spring + spring-dm + mvn:com.sun.jersey/jersey-client/${jersey.version} + + mvn:com.sun.jersey.contribs.jersey-oauth/oauth-signature/${jersey.version} + + + mvn:com.sun.jersey.contribs.jersey-oauth/oauth-client/${jersey.version} + + mvn:org.codehaus.jettison/jettison/${jettison.version} + + mvn:org.onap.ccsdk.sli.plugins/sshapi-call-node-provider/${project.version} + + + + diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml new file mode 100755 index 000000000..51bed972f --- /dev/null +++ b/sshapi-call-node/installer/pom.xml @@ -0,0 +1,148 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.1.0-SNAPSHOT + + + org.onap.ccsdk.sli.plugins + sshapi-call-node-installer + 0.3.0-SNAPSHOT + pom + + ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} + + + ccsdk-sshapi-call-node + ${application.name} + mvn:org.onap.ccsdk.sli.plugins/${features.boot}/${project.version}/xml/features + false + + + + + + org.onap.ccsdk.sli.plugins + ${application.name} + ${project.version} + xml + features + + + * + * + + + + + + org.onap.ccsdk.sli.plugins + sshapi-call-node-provider + ${project.version} + + + org.springframework + spring-beans + + + org.springframework + spring-context + + + + + + + maven-assembly-plugin + 2.6 + + + maven-repo-zip + + single + + package + + true + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + true + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli.core + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + + + diff --git a/sshapi-call-node/installer/src/assembly/assemble_installer_zip.xml b/sshapi-call-node/installer/src/assembly/assemble_installer_zip.xml new file mode 100644 index 000000000..b2e792123 --- /dev/null +++ b/sshapi-call-node/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,59 @@ + + + + + + installer_zip + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + + + + diff --git a/sshapi-call-node/installer/src/assembly/assemble_mvnrepo_zip.xml b/sshapi-call-node/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100644 index 000000000..2a6344697 --- /dev/null +++ b/sshapi-call-node/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,49 @@ + + + + + + repo + + zip + + + + false + + + + target/assembly/ + . + + + + + + + + diff --git a/sshapi-call-node/installer/src/main/resources/scripts/install-feature.sh b/sshapi-call-node/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..8e516a247 --- /dev/null +++ b/sshapi-call-node/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +### +# ============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========================================================= +### + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -nd ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} feature:install ${features.boot} diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml new file mode 100755 index 000000000..91b52e123 --- /dev/null +++ b/sshapi-call-node/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.1.0-SNAPSHOT + + + org.onap.ccsdk.sli.plugins + sshapi-call-node + 0.3.0-SNAPSHOT + pom + + ccsdk-sli-plugins :: sshapi-call-node + This is an implementation of DG Execute Node that makes a call to an external REST API + + + provider + features + installer + + diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml new file mode 100755 index 000000000..165003ff1 --- /dev/null +++ b/sshapi-call-node/provider/pom.xml @@ -0,0 +1,73 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + binding-parent + 1.1.0-SNAPSHOT + + + org.onap.ccsdk.sli.plugins + sshapi-call-node-provider + 0.3.0-SNAPSHOT + bundle + + ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + test + + + org.springframework + spring-test + test + + + org.onap.ccsdk.sli.core + sli-common + + + org.onap.ccsdk.sli.core + sli-provider + + + org.slf4j + slf4j-api + + + org.springframework + spring-beans + + + org.springframework + spring-context + + + com.sun.jersey + jersey-client + + + com.sun.jersey.contribs.jersey-oauth + oauth-signature + ${jersey.version} + + + com.sun.jersey.contribs.jersey-oauth + oauth-client + ${jersey.version} + + + org.codehaus.jettison + jettison + + + 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 000000000..4efddec80 --- /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 of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + * + * + * vpn-information.vrf-details + * + * + * + * + *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/sshapi/templates/vnf_service-configuration-operation_minimal.json
sshapiUrlMandatoryurl to make the SSH connection request to.
sshapiUserOptionaluser name to use for ssh basic authenticationsdnc_ws
sshapiPasswordOptionalunencrypted password to use for ssh basic authenticationplain_password
sshKeyOptionalConsumer SSH key to use for ssh authenticationplain_key
cmdMandatoryssh command to be executed on the server.get post put delete patch
responsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
listName[i]OptionalUsed for processing XML responses with repeating elements.
convertResponse Optionalwhether the response should be convertedtrue or false
dumpHeadersOptionalwhen true writes ssh response content to context memorytrue or false
returnRequestPayloadOptionalused to return payload built in the requesttrue or false
+ * 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 paramMap, SvcLogicContext ctx) throws SvcLogicException; + + /** + * Allows Directed Graphs the ability to interact with SSH APIs. + * @param paramMap HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + * + * + * vpn-information.vrf-details + * + * + * + * + *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/sshapi/templates/vnf_service-configuration-operation_minimal.json
sshapiUrlMandatoryurl to make the SSH connection request to.
sshapiUserOptionaluser name to use for ssh basic authenticationsdnc_ws
sshapiPasswordOptionalunencrypted password to use for ssh basic authenticationplain_password
sshKeyOptionalConsumer SSH key to use for ssh authenticationplain_key
cmdMandatoryssh command to be executed on the server.get post put delete patch
responsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
listName[i]OptionalUsed for processing XML responses with repeating elements.
convertResponse Optionalwhether the response should be convertedtrue or false
dumpHeadersOptionalwhen true writes ssh response content to context memorytrue or false
returnRequestPayloadOptionalused to return payload built in the requesttrue or false
+ * 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 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 000000000..308162271 --- /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 000000000..75604de66 --- /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 000000000..a392cc73c --- /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 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 000000000..9283b8b5f --- /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 paramMap, SvcLogicContext ctx) throws SvcLogicException { + //TODO: Implementation + } + + @Override + public void execCommandWithPty(Map 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 000000000..e840053f8 --- /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 convertToProperties(String s) + throws SvcLogicException { + + checkNotNull(s, "Input should not be null."); + + try { + JSONObject json = new JSONObject(s); + Map wm = new HashMap<>(); + Iterator ii = json.keys(); + while (ii.hasNext()) { + String key1 = ii.next(); + wm.put(key1, json.get(key1)); + } + + Map 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 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 000000000..9a1d3a312 --- /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 000000000..fef0f81af --- /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 000000000..65575b8ce --- /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 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 000000000..e7fc60edb --- /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 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 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 flatmap, String var) { + if (flatmap.containsKey(var)) { + if (var.endsWith("_length") || var.endsWith("].key")) + return null; + return flatmap.get(var); + } + + Map 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 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 mm = (Map) o; + for (Map.Entry 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('\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('\n'); + } else if (v instanceof List) { + List ll = (List) 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('\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 mm = (Map) o; + + if (padFirst) + ss.append(pad(indent)); + ss.append("{\n"); + + boolean first = true; + for (Map.Entry 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 ll = (List) 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 = " 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("&", "&"); + s = s.replaceAll("<", "<"); + s = s.replaceAll("'", "'"); + s = s.replaceAll("\"", """); + s = s.replaceAll(">", ">"); + 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 000000000..c23aca6cf --- /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 convertToProperties(String s, Set 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 listNameList; + + private Map properties = new HashMap<>(); + + public Map getProperties() { + return properties; + } + + public Handler(Set 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 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 000000000..4cce6ffad --- /dev/null +++ b/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-context.xml @@ -0,0 +1,51 @@ + + + + + + + + + file:${SDNC_CONFIG_DIR}/ueb.properties + file:${SDNC_CONFIG_DIR}/dme2.properties + + + + + + + + + + + + + + + + + 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 000000000..c8e9a99e3 --- /dev/null +++ b/sshapi-call-node/provider/src/main/resources/META-INF/spring/sshapi-call-node-osgi-context.xml @@ -0,0 +1,34 @@ + + + + + + + + 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 000000000..b24aaf1ee --- /dev/null +++ b/sshapi-call-node/provider/src/main/resources/org/opendaylight/blueprint/sshapi-call-node-blueprint.xml @@ -0,0 +1,16 @@ + + + + + + + + + + org.onap.ccsdk.sli.plugins.sshapicall.SshApiCallNode + + + + \ 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 000000000..9df790ae3 --- /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 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 mm) { + List 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 000000000..599043e9c --- /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 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 = "" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " blah\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " blah blah\n" + + "\n"; + + String xmloutexpected = "" + + "\n" + + " \n" + + " blah\n" + + " \n" + + " blah blah\n" + + "\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 000000000..d904721f8 --- /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 listNameList = new HashSet(); + 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 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 listNameList = new HashSet(); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); + + Map 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 listNameList = new HashSet(); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); + + Map mm = XmlParser.convertToProperties(b.toString(), listNameList); + logProperties(mm); + in.close(); + } + + private void logProperties(Map mm) { + List 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 000000000..b71f6391f --- /dev/null +++ b/sshapi-call-node/provider/src/test/resources/invalidlength.xml @@ -0,0 +1,49 @@ + + + + + + ICOREPVC-81114561 + + VPNL811182 + 811182 + 21302:811182 + SET_BVOIP_IN + SET6_BVOIP_IN + a + SET6_DSU + SET_DSU + SET6_MANAGED + SET_MANAGED + SET_LOVRF_COMMUNITY + SET_RESET_LP + + AG_MAX_MCASTROUTES + + + + 200 + Success + Y + + 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 000000000..cd5e74699 --- /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 000000000..e272d457a --- /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 000000000..7645f1992 --- /dev/null +++ b/sshapi-call-node/provider/src/test/resources/test.xml @@ -0,0 +1,184 @@ + + + + + 4.0.0 + + org.onap.ccsdk.sli.plugins + sshapi-call-node + 6.0.0-SNAPSHOT + + sshapi-call-node-provider + bundle + SSHAPI Call Node - Provider + http://maven.apache.org + + UTF-8 + + + + junit + junit + test + + + org.springframework + spring-test + 3.1.4.RELEASE + test + + + org.onap.ccsdk.sli + sli-common + compile + + + org.onap.ccsdk.sli + sli-provider + compile + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + org.springframework + spring-beans + 3.1.4.RELEASE + + + org.springframework + spring-context + 3.1.4.RELEASE + + + xerces + xerces + 2.4.0 + provided + + + com.sun.jersey + jersey-client + 1.17 + + + com.sun.jersey.contribs.jersey-oauth + oauth-signature + 1.17 + + + com.sun.jersey.contribs.jersey-oauth + oauth-client + 1.17 + + + commons-codec + commons-codec + + + + + + + com.brocade.developer + providermodule-plugin + + org.onap.ccsdk.sli.plugins + sshapi-call-node + + + + process-sources + + process + + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + org.onap.ccsdk.sli.plugins.sshapicall + org.onap.ccsdk.sli.plugins.sshapicall + * + + + ${project.basedir}/src/main/resources/META-INF + + + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + com.brocade.developer + + + providermodule-plugin + + + [1.2.0.100-SNAPSHOT,) + + + process + + + + + + + + + + + + + + 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 000000000..52a7a7d98 --- /dev/null +++ b/sshapi-call-node/provider/src/test/resources/test3.xml @@ -0,0 +1,82 @@ + + + + + + ICOREPVC-81114561 + + VPNL811182 + 811182 + 21302:811182 + SET_BVOIP_IN + SET6_BVOIP_IN + SET6_DSU + SET_DSU + SET6_MANAGED + SET_MANAGED + SET_LOVRF_COMMUNITY + SET_RESET_LP + + AG_MAX_MCASTROUTES + + + + BGP4_PROTOCOL + v4 + gp_21302:811182 + + AG_L3VPN_EBGP + + + AG_MAX_PREFIX + + + AG_BGP_UNMANAGED + + + AG_BFD_BGP_3000 + + + + BGP4_PROTOCOL + v6 + gp6_21302:811182 + + AG6_L3VPN_EBGP + + + AG6_MAX_PREFIX + + + AG6_BGP_UNMANAGED + + + AG6_BFD_BGP_3000 + + + + 200 + Success + Y + + -- cgit From d7d5ea0fe2e9bf6c5222174df2bdd80192b9d6ee Mon Sep 17 00:00:00 2001 From: gaurav Date: Wed, 18 Jul 2018 19:39:10 +0530 Subject: API for RestconfClient API for RestconfClient including: - RestconfApiCallNode - RestconfDiscoveryNode Change-Id: Ieda6251b91b6d399cd0106993c3fdd1a440d5b0a Issue-ID: CCSDK-371 Signed-off-by: Gaurav Agrawal --- features/ccsdk-sli-plugins-all/pom.xml | 10 +- pom.xml | 1 + restconf-client/.gitignore | 34 +++++ .../features/ccsdk-restconf-client/pom.xml | 55 ++++++++ .../features/features-restconf-client/pom.xml | 29 ++++ restconf-client/features/pom.xml | 22 +++ .../features/src/main/resources/features.xml | 41 ++++++ restconf-client/installer/pom.xml | 148 +++++++++++++++++++++ .../src/assembly/assemble_installer_zip.xml | 58 ++++++++ .../src/assembly/assemble_mvnrepo_zip.xml | 48 +++++++ .../src/main/resources/scripts/install-feature.sh | 38 ++++++ restconf-client/pom.xml | 24 ++++ restconf-client/provider/pom.xml | 73 ++++++++++ .../restconfapicall/RestconfapiCallNode.java | 65 +++++++++ .../restconfdiscovery/RestconfDiscoveryNode.java | 25 ++++ .../restconfdiscovery/SvcLogicDiscoveryPlugin.java | 110 +++++++++++++++ .../META-INF/spring/restconf-client-context.xml | 48 +++++++ .../spring/restconf-client-osgi-context.xml | 32 +++++ .../blueprint/restconf-client-blueprint.xml | 41 ++++++ 19 files changed, 899 insertions(+), 3 deletions(-) create mode 100755 restconf-client/.gitignore create mode 100644 restconf-client/features/ccsdk-restconf-client/pom.xml create mode 100644 restconf-client/features/features-restconf-client/pom.xml create mode 100755 restconf-client/features/pom.xml create mode 100644 restconf-client/features/src/main/resources/features.xml create mode 100755 restconf-client/installer/pom.xml create mode 100644 restconf-client/installer/src/assembly/assemble_installer_zip.xml create mode 100644 restconf-client/installer/src/assembly/assemble_mvnrepo_zip.xml create mode 100644 restconf-client/installer/src/main/resources/scripts/install-feature.sh create mode 100755 restconf-client/pom.xml create mode 100755 restconf-client/provider/pom.xml create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfapiCallNode.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicDiscoveryPlugin.java create mode 100644 restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-context.xml create mode 100644 restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-osgi-context.xml create mode 100755 restconf-client/provider/src/main/resources/org/opendaylight/blueprint/restconf-client-blueprint.xml diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index 756e75902..d41b48022 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -51,8 +51,12 @@ xml features - - - + + ${project.groupId} + ccsdk-restconf-client + ${project.version} + xml + features + diff --git a/pom.xml b/pom.xml index ecdce6505..164d81e27 100755 --- a/pom.xml +++ b/pom.xml @@ -24,6 +24,7 @@ properties-node restapi-call-node sshapi-call-node + restconf-client features diff --git a/restconf-client/.gitignore b/restconf-client/.gitignore new file mode 100755 index 000000000..b73caf31e --- /dev/null +++ b/restconf-client/.gitignore @@ -0,0 +1,34 @@ +#####standard .git ignore entries##### + +## IDE Specific Files ## +org.eclipse.core.resources.prefs +.classpath +.project +.settings +.idea +.externalToolBuilders +maven-eclipse.xml +workspace + +## Compilation Files ## +*.class +**/target +target +target-ide +MANIFEST.MF + +## Misc Ignores (OS specific etc) ## +bin/ +dist +*~ +*.ipr +*.iml +*.iws +classes +out/ +.DS_STORE +.metadata + +## Folders which contain auto generated source code ## +yang-gen-config +yang-gen-sal diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml new file mode 100644 index 000000000..8bdfe87a0 --- /dev/null +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.1.0-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + ccsdk-restconf-client + 0.3.0-SNAPSHOT + feature + + ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} + + + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + ${odl.mdsal.model.version} + pom + import + + + org.opendaylight.controller + mdsal-artifacts + ${odl.mdsal.version} + pom + import + + + + + + + + org.onap.ccsdk.sli.core + ccsdk-sli + ${ccsdk.sli.core.version} + xml + features + + + ${project.groupId} + restconf-client-provider + ${project.version} + + + diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml new file mode 100644 index 000000000..8ee5e7e21 --- /dev/null +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + feature-repo-parent + 1.1.0-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + features-restconf-client + 0.3.0-SNAPSHOT + feature + + ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} + + + + ${project.groupId} + ccsdk-restconf-client + ${project.version} + xml + features + + + + diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml new file mode 100755 index 000000000..c94be00be --- /dev/null +++ b/restconf-client/features/pom.xml @@ -0,0 +1,22 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.1.0-SNAPSHOT + + + org.onap.ccsdk.sli.plugins + restconf-client-features + 0.3.0-SNAPSHOT + pom + + ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} + + + ccsdk-restconf-client + features-restconf-client + + diff --git a/restconf-client/features/src/main/resources/features.xml b/restconf-client/features/src/main/resources/features.xml new file mode 100644 index 000000000..d7907ac29 --- /dev/null +++ b/restconf-client/features/src/main/resources/features.xml @@ -0,0 +1,41 @@ + + + + + + + mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features + + + sdnc-sli + spring + spring-dm + mvn:com.sun.jersey/jersey-client/${jersey.version} + mvn:com.sun.jersey.contribs.jersey-oauth/oauth-signature/${jersey.version} + mvn:com.sun.jersey.contribs.jersey-oauth/oauth-client/${jersey.version} + mvn:org.codehaus.jettison/jettison/${jettison.version} + mvn:org.onap.ccsdk.sli.plugins/restconf-client-provider/${project.version} + + + diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml new file mode 100755 index 000000000..ee632d434 --- /dev/null +++ b/restconf-client/installer/pom.xml @@ -0,0 +1,148 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.1.0-SNAPSHOT + + + org.onap.ccsdk.sli.plugins + restconf-client-installer + 0.3.0-SNAPSHOT + pom + + ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} + + + ccsdk-restconf-client + ${application.name} + mvn:org.onap.ccsdk.sli.plugins/${features.boot}/${project.version}/xml/features + false + + + + + + org.onap.ccsdk.sli.plugins + ${application.name} + ${project.version} + xml + features + + + * + * + + + + + + org.onap.ccsdk.sli.plugins + restconf-client-provider + ${project.version} + + + org.springframework + spring-beans + + + org.springframework + spring-context + + + + + + + maven-assembly-plugin + 2.6 + + + maven-repo-zip + + single + + package + + true + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + true + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli.core + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + + + diff --git a/restconf-client/installer/src/assembly/assemble_installer_zip.xml b/restconf-client/installer/src/assembly/assemble_installer_zip.xml new file mode 100644 index 000000000..8ffcb88a1 --- /dev/null +++ b/restconf-client/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,58 @@ + + + + + + installer_zip + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + + + + diff --git a/restconf-client/installer/src/assembly/assemble_mvnrepo_zip.xml b/restconf-client/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100644 index 000000000..252c39d3c --- /dev/null +++ b/restconf-client/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,48 @@ + + + + + + repo + + zip + + + + false + + + + target/assembly/ + . + + + + + + + + diff --git a/restconf-client/installer/src/main/resources/scripts/install-feature.sh b/restconf-client/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..8e9195d57 --- /dev/null +++ b/restconf-client/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +### +# ============LICENSE_START======================================================= +# ONAP : CCSDK +# ================================================================================ +# Copyright (C) 2018 Huawei Technologies Co., Ltd. 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========================================================= +### + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -nd ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} feature:install ${features.boot} diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml new file mode 100755 index 000000000..fecbd2b93 --- /dev/null +++ b/restconf-client/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.1.0-SNAPSHOT + + + org.onap.ccsdk.sli.plugins + restconf-client + 0.3.0-SNAPSHOT + pom + + ccsdk-sli-plugins :: restconf-client + This is an implementation of DG Execute Node that makes a call to an external RESTCONF API + + + provider + features + installer + + diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml new file mode 100755 index 000000000..776240e0c --- /dev/null +++ b/restconf-client/provider/pom.xml @@ -0,0 +1,73 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + binding-parent + 1.1.0-SNAPSHOT + + + org.onap.ccsdk.sli.plugins + restconf-client-provider + 0.3.0-SNAPSHOT + bundle + + ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + test + + + org.springframework + spring-test + test + + + org.onap.ccsdk.sli.core + sli-common + + + org.onap.ccsdk.sli.core + sli-provider + + + org.slf4j + slf4j-api + + + org.springframework + spring-beans + + + org.springframework + spring-context + + + com.sun.jersey + jersey-client + + + com.sun.jersey.contribs.jersey-oauth + oauth-signature + ${jersey.version} + + + com.sun.jersey.contribs.jersey-oauth + oauth-client + ${jersey.version} + + + org.codehaus.jettison + jettison + + + diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfapiCallNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfapiCallNode.java new file mode 100644 index 000000000..87cb92bc5 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfapiCallNode.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.restconfapicall; + +import java.util.Map; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; + +/** + * Representation of a plugin to enable RESTCONF based CRUD operations from DG. + */ +public class RestconfapiCallNode implements SvcLogicJavaPlugin { + + public RestconfapiCallNode() { + } + + /** + * Allows Directed Graphs the ability to interact with RESTCONF APIs. + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to YANG directory that can be used to build a request/sdncopt/bvc/resconfapi/test
restapiUrlMandatoryurl to send the request tohttps://sdncodl:8543/restconf/operations/L3VNF-API:create-update-vnf-request
restapiUserOptionaluser name to use for http basic authenticationsdnc_ws
restapiPasswordOptionalunencrypted password to use for http basic authenticationplain_password
contentTypeOptionalhttp content type to set in the http headerusually application/json or application/xml
formatOptionalshould match request body formatjson or xml
httpMethodOptionalhttp method to use when sending the requestget post put delete patch
responsePrefixOptionallocation the response will be written to in context memorytmp.resconftapi.result
skipSendingOptionaltrue or false
convertResponse Optionalwhether the response should be convertedtrue or false
customHttpHeadersOptionala list additional http headers to be passed in, follow the format in the exampleX-CSI-MessageId=messageId,headerFieldName=headerFieldValue
dumpHeadersOptionalwhen true writes http header content to context memorytrue or false
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + * @see String#split(String, int) + */ + public void sendRequest(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { + //TODO + } + +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java new file mode 100644 index 000000000..9eaa67916 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java @@ -0,0 +1,25 @@ +package org.onap.ccsdk.sli.plugins.restconfdiscovery; + +import java.util.Map; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; + +/** + * Created by root1 on 18/7/18. + */ +public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { + + @Override + public void establishSubscription(Map paramMap, SvcLogicContext ctx) { + + } + + @Override + public void modifySubscription(Map paramMap, SvcLogicContext ctx) { + + } + + @Override + public void deleteSubscription(Map paramMap, SvcLogicContext ctx) { + + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicDiscoveryPlugin.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicDiscoveryPlugin.java new file mode 100644 index 000000000..183d22297 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicDiscoveryPlugin.java @@ -0,0 +1,110 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.restconfdiscovery; + +import java.util.Map; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; + +/** + * Abstraction of a plugin to enable discovery from DG. + */ +public interface SvcLogicDiscoveryPlugin extends SvcLogicJavaPlugin { + + /** + * Allows directed graphs to establish a discovery subscription for a given subscriber. + * @param paramMap HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
parameterMandatory/Optionaldescriptionexample values
templateDirNameOptionalfull path to YANG directory that can be used to build a request/sdncopt/bvc/resconfapi/test
establishSubscriptionURLMandatoryurl to establish connection with serverhttps://127.0.0.1:8181/restconf/operations/ietf-subscribed-notifications:establish-subscription
sseConnectURLMandatoryurl to setup SSE connection with serverhttps://127.0.0.1:8181/restconf/streams/yang-push-json
callbackDGMandatorycallback DG to process the received notificationResource-Discovery:handleSOTNTopology
filterURLOptionalurl which needs to be subscribed, if null subscribe to allhttp://example.com/sample-data/1.0
subscriptionTypeOptionaltype of subscription, periodic or onDataChangeonDataChange
updateFrequencyOptionalupdate frequency in milli seconds when subscription type is periodic1000
restapiUserOptionaluser name to use for http basic authenticationsdnc_ws
restapiPasswordOptionalunencrypted password to use for http basic authenticationplain_password
contentTypeOptionalhttp content type to set in the http headerusually application/json or application/xml
formatOptionalshould match request body formatjson or xml
responsePrefixOptionallocation the notification response will be written to in context memorytmp.restconfdiscovery.result
skipSendingOptionaltrue or false
convertResponse Optionalwhether the response should be convertedtrue or false
customHttpHeadersOptionala list additional http headers to be passed in, follow the format in the exampleX-CSI-MessageId=messageId,headerFieldName=headerFieldValue
dumpHeadersOptionalwhen true writes http header content to context memorytrue or false
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + * @see String#split(String, int) + */ + void establishSubscription(Map paramMap, SvcLogicContext ctx); + + /** + * Allows directed graphs to modify a discovery subscription for a given subscriber. + * @param paramMap HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
parameterMandatory/Optionaldescriptionexample values
subscriberIdMandatorysubscription subscriber's identifiertopologyId/1111
templateDirNameOptionalfull path to YANG directory that can be used to build a request/sdncopt/bvc/resconfapi/test
establishSubscriptionURLMandatoryurl to establish connection with serverhttps://127.0.0.1:8181/restconf/operations/ietf-subscribed-notifications:establish-subscription
sseConnectURLMandatoryurl to setup SSE connection with serverhttps://127.0.0.1:8181/restconf/streams/yang-push-json
callbackDGMandatorycallback DG to process the received notificationResource-Discovery:handleSOTNTopology
filterURLOptionalurl filter list which needs to be subscribed, if null subscribe to allhttp://example.com/sample-data/1.0
subscriptionTypeOptionaltype of subscription, periodic or onDataChangeonDataChange
updateFrequencyOptionalupdate frequency in milli seconds when subscription type is periodic1000
restapiUserOptionaluser name to use for http basic authenticationsdnc_ws
restapiPasswordOptionalunencrypted password to use for http basic authenticationplain_password
contentTypeOptionalhttp content type to set in the http headerusually application/json or application/xml
formatOptionalshould match request body formatjson or xml
responsePrefixOptionallocation the notification response will be written to in context memorytmp.restconfdiscovery.result
skipSendingOptionaltrue or false
convertResponse Optionalwhether the response should be convertedtrue or false
customHttpHeadersOptionala list additional http headers to be passed in, follow the format in the exampleX-CSI-MessageId=messageId,headerFieldName=headerFieldValue
dumpHeadersOptionalwhen true writes http header content to context memorytrue or false
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + * @see String#split(String, int) + */ + void modifySubscription(Map paramMap, SvcLogicContext ctx); + + /** + * Allows directed graphs to delete the discovery subscription for a given subscriber. + * @param paramMap HashMap of parameters passed by the DG to this function + * + * + * + * + * + *
parameterMandatory/Optionaldescriptionexample values
subscriberIdMandatorysubscription subscriber's identifiertopologyId/1111
+ * @param ctx Reference to context memory + * @throws SvcLogicException + */ + void deleteSubscription(Map paramMap, SvcLogicContext ctx); + +} diff --git a/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-context.xml b/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-context.xml new file mode 100644 index 000000000..d7fa61c55 --- /dev/null +++ b/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-context.xml @@ -0,0 +1,48 @@ + + + + + + + + + file:${SDNC_CONFIG_DIR}/ueb.properties + file:${SDNC_CONFIG_DIR}/dme2.properties + + + + + + + + + + + + + + + + + diff --git a/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-osgi-context.xml b/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-osgi-context.xml new file mode 100644 index 000000000..d56e2fc11 --- /dev/null +++ b/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-osgi-context.xml @@ -0,0 +1,32 @@ + + + + + + + + + diff --git a/restconf-client/provider/src/main/resources/org/opendaylight/blueprint/restconf-client-blueprint.xml b/restconf-client/provider/src/main/resources/org/opendaylight/blueprint/restconf-client-blueprint.xml new file mode 100755 index 000000000..149ed9fcf --- /dev/null +++ b/restconf-client/provider/src/main/resources/org/opendaylight/blueprint/restconf-client-blueprint.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + org.onap.ccsdk.sli.plugins.restconfapicall.RestconfapiCallNode + + + + + + org.onap.ccsdk.sli.plugins.restconfdiscovery.RestconfDiscoveryNode + + + + \ No newline at end of file -- cgit From 5ed67078d4ea6822fa2d000d27ff8fca0017b6e8 Mon Sep 17 00:00:00 2001 From: gaurav Date: Mon, 23 Jul 2018 23:36:17 +0530 Subject: Adding APIs for YANG serializers Adding APIs for YANG based data format serializers. Change-Id: I8e17c475e636aa9bbf39be52d31583565bae8e92 Issue-ID: CCSDK-375 Signed-off-by: Gaurav Agrawal --- .../sli/plugins/yangserializers/Annotation.java | 59 ++++++++++++++ .../sli/plugins/yangserializers/DataFormat.java | 29 +++++++ .../yangserializers/DataFormatSerializer.java | 82 +++++++++++++++++++ .../DataFormatSerializerContext.java | 74 +++++++++++++++++ .../plugins/yangserializers/JsonSerializer.java | 49 ++++++++++++ .../sli/plugins/yangserializers/Listener.java | 34 ++++++++ .../yangserializers/MdsalSerializerHelper.java | 67 ++++++++++++++++ .../sli/plugins/yangserializers/NodeType.java | 31 ++++++++ .../plugins/yangserializers/SerializerHelper.java | 93 ++++++++++++++++++++++ .../sli/plugins/yangserializers/XmlSerializer.java | 49 ++++++++++++ 10 files changed, 567 insertions(+) create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/Annotation.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormat.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormatSerializer.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormatSerializerContext.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/JsonSerializer.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/Listener.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/MdsalSerializerHelper.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/NodeType.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/SerializerHelper.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/XmlSerializer.java diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/Annotation.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/Annotation.java new file mode 100644 index 000000000..13f1c323b --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/Annotation.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; + +/** + * Representation of an entity that represents annotated attribute. + */ +public class Annotation { + + private String name; + private String value; + + /** + * Creates an instance of annotation. + * + * @param n annotation name + * @param v annotation value + */ + public Annotation(String n, String v) { + name = n; + value = v; + } + + /** + * Returns name of annotation. + * + * @return name of annotation + */ + public String name() { + return name; + } + + /** + * Returns value of annotation. + * + * @return value of annotation + */ + public String value() { + return value; + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormat.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormat.java new file mode 100644 index 000000000..0d1928b35 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormat.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; + +/** + * Representation of data format. + */ +public enum DataFormat { + XML, + JSON +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormatSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormatSerializer.java new file mode 100644 index 000000000..bcd5991d7 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormatSerializer.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; + +import java.util.List; +import java.util.Map; + +/** + * Abstraction of serializer to encode/decode context memory parameters + * to/from specified data format. + */ +public abstract class DataFormatSerializer { + + private DataFormat dataFormat; + private DataFormatSerializerContext serializerContext; + + /** + * Creates an instance of data format serializer. + * + * @param dataFormat type of data format + * @param serializerContext data format serializer context + */ + protected DataFormatSerializer(DataFormat dataFormat, + DataFormatSerializerContext serializerContext) { + this.dataFormat = dataFormat; + this.serializerContext = serializerContext; + } + + /** + * Encodes context memory parameters to data format. + * + * @param param context memory parameter + * @param annotations annotations + * @return data format body + */ + public abstract String encode(Map param, + Map> annotations); + + /** + * Decodes data format body to context memory parameters. + * + * @param dataFormatBody abstract node + * @return context memory parameters + */ + public abstract Map decode(String dataFormatBody); + + /** + * Returns data format serializer context. + * + * @return data format serializer context + */ + public DataFormatSerializerContext serializerContext() { + return serializerContext; + } + + /** + * Returns supported data format. + * + * @return supported data format + */ + public DataFormat dataFormat() { + return dataFormat; + } +} \ No newline at end of file diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormatSerializerContext.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormatSerializerContext.java new file mode 100644 index 000000000..50cb2daf6 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormatSerializerContext.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; + +import java.util.Map; + +/** + * Abstraction of data format serializer context. + */ +public class DataFormatSerializerContext { + + private Listener listener; + private String uri; + private Map protocolAnnotation; + + /** + * Creates an instance of data format serializer context. + * + * @param listener data format listener + * @param uri URI corresponding to instance identifier + * @param protocolAnnotation protocol annotations + */ + public DataFormatSerializerContext(Listener listener, String uri, + Map protocolAnnotation) { + this.listener = listener; + this.uri = uri; + this.protocolAnnotation = protocolAnnotation; + } + + /** + * Retruns data format listener. + * + * @return data format listener + */ + public Listener listener() { + return listener; + } + + /** + * Returns URI. + * + * @return URI + */ + public String uri() { + return uri; + } + + /** + * Returns protocol annotations. + * + * @return protocol annotations + */ + public Map getProtocolAnnotation() { + return protocolAnnotation; + } +} \ No newline at end of file diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/JsonSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/JsonSerializer.java new file mode 100644 index 000000000..072cfb09c --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/JsonSerializer.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; + +import java.util.List; +import java.util.Map; + +/** + * Representation of JSON serializer. + */ +public class JsonSerializer extends DataFormatSerializer { + + /** + * Creates an instance of data format serializer. + * + * @param serializerContext data format serializer context + */ + protected JsonSerializer(DataFormatSerializerContext serializerContext) { + super(DataFormat.JSON, serializerContext); + } + + @Override + public String encode(Map param, Map> annotations) { + return null; + } + + @Override + public Map decode(String dataFormatBody) { + return null; + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/Listener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/Listener.java new file mode 100644 index 000000000..a0976822e --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/Listener.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; + +/** + * Abstraction of listener. + */ +public interface Listener { + + /** + * Returns serializer helper for this listener. + * + * @return serializer helper + */ + SerializerHelper serializerHelper(); +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/MdsalSerializerHelper.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/MdsalSerializerHelper.java new file mode 100644 index 000000000..c9bda511f --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/MdsalSerializerHelper.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; + +import java.util.Map; +import org.opendaylight.yangtools.yang.model.api.SchemaNode; + +/** + * Representation of MDSAL based schema helper. + */ +public class MdsalSerializerHelper extends SerializerHelper { + + protected MdsalSerializerHelper(SchemaNode node, String uri) { + super(node, uri); + } + + @Override + public SchemaNode getRootContext() { + return null; + } + + @Override + public SchemaNode getCurContext() { + return null; + } + + @Override + public SchemaNode getChildContext(SchemaNode schemaNode, String name, String namespace) { + return null; + } + + @Override + public NodeType getNodeType(SchemaNode schemaNode) { + return null; + } + + @Override + public void addNode(String name, String namespace, String value, String valNamespace, NodeType type) { + } + + @Override + public void exitNode() { + } + + @Override + public Map getProperties() { + return null; + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/NodeType.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/NodeType.java new file mode 100644 index 000000000..5a63d6325 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/NodeType.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; + +/** + * Representation of type of data node. + */ +public enum NodeType { + SINGLE_INSTANCE, + MULTI_INSTANCE, + SINGLE_INSTANCE_LEAF, + MULTI_INSTANCE_LEAF +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/SerializerHelper.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/SerializerHelper.java new file mode 100644 index 000000000..a4bbce529 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/SerializerHelper.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; + +import java.util.Map; + +/** + * Abstraction of an entity which helps the data format serializers to obtain + * schema context details and to build properties from data. + * + * @param type of schema node + */ +public abstract class SerializerHelper { + + private T rootSchema; + private String rootURI; + + protected SerializerHelper(T t, String uri) { + rootSchema = t; + } + + /** + * Returns root schema context node. + * + * @return root schema context node + */ + protected abstract T getRootContext(); + + /** + * Returns current schema context node. + * + * @return current schema context node + */ + protected abstract T getCurContext(); + + /** + * Returns child schema context node. + * + * @return child schema context node + */ + protected abstract T getChildContext(T t, String name, String namespace); + + /** + * Returns type of node + * @param t node + * @return node type + */ + protected abstract NodeType getNodeType(T t); + + /** + * Adds a node to current tree. + * + * @param name name of node + * @param namespace namespace of node, it can be either module name or + * namespace, null indicates parent namespace + * @param value value of node, in case it's leaf/leaf-list node + * @param valNamespace value namespace for identityref, could be module + * name or namespace + * @param type type of node if known like in case of JSON + */ + protected abstract void addNode(String name, String namespace, String value, + String valNamespace, NodeType type); + + /** + * Exits the node, in case if it's leaf node add to properties map. + */ + protected abstract void exitNode(); + + /** + * Returns the properties built corresponding to data. + * + * @return properties map + */ + protected abstract Map getProperties(); +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/XmlSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/XmlSerializer.java new file mode 100644 index 000000000..ba5d8ed27 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/XmlSerializer.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; + +import java.util.List; +import java.util.Map; + +/** + * Representation of XML serializer. + */ +public class XmlSerializer extends DataFormatSerializer { + + /** + * Creates an instance of XML serializer. + * + * @param serializerContext data format serializer context + */ + protected XmlSerializer(DataFormatSerializerContext serializerContext) { + super(DataFormat.XML, serializerContext); + } + + @Override + public String encode(Map param, Map> annotations) { + return null; + } + + @Override + public Map decode(String dataFormatBody) { + return null; + } +} \ No newline at end of file -- cgit From 8b39ca99c8a49197b05f8fea7de9a1606c810e63 Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Tue, 24 Jul 2018 16:40:14 +0900 Subject: SSHApiCallNode sshExec API Impl Issue-ID: CCSDK-385 Change-Id: I430f9075ced10edb49062fc12091774e91611b32 Signed-off-by: Ganesh Chandrasekaran --- .../sli/plugins/restapicall/RestapiCallNode.java | 2 +- .../features/ccsdk-sshapi-call-node/pom.xml | 3 +- sshapi-call-node/provider/pom.xml | 10 + .../sli/plugins/sshapicall/SshApiCallNode.java | 226 ++++++++++++++--- .../sli/plugins/sshapicall/impl/AuthType.java | 19 -- .../ccsdk/sli/plugins/sshapicall/impl/Format.java | 39 --- .../sli/plugins/sshapicall/impl/Parameters.java | 42 ---- .../sshapicall/impl/SshapiCallNodeImpl.java | 43 ---- .../sli/plugins/sshapicall/model/AuthType.java | 41 +++ .../ccsdk/sli/plugins/sshapicall/model/Format.java | 39 +++ .../sli/plugins/sshapicall/model/JsonParser.java | 6 +- .../sli/plugins/sshapicall/model/Parameters.java | 45 ++++ .../sli/plugins/sshapicall/model/ParseParam.java | 274 +++++++++++++++++++++ .../plugins/sshapicall/model/RetryException.java | 32 --- .../sli/plugins/sshapicall/model/RetryPolicy.java | 62 ----- .../plugins/sshapicall/model/RetryPolicyStore.java | 56 ----- .../META-INF/spring/sshapi-call-node-context.xml | 6 +- .../spring/sshapi-call-node-osgi-context.xml | 2 +- .../blueprint/sshapi-call-node-blueprint.xml | 2 +- .../sli/plugins/sshapicall/TestJsonParser.java | 16 +- 20 files changed, 623 insertions(+), 342 deletions(-) delete mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/AuthType.java delete mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Format.java delete mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Parameters.java delete mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/SshapiCallNodeImpl.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/AuthType.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Format.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Parameters.java create mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java delete mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryException.java delete mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicy.java delete mode 100644 sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicyStore.java diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 5168b3ec1..42462f0e6 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -90,7 +90,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { /** * Allows Directed Graphs the ability to interact with REST APIs. - * @param parameters HashMap of parameters passed by the DG to this function + * @param paramMap HashMap of parameters passed by the DG to this function * * * diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index 12ec06867..7b74d6de9 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -36,7 +36,7 @@ - + diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index 165003ff1..e380d7c25 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -39,6 +39,16 @@ org.onap.ccsdk.sli.coresli-provider + + org.onap.appc + appc-ssh-adapter-api + 1.3.0 + provided + + + org.json + json + org.slf4j slf4j-api 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 index 4efddec80..e4b082cda 100644 --- 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 @@ -1,10 +1,11 @@ /*- * ============LICENSE_START======================================================= - * openECOMP : SDN-C + * ONAP : APPC * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= * 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 @@ -16,36 +17,89 @@ * 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 com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.ByteArrayOutputStream; +import java.util.Collections; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import com.google.common.base.Strings; +import org.json.JSONObject; +import org.onap.appc.adapter.ssh.SshAdapter; +import org.onap.appc.adapter.ssh.SshConnection; import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import java.io.OutputStream; -import java.util.Map; +import org.onap.ccsdk.sli.plugins.sshapicall.model.AuthType; +import org.onap.ccsdk.sli.plugins.sshapicall.model.Parameters; +import org.onap.ccsdk.sli.plugins.sshapicall.model.ParseParam; + + +public class SshApiCallNode implements SvcLogicJavaPlugin { + + private static final EELFLogger logger = EELFManager.getInstance().getApplicationLogger(); + + /** + * Output parameter - SSH command execution status. + */ + String PARAM_OUT_status = "status"; + + /** + * Output parameter - content of SSH command stdout. + */ + String PARAM_OUT_stdout = "stdout"; + + /** + * Output parameter - content of SSH command stderr. + */ + String PARAM_OUT_stderr = "stderr"; + + /** + * Default success status. + */ + int DEF_SUCCESS_STATUS = 0; + + private SshAdapter sshAdapter; -public interface SshApiCallNode extends SvcLogicJavaPlugin { + public void setSshAdapter(SshAdapter sshAdapter) { + this.sshAdapter = sshAdapter; + } /** * Allows Directed Graphs the ability to interact with SSH APIs. - * @param paramMap HashMap of parameters passed by the DG to this function + * @param params HashMap of parameters passed by the DG to this function *
parameterMandatory/Optionaldescriptionexample values
* * * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * * vpn-information.vrf-details - * - * - * + * + * + * + * * *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/sshapi/templates/vnf_service-configuration-operation_minimal.json
sshapiUrlMandatoryurl to make the SSH connection request to.
sshapiUserOptionaluser name to use for ssh basic authenticationsdnc_ws
sshapiPasswordOptionalunencrypted password to use for ssh basic authenticationplain_password
sshKeyOptionalConsumer SSH key to use for ssh authenticationplain_key
cmdMandatoryssh command to be executed on the server.get post put delete patch
responsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
UrlMandatoryurl to make the SSH connection request to.
PortMandatoryport to make the SSH connection request to.
UserOptionaluser name to use for ssh basic authenticationsdnc_ws
PasswordOptionalunencrypted password to use for ssh basic authenticationplain_password
SshKeyOptionalConsumer SSH key to use for ssh authenticationplain_key
ExecTimeoutOptionalSSH command execution timeoutplain_key
RetryOptionalMake ssh connection with default retry policyplain_key
CmdMandatoryssh command to be executed on the server.get post put delete patch
ResponsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
ResponseTypeOptionalIf we know the response is to be in a specific format (supported are JSON, XML and NONE) tmp.sshapi.result
listName[i]OptionalUsed for processing XML responses with repeating elements.
convertResponse Optionalwhether the response should be convertedtrue or false
dumpHeadersOptionalwhen true writes ssh response content to context memorytrue or false
returnRequestPayloadOptionalused to return payload built in the requesttrue or false
ConvertResponse Optionalwhether the response should be convertedtrue or false
AuthTypeOptionalType of authentiation to be used BASIC or sshKey basedtrue or false
EnvParametersOptionalA JSON dictionary which should list key value pairs to be passed to the command execution. + * These values would correspond to instance specific parameters that a command may need to execute an action.
FileParametersOptionalA JSON dictionary where keys are filenames and values are contents of files. + * The SSH Server will utilize this feature to generate files with keys as filenames and values as content. + * This attribute can be used to generate files that a command may require as part of execution.
* Exec remote command over SSH. Return command execution status. @@ -53,32 +107,140 @@ public interface SshApiCallNode extends SvcLogicJavaPlugin { * * @param ctx Reference to context memory */ - void execCommand(Map paramMap, SvcLogicContext ctx) throws SvcLogicException; + + public void execCommand(Map params, SvcLogicContext ctx) throws SvcLogicException { + ParseParam parser = new ParseParam(); + Parameters p = parser.getParameters(params); + logger.debug("=> Connecting to SSH server..."); + SshConnection sshConnection = getSshConnection(p); + sshConnection.connect(); + try { + logger.debug("=> Connected to SSH server..."); + logger.debug("=> Running SSH command..."); + sshConnection.setExecTimeout(p.sshExecTimeout); + ByteArrayOutputStream stdout = new ByteArrayOutputStream(); + ByteArrayOutputStream stderr = new ByteArrayOutputStream(); + int status = sshConnection.execCommand(parser.makeCommand(params), stdout, stderr); + String stdoutRes = stdout.toString(); + String stderrRes = stderr.toString(); + logger.debug("=> executed SSH command"); + + if(status == DEF_SUCCESS_STATUS) { + parser.parseOutput(ctx, stdoutRes); + } + ctx.setAttribute(PARAM_OUT_status, String.format("%01d", status)); + ctx.setAttribute(PARAM_OUT_stdout, stdoutRes); + ctx.setAttribute(PARAM_OUT_stderr, stderrRes); + } finally { + sshConnection.disconnect(); + } + } + + private SshConnection getSshConnection(Parameters p) throws SvcLogicException{ + if (p.authtype == AuthType.BASIC) + return sshAdapter.getConnection(p.sshapiUrl, p.sshapiPort, p.sshapiUser, p.sshapiPassword); + // This is not supported yet in the API, patch has already been added to APPC + else if (p.authtype == AuthType.KEY){ + //return sshAdapter.getConnection(p.sshapiUrl, p.sshapiPort, p.sshKey); + throw new SvcLogicException("SSH Key based Auth method not supported"); + } + else if (p.authtype == AuthType.NONE){ + //return sshAdapter.getConnection(p.sshapiUrl, p.sshapiPort, p.sshKey); + throw new SvcLogicException("SSH Auth type required, BASIC auth in support"); + } + else if (p.authtype == AuthType.UNSPECIFIED){ + if (p.sshapiUser != null && p.sshapiPassword != null) + return sshAdapter.getConnection(p.sshapiUrl, p.sshapiPort, p.sshapiUser, p.sshapiPassword); + else if (p.sshKey != null) + throw new SvcLogicException("SSH Key based Auth method not supported"); + } + throw new SvcLogicException("SSH Auth type required, BASIC auth in support"); + } + /** * Allows Directed Graphs the ability to interact with SSH APIs. - * @param paramMap HashMap of parameters passed by the DG to this function + * @param params HashMap of parameters passed by the DG to this function * * * * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * * vpn-information.vrf-details - * - * - * + * + * + * + * * *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/sshapi/templates/vnf_service-configuration-operation_minimal.json
sshapiUrlMandatoryurl to make the SSH connection request to.
sshapiUserOptionaluser name to use for ssh basic authenticationsdnc_ws
sshapiPasswordOptionalunencrypted password to use for ssh basic authenticationplain_password
sshKeyOptionalConsumer SSH key to use for ssh authenticationplain_key
cmdMandatoryssh command to be executed on the server.get post put delete patch
responsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
UrlMandatoryurl to make the SSH connection request to.
PortMandatoryport to make the SSH connection request to.
UserOptionaluser name to use for ssh basic authenticationsdnc_ws
PasswordOptionalunencrypted password to use for ssh basic authenticationplain_password
SshKeyOptionalConsumer SSH key to use for ssh authenticationplain_key
ExecTimeoutOptionalSSH command execution timeoutplain_key
RetryOptionalMake ssh connection with default retry policyplain_key
CmdMandatoryssh command to be executed on the server.get post put delete patch
ResponsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
ResponseTypeOptionalIf we know the response is to be in a specific format (supported are JSON, XML and NONE) tmp.sshapi.result
listName[i]OptionalUsed for processing XML responses with repeating elements.
convertResponse Optionalwhether the response should be convertedtrue or false
dumpHeadersOptionalwhen true writes ssh response content to context memorytrue or false
returnRequestPayloadOptionalused to return payload built in the requesttrue or false
ConvertResponse Optionalwhether the response should be convertedtrue or false
AuthTypeOptionalType of authentiation to be used BASIC or sshKey basedtrue or false
EnvParametersOptionalA JSON dictionary which should list key value pairs to be passed to the command execution. + * These values would correspond to instance specific parameters that a command may need to execute an action.
FileParametersOptionalA JSON dictionary where keys are filenames and values are contents of files. + * The SSH Server will utilize this feature to generate files with keys as filenames and values as content. + * This attribute can be used to generate files that a command may require as part of execution.
- * 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. + * Exec remote command over SSH. Return command execution status. + * Command output is written to out or err stream. * - * @param ctx Reference to context memory + * @param ctx Reference to context memory + */ + + public void execWithStatusCheck(Map params, SvcLogicContext ctx) throws SvcLogicException { + execCommand(params, ctx); + int status = Integer.parseInt(ctx.getAttribute(PARAM_OUT_status)); + if(status != DEF_SUCCESS_STATUS) { + StringBuilder errmsg = new StringBuilder(); + errmsg.append("SSH command returned error status [").append(status).append(']'); + String stderrRes = ctx.getAttribute(PARAM_OUT_stderr); + String stdoutRes = ctx.getAttribute(PARAM_OUT_stdout); + if((stderrRes != null) && !stderrRes.isEmpty()) { + errmsg.append(". Error: [").append(stderrRes).append(']'); + } else if ((stdoutRes != null) && !stdoutRes.isEmpty()) { + errmsg.append(". Error: [").append(stdoutRes).append(']'); + } + throw new SvcLogicException(errmsg.toString()); + } + } + + /** + * Allows Directed Graphs the ability to interact with SSH APIs. + * @param params HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * vpn-information.vrf-details + * + * + * + * + * + *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/sshapi/templates/vnf_service-configuration-operation_minimal.json
UrlMandatoryurl to make the SSH connection request to.
PortMandatoryport to make the SSH connection request to.
UserOptionaluser name to use for ssh basic authenticationsdnc_ws
PasswordOptionalunencrypted password to use for ssh basic authenticationplain_password
SshKeyOptionalConsumer SSH key to use for ssh authenticationplain_key
ExecTimeoutOptionalSSH command execution timeoutplain_key
RetryOptionalMake ssh connection with default retry policyplain_key
CmdMandatoryssh command to be executed on the server.get post put delete patch
ResponsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
ResponseTypeOptionalIf we know the response is to be in a specific format (supported are JSON, XML and NONE) tmp.sshapi.result
listName[i]OptionalUsed for processing XML responses with repeating elements.
ConvertResponse Optionalwhether the response should be convertedtrue or false
AuthTypeOptionalType of authentiation to be used BASIC or sshKey basedtrue or false
EnvParametersOptionalA JSON dictionary which should list key value pairs to be passed to the command execution. + * These values would correspond to instance specific parameters that a command may need to execute an action.
FileParametersOptionalA JSON dictionary where keys are filenames and values are contents of files. + * The SSH Server will utilize this feature to generate files with keys as filenames and values as content. + * This attribute can be used to generate files that a command may require as part of execution.
+ * 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 execCommandWithPty(Map paramMap, SvcLogicContext ctx) throws SvcLogicException ; + public void execCommandWithPty(Map params, 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 deleted file mode 100644 index 308162271..000000000 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/AuthType.java +++ /dev/null @@ -1,19 +0,0 @@ -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 deleted file mode 100644 index 75604de66..000000000 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Format.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index a392cc73c..000000000 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/Parameters.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============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 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 deleted file mode 100644 index 9283b8b5f..000000000 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/impl/SshapiCallNodeImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============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 paramMap, SvcLogicContext ctx) throws SvcLogicException { - //TODO: Implementation - } - - @Override - public void execCommandWithPty(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { - //TODO: Implementation - } -} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/AuthType.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/AuthType.java new file mode 100644 index 000000000..2ec48c70c --- /dev/null +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/AuthType.java @@ -0,0 +1,41 @@ +/*- + * ============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 enum AuthType { + NONE, BASIC, KEY, UNSPECIFIED; + + public static AuthType fromString(String s) { + if ("basic".equalsIgnoreCase(s)) + return BASIC; + if ("key".equalsIgnoreCase(s)) + return KEY; + if ("unspecified".equalsIgnoreCase(s)) + return UNSPECIFIED; + 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/model/Format.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Format.java new file mode 100644 index 000000000..e50a96c6c --- /dev/null +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/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.model; + +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/model/JsonParser.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java index e840053f8..f40f1ad71 100644 --- 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 @@ -47,11 +47,10 @@ public final class JsonParser { @SuppressWarnings("unchecked") public static Map convertToProperties(String s) - throws SvcLogicException { + throws JSONException { checkNotNull(s, "Input should not be null."); - try { JSONObject json = new JSONObject(s); Map wm = new HashMap<>(); Iterator ii = json.keys(); @@ -89,8 +88,5 @@ public final class JsonParser { } } 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/Parameters.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Parameters.java new file mode 100644 index 000000000..a22da5bcb --- /dev/null +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Parameters.java @@ -0,0 +1,45 @@ +/*- + * ============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.Set; + +public class Parameters { + public String sshapiUrl; + public int sshapiPort; + public String sshapiUser; + public String sshapiPassword; + public String sshKey; + public long sshExecTimeout; + public String sshFileParameters; + public String sshEnvParameters; + public boolean sshWithRetry; + public String cmd; + public String responsePrefix; + public Format responseType; + + public Set listNameList; + public boolean convertResponse; + public AuthType authtype; +} diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java new file mode 100644 index 000000000..caf49ef91 --- /dev/null +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java @@ -0,0 +1,274 @@ +/*- + * ============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 com.google.common.base.Strings; +import org.json.JSONException; +import org.json.JSONObject; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.HashSet; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +public class ParseParam { + private static final Logger log = LoggerFactory.getLogger(ParseParam.class); + /** + * Default SSH command timeout + */ + private long dEF_timeout = 12000; + /** + * Default SSH connection port. + */ + private int dEF_port = 22; + /** + * Default SSH command timeout + */ + private final String FILE_PARAMETERS_OPT_KEY = "FileParameters"; + /** + * Default SSH connection port. + */ + private final String ENV_PARAMETERS_OPT_KEY = "EnvParameters"; + private Parameters p = new Parameters(); + + public Parameters getParameters(Map paramMap) throws SvcLogicException { + p.sshapiUrl = parseParam(paramMap, "Url", true, null); + p.sshapiPort = Integer.parseInt(parseParam(paramMap, "Port", true, Integer.toString(dEF_port))); + p.sshapiUser = parseParam(paramMap, "User", false, null); + p.sshapiPassword = parseParam(paramMap, "Password", false, null); + p.sshKey = parseParam(paramMap, "SshKey", false, null); + p.sshExecTimeout = Long.parseLong(parseParam(paramMap, "ExecTimeout", false, Long.toString(dEF_timeout))); + p.sshWithRetry = Boolean.valueOf(parseParam(paramMap, "Retry", false, "false")); + p.cmd = parseParam(paramMap, "Cmd", true, null); + p.responsePrefix = parseParam(paramMap, "ResponsePrefix", false, null); + p.responseType = Format.fromString(parseParam(paramMap, "ResponseType", false, "none")); + p.listNameList = getListNameList(paramMap); + p.convertResponse = Boolean.valueOf(parseParam(paramMap, "ConvertResponse", false, "true")); + p.authtype = AuthType.fromString(parseParam(paramMap, "AuthType", false, "unspecified")); + + return p; + } + + public void parseOutput (SvcLogicContext ctx, String outMessage) throws SvcLogicException { + if (p.convertResponse) { + if (p.responseType == Format.NONE) { + classifyOutput(ctx, outMessage); + } else if (p.responseType == Format.JSON) { + classifyOutput(ctx, outMessage); + } else if (p.responseType == Format.XML) { + classifyOutput(ctx, outMessage, p.listNameList); + } + } + } + + private void classifyOutput(SvcLogicContext ctx, String outMessage, Set listNameList) throws SvcLogicException { + Map mm = XmlParser.convertToProperties(outMessage, p.listNameList); + toCtx (ctx, mm); + } + + private void toCtx (SvcLogicContext ctx, Map mm) { + if (mm != null) { + for (Map.Entry entry : mm.entrySet()) { + if (p.responsePrefix != null) { + ctx.setAttribute(p.responsePrefix + "." + entry.getKey(), entry.getValue()); + log.info("+++ " + p.responsePrefix + "." + entry.getKey() + ": [" + entry.getValue() + "]"); + } else { + ctx.setAttribute(entry.getKey(), entry.getValue()); + log.info("+++ " + entry.getKey() + ": [" + entry.getValue() + "]"); + } + } + } + } + + private void classifyOutput(SvcLogicContext ctx, String outMessage) throws SvcLogicException { + try { + Map mm = JsonParser.convertToProperties(outMessage); + toCtx (ctx, mm); + } catch (org.codehaus.jettison.json.JSONException e) { + log.info("Output not in JSON format"); + putToProperties(ctx, p.responsePrefix); + } catch (Exception e) { + throw new SvcLogicException("error parsing response file"); + } + } + + private void putToProperties(SvcLogicContext ctx, String outMessage) throws SvcLogicException { + + try { + Properties prop = new Properties(); + prop.load(new ByteArrayInputStream(outMessage.getBytes(StandardCharsets.UTF_8))); + for (Object key : prop.keySet()) { + String name = (String) key; + String value = prop.getProperty(name); + if (value != null && value.trim().length() > 0) { + if (p.responsePrefix != null) { + ctx.setAttribute(p.responsePrefix + "." + name, value.trim()); + log.info("+++ " + p.responsePrefix + "." + name + ": [" + value + "]"); + } else { + ctx.setAttribute(name, value.trim()); + log.info("+++ " + name + ": [" + value + "]"); + } + } + } + } catch (Exception e) { + throw new SvcLogicException( "Error parsing response file."); + } + } + + public String makeCommand (Map params) { + JSONObject jsonPayload = new JSONObject(); + final String[] optionalTestParams = {ENV_PARAMETERS_OPT_KEY, FILE_PARAMETERS_OPT_KEY}; + parseParam(params, optionalTestParams, jsonPayload); + JSONObject envParams = (JSONObject) jsonPayload.remove(ENV_PARAMETERS_OPT_KEY); + JSONObject fileParams = (JSONObject) jsonPayload.remove(FILE_PARAMETERS_OPT_KEY); + + StringBuilder constructedCommand = new StringBuilder(); + constructedCommand.append(parseFileParam(fileParams)).append(p.cmd).append(" ").append(parseEnvParam(envParams)); + + return constructedCommand.toString(); + } + + private String parseEnvParam(JSONObject envParams) { + StringBuilder envParamBuilder = new StringBuilder(); + if (envParams != null) { + for (Object key : envParams.keySet()) { + if (envParamBuilder.length() > 0) { + envParamBuilder.append(", "); + } + envParamBuilder.append(key + "=" + envParams.get((String) key)); + } + } + return envParamBuilder.toString(); + } + + private String parseFileParam(JSONObject fileParams) { + StringBuilder fileParamBuilder = new StringBuilder(); + if (fileParams != null) { + for (Object key : fileParams.keySet()) { + fileParamBuilder.append("echo -e \"" + fileParams.get((String) key) + "\" > /srv/salt/" + key).append("; "); + } + } + return fileParamBuilder.toString(); + } + + private void parseParam(Map params, String[] optionalTestParams, JSONObject jsonPayload) + throws JSONException { + + Set optionalParamsSet = new HashSet<>(); + Collections.addAll(optionalParamsSet, optionalTestParams); + + //@formatter:off + params.entrySet() + .stream() + .filter(entry -> optionalParamsSet.contains(entry.getKey())) + .filter(entry -> !Strings.isNullOrEmpty(entry.getValue())) + .forEach(entry -> parseParam(entry, jsonPayload)); + //@formatter:on + } + + private void parseParam(Map.Entry params, JSONObject jsonPayload) + throws JSONException { + String key = params.getKey(); + String payload = params.getValue(); + + switch (key) { + case ENV_PARAMETERS_OPT_KEY: + JSONObject paramsJson = new JSONObject(payload); + jsonPayload.put(key, paramsJson); + break; + + case FILE_PARAMETERS_OPT_KEY: + jsonPayload.put(key, getFilePayload(payload)); + break; + + default: + break; + } + } + + /** + * Return payload with escaped newlines + */ + private JSONObject getFilePayload(String payload) { + String formattedPayload = payload.replace("\n", "\\n").replace("\r", "\\r"); + return new JSONObject(formattedPayload); + } + + private Set getListNameList(Map paramMap) { + Set ll = new HashSet<>(); + for (Map.Entry entry : paramMap.entrySet()) + if (entry.getKey().startsWith("listName")) + ll.add(entry.getValue()); + return ll; + } + + private String parseParam(Map paramMap, String name, boolean required, String def) + throws SvcLogicException { + String s = paramMap.get(name); + + if (s == null || s.trim().length() == 0) { + if (!required) + return def; + throw new SvcLogicException("Parameter " + name + " is required in sshapiCallNode"); + } + + s = s.trim(); + StringBuilder value = new StringBuilder(); + int i = 0; + int i1 = s.indexOf('%'); + while (i1 >= 0) { + int i2 = s.indexOf('%', i1 + 1); + if (i2 < 0) + break; + + String varName = s.substring(i1 + 1, i2); + String varValue = System.getenv(varName); + if (varValue == null) + varValue = "%" + varName + "%"; + + value.append(s.substring(i, i1)); + value.append(varValue); + + i = i2 + 1; + i1 = s.indexOf('%', i); + } + value.append(s.substring(i)); + + log.info("Parameter {}: [{}]", name, value); + return value.toString(); + } +} 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 deleted file mode 100644 index 9a1d3a312..000000000 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryException.java +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index fef0f81af..000000000 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicy.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 65575b8ce..000000000 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/RetryPolicyStore.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============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 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/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 index 4cce6ffad..50c9b2aa3 100644 --- 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 @@ -40,12 +40,8 @@ - + - - - - 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 index c8e9a99e3..25631d6af 100644 --- 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 @@ -29,6 +29,6 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - + 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 index b24aaf1ee..7a5424329 100755 --- 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 @@ -3,7 +3,7 @@ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" odl:use-default-for-reference-types="true"> - + 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 index 9df790ae3..66be73001 100644 --- 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 @@ -31,6 +31,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import org.codehaus.jettison.json.JSONException; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.plugins.sshapicall.model.JsonParser; @@ -50,8 +51,12 @@ public class TestJsonParser { String line; while ((line = in.readLine()) != null) b.append(line).append('\n'); - - Map mm = JsonParser.convertToProperties(b.toString()); + Map mm = null; + try { + mm = JsonParser.convertToProperties(b.toString()); + } catch (JSONException e){ + throw new SvcLogicException(e.getMessage()); + } logProperties(mm); @@ -60,7 +65,12 @@ public class TestJsonParser { @Test(expected = NullPointerException.class) public void testNullString() throws SvcLogicException { - JsonParser.convertToProperties(null); + Map mm = null; + try { + mm = JsonParser.convertToProperties(null); + } catch (JSONException e){ + throw new SvcLogicException(e.getMessage()); + } } private void logProperties(Map mm) { -- cgit From be3d4606d9627e5dfb461b72140f7be52e1c7776 Mon Sep 17 00:00:00 2001 From: gaurav Date: Wed, 25 Jul 2018 11:33:13 +0530 Subject: Adding additional APIs for YANG serializers Adding APIs for YANG based properties node serializer Change-Id: Ic76204e0292fdbaede4ff47f4ddda91dcfa3b764 Issue-ID: CCSDK-377 Signed-off-by: Gaurav Agrawal --- .../sli/plugins/yangserializers/Annotation.java | 59 ---------- .../sli/plugins/yangserializers/DataFormat.java | 29 ----- .../yangserializers/DataFormatSerializer.java | 82 -------------- .../DataFormatSerializerContext.java | 74 ------------ .../plugins/yangserializers/JsonSerializer.java | 49 -------- .../sli/plugins/yangserializers/Listener.java | 34 ------ .../yangserializers/MdsalSerializerHelper.java | 67 ----------- .../sli/plugins/yangserializers/NodeType.java | 31 ------ .../plugins/yangserializers/SerializerHelper.java | 93 ---------------- .../sli/plugins/yangserializers/XmlSerializer.java | 49 -------- .../yangserializers/dfserializer/Annotation.java | 59 ++++++++++ .../yangserializers/dfserializer/DataFormat.java | 29 +++++ .../dfserializer/DataFormatSerializer.java | 82 ++++++++++++++ .../dfserializer/DataFormatSerializerContext.java | 74 ++++++++++++ .../dfserializer/JsonSerializer.java | 49 ++++++++ .../yangserializers/dfserializer/Listener.java | 34 ++++++ .../dfserializer/MdsalSerializerHelper.java | 67 +++++++++++ .../yangserializers/dfserializer/NodeType.java | 31 ++++++ .../dfserializer/SerializerHelper.java | 93 ++++++++++++++++ .../dfserializer/XmlSerializer.java | 49 ++++++++ .../MdsalPropertiesNodeSerializer.java | 59 ++++++++++ .../yangserializers/pnserializer/NodeType.java | 33 ++++++ .../pnserializer/PropertiesNode.java | 124 +++++++++++++++++++++ .../pnserializer/PropertiesNodeSerializer.java | 108 ++++++++++++++++++ 24 files changed, 891 insertions(+), 567 deletions(-) delete mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/Annotation.java delete mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormat.java delete mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormatSerializer.java delete mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormatSerializerContext.java delete mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/JsonSerializer.java delete mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/Listener.java delete mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/MdsalSerializerHelper.java delete mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/NodeType.java delete mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/SerializerHelper.java delete mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/XmlSerializer.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/Annotation.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormat.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializer.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerContext.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/Listener.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/NodeType.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/SerializerHelper.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/NodeType.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNode.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeSerializer.java diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/Annotation.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/Annotation.java deleted file mode 100644 index 13f1c323b..000000000 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/Annotation.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; - -/** - * Representation of an entity that represents annotated attribute. - */ -public class Annotation { - - private String name; - private String value; - - /** - * Creates an instance of annotation. - * - * @param n annotation name - * @param v annotation value - */ - public Annotation(String n, String v) { - name = n; - value = v; - } - - /** - * Returns name of annotation. - * - * @return name of annotation - */ - public String name() { - return name; - } - - /** - * Returns value of annotation. - * - * @return value of annotation - */ - public String value() { - return value; - } -} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormat.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormat.java deleted file mode 100644 index 0d1928b35..000000000 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormat.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; - -/** - * Representation of data format. - */ -public enum DataFormat { - XML, - JSON -} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormatSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormatSerializer.java deleted file mode 100644 index bcd5991d7..000000000 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormatSerializer.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; - -import java.util.List; -import java.util.Map; - -/** - * Abstraction of serializer to encode/decode context memory parameters - * to/from specified data format. - */ -public abstract class DataFormatSerializer { - - private DataFormat dataFormat; - private DataFormatSerializerContext serializerContext; - - /** - * Creates an instance of data format serializer. - * - * @param dataFormat type of data format - * @param serializerContext data format serializer context - */ - protected DataFormatSerializer(DataFormat dataFormat, - DataFormatSerializerContext serializerContext) { - this.dataFormat = dataFormat; - this.serializerContext = serializerContext; - } - - /** - * Encodes context memory parameters to data format. - * - * @param param context memory parameter - * @param annotations annotations - * @return data format body - */ - public abstract String encode(Map param, - Map> annotations); - - /** - * Decodes data format body to context memory parameters. - * - * @param dataFormatBody abstract node - * @return context memory parameters - */ - public abstract Map decode(String dataFormatBody); - - /** - * Returns data format serializer context. - * - * @return data format serializer context - */ - public DataFormatSerializerContext serializerContext() { - return serializerContext; - } - - /** - * Returns supported data format. - * - * @return supported data format - */ - public DataFormat dataFormat() { - return dataFormat; - } -} \ No newline at end of file diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormatSerializerContext.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormatSerializerContext.java deleted file mode 100644 index 50cb2daf6..000000000 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/DataFormatSerializerContext.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; - -import java.util.Map; - -/** - * Abstraction of data format serializer context. - */ -public class DataFormatSerializerContext { - - private Listener listener; - private String uri; - private Map protocolAnnotation; - - /** - * Creates an instance of data format serializer context. - * - * @param listener data format listener - * @param uri URI corresponding to instance identifier - * @param protocolAnnotation protocol annotations - */ - public DataFormatSerializerContext(Listener listener, String uri, - Map protocolAnnotation) { - this.listener = listener; - this.uri = uri; - this.protocolAnnotation = protocolAnnotation; - } - - /** - * Retruns data format listener. - * - * @return data format listener - */ - public Listener listener() { - return listener; - } - - /** - * Returns URI. - * - * @return URI - */ - public String uri() { - return uri; - } - - /** - * Returns protocol annotations. - * - * @return protocol annotations - */ - public Map getProtocolAnnotation() { - return protocolAnnotation; - } -} \ No newline at end of file diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/JsonSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/JsonSerializer.java deleted file mode 100644 index 072cfb09c..000000000 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/JsonSerializer.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; - -import java.util.List; -import java.util.Map; - -/** - * Representation of JSON serializer. - */ -public class JsonSerializer extends DataFormatSerializer { - - /** - * Creates an instance of data format serializer. - * - * @param serializerContext data format serializer context - */ - protected JsonSerializer(DataFormatSerializerContext serializerContext) { - super(DataFormat.JSON, serializerContext); - } - - @Override - public String encode(Map param, Map> annotations) { - return null; - } - - @Override - public Map decode(String dataFormatBody) { - return null; - } -} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/Listener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/Listener.java deleted file mode 100644 index a0976822e..000000000 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/Listener.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; - -/** - * Abstraction of listener. - */ -public interface Listener { - - /** - * Returns serializer helper for this listener. - * - * @return serializer helper - */ - SerializerHelper serializerHelper(); -} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/MdsalSerializerHelper.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/MdsalSerializerHelper.java deleted file mode 100644 index c9bda511f..000000000 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/MdsalSerializerHelper.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; - -import java.util.Map; -import org.opendaylight.yangtools.yang.model.api.SchemaNode; - -/** - * Representation of MDSAL based schema helper. - */ -public class MdsalSerializerHelper extends SerializerHelper { - - protected MdsalSerializerHelper(SchemaNode node, String uri) { - super(node, uri); - } - - @Override - public SchemaNode getRootContext() { - return null; - } - - @Override - public SchemaNode getCurContext() { - return null; - } - - @Override - public SchemaNode getChildContext(SchemaNode schemaNode, String name, String namespace) { - return null; - } - - @Override - public NodeType getNodeType(SchemaNode schemaNode) { - return null; - } - - @Override - public void addNode(String name, String namespace, String value, String valNamespace, NodeType type) { - } - - @Override - public void exitNode() { - } - - @Override - public Map getProperties() { - return null; - } -} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/NodeType.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/NodeType.java deleted file mode 100644 index 5a63d6325..000000000 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/NodeType.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; - -/** - * Representation of type of data node. - */ -public enum NodeType { - SINGLE_INSTANCE, - MULTI_INSTANCE, - SINGLE_INSTANCE_LEAF, - MULTI_INSTANCE_LEAF -} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/SerializerHelper.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/SerializerHelper.java deleted file mode 100644 index a4bbce529..000000000 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/SerializerHelper.java +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; - -import java.util.Map; - -/** - * Abstraction of an entity which helps the data format serializers to obtain - * schema context details and to build properties from data. - * - * @param type of schema node - */ -public abstract class SerializerHelper { - - private T rootSchema; - private String rootURI; - - protected SerializerHelper(T t, String uri) { - rootSchema = t; - } - - /** - * Returns root schema context node. - * - * @return root schema context node - */ - protected abstract T getRootContext(); - - /** - * Returns current schema context node. - * - * @return current schema context node - */ - protected abstract T getCurContext(); - - /** - * Returns child schema context node. - * - * @return child schema context node - */ - protected abstract T getChildContext(T t, String name, String namespace); - - /** - * Returns type of node - * @param t node - * @return node type - */ - protected abstract NodeType getNodeType(T t); - - /** - * Adds a node to current tree. - * - * @param name name of node - * @param namespace namespace of node, it can be either module name or - * namespace, null indicates parent namespace - * @param value value of node, in case it's leaf/leaf-list node - * @param valNamespace value namespace for identityref, could be module - * name or namespace - * @param type type of node if known like in case of JSON - */ - protected abstract void addNode(String name, String namespace, String value, - String valNamespace, NodeType type); - - /** - * Exits the node, in case if it's leaf node add to properties map. - */ - protected abstract void exitNode(); - - /** - * Returns the properties built corresponding to data. - * - * @return properties map - */ - protected abstract Map getProperties(); -} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/XmlSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/XmlSerializer.java deleted file mode 100644 index ba5d8ed27..000000000 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/XmlSerializer.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers; - -import java.util.List; -import java.util.Map; - -/** - * Representation of XML serializer. - */ -public class XmlSerializer extends DataFormatSerializer { - - /** - * Creates an instance of XML serializer. - * - * @param serializerContext data format serializer context - */ - protected XmlSerializer(DataFormatSerializerContext serializerContext) { - super(DataFormat.XML, serializerContext); - } - - @Override - public String encode(Map param, Map> annotations) { - return null; - } - - @Override - public Map decode(String dataFormatBody) { - return null; - } -} \ No newline at end of file diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/Annotation.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/Annotation.java new file mode 100644 index 000000000..7271c3d71 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/Annotation.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +/** + * Representation of an entity that represents annotated attribute. + */ +public class Annotation { + + private String name; + private String value; + + /** + * Creates an instance of annotation. + * + * @param n annotation name + * @param v annotation value + */ + public Annotation(String n, String v) { + name = n; + value = v; + } + + /** + * Returns name of annotation. + * + * @return name of annotation + */ + public String name() { + return name; + } + + /** + * Returns value of annotation. + * + * @return value of annotation + */ + public String value() { + return value; + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormat.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormat.java new file mode 100644 index 000000000..6fb11e70f --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormat.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +/** + * Representation of data format. + */ +public enum DataFormat { + XML, + JSON +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializer.java new file mode 100644 index 000000000..e703b1732 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializer.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import java.util.List; +import java.util.Map; + +/** + * Abstraction of serializer to encode/decode context memory parameters + * to/from specified data format. + */ +public abstract class DataFormatSerializer { + + private DataFormat dataFormat; + private DataFormatSerializerContext serializerContext; + + /** + * Creates an instance of data format serializer. + * + * @param dataFormat type of data format + * @param serializerContext data format serializer context + */ + protected DataFormatSerializer(DataFormat dataFormat, + DataFormatSerializerContext serializerContext) { + this.dataFormat = dataFormat; + this.serializerContext = serializerContext; + } + + /** + * Encodes context memory parameters to data format. + * + * @param param context memory parameter + * @param annotations annotations + * @return data format body + */ + public abstract String encode(Map param, + Map> annotations); + + /** + * Decodes data format body to context memory parameters. + * + * @param dataFormatBody abstract node + * @return context memory parameters + */ + public abstract Map decode(String dataFormatBody); + + /** + * Returns data format serializer context. + * + * @return data format serializer context + */ + public DataFormatSerializerContext serializerContext() { + return serializerContext; + } + + /** + * Returns supported data format. + * + * @return supported data format + */ + public DataFormat dataFormat() { + return dataFormat; + } +} \ No newline at end of file diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerContext.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerContext.java new file mode 100644 index 000000000..e2ead53fb --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerContext.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import java.util.Map; + +/** + * Abstraction of data format serializer context. + */ +public class DataFormatSerializerContext { + + private Listener listener; + private String uri; + private Map protocolAnnotation; + + /** + * Creates an instance of data format serializer context. + * + * @param listener data format listener + * @param uri URI corresponding to instance identifier + * @param protocolAnnotation protocol annotations + */ + public DataFormatSerializerContext(Listener listener, String uri, + Map protocolAnnotation) { + this.listener = listener; + this.uri = uri; + this.protocolAnnotation = protocolAnnotation; + } + + /** + * Retruns data format listener. + * + * @return data format listener + */ + public Listener listener() { + return listener; + } + + /** + * Returns URI. + * + * @return URI + */ + public String uri() { + return uri; + } + + /** + * Returns protocol annotations. + * + * @return protocol annotations + */ + public Map getProtocolAnnotation() { + return protocolAnnotation; + } +} \ No newline at end of file diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java new file mode 100644 index 000000000..6013664cb --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import java.util.List; +import java.util.Map; + +/** + * Representation of JSON serializer. + */ +public class JsonSerializer extends DataFormatSerializer { + + /** + * Creates an instance of data format serializer. + * + * @param serializerContext data format serializer context + */ + protected JsonSerializer(DataFormatSerializerContext serializerContext) { + super(DataFormat.JSON, serializerContext); + } + + @Override + public String encode(Map param, Map> annotations) { + return null; + } + + @Override + public Map decode(String dataFormatBody) { + return null; + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/Listener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/Listener.java new file mode 100644 index 000000000..e5812dbb7 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/Listener.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +/** + * Abstraction of listener. + */ +public interface Listener { + + /** + * Returns serializer helper for this listener. + * + * @return serializer helper + */ + SerializerHelper serializerHelper(); +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java new file mode 100644 index 000000000..311fc2d6b --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import java.util.Map; +import org.opendaylight.yangtools.yang.model.api.SchemaNode; + +/** + * Representation of MDSAL based schema helper. + */ +public class MdsalSerializerHelper extends SerializerHelper { + + protected MdsalSerializerHelper(SchemaNode node, String uri) { + super(node, uri); + } + + @Override + public SchemaNode getRootContext() { + return null; + } + + @Override + public SchemaNode getCurContext() { + return null; + } + + @Override + public SchemaNode getChildContext(SchemaNode schemaNode, String name, String namespace) { + return null; + } + + @Override + public NodeType getNodeType(SchemaNode schemaNode) { + return null; + } + + @Override + public void addNode(String name, String namespace, String value, String valNamespace, NodeType type) { + } + + @Override + public void exitNode() { + } + + @Override + public Map getProperties() { + return null; + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/NodeType.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/NodeType.java new file mode 100644 index 000000000..ffa35e2b6 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/NodeType.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +/** + * Representation of type of data node. + */ +public enum NodeType { + SINGLE_INSTANCE, + MULTI_INSTANCE, + SINGLE_INSTANCE_LEAF, + MULTI_INSTANCE_LEAF +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/SerializerHelper.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/SerializerHelper.java new file mode 100644 index 000000000..4e6d2944d --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/SerializerHelper.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import java.util.Map; + +/** + * Abstraction of an entity which helps the data format serializers to obtain + * schema context details and to build properties from data. + * + * @param type of schema node + */ +public abstract class SerializerHelper { + + private T rootSchema; + private String rootURI; + + protected SerializerHelper(T t, String uri) { + rootSchema = t; + } + + /** + * Returns root schema context node. + * + * @return root schema context node + */ + protected abstract T getRootContext(); + + /** + * Returns current schema context node. + * + * @return current schema context node + */ + protected abstract T getCurContext(); + + /** + * Returns child schema context node. + * + * @return child schema context node + */ + protected abstract T getChildContext(T t, String name, String namespace); + + /** + * Returns type of node + * @param t node + * @return node type + */ + protected abstract NodeType getNodeType(T t); + + /** + * Adds a node to current tree. + * + * @param name name of node + * @param namespace namespace of node, it can be either module name or + * namespace, null indicates parent namespace + * @param value value of node, in case it's leaf/leaf-list node + * @param valNamespace value namespace for identityref, could be module + * name or namespace + * @param type type of node if known like in case of JSON + */ + protected abstract void addNode(String name, String namespace, String value, + String valNamespace, NodeType type); + + /** + * Exits the node, in case if it's leaf node add to properties map. + */ + protected abstract void exitNode(); + + /** + * Returns the properties built corresponding to data. + * + * @return properties map + */ + protected abstract Map getProperties(); +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java new file mode 100644 index 000000000..0cfb4d17f --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import java.util.List; +import java.util.Map; + +/** + * Representation of XML serializer. + */ +public class XmlSerializer extends DataFormatSerializer { + + /** + * Creates an instance of XML serializer. + * + * @param serializerContext data format serializer context + */ + protected XmlSerializer(DataFormatSerializerContext serializerContext) { + super(DataFormat.XML, serializerContext); + } + + @Override + public String encode(Map param, Map> annotations) { + return null; + } + + @Override + public Map decode(String dataFormatBody) { + return null; + } +} \ No newline at end of file diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java new file mode 100644 index 000000000..67e9c1e59 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +import java.util.Map; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.SchemaNode; +import org.slf4j.Logger; +import static org.slf4j.LoggerFactory.getLogger; + +/** + * Representation of mdsal based properties node serializer implementation. + */ +public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer { + + private SchemaNode curSchema; + private PropertiesNode node; + private static final Logger LOG = getLogger(MdsalPropertiesNodeSerializer.class); + + /** + * Creates the properties node serializer. + * + * @param schemaNode schema node. + * @param schemaCtx schema context + * @param uri URL of the request + */ + public MdsalPropertiesNodeSerializer(SchemaNode schemaNode, SchemaContext schemaCtx, String uri) { + super(schemaNode, schemaCtx, uri); + } + + @Override + public PropertiesNode encode(Map paramMap) { + return null; + } + + @Override + public Map decode(PropertiesNode propertiesNode) { + return null; + } + +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/NodeType.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/NodeType.java new file mode 100644 index 000000000..94f2915ac --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/NodeType.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +/** + * Representation of types of node in properties node tree. + */ +public enum NodeType { + SINGLE_INSTANCE_NODE, + MULTI_INSTANCE_NODE, + SINGLE_INSTANCE_LEAF_NODE, + MULTI_INSTANCE_LEAF_NODE, + MULTI_INSTANCE_HOLDER_NODE, + MULTI_INSTANCE_LEAF_HOLDER_NODE +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNode.java new file mode 100644 index 000000000..fccfa6a9d --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNode.java @@ -0,0 +1,124 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +/** + * Abstraction of properties node data tree. This intermediate representation + * will enable data format serializers to be agnostic of DG context memory + * nuances and thereby will enable faster development of new data faormat + * serializers. + */ +public abstract class PropertiesNode { + + private String name; + private String namespace; + private String uri; + private PropertiesNode parent; + + /** + * Creates an instance of properties node. + */ + protected PropertiesNode() { + } + + /** + * Creates an instance of properties node. + * + * @param name name of node + * @param namespace namespace of node, null indicates parent namespace + * @param uri URI of this node, if null its calculated based on parent and + * current value of name and namespace + * @param parent parent's node + */ + protected PropertiesNode(String name, String namespace, String uri, PropertiesNode parent) { + this.name = name; + this.namespace = namespace; + this.uri = uri; + this.parent = parent; + } + + /** + * Adds a child to a current node. + * + * @param name name of child + * @param namespace namespace of child, null represents parent namespace + * @param type type of node + * @return added properties node + */ + public abstract PropertiesNode addChild(String name, String namespace, NodeType type); + + /** + * Adds a child with value to a current node. + * + * @param name name of child + * @param namespace namespace of child, null represents parent namespace + * @param type type of node + * @param value value of node + * @return added properties node + */ + public abstract PropertiesNode addChild(String name, String namespace, NodeType type, String value); + + /** + * Adds a child at a given index to a current node. To be used in case of + * leaf holder child's which is multi instance node. + * + * @param index index at which node is to be added + * @param name name of child + * @param namespace namespace of child, null represents parent namespace + * @param type type of node + * @return added properties node + */ + public abstract PropertiesNode addChild(String index, String name, String namespace, NodeType type); + + public void name(String name) { + this.name = name; + } + + public void namespace(String namespace) { + this.namespace = namespace; + } + + public void uri(String uri) { + this.uri = uri; + } + + public void parent(PropertiesNode parent) { + this.parent = parent; + } + + public PropertiesNode parent() { + return parent; + } + + public String name() { + return name; + } + + public String namespace() { + return namespace; + } + + public String uri() { + return uri; + } + +} + diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeSerializer.java new file mode 100644 index 000000000..81609a6da --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeSerializer.java @@ -0,0 +1,108 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +import java.util.Map; + +/** + * Abstraction of an entity to enable encoding and decoding of properties + * to an abstract properties node tree using YANG based schema. + * This serializer will be used by other data format serializers and will keep + * them abstract from properties nuances thereby enabling quick addition of any + * new data format serializer. + * + * @param type of schema node + * @param

schema context of the model + */ +public abstract class PropertiesNodeSerializer { + + /** + * Schema node from which the property is made. + */ + private T schemaNode; + + /** + * Schema context of the model. + */ + private P schemaCtx; + + /** + * URL pointing to the schema node. + */ + private String uri; + + /** + * Creates the properties node serializer. + * + * @param schemaNode schema node. + * @param schemaCtx schema context + * @param uri URL of the request + */ + public PropertiesNodeSerializer(T schemaNode, P schemaCtx, String uri) { + this.schemaNode = schemaNode; + this.schemaCtx = schemaCtx; + this.uri = uri; + } + + + /** + * Encodes from properties to properties-node tree. + * + * @param paramMap parameter map + * @return properties node + */ + public abstract PropertiesNode encode(Map paramMap); + + /** + * Decodes from properties-node to properties map. + * + * @param propertiesNode properties-node + * @return parameter map + */ + public abstract Map decode(PropertiesNode propertiesNode); + + /** + * Returns the schema node of the property + * + * @return schema node + */ + public T getSchemaNode(){ + return schemaNode; + } + + /** + * Returns the schema context + * + * @return schema node + */ + public P getSchemaCtx() { + return schemaCtx; + } + + /** + * Returns the URI. + * + * @return uri + */ + public String getUri() { + return uri; + } +} -- cgit From 1476ff884265181b5934d71a7a0e59b705ee1aac Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Thu, 2 Aug 2018 15:06:36 +0900 Subject: dependancy and tests cases added Issue-ID: CCSDK-407 Change-Id: I0450875b0a29cc4612e0979e3d6e97b6c4b398f0 Signed-off-by: Ganesh Chandrasekaran --- features/ccsdk-sli-plugins-all/pom.xml | 7 + .../features/src/main/resources/features.xml | 6 +- .../features/src/main/resources/features.xml | 14 +- sshapi-call-node/provider/ReadMe.md | 32 +++ sshapi-call-node/provider/pom.xml | 31 --- .../sli/plugins/sshapicall/SshApiCallNode.java | 69 ++++--- .../sli/plugins/sshapicall/model/AuthType.java | 2 +- .../ccsdk/sli/plugins/sshapicall/model/Format.java | 2 +- .../sli/plugins/sshapicall/model/JsonParser.java | 2 +- .../sli/plugins/sshapicall/model/Parameters.java | 2 +- .../sli/plugins/sshapicall/model/ParseParam.java | 9 +- .../sli/plugins/sshapicall/model/XmlJsonUtil.java | 2 +- .../sli/plugins/sshapicall/model/XmlParser.java | 2 +- .../sli/plugins/sshapicall/TestJsonParser.java | 2 +- .../sli/plugins/sshapicall/TestSshApiCallNode.java | 228 +++++++++++++++++++++ .../sli/plugins/sshapicall/TestXmlJsonUtil.java | 2 +- .../sli/plugins/sshapicall/TestXmlParser.java | 2 +- 17 files changed, 332 insertions(+), 82 deletions(-) create mode 100644 sshapi-call-node/provider/ReadMe.md create mode 100644 sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index d41b48022..051f3a463 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -51,6 +51,13 @@ xml features + + ${project.groupId} + ccsdk-sshapi-call-node + ${project.version} + xml + features + ${project.groupId} ccsdk-restconf-client diff --git a/restapi-call-node/features/src/main/resources/features.xml b/restapi-call-node/features/src/main/resources/features.xml index a764aa477..3734a951a 100644 --- a/restapi-call-node/features/src/main/resources/features.xml +++ b/restapi-call-node/features/src/main/resources/features.xml @@ -32,9 +32,9 @@ sdnc-sli spring spring-dm - mvn:com.sun.jersey/jersey-client/${jersey.version} - mvn:com.sun.jersey.contribs.jersey-oauth/oauth-signature/${jersey.version} - mvn:com.sun.jersey.contribs.jersey-oauth/oauth-client/${jersey.version} + mvn:com.sun.jersey/jersey-client/${jersey.version} + mvn:com.sun.jersey.contribs.jersey-oauth/oauth-signature/${jersey.version} + mvn:com.sun.jersey.contribs.jersey-oauth/oauth-client/${jersey.version} mvn:org.codehaus.jettison/jettison/${jettison.version} mvn:org.onap.ccsdk.sli.plugins/restapi-call-node-provider/${project.version} diff --git a/sshapi-call-node/features/src/main/resources/features.xml b/sshapi-call-node/features/src/main/resources/features.xml index 573f5cb05..fd7caf535 100644 --- a/sshapi-call-node/features/src/main/resources/features.xml +++ b/sshapi-call-node/features/src/main/resources/features.xml @@ -35,17 +35,11 @@ sdnc-sli spring spring-dm - mvn:com.sun.jersey/jersey-client/${jersey.version} - - mvn:com.sun.jersey.contribs.jersey-oauth/oauth-signature/${jersey.version} - - - mvn:com.sun.jersey.contribs.jersey-oauth/oauth-client/${jersey.version} - mvn:org.codehaus.jettison/jettison/${jettison.version} - - mvn:org.onap.ccsdk.sli.plugins/sshapi-call-node-provider/${project.version} - + mvn:org.onap.ccsdk.sli.core/sli-common/${project.version} + mvn:org.onap.ccsdk.sli.core/sli-provider/${project.version} + mvn:org.onap.appc/appc-ssh-adapter-api/1.3.0 + mvn:org.onap.ccsdk.sli.plugins/sshapi-call-node-provider/${project.version} diff --git a/sshapi-call-node/provider/ReadMe.md b/sshapi-call-node/provider/ReadMe.md new file mode 100644 index 000000000..6c31ae0c2 --- /dev/null +++ b/sshapi-call-node/provider/ReadMe.md @@ -0,0 +1,32 @@ +SSHApi-Call-Node Plugin: + +Parameters List that managed in from Directed Graphs: + +Input: +Url -> Mandatory -> url to make the SSH connection request to. +Port -> Mandatory -> port to make the SSH connection request to. +AuthType -> Optional -> Type of authentiation to be used BASIC or sshKey based -> true or false +User -> Optional -> user name to use for ssh basic authentication -> sdnc_ws +Password -> Optional -> unencrypted password to use for ssh basic authentication -> plain_password +SshKey -> Optional -> Consumer SSH key to use for ssh authentication -> plain_key +ExecTimeout -> Optional -> SSH command execution timeout -> plain_key +Retry -> Optional -> Make ssh connection with default retry policy -> plain_key +Cmd -> Mandatory -> ssh command to be executed on the server. -> get post put delete patch +EnvParameters -> Optional -> A JSON dictionary which should list key value pairs to be passed to the command execution. These values would correspond to instance specific parameters that a command may need to execute an action. +FileParameters -> Optional -> A JSON dictionary where keys are filenames and values are contents of files. The SSH Server will utilize this feature to generate files with keys as filenames and values as content. This attribute can be used to generate files that a command may require as part of execution. +ConvertResponse -> Optional -> whether the response should be converted to properties -> true or false +ResponseType -> Optional -> If we know the response is to be in a specific format (supported are JSON, XML and NONE) +ResponsePrefix -> Optional -> location the response will be written to in context memory +listName[i] -> Optional -> Used for processing XML responses with repeating elements.vpn-information.vrf-details + +Output: +"'ResponsePrefix'.sshApi.call.node.status" -> SSH Exit status code is set in here. +"'ResponsePrefix'.sshApi.call.node.stdout" -> SSH command execution result is put in here. +"'ResponsePrefix'.sshApi.call.node.stderr" -> SSH execution failure message is put in here. + + + +API methods that are exposed: +1) execCommand +2) execWithStatusCheck: Throws exception if the exit status is not successful. +3) execCommandWithPty \ No newline at end of file diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index e380d7c25..5434e60fe 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -26,11 +26,6 @@ junit test - - org.springframework - spring-test - test - org.onap.ccsdk.sli.core sli-common @@ -49,32 +44,6 @@ org.json json - - org.slf4j - slf4j-api - - - org.springframework - spring-beans - - - org.springframework - spring-context - - - com.sun.jersey - jersey-client - - - com.sun.jersey.contribs.jersey-oauth - oauth-signature - ${jersey.version} - - - com.sun.jersey.contribs.jersey-oauth - oauth-client - ${jersey.version} - org.codehaus.jettison jettison 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 index e4b082cda..10635be71 100644 --- 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 @@ -3,9 +3,10 @@ * ONAP : APPC * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs * ============================================================================= + * 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 @@ -52,22 +53,22 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { /** * Output parameter - SSH command execution status. */ - String PARAM_OUT_status = "status"; + private String PARAM_OUT_status = "sshApi.call.node.status"; /** * Output parameter - content of SSH command stdout. */ - String PARAM_OUT_stdout = "stdout"; + private String PARAM_OUT_stdout = "sshApi.call.node.stdout"; /** * Output parameter - content of SSH command stderr. */ - String PARAM_OUT_stderr = "stderr"; + private String PARAM_OUT_stderr = "sshApi.call.node.stderr"; /** * Default success status. */ - int DEF_SUCCESS_STATUS = 0; + private int DEF_SUCCESS_STATUS = 0; private SshAdapter sshAdapter; @@ -81,7 +82,6 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { * * * - * * * * @@ -90,8 +90,8 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { * * * - * - * + * + * * vpn-information.vrf-details * * @@ -109,18 +109,29 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { */ public void execCommand(Map params, SvcLogicContext ctx) throws SvcLogicException { + execSshCommand(params, ctx, false); + } + + private void execSshCommand(Map params, SvcLogicContext ctx, boolean withPty) throws SvcLogicException { ParseParam parser = new ParseParam(); Parameters p = parser.getParameters(params); logger.debug("=> Connecting to SSH server..."); - SshConnection sshConnection = getSshConnection(p); - sshConnection.connect(); + SshConnection sshConnection = null; try { + sshConnection = getSshConnection(p); + sshConnection.connect(); logger.debug("=> Connected to SSH server..."); logger.debug("=> Running SSH command..."); sshConnection.setExecTimeout(p.sshExecTimeout); ByteArrayOutputStream stdout = new ByteArrayOutputStream(); ByteArrayOutputStream stderr = new ByteArrayOutputStream(); - int status = sshConnection.execCommand(parser.makeCommand(params), stdout, stderr); + int status; + if (withPty) { + status = sshConnection.execCommandWithPty(parser.makeCommand(params), stdout); + stderr = stdout; + } + else + status = sshConnection.execCommand(parser.makeCommand(params), stdout, stderr); String stdoutRes = stdout.toString(); String stderrRes = stderr.toString(); logger.debug("=> executed SSH command"); @@ -131,12 +142,15 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { ctx.setAttribute(PARAM_OUT_status, String.format("%01d", status)); ctx.setAttribute(PARAM_OUT_stdout, stdoutRes); ctx.setAttribute(PARAM_OUT_stderr, stderrRes); + } catch (Exception e){ + throw new SvcLogicException("Exception in SSH adaptor : " + e.getMessage()); } finally { - sshConnection.disconnect(); + if (sshConnection != null) + sshConnection.disconnect(); } } - private SshConnection getSshConnection(Parameters p) throws SvcLogicException{ + private SshConnection getSshConnection(Parameters p) throws SvcLogicException { if (p.authtype == AuthType.BASIC) return sshAdapter.getConnection(p.sshapiUrl, p.sshapiPort, p.sshapiUser, p.sshapiPassword); // This is not supported yet in the API, patch has already been added to APPC @@ -164,7 +178,6 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/sshapi/templates/vnf_service-configuration-operation_minimal.json
UrlMandatoryurl to make the SSH connection request to.
PortMandatoryport to make the SSH connection request to.
UserOptionaluser name to use for ssh basic authenticationsdnc_ws
ExecTimeoutOptionalSSH command execution timeoutplain_key
RetryOptionalMake ssh connection with default retry policyplain_key
CmdMandatoryssh command to be executed on the server.get post put delete patch
ResponsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
ResponseTypeOptionalIf we know the response is to be in a specific format (supported are JSON, XML and NONE) tmp.sshapi.result
ResponsePrefixOptionallocation the response will be written to in context memory
ResponseTypeOptionalIf we know the response is to be in a specific format (supported are JSON, XML and NONE)
listName[i]OptionalUsed for processing XML responses with repeating elements.
ConvertResponse Optionalwhether the response should be convertedtrue or false
AuthTypeOptionalType of authentiation to be used BASIC or sshKey basedtrue or false
* * - * * * * @@ -173,8 +186,8 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { * * * - * - * + * + * * vpn-information.vrf-details * * @@ -193,16 +206,19 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { public void execWithStatusCheck(Map params, SvcLogicContext ctx) throws SvcLogicException { execCommand(params, ctx); + ParseParam parser = new ParseParam(); + String responsePrefix = parser.getStringParameters(params, parser.SSH_ResponsePrefix); + parseResponse(ctx, responsePrefix); + } + + private void parseResponse (SvcLogicContext ctx, String responsePrefix) throws SvcLogicException { int status = Integer.parseInt(ctx.getAttribute(PARAM_OUT_status)); if(status != DEF_SUCCESS_STATUS) { StringBuilder errmsg = new StringBuilder(); errmsg.append("SSH command returned error status [").append(status).append(']'); - String stderrRes = ctx.getAttribute(PARAM_OUT_stderr); - String stdoutRes = ctx.getAttribute(PARAM_OUT_stdout); - if((stderrRes != null) && !stderrRes.isEmpty()) { - errmsg.append(". Error: [").append(stderrRes).append(']'); - } else if ((stdoutRes != null) && !stdoutRes.isEmpty()) { - errmsg.append(". Error: [").append(stdoutRes).append(']'); + String stderr = ctx.getAttribute(PARAM_OUT_stderr); + if((stderr != null) && !stderr.isEmpty()) { + errmsg.append(". Error: [").append(stderr).append(']'); } throw new SvcLogicException(errmsg.toString()); } @@ -214,7 +230,6 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/sshapi/templates/vnf_service-configuration-operation_minimal.json
UrlMandatoryurl to make the SSH connection request to.
PortMandatoryport to make the SSH connection request to.
UserOptionaluser name to use for ssh basic authenticationsdnc_ws
ExecTimeoutOptionalSSH command execution timeoutplain_key
RetryOptionalMake ssh connection with default retry policyplain_key
CmdMandatoryssh command to be executed on the server.get post put delete patch
ResponsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
ResponseTypeOptionalIf we know the response is to be in a specific format (supported are JSON, XML and NONE) tmp.sshapi.result
ResponsePrefixOptionallocation the response will be written to in context memory
ResponseTypeOptionalIf we know the response is to be in a specific format (supported are JSON, XML and NONE)
listName[i]OptionalUsed for processing XML responses with repeating elements.
ConvertResponse Optionalwhether the response should be convertedtrue or false
AuthTypeOptionalType of authentiation to be used BASIC or sshKey basedtrue or false
* * - * * * * @@ -223,8 +238,8 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { * * * - * - * + * + * * vpn-information.vrf-details * * @@ -241,6 +256,6 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { * @param ctx Reference to context memory */ public void execCommandWithPty(Map params, SvcLogicContext ctx) throws SvcLogicException { - + execSshCommand(params, ctx, true); } } diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/AuthType.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/AuthType.java index 2ec48c70c..806c80890 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/AuthType.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/AuthType.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Format.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Format.java index e50a96c6c..43c3c38d6 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Format.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Format.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. 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 index f40f1ad71..296192a5b 100644 --- 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Parameters.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Parameters.java index a22da5bcb..fa2371e88 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Parameters.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/Parameters.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java index caf49ef91..a72bc7bbe 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. @@ -59,6 +59,7 @@ public class ParseParam { * Default SSH command timeout */ private final String FILE_PARAMETERS_OPT_KEY = "FileParameters"; + public final String SSH_ResponsePrefix = "ResponsePrefix"; /** * Default SSH connection port. */ @@ -74,7 +75,7 @@ public class ParseParam { p.sshExecTimeout = Long.parseLong(parseParam(paramMap, "ExecTimeout", false, Long.toString(dEF_timeout))); p.sshWithRetry = Boolean.valueOf(parseParam(paramMap, "Retry", false, "false")); p.cmd = parseParam(paramMap, "Cmd", true, null); - p.responsePrefix = parseParam(paramMap, "ResponsePrefix", false, null); + p.responsePrefix = parseParam(paramMap, SSH_ResponsePrefix, false, null); p.responseType = Format.fromString(parseParam(paramMap, "ResponseType", false, "none")); p.listNameList = getListNameList(paramMap); p.convertResponse = Boolean.valueOf(parseParam(paramMap, "ConvertResponse", false, "true")); @@ -83,6 +84,10 @@ public class ParseParam { return p; } + public String getStringParameters(Map paramMap, String paramName) throws SvcLogicException { + return parseParam(paramMap, SSH_ResponsePrefix, false, null); + } + public void parseOutput (SvcLogicContext ctx, String outMessage) throws SvcLogicException { if (p.convertResponse) { if (p.responseType == Format.NONE) { 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 index e7fc60edb..d68fbc6ac 100644 --- 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. 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 index c23aca6cf..e31754bcd 100644 --- 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. 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 index 66be73001..4a5b765a8 100644 --- 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java new file mode 100644 index 000000000..3992dffe1 --- /dev/null +++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java @@ -0,0 +1,228 @@ +package jtest.org.onap.ccsdk.sli.plugins.sshapicall; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +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 org.onap.ccsdk.sli.plugins.sshapicall.model.XmlParser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import static org.junit.Assert.assertEquals; + +public class TestSshApiCallNode { + + private static final Logger log = LoggerFactory.getLogger(TestSshApiCallNode.class); + + private SshApiCallNode adapter; + private String TestId; + private boolean testMode = true; + private Map params; + private SvcLogicContext svcContext; + + + @Before + public void setup() throws IllegalArgumentException { + testMode = true; + svcContext = new SvcLogicContext(); + adapter = new SshApiCallNode(); + + params = new HashMap<>(); + params.put("AgentUrl", "https://192.168.1.1"); + params.put("User", "test"); + params.put("Password", "test"); + } + + @After + public void tearDown() { + testMode = false; + adapter = null; + params = null; + svcContext = null; + } + + @Test(expected = SvcLogicException.class) + public void testExecCommand_noUrlFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("HostName", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Test", "fail"); + adapter.execCommand(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandPty_noUrlFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("HostName", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Test", "fail"); + adapter.execCommandWithPty(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noUrlFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("HostName", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Test", "fail"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommand_noPortFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Test", "fail"); + adapter.execCommand(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandPty_noPortFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Test", "fail"); + adapter.execCommandWithPty(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noPortFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Test", "fail"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommand_noCmdFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + adapter.execCommand(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandPty_noCmdFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + adapter.execCommandWithPty(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noCmdFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noSSHBasicFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("AuthType", "basic"); + params.put("Cmd", "test"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noSSHKeyFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("AuthType", "key"); + params.put("Cmd", "test"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noSSHNoneFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("AuthType", "none"); + params.put("Cmd", "test"); + params.put("ResponseType", "xml"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noSSHFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("ResponseType", "json"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = IllegalArgumentException.class) + public void testExecCommandResponse_noSSHInvalidParam() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("ResponseType", "txt"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = IllegalArgumentException.class) + public void testExecCommandResponse_noSSHInvalidAuthParam() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("AuthType", "spring"); + params.put("ResponseType", "json"); + adapter.execWithStatusCheck(params, svcContext); + } +} 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 index 599043e9c..218ad6a8d 100644 --- 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. 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 index d904721f8..3f8d37163 100644 --- 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * * Copyright (C) 2017 AT&T Intellectual Property. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. -- cgit From efd6f9e3d2f770f16a6cb93efc061fe502a56979 Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Fri, 3 Aug 2018 18:06:37 +0900 Subject: mocked testcases added Issue-ID: CCSDK-433 Change-Id: I9961df9131b4672a99601b31ed2e9312d0840d6b Signed-off-by: Ganesh Chandrasekaran --- sshapi-call-node/provider/ReadMe.md | 6 +- .../sli/plugins/sshapicall/SshApiCallNode.java | 64 ++++++++---- .../sli/plugins/sshapicall/TestSshApiCallNode.java | 107 +++++++++++++++++++++ 3 files changed, 155 insertions(+), 22 deletions(-) diff --git a/sshapi-call-node/provider/ReadMe.md b/sshapi-call-node/provider/ReadMe.md index 6c31ae0c2..beaadcda8 100644 --- a/sshapi-call-node/provider/ReadMe.md +++ b/sshapi-call-node/provider/ReadMe.md @@ -20,9 +20,9 @@ ResponsePrefix -> Optional -> location the response will be written listName[i] -> Optional -> Used for processing XML responses with repeating elements.vpn-information.vrf-details Output: -"'ResponsePrefix'.sshApi.call.node.status" -> SSH Exit status code is set in here. -"'ResponsePrefix'.sshApi.call.node.stdout" -> SSH command execution result is put in here. -"'ResponsePrefix'.sshApi.call.node.stderr" -> SSH execution failure message is put in here. +"sshApi.call.node.status" -> SSH Exit status code is set in here. +"sshApi.call.node.stdout" -> SSH command execution result is put in here. +"sshApi.call.node.stderr" -> SSH execution failure message is put in here. 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 index 10635be71..452d94785 100644 --- 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 @@ -65,11 +65,29 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { */ private String PARAM_OUT_stderr = "sshApi.call.node.stderr"; + /** + * Testing parameter - content of mocked SSH. + */ + private boolean PARAM_TEST_MODE = false; + private String PARAM_OUT_MESSAGE = "TestOut"; + + /** * Default success status. */ private int DEF_SUCCESS_STATUS = 0; + /** + * Used for jUnit test and testing interface + */ + public SshApiCallNode(boolean mode) { + PARAM_TEST_MODE = mode; + } + + public SshApiCallNode() { + PARAM_TEST_MODE = false; + } + private SshAdapter sshAdapter; public void setSshAdapter(SshAdapter sshAdapter) { @@ -117,23 +135,33 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { Parameters p = parser.getParameters(params); logger.debug("=> Connecting to SSH server..."); SshConnection sshConnection = null; + int status = -1; + ByteArrayOutputStream stdout = new ByteArrayOutputStream(); + ByteArrayOutputStream stderr = new ByteArrayOutputStream(); + String stdoutRes = "", stderrRes = ""; try { - sshConnection = getSshConnection(p); - sshConnection.connect(); - logger.debug("=> Connected to SSH server..."); - logger.debug("=> Running SSH command..."); - sshConnection.setExecTimeout(p.sshExecTimeout); - ByteArrayOutputStream stdout = new ByteArrayOutputStream(); - ByteArrayOutputStream stderr = new ByteArrayOutputStream(); - int status; - if (withPty) { - status = sshConnection.execCommandWithPty(parser.makeCommand(params), stdout); - stderr = stdout; + if (!PARAM_TEST_MODE) { + sshConnection = getSshConnection(p); + sshConnection.connect(); + logger.debug("=> Connected to SSH server..."); + logger.debug("=> Running SSH command..."); + sshConnection.setExecTimeout(p.sshExecTimeout); + if (withPty) { + status = sshConnection.execCommandWithPty(parser.makeCommand(params), stdout); + stderr = stdout; + } + else + status = sshConnection.execCommand(parser.makeCommand(params), stdout, stderr); + stdoutRes = stdout.toString(); + stderrRes = stderr.toString(); + + } else { + if (params.get("TestFail").equalsIgnoreCase("true")) + status = 202; + else + status = DEF_SUCCESS_STATUS; + stdoutRes = params.get(PARAM_OUT_MESSAGE); } - else - status = sshConnection.execCommand(parser.makeCommand(params), stdout, stderr); - String stdoutRes = stdout.toString(); - String stderrRes = stderr.toString(); logger.debug("=> executed SSH command"); if(status == DEF_SUCCESS_STATUS) { @@ -206,12 +234,10 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { public void execWithStatusCheck(Map params, SvcLogicContext ctx) throws SvcLogicException { execCommand(params, ctx); - ParseParam parser = new ParseParam(); - String responsePrefix = parser.getStringParameters(params, parser.SSH_ResponsePrefix); - parseResponse(ctx, responsePrefix); + parseResponse(ctx); } - private void parseResponse (SvcLogicContext ctx, String responsePrefix) throws SvcLogicException { + private void parseResponse (SvcLogicContext ctx) throws SvcLogicException { int status = Integer.parseInt(ctx.getAttribute(PARAM_OUT_status)); if(status != DEF_SUCCESS_STATUS) { StringBuilder errmsg = new StringBuilder(); diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java index 3992dffe1..544057a6e 100644 --- a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java +++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java @@ -225,4 +225,111 @@ public class TestSshApiCallNode { params.put("ResponseType", "json"); adapter.execWithStatusCheck(params, svcContext); } + + @Test + public void testExecCommandResponse_validJSON() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("AuthType", "basic"); + params.put("ResponseType", "json"); + params.put("TestOut", "{\"equipment-data\":\"boo\"}"); + params.put("TestFail", "false"); + adapter = new SshApiCallNode(true); + adapter.execWithStatusCheck(params, svcContext); + assertEquals("boo", svcContext.getAttribute("equipment-data")); + } + + @Test + public void testExecCommandResponse_validXML() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("AuthType", "basic"); + params.put("ResponseType", "xml"); + params.put("TestOut", "4.0.0"); + params.put("TestFail", "false"); + adapter = new SshApiCallNode(true); + adapter.execWithStatusCheck(params, svcContext); + assertEquals("4.0.0", svcContext.getAttribute("modelVersion")); + } + + @Test + public void testExecCommandResponse_validJSONPrefix() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("AuthType", "basic"); + params.put("ResponseType", "json"); + params.put("TestOut", "{\"equipment-data\":\"boo\"}"); + params.put("ResponsePrefix", "test"); + params.put("TestFail", "false"); + adapter = new SshApiCallNode(true); + adapter.execWithStatusCheck(params, svcContext); + assertEquals("boo", svcContext.getAttribute("test.equipment-data")); + } + + @Test + public void testExecCommandResponse_validXMLPrefix() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("AuthType", "basic"); + params.put("ResponseType", "xml"); + params.put("TestOut", "4.0.0"); + params.put("ResponsePrefix", "test"); + params.put("TestFail", "false"); + adapter = new SshApiCallNode(true); + adapter.execWithStatusCheck(params, svcContext); + assertEquals("4.0.0", svcContext.getAttribute("test.modelVersion")); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_validXMLFail() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("AuthType", "basic"); + params.put("ResponseType", "xml"); + params.put("TestOut", "4.0.0"); + params.put("TestFail", "true"); + params.put("ResponsePrefix", "test"); + adapter = new SshApiCallNode(true); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_validXMLPrefixKey() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + params = new HashMap<>(); + params.put("Url", "test"); + params.put("Port", "10"); + params.put("SshKey", "test"); + params.put("Cmd", "test"); + params.put("ResponseType", "xml"); + params.put("TestOut", "4.0.0"); + params.put("ResponsePrefix", "test"); + adapter.execWithStatusCheck(params, svcContext); + assertEquals("4.0.0", svcContext.getAttribute("test.modelVersion")); + } } -- cgit From 42478b1721879ead6d595a238c45acd1c1f039c6 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Tue, 7 Aug 2018 19:07:35 +0000 Subject: add template node add tempalte node implementation Change-Id: Ifd3e6e7f2a7b9ff7029b523eab50274e440652cc Issue-ID: CCSDK-440 Signed-off-by: Smokowski, Kevin (ks6305) --- pom.xml | 1 + template-node/features/ccsdk-template-node/pom.xml | 28 +++++ .../features/features-template-node/pom.xml | 27 ++++ template-node/features/pom.xml | 20 +++ template-node/installer/pom.xml | 136 +++++++++++++++++++++ .../src/assembly/assemble_installer_zip.xml | 59 +++++++++ .../src/assembly/assemble_mvnrepo_zip.xml | 49 ++++++++ .../src/main/resources/scripts/install-feature.sh | 39 ++++++ template-node/pom.xml | 21 ++++ template-node/provider/pom.xml | 40 ++++++ .../ccsdk/sli/plugins/template/TemplateNode.java | 108 ++++++++++++++++ .../resources/OSGI-INF/blueprint/blueprint.xml | 8 ++ .../sli/plugins/template/MockTemplateNode.java | 7 ++ .../sli/plugins/template/TemplateNodeTest.java | 85 +++++++++++++ .../provider/src/test/resources/basic.vtl | 12 ++ .../src/test/resources/template-node.properties | 4 + 16 files changed, 644 insertions(+) create mode 100644 template-node/features/ccsdk-template-node/pom.xml create mode 100644 template-node/features/features-template-node/pom.xml create mode 100644 template-node/features/pom.xml create mode 100644 template-node/installer/pom.xml create mode 100644 template-node/installer/src/assembly/assemble_installer_zip.xml create mode 100644 template-node/installer/src/assembly/assemble_mvnrepo_zip.xml create mode 100644 template-node/installer/src/main/resources/scripts/install-feature.sh create mode 100644 template-node/pom.xml create mode 100644 template-node/provider/pom.xml create mode 100644 template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java create mode 100644 template-node/provider/src/main/resources/OSGI-INF/blueprint/blueprint.xml create mode 100644 template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/MockTemplateNode.java create mode 100644 template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/TemplateNodeTest.java create mode 100644 template-node/provider/src/test/resources/basic.vtl create mode 100644 template-node/provider/src/test/resources/template-node.properties diff --git a/pom.xml b/pom.xml index 164d81e27..a41f2311c 100755 --- a/pom.xml +++ b/pom.xml @@ -26,6 +26,7 @@ sshapi-call-node restconf-client features + template-node diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml new file mode 100644 index 000000000..fd3a92457 --- /dev/null +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.1.0-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + ccsdk-template-node + 0.3.3-SNAPSHOT + feature + + + true + + + + + ${project.groupId} + template-node-provider + ${project.version} + + + diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml new file mode 100644 index 000000000..c352ba514 --- /dev/null +++ b/template-node/features/features-template-node/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + feature-repo-parent + 1.1.0-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + features-template-node + 0.3.3-SNAPSHOT + feature + + + + ${project.groupId} + ccsdk-template-node + ${project.version} + xml + features + + + + diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml new file mode 100644 index 000000000..1abcdbe3e --- /dev/null +++ b/template-node/features/pom.xml @@ -0,0 +1,20 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.1.0-SNAPSHOT + + + org.onap.ccsdk.sli.plugins + template-node-features + 0.3.3-SNAPSHOT + pom + + + ccsdk-template-node + features-template-node + + diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml new file mode 100644 index 000000000..1e4d24cd3 --- /dev/null +++ b/template-node/installer/pom.xml @@ -0,0 +1,136 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.1.0-SNAPSHOT + + + org.onap.ccsdk.sli.plugins + template-node-installer + 0.3.3-SNAPSHOT + pom + + + ccsdk-template-node + ${application.name} + mvn:org.onap.ccsdk.sli.plugins/${features.boot}/${project.version}/xml/features + false + + + + + org.onap.ccsdk.sli.plugins + ${application.name} + ${project.version} + xml + features + + + * + * + + + + + org.onap.ccsdk.sli.plugins + template-node-provider + ${project.version} + + + + + + + maven-assembly-plugin + 2.6 + + + maven-repo-zip + + single + + package + + false + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + false + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli.plugins,org.apache.velocity + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + + + diff --git a/template-node/installer/src/assembly/assemble_installer_zip.xml b/template-node/installer/src/assembly/assemble_installer_zip.xml new file mode 100644 index 000000000..b6fd65582 --- /dev/null +++ b/template-node/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,59 @@ + + + + + + installer_zip + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + + + + diff --git a/template-node/installer/src/assembly/assemble_mvnrepo_zip.xml b/template-node/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100644 index 000000000..2ee224477 --- /dev/null +++ b/template-node/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,49 @@ + + + + + + mvnrepo_zip + + zip + + + + false + + + + target/assembly/ + . + + + + + + + + diff --git a/template-node/installer/src/main/resources/scripts/install-feature.sh b/template-node/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..0eab001d5 --- /dev/null +++ b/template-node/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,39 @@ +#!/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========================================================= +### + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} feature:install ${features.boot} diff --git a/template-node/pom.xml b/template-node/pom.xml new file mode 100644 index 000000000..21ab127f3 --- /dev/null +++ b/template-node/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.1.0-SNAPSHOT + + + org.onap.ccsdk.sli.plugins + template-node + 0.3.3-SNAPSHOT + pom + + + provider + features + installer + + diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml new file mode 100644 index 000000000..936f76f37 --- /dev/null +++ b/template-node/provider/pom.xml @@ -0,0 +1,40 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + binding-parent + 1.1.0-SNAPSHOT + + + org.onap.ccsdk.sli.plugins + template-node-provider + 0.3.3-SNAPSHOT + bundle + + + + junit + junit + test + + + org.onap.ccsdk.sli.core + sli-common + + + org.onap.ccsdk.sli.core + sli-provider + + + org.slf4j + slf4j-api + + + org.apache.velocity + velocity + 1.7 + + + diff --git a/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java b/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java new file mode 100644 index 000000000..8a9676817 --- /dev/null +++ b/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java @@ -0,0 +1,108 @@ +/*- + * ============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.template; + +import java.io.FileInputStream; +import java.io.StringWriter; +import java.util.Map; +import java.util.Properties; +import org.apache.velocity.Template; +import org.apache.velocity.VelocityContext; +import org.apache.velocity.app.VelocityEngine; +import org.apache.velocity.runtime.RuntimeConstants; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TemplateNode implements SvcLogicJavaPlugin { + private static final Logger logger = LoggerFactory.getLogger(TemplateNode.class); + public final static String TEMPLATE_PATH = "templatePath"; + public final static String OUTPUT_PATH_KEY = "output"; + public final static String PREFIX_KEY = "prefix"; + public final static String REQUIRED_PARAMETERS_ERROR_MESSAGE = "templateName & outputPath are required fields"; + protected static final String TEMPLATE_PROPERTIES_FILE_NAME = "template-node.properties"; + protected static final String DEFAULT_PROPERTIES_DIR = "/opt/onap/ccsdk/data/properties"; + protected static final String PROPERTIES_DIR_KEY = "SDNC_CONFIG_DIR"; + + protected VelocityEngine ve; + + public TemplateNode() { + ve = new VelocityEngine(); + setProperties(); + ve.init(); + } + + protected void setProperties() { + String configDir = System.getProperty(PROPERTIES_DIR_KEY, DEFAULT_PROPERTIES_DIR); + Properties props = new Properties(); + + try (FileInputStream in = new FileInputStream(configDir + "/" + TEMPLATE_PROPERTIES_FILE_NAME)) { + props.load(in); + } catch (Exception e) { + logger.error("Caught exception loading properties!", e); + } + + // give sensible defaults for required properties + ve.setProperty(RuntimeConstants.RESOURCE_LOADER, props.getProperty("velocity.resource.loader", "file")); + ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, + props.getProperty("velocity.file.resource.loader.path", "/opt/onap/sdnc/restapi/templates")); + ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, + props.getProperty("velocity.file.resource.loader.cache", "false")); + + // allow flexible reading of additional velocity properties + for (String propertyName : props.stringPropertyNames()) { + if (propertyName.startsWith("velocity")) { + logger.error("set " + propertyName.substring(9) + "=" + props.get(propertyName)); + ve.setProperty(propertyName.substring(9), props.get(propertyName)); + } + } + } + + public void evaluateTemplate(Map params, SvcLogicContext ctx) throws SvcLogicException { + String templateName = params.get(TEMPLATE_PATH); + String outputPath = params.get(OUTPUT_PATH_KEY); + String prefix = params.get(PREFIX_KEY); + + if (prefix != null && prefix.length() > 0) { + outputPath = prefix + "." + outputPath; + } + + if (templateName == null || outputPath == null) { + throw new SvcLogicException(REQUIRED_PARAMETERS_ERROR_MESSAGE); + } else { + try { + Template template = ve.getTemplate(templateName); + VelocityContext context = new VelocityContext(); + context.put("ctx", ctx); + context.put("params", params); + StringWriter sw = new StringWriter(); + template.merge(context, sw); + ctx.setAttribute(outputPath, sw.toString()); + } catch (Exception e) { + throw new SvcLogicException(e.getMessage()); + } + } + } + +} \ No newline at end of file diff --git a/template-node/provider/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/template-node/provider/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 000000000..a8006b9b0 --- /dev/null +++ b/template-node/provider/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/MockTemplateNode.java b/template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/MockTemplateNode.java new file mode 100644 index 000000000..d628ac929 --- /dev/null +++ b/template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/MockTemplateNode.java @@ -0,0 +1,7 @@ +package org.onap.ccsdk.sli.plugins.template; + +public class MockTemplateNode extends TemplateNode { + protected void setProperties() { + // do nothing + } +} diff --git a/template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/TemplateNodeTest.java b/template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/TemplateNodeTest.java new file mode 100644 index 000000000..29c5c973e --- /dev/null +++ b/template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/TemplateNodeTest.java @@ -0,0 +1,85 @@ +package org.onap.ccsdk.sli.plugins.template; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import java.util.HashMap; +import java.util.Map; +import java.util.Vector; +import org.apache.velocity.runtime.RuntimeConstants; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + +public class TemplateNodeTest { + + @Test + public void sunnyDay() throws Exception { + String requestId = "REQ001"; + String uniqueKey = "UNIQUE_TEST"; + String action = "uPdaTe"; + String serviceType = "VPN"; + + TemplateNode t = new MockTemplateNode(); + + Map params = new HashMap(); + params.put(TemplateNode.PREFIX_KEY, "output"); + params.put(TemplateNode.OUTPUT_PATH_KEY, "mycontainer"); + params.put(TemplateNode.TEMPLATE_PATH, "src/test/resources/basic.vtl"); + params.put("service-type", serviceType); + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("input.svc-request-id", requestId); + ctx.setAttribute("input.unique-key", uniqueKey); + ctx.setAttribute("action", action); + + t.evaluateTemplate(params, ctx); + String result = ctx.getAttribute("output.mycontainer"); + assertNotNull(result); + assertTrue(result.contains(requestId)); + assertTrue(result.contains(uniqueKey)); + assertTrue(result.contains(action.toUpperCase())); + assertTrue(result.contains(serviceType)); + } + + @Test(expected = SvcLogicException.class) + public void parameterException() throws Exception { + TemplateNode t = new MockTemplateNode(); + Map params = new HashMap(); + SvcLogicContext ctx = new SvcLogicContext(); + t.evaluateTemplate(params, ctx); + } + + @Test(expected = SvcLogicException.class) + public void missingTemplate() throws Exception { + TemplateNode t = new MockTemplateNode(); + Map params = new HashMap(); + params.put(TemplateNode.PREFIX_KEY, "output"); + params.put(TemplateNode.OUTPUT_PATH_KEY, "mycontainer"); + params.put(TemplateNode.TEMPLATE_PATH, "src/test/resources/missing.vtl"); + SvcLogicContext ctx = new SvcLogicContext(); + t.evaluateTemplate(params, ctx); + } + + @Test + public void withProperties() throws Exception { + System.setProperty(TemplateNode.PROPERTIES_DIR_KEY, "src/test/resources"); + TemplateNode t = new TemplateNode(); + Vector loader = (Vector) t.ve.getProperty(RuntimeConstants.RESOURCE_LOADER); + assertTrue(loader.contains("class")); + assertEquals("/home/my/example", t.ve.getProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH)); + assertEquals("true", t.ve.getProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE)); + assertEquals("customValue", t.ve.getProperty("custom.property")); + } + + @Test + public void withNoProperties() throws Exception { + System.setProperty(TemplateNode.PROPERTIES_DIR_KEY, "i/do/not/exist"); + TemplateNode t = new TemplateNode(); + Vector loader = (Vector) t.ve.getProperty(RuntimeConstants.RESOURCE_LOADER); + assertTrue(loader.contains("file")); + assertEquals("/opt/onap/sdnc/restapi/templates", t.ve.getProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH)); + assertEquals("false", t.ve.getProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE)); + assertEquals(null, t.ve.getProperty("custom.property")); + } + +} \ No newline at end of file diff --git a/template-node/provider/src/test/resources/basic.vtl b/template-node/provider/src/test/resources/basic.vtl new file mode 100644 index 000000000..63fcc670a --- /dev/null +++ b/template-node/provider/src/test/resources/basic.vtl @@ -0,0 +1,12 @@ +{ + "input": { + "sdnc-request-header": { + "svc-request-id": "$ctx.getAttribute("input.svc-request-id")", + "svc-action": "$ctx.getAttribute("action").toUpperCase()" + }, + "service-information": { + "service-type": "$params.get("service-type")", + "service-instance-id": "$ctx.getAttribute("input.unique-key")" + } + } +} \ No newline at end of file diff --git a/template-node/provider/src/test/resources/template-node.properties b/template-node/provider/src/test/resources/template-node.properties new file mode 100644 index 000000000..1199a0cde --- /dev/null +++ b/template-node/provider/src/test/resources/template-node.properties @@ -0,0 +1,4 @@ +velocity.resource.loader=class +velocity.file.resource.loader.path=/home/my/example +velocity.file.resource.loader.cache=true +velocity.custom.property=customValue \ No newline at end of file -- cgit From c29034ab5ea15d4c336f068ca8007ccebfad73e3 Mon Sep 17 00:00:00 2001 From: gaurav Date: Tue, 14 Aug 2018 16:55:13 +0530 Subject: Fix ccsdk/plugin compilation issue Added pom dependency of eelf-core in sshapi-call-node provider to fix broken build of plugins. Change-Id: I8a69798f896278ffa50c4a09fadf1c064ea49fff Issue-ID: CCSDK-457 Signed-off-by: Gaurav Agrawal --- sshapi-call-node/provider/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index 5434e60fe..d37972efc 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -48,5 +48,9 @@ org.codehaus.jettison jettison + + com.att.eelf + eelf-core + -- cgit From 8e8ec2eb81e062010da230fae30626cb07c25bd1 Mon Sep 17 00:00:00 2001 From: Vidyashree Rama Date: Thu, 9 Aug 2018 12:21:34 +0530 Subject: RestconfDiscoveryNode Plugin implementation Initial code submit for supporting RestconfDiscoveryNode Plugin implementation Issue-ID: CCSDK-374 Change-Id: Ieb0b622b135ea78ef58bd36dfe171f4117bc3328 Signed-off-by: Vidyashree Rama --- .../features/ccsdk-restconf-client/pom.xml | 10 +- .../features/src/main/resources/features.xml | 7 +- restconf-client/provider/pom.xml | 49 ++--- .../plugins/restconfdiscovery/EventHandler.java | 50 +++++ .../plugins/restconfdiscovery/EventProcessor.java | 69 +++++++ .../restconfdiscovery/RestconfDiscoveryNode.java | 221 ++++++++++++++++++++- .../restconfdiscovery/SubscriptionInfo.java | 122 ++++++++++++ .../restconfdiscovery/SvcLogicDiscoveryPlugin.java | 2 +- .../restconfdiscovery/SvcLogicGraphInfo.java | 178 +++++++++++++++++ .../META-INF/spring/restconf-client-context.xml | 2 +- .../plugins/restconfdiscovery/SseServerMock.java | 68 +++++++ .../TestRestconfDiscoveryNode.java | 105 ++++++++++ 12 files changed, 843 insertions(+), 40 deletions(-) create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventHandler.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SubscriptionInfo.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicGraphInfo.java create mode 100644 restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SseServerMock.java create mode 100644 restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index 8bdfe87a0..1877f19d8 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -46,10 +46,10 @@ xml features - - ${project.groupId} - restconf-client-provider - ${project.version} - + + + + + diff --git a/restconf-client/features/src/main/resources/features.xml b/restconf-client/features/src/main/resources/features.xml index d7907ac29..c07cddffb 100644 --- a/restconf-client/features/src/main/resources/features.xml +++ b/restconf-client/features/src/main/resources/features.xml @@ -31,11 +31,8 @@ sdnc-sli spring spring-dm - mvn:com.sun.jersey/jersey-client/${jersey.version} - mvn:com.sun.jersey.contribs.jersey-oauth/oauth-signature/${jersey.version} - mvn:com.sun.jersey.contribs.jersey-oauth/oauth-client/${jersey.version} - mvn:org.codehaus.jettison/jettison/${jettison.version} - mvn:org.onap.ccsdk.sli.plugins/restconf-client-provider/${project.version} + mvn:org.onap.ccsdk.sli.plugins/properties-node-provider/0.3.0-SNAPSHOT + mvn:org.onap.ccsdk.sli.plugins/restconf-client-provider/0.3.0-SNAPSHOT diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 776240e0c..5a74d8fc0 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -28,46 +28,47 @@ org.springframework - spring-test - test - - - org.onap.ccsdk.sli.core - sli-common + spring-beans - org.onap.ccsdk.sli.core - sli-provider + org.springframework + spring-context - org.slf4j - slf4j-api + org.glassfish.jersey.media + jersey-media-sse + 2.27 + provided - org.springframework - spring-beans + javax.ws.rs + javax.ws.rs-api + 2.1 - org.springframework - spring-context + org.glassfish.jersey.inject + jersey-hk2 + 2.27 - com.sun.jersey - jersey-client + org.glassfish.jersey.containers + jersey-container-servlet + 2.27 - com.sun.jersey.contribs.jersey-oauth - oauth-signature - ${jersey.version} + org.glassfish.jersey.containers + jersey-container-grizzly2-http + 2.27 + test - com.sun.jersey.contribs.jersey-oauth - oauth-client - ${jersey.version} + org.onap.ccsdk.sli.core + sli-common - org.codehaus.jettison - jettison + org.onap.ccsdk.sli.plugins + properties-node-provider + 0.3.0-SNAPSHOT diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventHandler.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventHandler.java new file mode 100644 index 000000000..155656e27 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventHandler.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.restconfdiscovery; + +import org.glassfish.jersey.media.sse.InboundEvent; +import org.glassfish.jersey.media.sse.EventListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Listener that can be registered to listen for notifications. + */ +class EventHandler implements EventListener { + private static final Logger log = LoggerFactory.getLogger(EventListener.class); + private RestconfDiscoveryNode node; + + public EventHandler(RestconfDiscoveryNode node) { + this.node = node; + } + + @Override + public void onEvent(InboundEvent event) { + String payload = event.readData(); + if (!node.eventQueue().offer(payload)) { + log.error("Unable to process event " + + payload + "as processing queue is full"); + throw new RuntimeException("Unable to process event " + + payload + + "as processing queue is full"); + } + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java new file mode 100644 index 000000000..a85876cae --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.restconfdiscovery; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Map; + +import static org.onap.ccsdk.sli.plugins.prop.JsonParser.convertToProperties; + +/** + * Processes the events from event queue and executes callback DG. + */ +class EventProcessor implements Runnable { + private static final Logger log = LoggerFactory.getLogger(EventProcessor.class); + private RestconfDiscoveryNode node; + + private static final String EVENT_SUBSCRIPTION_ID = "ietf-notification:notification" + + ".ietf-yang-push:push-change-update" + + ".subscription-id"; + + public EventProcessor(RestconfDiscoveryNode node) { + this.node = node; + } + + @Override + public void run() { + while(true) { + try { + String payload = node.eventQueue().take(); + Map param = convertToProperties(payload); + String id = param.get(EVENT_SUBSCRIPTION_ID); + SubscriptionInfo info = node.subscriptionInfoMap().get(id); + if (info != null) { + SvcLogicContext ctx = new SvcLogicContext(); + for (Map.Entry entry : param.entrySet()) { + ctx.setAttribute(entry.getKey(), entry.getValue()); + } + SvcLogicGraphInfo callbackDG = info.callBackDG(); + callbackDG.executeGraph(ctx); + } + } catch (InterruptedException | SvcLogicException e) { + log.error(e.getMessage()); + throw new RuntimeException(e.getMessage()); + } + } + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java index 9eaa67916..34bb2ee6e 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java @@ -1,25 +1,238 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.restconfdiscovery; -import java.util.Map; +import org.glassfish.jersey.media.sse.EventSource; +import org.glassfish.jersey.media.sse.SseFeature; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfapiCallNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.WebTarget; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.LinkedBlockingQueue; /** - * Created by root1 on 18/7/18. + * Representation of a plugin to subscribe for notification and then + * to handle the received notifications. */ public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { + private static final Logger log = LoggerFactory.getLogger(RestconfDiscoveryNode.class); + + private ExecutorService executor = Executors.newCachedThreadPool(); + private Map runnableInfo = new ConcurrentHashMap<>(); + private RestconfapiCallNode restconfapiCallNode; + + private volatile Map subscriptionInfoMap = new ConcurrentHashMap<>(); + private volatile LinkedBlockingQueue eventQueue = new LinkedBlockingQueue<>(); + + private static final String SUBSCRIBER_ID = "subscriberId"; + private static final String RESPONSE_CODE = "response-code"; + private static final String RESPONSE_PREFIX = "responsePrefix"; + private static final String OUTPUT_IDENTIFIER = "ietf-subscribed-notifications:output.identifier"; + private static final String RESPONSE_CODE_200 = "200"; + private static final String SSE_URL = "sseConnectURL"; + + /** + * Creates an instance of RestconfDiscoveryNode and + * starts processing of event. + */ + public RestconfDiscoveryNode() { + ExecutorService e = Executors.newFixedThreadPool(20); + EventProcessor p = new EventProcessor(this); + for (int i = 0; i < 20; ++i) { + e.execute(p); + } + } @Override - public void establishSubscription(Map paramMap, SvcLogicContext ctx) { + public void establishSubscription(Map paramMap, + SvcLogicContext ctx) throws SvcLogicException { + String subscriberId = paramMap.get(SUBSCRIBER_ID); + if (subscriberId == null) { + throw new SvcLogicException("Subscriber Id is null"); + } + restconfapiCallNode.sendRequest(paramMap, ctx); + + if (getResponseCode(paramMap.get(RESPONSE_PREFIX), ctx).equals(RESPONSE_CODE_200)) { + // TODO: save subscription id and subscriber in MYSQL + + establishPersistentConnection(paramMap, ctx, subscriberId); + } else { + log.info("Failed to subscribe " + subscriberId); + throw new SvcLogicException(ctx.getAttribute(RESPONSE_CODE)); + } } @Override public void modifySubscription(Map paramMap, SvcLogicContext ctx) { - + // TODO: to be implemented } @Override public void deleteSubscription(Map paramMap, SvcLogicContext ctx) { + String id = getSubscriptionId(paramMap.get(SUBSCRIBER_ID)); + if (id != null) { + PersistentConnection conn = runnableInfo.get(id); + conn.terminate(); + runnableInfo.remove(id); + subscriptionInfoMap.remove(id); + } + } + + class PersistentConnection implements Runnable { + private String url; + private volatile boolean running = true; + + PersistentConnection(String url) { + this.url = url; + } + + private void terminate() { + running = false; + } + + @Override + public void run() { + Client client = ClientBuilder.newBuilder() + .register(SseFeature.class).build(); + WebTarget target = client.target(url); + EventSource eventSource = EventSource.target(target).build(); + eventSource.register(new EventHandler(RestconfDiscoveryNode.this)); + eventSource.open(); + log.info("Connected to SSE source"); + while (running) { + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + log.error("Exception: " + e.getMessage()); + } + } + eventSource.close(); + log.info("Closed connection to SSE source"); + } + } + + /** + * Establishes a persistent between the client and server. + * + * @param paramMap input paramter map + * @param ctx service logic context + * @param subscriberId subscriber identifier + */ + void establishPersistentConnection(Map paramMap, SvcLogicContext ctx, + String subscriberId) { + String id = getOutputIdentifier(paramMap.get(RESPONSE_PREFIX), ctx); + SvcLogicGraphInfo callbackDG = new SvcLogicGraphInfo(paramMap.get("module"), + paramMap.get("rpc"), + paramMap.get("version"), + paramMap.get("mode")); + SubscriptionInfo info = new SubscriptionInfo(); + info.callBackDG(callbackDG); + info.subscriptionId(id); + info.subscriberId(subscriberId); + subscriptionInfoMap.put(id, info); + + String url = paramMap.get(SSE_URL); + PersistentConnection connection = new PersistentConnection(url); + runnableInfo.put(id, connection); + executor.execute(connection); + } + + /** + * Returns response code. + * + * @param prefix prefix given in input parameter + * @param ctx service logic context + * @return response code + */ + String getResponseCode(String prefix, SvcLogicContext ctx) { + return ctx.getAttribute(getPrefix(prefix) + RESPONSE_CODE); + } + + /** + * Returns subscription id from event. + * + * @param prefix prefix given in input parameter + * @param ctx service logic context + * @return subscription id from event + */ + String getOutputIdentifier(String prefix, SvcLogicContext ctx) { + return ctx.getAttribute(getPrefix(prefix) + OUTPUT_IDENTIFIER); + } + + private String getPrefix(String prefix) { + return prefix != null ? prefix + "." : ""; + } + + private String getSubscriptionId(String subscriberId) { + for (Map.Entry entry + : subscriptionInfoMap.entrySet()) { + if (entry.getValue().subscriberId() + .equals(subscriberId)) { + return entry.getKey(); + } + } + return null; + } + + /** + * Returns restconfApiCallNode. + * + * @return restconfApiCallNode + */ + protected RestconfapiCallNode restconfapiCallNode() { + return restconfapiCallNode; + } + + /** + * Sets restconfApiCallNode. + * + * @param node restconfApiCallNode + */ + void restconfapiCallNode(RestconfapiCallNode node) { + restconfapiCallNode = node; + } + + Map subscriptionInfoMap() { + return subscriptionInfoMap; + } + + void subscriptionInfoMap(Map subscriptionInfoMap) { + this.subscriptionInfoMap = subscriptionInfoMap; + } + + LinkedBlockingQueue eventQueue() { + return eventQueue; + } + void eventQueue(LinkedBlockingQueue eventQueue) { + this.eventQueue = eventQueue; } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SubscriptionInfo.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SubscriptionInfo.java new file mode 100644 index 000000000..4ed3660ca --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SubscriptionInfo.java @@ -0,0 +1,122 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.restconfdiscovery; + +/** + * Holder to store information of subscription. + */ +public class SubscriptionInfo { + private String subscriptionId; + private String subscriberId; + private SvcLogicGraphInfo callbackDG; + private String yangFilePath; + private String filterUrl; + + /** + * Returns callback DG. + * + * @return callback DG + */ + public SvcLogicGraphInfo callBackDG() { + return callbackDG; + } + + /** + * Sets callback DG. + * + * @param callbackDg callback DG + */ + public void callBackDG(SvcLogicGraphInfo callbackDg) { + this.callbackDG = callbackDg; + } + + /** + * Returns YANG file path. + * + * @return YANG file path + */ + public String yangFilePath() { + return yangFilePath; + } + + /** + * Sets YANG file path. + * + * @param yangFilePath yang file path + */ + public void yangFilePath(String yangFilePath) { + this.yangFilePath = yangFilePath; + } + + /** + * Returns filter URL. + * + * @return filter URL + */ + public String filterUrl() { + return filterUrl; + } + + /** + * Sets filter URL. + * + * @param filterUrl filter URL + */ + public void filterUrl(String filterUrl) { + this.filterUrl = filterUrl; + } + + /** + * Returns subscription Id. + * + * @return subscription Id + */ + public String subscriptionId() { + return subscriptionId; + } + + /** + * Sets subscription id. + * + * @param subscriptionId subscription id + */ + public void subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + } + + /** + * Returns subscription Id. + * + * @return subscription Id + */ + public String subscriberId() { + return subscriberId; + } + + /** + * Sets subscriber id. + * + * @param subscriberId subscriber id + */ + public void subscriberId(String subscriberId) { + this.subscriberId = subscriberId; + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicDiscoveryPlugin.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicDiscoveryPlugin.java index 183d22297..dfe8cd5b7 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicDiscoveryPlugin.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicDiscoveryPlugin.java @@ -59,7 +59,7 @@ public interface SvcLogicDiscoveryPlugin extends SvcLogicJavaPlugin { * @since 11.0.2 * @see String#split(String, int) */ - void establishSubscription(Map paramMap, SvcLogicContext ctx); + void establishSubscription(Map paramMap, SvcLogicContext ctx) throws SvcLogicException; /** * Allows directed graphs to modify a discovery subscription for a given subscriber. diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicGraphInfo.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicGraphInfo.java new file mode 100644 index 000000000..725826bda --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicGraphInfo.java @@ -0,0 +1,178 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.restconfdiscovery; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; + +/** + * Holder to store callback directed graph info. + */ +class SvcLogicGraphInfo { + private String module; + private String rpc; + private String mode; + private String version; + + /** + * Creates an instance of SvcLogicGraphInfo. + * + * @param module module name of callback DG + * @param rpc rpc name of callback DG + * @param mode mode of callback DG + * @param version version of callback DG + */ + public SvcLogicGraphInfo(String module, String rpc, String mode, String version) { + this.module = module; + this.rpc = rpc; + this.mode = mode; + this.version = version; + } + + public SvcLogicGraphInfo() {} + + /** + * Returns module name of callback DG. + * + * @return module name of callback DG + */ + public String module() { + return module; + } + + /** + * Sets module of callback DG. + * + * @param module module name of the DG + */ + public void module(String module) { + this.module = module; + } + + /** + * Returns rpc of callback DG. + * + * @return rpc of callback DG + */ + public String rpc() { + return rpc; + } + + /** + * Sets rpc of callback DG. + * + * @param rpc rpc attribute of the DG + */ + public void rpc(String rpc) { + this.rpc = rpc; + } + + /** + * Returns mode of callback DG. + * + * @return mode of callback DG + */ + public String mode() { + return mode; + } + + /** + * Sets mode of DG. + * + * @param mode mode of the DG + */ + public void mode(String mode) { + this.mode = mode; + } + + /** + * Returns version of callback DG. + * + * @return version of callback DG + */ + public String version() { + return version; + } + + /** + * Sets version of DG. + * + * @param version version of the DG + */ + public void version(String version) { + this.version = version; + } + + /** + * Executes call back DG. + * + * @param ctx service logic context + * @throws SvcLogicException service logic error + */ + public void executeGraph(SvcLogicContext ctx) throws SvcLogicException { + SvcLogicService service = findSvcLogicService(); + if (service == null) { + throw new SvcLogicException("\"Could not get SvcLogicService reference\""); + } + + SvcLogicStore store = service.getStore(); + if (store != null) { + SvcLogicGraph subGraph = store.fetch(module, rpc, version, mode); + if (subGraph != null) { + ctx.setAttribute("subGraph", subGraph.toString()); + service.execute(subGraph, ctx); + } else { + throw new SvcLogicException("Failed to call child [" + module + + "," + rpc + "," + version + + "," + mode + "] because" + + " the" + " graph could" + + " not be found"); + } + } else { + throw new SvcLogicException("\"Could not get SvcLogicStore reference\""); + } + } + + private static SvcLogicService findSvcLogicService() throws SvcLogicException { + Bundle bundle = FrameworkUtil.getBundle(SvcLogicService.class); + if (bundle == null) { + throw new SvcLogicException("Cannot find bundle reference for " + + SvcLogicService.NAME); + } + + BundleContext bctx = bundle.getBundleContext(); + ServiceReference sref = bctx.getServiceReference( + SvcLogicService.class); + if (sref != null) { + return bctx.getService(sref); + } else { + throw new SvcLogicException("Cannot find service reference for " + + SvcLogicService.NAME); + } + } +} diff --git a/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-context.xml b/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-context.xml index d7fa61c55..34344fe07 100644 --- a/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-context.xml +++ b/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-context.xml @@ -42,7 +42,7 @@ - + diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SseServerMock.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SseServerMock.java new file mode 100644 index 000000000..1b234a236 --- /dev/null +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SseServerMock.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.restconfdiscovery; + +import org.glassfish.jersey.media.sse.EventOutput; +import org.glassfish.jersey.media.sse.OutboundEvent; +import org.glassfish.jersey.media.sse.SseFeature; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import java.io.IOException; + +@Path("events") +public class SseServerMock { + + @GET + @Produces(SseFeature.SERVER_SENT_EVENTS) + public EventOutput getServerSentEvents() throws IOException { + String data = "{" + + "\"ietf-notification:notification\" : {" + + " \"eventTime\" : \"2017-10-25T08:22:33.44Z\"," + + " \"ietf-yang-push:push-change-update\": {" + + "\"subscription-id\":\"89\"," + + "\"datastore-changes\": {" + + "\"ietf-yang-patch:yang-patch\":{" + + "\"patch-id\":\"1\"," + + "\"edit\":[{" + + "\"edit-id\":\"edit1\"," + + "\"operation\":\"merge\"," + + "\"target\":\"/ietf-interfaces:interfaces-state\"," + + "\"value\": {" + + "\"ietf-interfaces:interfaces-state\":{"+ + "\"interface\": {" + + "\"name\":\"eth0\"," + + "\"oper-status\":\"down\"," + + "}" + + "}" + + "}" + + "}]"+ + "}" + + "}" + + "}" + + "}" + + "}"; + final EventOutput result = new EventOutput(); + result.write(new OutboundEvent.Builder().data(String.class, data).build()); + result.close(); + return result; + } +} diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java new file mode 100644 index 000000000..db878f0af --- /dev/null +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java @@ -0,0 +1,105 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.restconfdiscovery; + +import java.net.URI; +import java.util.HashMap; +import java.util.Map; + +import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; +import org.glassfish.jersey.media.sse.SseFeature; +import org.glassfish.jersey.server.ResourceConfig; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +public class TestRestconfDiscoveryNode { + + private static final URI CONTEXT = URI.create("http://localhost:8080/"); + + @Test + public void testEstablishPersistentConnection() throws SvcLogicException, + InterruptedException { + final ResourceConfig resourceConfig = new ResourceConfig( + SseServerMock.class, SseFeature.class); + GrizzlyHttpServerFactory.createHttpServer(CONTEXT, resourceConfig); + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.encoding-json", "encoding-json"); + ctx.setAttribute("restapi-result.response-code", "200"); + ctx.setAttribute("restapi-result.ietf-subscribed-notifications" + + ":output.identifier", "100"); + + Map p = new HashMap<>(); + p.put("sseConnectURL", "http://localhost:8080/events"); + p.put("subscriberId", "networkId"); + p.put("responsePrefix", "restapi-result"); + RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(); + rdn.establishPersistentConnection(p, ctx, "networkId"); + Thread.sleep(2000); + rdn.deleteSubscription(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testSubGraphExecution() throws SvcLogicException{ + SvcLogicGraphInfo subDg = new SvcLogicGraphInfo(); + subDg.mode("sync"); + subDg.module("l3VpnService"); + subDg.rpc("createVpn"); + subDg.version("1.0"); + SvcLogicContext ctx = new SvcLogicContext(); + subDg.executeGraph(ctx); + } + + @Test(expected = SvcLogicException.class) + public void testEstablishSubscriptionWithoutSubscriberId() + throws SvcLogicException{ + SvcLogicContext ctx = new SvcLogicContext(); + Map p = new HashMap<>(); + RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(); + rdn.establishSubscription(p, ctx); + } + + @Test + public void testResponseCode() { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("restapi-result.response-code", "200"); + ctx.setAttribute("response-code", "404"); + RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(); + assertThat(rdn.getResponseCode("restapi-result", ctx), + is("200")); + assertThat(rdn.getResponseCode(null, ctx), + is("404")); + } + + @Test + public void testOutputIdentifier() { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("restapi-result.ietf-subscribed-notifications:" + + "output.identifier", "89"); + ctx.setAttribute("ietf-subscribed-notifications:output.identifier", + "89"); + RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(); + assertThat(rdn.getOutputIdentifier("restapi-result", ctx), + is("89")); + } +} -- cgit From f4817b420b59de111a0abe1eec761bd3e4458530 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Tue, 14 Aug 2018 14:43:31 +0000 Subject: dme2 & ueb support fix dme2 & ueb support in rest api call node Change-Id: Ia387c0be8e907900e0b808879582048624dbef36 Issue-ID: CCSDK-459 Signed-off-by: Smokowski, Kevin (ks6305) --- restapi-call-node/provider/pom.xml | 14 ------- .../sli/plugins/restapicall/RestapiCallNode.java | 24 +++++++++++ .../META-INF/spring/restapi-call-node-context.xml | 49 ---------------------- .../spring/restapi-call-node-osgi-context.xml | 32 -------------- 4 files changed, 24 insertions(+), 95 deletions(-) delete mode 100644 restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml delete mode 100644 restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 18a20cef1..6670cfd8c 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -14,7 +14,6 @@ bundle ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} - http://maven.apache.org UTF-8 @@ -26,11 +25,6 @@ junit test - - org.springframework - spring-test - test - org.onap.ccsdk.sli.core sli-common @@ -43,14 +37,6 @@ org.slf4j slf4j-api - - org.springframework - spring-beans - - - org.springframework - spring-context - com.sun.jersey jersey-client diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 42462f0e6..46c74ff8a 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -37,6 +37,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Properties; import java.util.Set; import javax.net.ssl.HostnameVerifier; @@ -75,6 +76,10 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { private String uebServers; private String defaultUebTemplateFileName = "/opt/bvc/restapi/templates/default-ueb-message.json"; protected RetryPolicyStore retryPolicyStore; + protected static final String DME2_PROPERTIES_FILE_NAME = "dme2.properties"; + protected static final String UEB_PROPERTIES_FILE_NAME = "ueb.properties"; + protected static final String DEFAULT_PROPERTIES_DIR = "/opt/onap/ccsdk/data/properties"; + protected static final String PROPERTIES_DIR_KEY = "SDNC_CONFIG_DIR"; protected RetryPolicyStore getRetryPolicyStore() { return retryPolicyStore; @@ -85,7 +90,26 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } public RestapiCallNode() { + String configDir = System.getProperty(PROPERTIES_DIR_KEY, DEFAULT_PROPERTIES_DIR); + + try (FileInputStream in = new FileInputStream(configDir + "/" + DME2_PROPERTIES_FILE_NAME)) { + Properties props = new Properties(); + props.load(in); + this.retryPolicyStore = new RetryPolicyStore(); + this.retryPolicyStore.setProxyServers(props.getProperty("proxyUrl")); + log.info("DME2 support enabled"); + } catch (Exception e) { + log.warn("DME2 properties could not be read, DME2 support will not be enabled.", e); + } + try (FileInputStream in = new FileInputStream(configDir + "/" + UEB_PROPERTIES_FILE_NAME)) { + Properties props = new Properties(); + props.load(in); + this.uebServers = props.getProperty("servers"); + log.info("UEB support enabled"); + } catch (Exception e) { + log.warn("UEB properties could not be read, UEB support will not be enabled.", e); + } } /** diff --git a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml deleted file mode 100644 index 87850624c..000000000 --- a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - file:${SDNC_CONFIG_DIR}/ueb.properties - file:${SDNC_CONFIG_DIR}/dme2.properties - - - - - - - - - - - - - - - - - diff --git a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml deleted file mode 100644 index 2f1e4dbde..000000000 --- a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - -- cgit From 436c3a034313ef7f27e6df32a33c667d7c89940b Mon Sep 17 00:00:00 2001 From: Vidyashree Rama Date: Fri, 17 Aug 2018 09:27:24 +0530 Subject: Add abstract properties node tree properties node tree definations Issue-ID: CCSDK-379 Change-Id: Ib498cd57b0de5e67a31764f2fe46a2aeed7ac3f4 Signed-off-by: Vidyashree Rama --- .../pnserializer/DataNodeChild.java | 27 +++ .../yangserializers/pnserializer/HolderNode.java | 59 ++++++ .../yangserializers/pnserializer/InnerNode.java | 94 +++++++++ .../pnserializer/LeafListHolderChild.java | 28 +++ .../pnserializer/LeafListHolderNode.java | 81 ++++++++ .../yangserializers/pnserializer/LeafNode.java | 119 ++++++++++++ .../pnserializer/ListHolderChild.java | 28 +++ .../pnserializer/ListHolderNode.java | 66 +++++++ .../MdsalPropertiesNodeSerializer.java | 4 +- .../pnserializer/MultiInstanceNode.java | 32 +++ .../yangserializers/pnserializer/Namespace.java | 100 ++++++++++ .../yangserializers/pnserializer/NodeChild.java | 28 +++ .../pnserializer/PropertiesNode.java | 216 +++++++++++++++++---- .../pnserializer/PropertiesNodeSerializer.java | 15 +- .../yangserializers/pnserializer/RootNode.java | 91 +++++++++ .../pnserializer/SingleInstanceNode.java | 33 ++++ 16 files changed, 974 insertions(+), 47 deletions(-) create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DataNodeChild.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/HolderNode.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderChild.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafNode.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderChild.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderNode.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MultiInstanceNode.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/Namespace.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/NodeChild.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/RootNode.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/SingleInstanceNode.java diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DataNodeChild.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DataNodeChild.java new file mode 100644 index 000000000..7be54690a --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DataNodeChild.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +/** + * Abstraction of entity representing child's to data node. + */ +public interface DataNodeChild extends NodeChild { +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/HolderNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/HolderNode.java new file mode 100644 index 000000000..52bec3412 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/HolderNode.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +import java.util.HashMap; +import java.util.Map; + +/** + * Abstraction of an entity that represents holder node to multi instance node + * in properties data tree. + * + * @param type of child + */ +public abstract class HolderNode extends PropertiesNode { + + private Map children = new HashMap<>(); + + protected HolderNode(String name, Namespace namespace, String uri, + PropertiesNode parent, Object appInfo, + NodeType nodeType) { + super(name, namespace, uri, parent, appInfo, nodeType); + } + + /** + * Returns children. + * + * @return children + */ + public Map children() { + return children; + } + + /** + * Returns child based on index. + * + * @return child based on index + */ + public T child(String index) { + return children.get(index); + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java new file mode 100644 index 000000000..21f0b7c03 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + +import java.util.HashMap; +import java.util.Map; + +/** + * Abstraction of an entity that represents an inner node to properties data + * tree. + * + * @param type of child + */ +public abstract class InnerNode extends PropertiesNode { + + private Map children = new HashMap(); + + protected InnerNode(String name, Namespace namespace, String uri, + PropertiesNode parent, Object appInfo, NodeType nodeType) { + super(name, namespace, uri, parent, appInfo, nodeType); + } + + /** + * Returns children. + * + * @return children + */ + public Map children() { + return children; + } + + /** + * Sets children. + * + * @param children child nodes + */ + public void children(Map children) { + this.children = children; + } + + @Override + public PropertiesNode addChild(String name, Namespace namespace, + NodeType type, + Object appInfo) throws SvcLogicException { + // TODO : to be implemented + return null; + } + + @Override + public PropertiesNode addChild(String name, Namespace namespace, + NodeType type, String value, + Namespace valuens, + Object appInfo) throws SvcLogicException { + // TODO : to be implemented + return null; + } + + @Override + public PropertiesNode addChild(String index, String name, + Namespace namespace, NodeType type, + Object appInfo) throws SvcLogicException { + // TODO : to be implemented + return null; + } + + @Override + public PropertiesNode addChild(String index, String name, + Namespace namespace, NodeType type, + String value, Namespace valueNs, + Object appInfo) throws SvcLogicException { + // TODO : to be implemented + return null; + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderChild.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderChild.java new file mode 100644 index 000000000..e43249a3d --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderChild.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +/** + * Abstraction of entity representing child's to leaf list holder. + */ +public interface LeafListHolderChild extends NodeChild { + +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java new file mode 100644 index 000000000..aa10e3307 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + +/** + * Representation of leaf list holder node which will hold multi instance leaf + * node in properties data tree. + */ +public class LeafListHolderNode extends HolderNode implements DataNodeChild { + + /** + * Creates an instance of LeafListHolderNode. + * + * @param name name of the leaf-list node + * @param namespace namespace of the leaf-list node + * @param uri uri of the leaf-list node + * @param parent parent node of the leaf-list + * @param appInfo application info + * @param nodeType node type + */ + public LeafListHolderNode(String name, Namespace namespace, + String uri, PropertiesNode parent, + Object appInfo, NodeType nodeType) { + super(name, namespace, uri, parent, appInfo, nodeType); + } + + @Override + public PropertiesNode addChild(String name, Namespace namespace, + NodeType type, String value, + Namespace valueNs, + Object appInfo) throws SvcLogicException { + throw new SvcLogicException("Leaf cannot be child of leaf-list" + + " holder node"); + } + + @Override + public PropertiesNode addChild(String name, Namespace namespace, + NodeType type, + Object appInfo) throws SvcLogicException { + throw new SvcLogicException("Container cannot be child of leaf-list" + + " holder node"); + } + + @Override + public PropertiesNode addChild(String index, String name, + Namespace namespace, + NodeType type, + Object appInfo) throws SvcLogicException { + throw new SvcLogicException("List cannot be child of leaf-list" + + " holder node"); + } + + @Override + public PropertiesNode addChild(String index, String name, + Namespace namespace, NodeType type, + String value, Namespace valueNs, + Object appInfo) throws SvcLogicException { + // TODO : to be implemented + return null; + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafNode.java new file mode 100644 index 000000000..c9cf95ba3 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafNode.java @@ -0,0 +1,119 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + +/** + * Representation of leaf node in properties data tree. + */ +public class LeafNode extends PropertiesNode implements LeafListHolderChild, DataNodeChild { + + private String value; + private Namespace valueNs; + + /** + * Creates an instance of leaf node. + * + * @param name name of the leaf node + * @param namespace namespace of the leaf node + * @param uri uri of the leaf node + * @param parent parent of the leaf node + * @param appInfo application info + * @param nodeType node type + * @param value value of the leaf + */ + public LeafNode(String name, Namespace namespace, + String uri, PropertiesNode parent, + Object appInfo, NodeType nodeType, + String value) { + super(name, namespace, uri, parent, appInfo, nodeType); + this.value = value; + } + + /** + * Returns value of the leaf. + * + * @return value of the leaf + */ + public String value() { + return value; + } + + /** + * Sets value of the leaf. + * + * @param value value of the leaf + */ + public void value(String value) { + this.value = value; + } + + /** + * Returns value namespace. + * + * @return value namespace + */ + public Namespace valueNs() { + return valueNs; + } + + /** + * Sets value namespace. + * + * @param valueNs value namespace + */ + public void valueNs(Namespace valueNs) { + this.valueNs = valueNs; + } + + @Override + public PropertiesNode addChild(String name, Namespace namespace, + NodeType type, + Object appInfo) throws SvcLogicException { + throw new SvcLogicException("Leaf cannot hold child nodes"); + } + + @Override + public PropertiesNode addChild(String name, Namespace namespace, + NodeType type, String value, + Namespace valueNs, + Object appInfo) throws SvcLogicException { + throw new SvcLogicException("Leaf cannot hold child nodes"); + } + + @Override + public PropertiesNode addChild(String index, String name, + Namespace namespace, + NodeType type, + Object appInfo) throws SvcLogicException { + throw new SvcLogicException("Leaf cannot hold child nodes"); + } + + @Override + public PropertiesNode addChild(String index, String name, + Namespace namespace, + NodeType type, String value, + Namespace valueNs, + Object appInfo) throws SvcLogicException { + throw new SvcLogicException("Leaf cannot hold child nodes"); + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderChild.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderChild.java new file mode 100644 index 000000000..ec9cc2a0f --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderChild.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +/** + * Abstraction of entity representing child's to list holder. + */ +public interface ListHolderChild extends NodeChild { + +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderNode.java new file mode 100644 index 000000000..9d1168b8f --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderNode.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + +/** + * Representation of list holder node which will hold multi instance node in + * properties data tree. + */ +public class ListHolderNode extends HolderNode implements DataNodeChild { + + protected ListHolderNode(String name, Namespace namespace, String uri, + PropertiesNode parent, Object appInfo, NodeType nodeType) { + super(name, namespace, uri, parent, appInfo, nodeType); + } + + @Override + public PropertiesNode addChild(String name, Namespace namespace, + NodeType type, String value, + Namespace valueNs, + Object appInfo) throws SvcLogicException { + throw new SvcLogicException("Leaf cannot be child of list holder node"); + } + + @Override + public PropertiesNode addChild(String name, Namespace namespace, + NodeType type, + Object appInfo) throws SvcLogicException { + throw new SvcLogicException("Container cannot be child of list holder node"); + } + + @Override + public PropertiesNode addChild(String index, String name, + Namespace namespace, NodeType type, + Object appInfo) throws SvcLogicException { + // TODO : to be implemented + return null; + } + + @Override + public PropertiesNode addChild(String index, String name, + Namespace namespace, NodeType type, + String value, Namespace valueNs, + Object appInfo) throws SvcLogicException { + throw new SvcLogicException("Leaf-list cannot be child of list holder node"); + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java index 67e9c1e59..05e1ac1e6 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java @@ -20,10 +20,12 @@ package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer; -import java.util.Map; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaNode; import org.slf4j.Logger; + +import java.util.Map; + import static org.slf4j.LoggerFactory.getLogger; /** diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MultiInstanceNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MultiInstanceNode.java new file mode 100644 index 000000000..c251cdaea --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MultiInstanceNode.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +/** + * Representation of multi instance node in properties data tree. + */ +public class MultiInstanceNode extends InnerNode implements ListHolderChild { + + public MultiInstanceNode(String name, Namespace namespace, String uri, + PropertiesNode parent, Object appinfo, NodeType nodeType) { + super(name, namespace, uri, parent, appinfo, nodeType); + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/Namespace.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/Namespace.java new file mode 100644 index 000000000..4f27ee1e7 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/Namespace.java @@ -0,0 +1,100 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +import java.net.URI; + +/** + * Representation of YANG namespace. + */ +public class Namespace { + private String moduleName; + private URI moduleNs; + private String revision; + + /** + * Creates an instance of namespace with specified module name, + * namespace and revision. + * + * @param modulename module name + * @param moduleNs module namespace + * @param revision revision + */ + public Namespace(String modulename, URI moduleNs, String revision) { + this.moduleName = modulename; + this.moduleNs = moduleNs; + this.revision = revision; + } + + /** + * Returns module name. + * + * @return module name + */ + public String moduleName() { + return moduleName; + } + + /** + * Sets module name. + * + * @param moduleName module name + */ + public void moduleName(String moduleName) { + this.moduleName = moduleName; + } + + /** + * Sets module namespace. + * + * @return module namespace + */ + public URI moduleNs() { + return moduleNs; + } + + /** + * Sets module namespace. + * + * @param moduleNs module namespace + */ + public void moduleNs(URI moduleNs) { + this.moduleNs = moduleNs; + } + + /** + * Returns revision. + * + * @return revision + */ + public String revision() { + return revision; + } + + /** + * Sets revision. + * + * @param revision revision + */ + public void revision(String revision) { + this.revision = revision; + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/NodeChild.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/NodeChild.java new file mode 100644 index 000000000..d482c6763 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/NodeChild.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +/** + * Abstraction of an entity that represents child's of a node. + */ +public interface NodeChild { + +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNode.java index fccfa6a9d..bb07382a4 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNode.java @@ -20,24 +20,25 @@ package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + /** * Abstraction of properties node data tree. This intermediate representation * will enable data format serializers to be agnostic of DG context memory - * nuances and thereby will enable faster development of new data faormat + * nuances and thereby will enable faster development of new data format * serializers. */ public abstract class PropertiesNode { private String name; - private String namespace; + private Namespace namespace; private String uri; private PropertiesNode parent; - - /** - * Creates an instance of properties node. - */ - protected PropertiesNode() { - } + private Object appInfo; + private NodeType nodeType; + private Multimap augmentations = ArrayListMultimap.create(); /** * Creates an instance of properties node. @@ -47,78 +48,213 @@ public abstract class PropertiesNode { * @param uri URI of this node, if null its calculated based on parent and * current value of name and namespace * @param parent parent's node + * @param appInfo application related information + * @param nodeType node type */ - protected PropertiesNode(String name, String namespace, String uri, PropertiesNode parent) { + protected PropertiesNode(String name, Namespace namespace, String uri, + PropertiesNode parent, Object appInfo, NodeType nodeType) { this.name = name; this.namespace = namespace; this.uri = uri; this.parent = parent; + this.appInfo = appInfo; + this.nodeType = nodeType; } /** - * Adds a child to a current node. + * Sets name. * - * @param name name of child - * @param namespace namespace of child, null represents parent namespace - * @param type type of node - * @return added properties node + * @param name name of the node */ - public abstract PropertiesNode addChild(String name, String namespace, NodeType type); + public void name(String name) { + this.name = name; + } /** - * Adds a child with value to a current node. + * Sets namespace. * - * @param name name of child - * @param namespace namespace of child, null represents parent namespace - * @param type type of node - * @param value value of node - * @return added properties node + * @param namespace namespace of the node */ - public abstract PropertiesNode addChild(String name, String namespace, NodeType type, String value); + public void namespace(Namespace namespace) { + this.namespace = namespace; + } /** - * Adds a child at a given index to a current node. To be used in case of - * leaf holder child's which is multi instance node. + * Sets uri. * - * @param index index at which node is to be added - * @param name name of child - * @param namespace namespace of child, null represents parent namespace - * @param type type of node - * @return added properties node + * @param uri uri of the node */ - public abstract PropertiesNode addChild(String index, String name, String namespace, NodeType type); - - public void name(String name) { - this.name = name; - } - - public void namespace(String namespace) { - this.namespace = namespace; - } - public void uri(String uri) { this.uri = uri; } + /** + * Sets parent node. + * + * @param parent parent node + */ public void parent(PropertiesNode parent) { this.parent = parent; } + /** + * Sets application info. + * + * @param appInfo application info + */ + public void appInfo(Object appInfo) { + this.appInfo = appInfo; + } + + /** + * Returns parent. + * + * @return parent node + */ public PropertiesNode parent() { return parent; } + /** + * Returns name. + * + * @return name of the node + */ public String name() { return name; } - public String namespace() { + /** + * Returns namespace. + * + * @return namespace of the node + */ + public Namespace namespace() { return namespace; } + /** + * Returns uri. + * + * @return uri of the node + */ public String uri() { return uri; } + /** + * Returns application info. + * + * @return application info + */ + public Object appInfo() { + return appInfo; + } + + /** + * Returns node type. + * + * @return node type + */ + public NodeType nodeType() { + return nodeType; + } + + /** + * Returns augmentations. + * + * @return augmentations + */ + public Multimap augmentations() { + return augmentations; + } + + /** + * Sets augmentations. + * + * @param augmentations augmentations of the node + */ + public void augmentations(Multimap augmentations) { + this.augmentations = augmentations; + } + + /** + * Adds a child to a current node. + * + * @param name name of child + * @param namespace namespace of child, null represents parent namespace + * @param type type of node + * @param appInfo application info + * @return added properties node + */ + public abstract PropertiesNode addChild(String name, Namespace namespace, + NodeType type, + Object appInfo) throws SvcLogicException; + + /** + * Adds a child with value to a current node. + * + * @param name name of child + * @param namespace namespace of child, null represents parent namespace + * @param type type of node + * @param value value of node + * @param valueNs value namespace + * @param appInfo application info + * @throws SvcLogicException if failed to add child + * @return added properties node + */ + public abstract PropertiesNode addChild(String name, Namespace namespace, + NodeType type, String value, + Namespace valueNs, + Object appInfo) throws SvcLogicException; + + /** + * Adds a child at a given index to a current node. To be used in case of + * leaf holder child's which is multi instance node. + * + * @param index index at which node is to be added + * @param name name of child + * @param namespace namespace of child, null represents parent namespace + * @param type type of node + * @param appInfo application info + * @throws SvcLogicException if failed to add child + * @return added properties node + */ + public abstract PropertiesNode addChild(String index, String name, + Namespace namespace, + NodeType type, + Object appInfo) throws SvcLogicException; + + /** + * Adds a child at a given index to a current node. To be used in case of + * leaf holder child's which is multi instance node. + * + * @param index index at which node is to be added + * @param name name of child + * @param namespace namespace of child, null represents parent namespace + * @param type type of node + * @param value value of node + * @param valueNs value namespace + * @param appInfo application info + * @throws SvcLogicException if failed to add child + * @return added properties node + */ + public abstract PropertiesNode addChild(String index, String name, + Namespace namespace, NodeType type, + String value, Namespace valueNs, + Object appInfo) throws SvcLogicException; + + /** + * Returns root node. + * + * @return root node + */ + public PropertiesNode endNode() { + PropertiesNode node = this; + while (node.parent() != null){ + node = node.parent(); + } + return node; + } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeSerializer.java index 81609a6da..3e3483721 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeSerializer.java @@ -20,6 +20,8 @@ package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + import java.util.Map; /** @@ -62,29 +64,30 @@ public abstract class PropertiesNodeSerializer { this.uri = uri; } - /** * Encodes from properties to properties-node tree. * * @param paramMap parameter map + * @throws SvcLogicException fails to encode properties to properties node * @return properties node */ - public abstract PropertiesNode encode(Map paramMap); + public abstract PropertiesNode encode(Map paramMap) throws SvcLogicException; /** * Decodes from properties-node to properties map. * * @param propertiesNode properties-node + * @throws SvcLogicException fails to decode properties node to properties * @return parameter map */ - public abstract Map decode(PropertiesNode propertiesNode); + public abstract Map decode(PropertiesNode propertiesNode) throws SvcLogicException; /** * Returns the schema node of the property * * @return schema node */ - public T getSchemaNode(){ + public T schemaNode(){ return schemaNode; } @@ -93,7 +96,7 @@ public abstract class PropertiesNodeSerializer { * * @return schema node */ - public P getSchemaCtx() { + public P schemaCtx() { return schemaCtx; } @@ -102,7 +105,7 @@ public abstract class PropertiesNodeSerializer { * * @return uri */ - public String getUri() { + public String uri() { return uri; } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/RootNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/RootNode.java new file mode 100644 index 000000000..5cb8e4c97 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/RootNode.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + +import java.util.HashMap; +import java.util.Map; + +/** + * Abstraction of node representing properties data tree. + */ +public class RootNode extends PropertiesNode { + + private Map children = new HashMap(); + + protected RootNode(String name, Namespace namespace, + Object appInfo, String uri) { + super(name, namespace, uri, null, appInfo, null); + } + + /** + * Returns children. + * + * @return children + */ + public Map children() { + return children; + } + + /** + * Sets children. + * + * @param children child nodes + */ + public void children(Map children) { + this.children = children; + } + + @Override + public PropertiesNode addChild(String name, Namespace namespace, + NodeType type, + Object appInfo) throws SvcLogicException { + // TODO : to be implemented + return null; + } + + @Override + public PropertiesNode addChild(String name, Namespace namespace, + NodeType type, String value, + Namespace valuens, + Object appInfo) throws SvcLogicException { + // TODO : to be implemented + return null; + } + + @Override + public PropertiesNode addChild(String index, String name, + Namespace namespace, NodeType type, + Object appInfo) throws SvcLogicException { + // TODO : to be implemented + return null; + } + + @Override + public PropertiesNode addChild(String index, String name, + Namespace namespace, NodeType type, + String value, Namespace valueNs, + Object appInfo) throws SvcLogicException { + // TODO : to be implemented + return null; + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/SingleInstanceNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/SingleInstanceNode.java new file mode 100644 index 000000000..6eb24c1a4 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/SingleInstanceNode.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +/** + * Representation of single instance node in properties data tree. + */ +public class SingleInstanceNode extends InnerNode implements DataNodeChild { + + public SingleInstanceNode(String name, Namespace namespace, String uri, + PropertiesNode parent, Object appInfo, + NodeType nodeType) { + super(name, namespace, uri, parent, appInfo, nodeType); + } +} -- cgit From 21190939f08b40c46f908fefabf8cc13e7365f2a Mon Sep 17 00:00:00 2001 From: Vidyashree Rama Date: Fri, 17 Aug 2018 12:21:05 +0530 Subject: Implementation for properties node serializer properties node serializer implementation Issue-ID: CCSDK-378 Change-Id: I4eeecb45227e4152d9ff81551fd98efdd1371f84 Signed-off-by: Vidyashree Rama --- restconf-client/provider/pom.xml | 6 + .../yangserializers/pnserializer/InnerNode.java | 133 ++++++++- .../pnserializer/LeafListHolderNode.java | 11 +- .../pnserializer/ListHolderNode.java | 11 +- .../MdsalPropertiesNodeSerializer.java | 84 +++++- .../pnserializer/MdsalPropertiesNodeUtils.java | 297 +++++++++++++++++++++ .../yangserializers/pnserializer/RootNode.java | 129 ++++++++- 7 files changed, 645 insertions(+), 26 deletions(-) create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeUtils.java diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 5a74d8fc0..46e000094 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -70,5 +70,11 @@ properties-node-provider 0.3.0-SNAPSHOT + + org.opendaylight.yangtools + yang-data-impl + 2.0.3 + + diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java index 21f0b7c03..063c3d050 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java @@ -21,10 +21,22 @@ package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer; import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode; +import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import java.util.HashMap; import java.util.Map; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.addToAugmentations; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.createNode; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getAugmentationNode; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getUri; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.isNamespaceAsParent; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.resolveName; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_HOLDER_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_LEAF_HOLDER_NODE; +import static org.opendaylight.yangtools.yang.data.impl.schema.SchemaUtils.findCorrespondingAugment; + /** * Abstraction of an entity that represents an inner node to properties data * tree. @@ -62,8 +74,31 @@ public abstract class InnerNode extends PropertiesNode { public PropertiesNode addChild(String name, Namespace namespace, NodeType type, Object appInfo) throws SvcLogicException { - // TODO : to be implemented - return null; + PropertiesNode node = ((PropertiesNode) children.get(name)); + if (node != null) { + return node; + } + + // get augment schema, if it is augmented node + AugmentationSchemaNode augSchema = null; + if (((DataSchemaNode) appInfo).isAugmenting()) { + augSchema = findCorrespondingAugment(((DataSchemaNode) this.appInfo()), ((DataSchemaNode) appInfo)); + node = getAugmentationNode(augSchema, this, name); + } + + // create node based on type + if (node == null) { + String uri = getUri(this, name, namespace); + node = createNode(name, namespace, uri, this, appInfo, type); + } + + // If namespace is not same as parent then it is augmented node + if (augSchema != null && !isNamespaceAsParent(this, node)) { + addToAugmentations(augSchema, this, node); + } else { + children.put(name, ((T) node)); + } + return node; } @Override @@ -71,16 +106,65 @@ public abstract class InnerNode extends PropertiesNode { NodeType type, String value, Namespace valuens, Object appInfo) throws SvcLogicException { - // TODO : to be implemented - return null; + LeafNode node = ((LeafNode) children.get(name)); + if (node != null) { + return node; + } + + AugmentationSchemaNode augSchema = null; + if (((DataSchemaNode) appInfo).isAugmenting()) { + augSchema = findCorrespondingAugment(((DataSchemaNode) this.appInfo()), + ((DataSchemaNode) appInfo)); + } + + String uri = getUri(this, name, namespace); + node = new LeafNode(name, namespace, uri, this, + appInfo, type, value); + + if (augSchema != null && !isNamespaceAsParent(this, node)) { + addToAugmentations(augSchema, this, node); + } else { + children.put(name, ((T) node)); + } + return node; } @Override public PropertiesNode addChild(String index, String name, Namespace namespace, NodeType type, Object appInfo) throws SvcLogicException { - // TODO : to be implemented - return null; + String localname = resolveName(name); + PropertiesNode node = ((PropertiesNode) children.get(localname)); + + if (node == null) { + AugmentationSchemaNode augSchema = null; + if (((DataSchemaNode) appInfo).isAugmenting()) { + augSchema = findCorrespondingAugment(((DataSchemaNode) this.appInfo()), + ((DataSchemaNode) appInfo)); + node = getAugmentationNode(augSchema, this, localname); + } + + if (node == null) { + String uri = getUri(this, name, namespace); + node = new ListHolderNode(localname, namespace, uri, + this, appInfo, MULTI_INSTANCE_HOLDER_NODE); + } + + if (augSchema != null && !isNamespaceAsParent(this, node)) { + addToAugmentations(augSchema, this, node); + } else { + children.put(localname, ((T) node)); + } + + node = node.addChild(index, localname, namespace, type, appInfo); + } else if (node instanceof ListHolderNode) { + ListHolderChild child = ((ListHolderNode) node).child(index); + node = (child != null ? ((MultiInstanceNode) child) : + node.addChild(index, localname, namespace, type, appInfo)); + } else { + throw new SvcLogicException("Duplicate node exist with same node"); + } + return node; } @Override @@ -88,7 +172,40 @@ public abstract class InnerNode extends PropertiesNode { Namespace namespace, NodeType type, String value, Namespace valueNs, Object appInfo) throws SvcLogicException { - // TODO : to be implemented - return null; + String localName = resolveName(name); + PropertiesNode node = ((PropertiesNode) children.get(localName)); + + if (node == null) { + + AugmentationSchemaNode augSchema = null; + if (((DataSchemaNode) appInfo).isAugmenting()) { + augSchema = findCorrespondingAugment(((DataSchemaNode) this.appInfo()), + ((DataSchemaNode) appInfo)); + node = getAugmentationNode(augSchema, this, localName); + } + + if (node == null) { + String uri = getUri(this, name, namespace); + node = new LeafListHolderNode(localName, namespace, uri, this, + appInfo, MULTI_INSTANCE_LEAF_HOLDER_NODE); + } + + if (augSchema != null && !isNamespaceAsParent(this, node)) { + addToAugmentations(augSchema, this, node); + } else { + children.put(localName, ((T) node)); + } + + node = node.addChild(index, localName, namespace, type, value, null, appInfo); + } else if (node instanceof LeafListHolderNode) { + LeafNode child = ((LeafNode) ((HolderNode) node).child(index)); + node = (child != null ? child : node.addChild(index, localName, + namespace, type, + value, null, + appInfo)); + } else { + throw new SvcLogicException("Duplicate node exist with same node"); + } + return node; } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java index aa10e3307..94892dcac 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java @@ -75,7 +75,14 @@ public class LeafListHolderNode extends HolderNode implemen Namespace namespace, NodeType type, String value, Namespace valueNs, Object appInfo) throws SvcLogicException { - // TODO : to be implemented - return null; + LeafNode node = ((LeafNode) children().get(index)); + if (index == null) { + index = String.valueOf(children().size()); + } + String uri = this.uri() + "[" + index + "]"; + node = (node != null) ? node : new LeafNode(name, namespace, uri, + this, appInfo, type, value); + children().put(index, node); + return node; } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderNode.java index 9d1168b8f..ba9da54cf 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/ListHolderNode.java @@ -52,8 +52,15 @@ public class ListHolderNode extends HolderNode implements DataN public PropertiesNode addChild(String index, String name, Namespace namespace, NodeType type, Object appInfo) throws SvcLogicException { - // TODO : to be implemented - return null; + MultiInstanceNode node = ((MultiInstanceNode) children().get(index)); + if (index == null) { + index = String.valueOf(children().size()); + } + String uri = this.uri() + "[" + index + "]"; + node = (node != null) ? node : new MultiInstanceNode(name, namespace, uri, + this, appInfo, type); + children().put(index, node); + return node; } @Override diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java index 05e1ac1e6..405e24127 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java @@ -20,13 +20,25 @@ package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaNode; -import org.slf4j.Logger; +import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil; import java.util.Map; -import static org.slf4j.LoggerFactory.getLogger; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getChildSchemaNode; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getIndex; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getListName; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getNamespace; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getNodeType; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getRevision; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.resolveName; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_LEAF_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.SINGLE_INSTANCE_LEAF_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.SINGLE_INSTANCE_NODE; /** * Representation of mdsal based properties node serializer implementation. @@ -35,7 +47,6 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer paramMap) { - return null; + public PropertiesNode encode(Map paramMap) throws SvcLogicException { + curSchema = schemaNode(); + String nodeInUri[] = uri().split("\\/"); + String lastNodeName = nodeInUri[nodeInUri.length - 1]; + String rootUri = uri().replaceAll("\\/", "\\."); + node = createRootNode(lastNodeName, rootUri); + + for (Map.Entry entry : paramMap.entrySet()) { + String[] names = entry.getKey().split("\\."); + for (int i = 0; i < names.length; i++) { + if (i < nodeInUri.length) { + if (!(nodeInUri[i].equals(names[i]))) { + break; + } + } else { + createPropertyNode(i, names.length, names[i], + entry.getValue()); + } + } + } + return node; } @Override @@ -58,4 +89,45 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer 1; + } + + /** + * Returns name of the property after pruning namespace and + * index if the property is multi instance. + * + * @param name name of the property + * @return name of the property + */ + public static String resolveName(String name) { + String localName = getListName(name); + final int lastIndexOfColon = localName.lastIndexOf(":"); + if (lastIndexOfColon != -1) { + localName = localName.substring(lastIndexOfColon + 1); + } + return localName; + } + + /** + * Adds current node to parent's augmentation map. + * + * @param augSchema augment schema + * @param parent parent property node + * @param curNode current property node + */ + public static void addToAugmentations(AugmentationSchemaNode augSchema, + PropertiesNode parent, + PropertiesNode curNode) { + Collection childsFromAugmentation = parent + .augmentations().get(augSchema); + if (!childsFromAugmentation.isEmpty()) { + for (PropertiesNode pNode : childsFromAugmentation) { + if (pNode.name().equals(curNode.name())) { + return; + } + } + } + parent.augmentations().put(augSchema, curNode); + } + + + /** + * Returns augmented properties node if it is already + * added in properties tree. + * + * @param augSchema augmented schema node + * @param parent parent properties node + * @param name name of the properties + * @return augmented properties node if it is already added + */ + public static PropertiesNode getAugmentationNode( + AugmentationSchemaNode augSchema, + PropertiesNode parent, String name) { + if (augSchema != null) { + Collection childsFromAugmentation = parent + .augmentations().get(augSchema); + if (!childsFromAugmentation.isEmpty()) { + for (PropertiesNode pNode : childsFromAugmentation) { + if (pNode.name().equals(name)) { + return pNode; + } + } + } + } + return null; + } + + /** + * Creates uri with specified name and namespace. + * + * @param parent parent properties node + * @param name name of the node + * @param ns namespace of the node + * @return uri with specified name and namespace + */ + public static String getUri(PropertiesNode parent, String name, + Namespace ns) { + String uri = name; + if (!(parent.namespace().moduleNs().equals(ns.moduleNs()))) { + uri = ns.moduleName() + ":" + name; + } + return parent.uri() + "." + uri; + } + + /** + * Creates new properties with specified parameters. + * + * @param name name of the properties node + * @param namespace namespace of the properties node + * @param uri uri of the properties node + * @param parent parent node + * @param appInfo application info + * @param type node type + * @return new properties node + */ + public static PropertiesNode createNode(String name, Namespace namespace, + String uri, PropertiesNode parent, + Object appInfo, NodeType type) { + switch (type) { + case SINGLE_INSTANCE_NODE: + return new SingleInstanceNode(name, namespace, uri, parent, appInfo, type); + case MULTI_INSTANCE_HOLDER_NODE: + return new ListHolderNode(name, namespace, uri, parent, appInfo, type); + case MULTI_INSTANCE_LEAF_HOLDER_NODE: + return new LeafListHolderNode(name, namespace, uri, parent, appInfo, type); + default: + throw new RuntimeException("Invalid node type"); + } + } + + /** + * Returns true if namespace is same as parent's namespace. + * + * @param parent parent property node + * @param curNode current property node + * @return true if namespace is same as parent namespace + */ + public static boolean isNamespaceAsParent(PropertiesNode parent, + PropertiesNode curNode) { + return parent.namespace().moduleNs().equals(curNode.namespace().moduleNs()); + } + + /** + * Returns namespace. + * + * @param childName name of the property + * @param ctx schema context + * @param parent parent property node + * @return namespace + */ + public static Namespace getNamespace(String childName, + SchemaContext ctx, + PropertiesNode parent) { + int lastIndexOfColon = childName.lastIndexOf(":"); + if (lastIndexOfColon != -1) { + String moduleName = childName.substring(0, lastIndexOfColon); + Iterator it = ctx.findModules(moduleName).iterator(); + if (!it.hasNext()) { + // module is not present in context + return null; + } + Module m = it.next(); + return new Namespace(moduleName, m.getQNameModule().getNamespace(), + getRevision(m.getRevision())); + } + Namespace parentNs = parent.namespace(); + return new Namespace(parentNs.moduleName(), parentNs.moduleNs(), + parentNs.revision()); + } + + /** + * Returns child schema node. + * + * @param curSchema current schema node + * @param name name of the property + * @param namespace namespace of the property + * @return child schema node + */ + public static SchemaNode getChildSchemaNode(SchemaNode curSchema, + String name, + Namespace namespace) { + if (namespace == null) { + return null; + } + + QName qname = QName.create(namespace.moduleNs(), + Revision.of(namespace.revision()), name); + + // YANG RPC will not be instance of DataSchemaNode + if (curSchema instanceof DataSchemaNode) { + Deque schemaNodeDeque = ParserStreamUtils. + findSchemaNodeByNameAndNamespace(((DataSchemaNode) + curSchema), name, namespace.moduleNs()); + if (schemaNodeDeque.isEmpty()) { + // could not find schema node + return null; + } + + DataSchemaNode schemaNode = schemaNodeDeque.pop(); + if (schemaNodeDeque.isEmpty()){ + // Simple node + return schemaNode; + } + + // node is child of Choice/case + return SchemaUtils.findSchemaForChild(((ChoiceSchemaNode) schemaNode), + qname); + } else { + return SchemaUtils.findDataChildSchemaByQName(curSchema, qname); + } + } + + /** + * Returns the property node type. + * + * @param index current index + * @param length length of the properties + * @param name name of the property + * @return the property node type + */ + public static NodeType getNodeType(int index, int length, String name) { + if (index == length-1) { + return (isListEntry(name) ? NodeType.MULTI_INSTANCE_LEAF_NODE : + NodeType.SINGLE_INSTANCE_LEAF_NODE); + } else { + return (isListEntry(name) ? NodeType.MULTI_INSTANCE_NODE : + NodeType.SINGLE_INSTANCE_NODE); + } + } + + /** + * Returns revision in string. + * + * @param r YANG revision + * @return revision in string + */ + public static String getRevision(Optional r) { + return (r.isPresent()) ? r.get().toString() : null; + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/RootNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/RootNode.java index 5cb8e4c97..0159683ac 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/RootNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/RootNode.java @@ -21,10 +21,22 @@ package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer; import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode; +import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import java.util.HashMap; import java.util.Map; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.addToAugmentations; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.createNode; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getAugmentationNode; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getUri; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.isNamespaceAsParent; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.resolveName; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_HOLDER_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_LEAF_HOLDER_NODE; +import static org.opendaylight.yangtools.yang.data.impl.schema.SchemaUtils.findCorrespondingAugment; + /** * Abstraction of node representing properties data tree. */ @@ -59,8 +71,32 @@ public class RootNode extends PropertiesNode { public PropertiesNode addChild(String name, Namespace namespace, NodeType type, Object appInfo) throws SvcLogicException { - // TODO : to be implemented - return null; + PropertiesNode node = ((PropertiesNode) children.get(name)); + if (node != null) { + return node; + } + + // get augment schema, if it is augmented node + AugmentationSchemaNode augSchema = null; + if (((DataSchemaNode) appInfo).isAugmenting()) { + augSchema = findCorrespondingAugment(((DataSchemaNode) this.appInfo()), + ((DataSchemaNode) appInfo)); + node = getAugmentationNode(augSchema, this, name); + } + + // create node based on type, this api will be invoked only for these three types + if (node == null) { + String uri = getUri(this, name, namespace); + node = createNode(name, namespace, uri, this, appInfo, type); + } + + // If namespace is not same as parent then it is augmented node + if (augSchema != null && !isNamespaceAsParent(this, node)) { + addToAugmentations(augSchema, this, node); + } else { + children.put(name, ((T) node)); + } + return node; } @Override @@ -68,16 +104,63 @@ public class RootNode extends PropertiesNode { NodeType type, String value, Namespace valuens, Object appInfo) throws SvcLogicException { - // TODO : to be implemented - return null; + LeafNode node = ((LeafNode) children.get(name)); + if (node != null) { + return node; + } + + AugmentationSchemaNode augSchema = null; + if (((DataSchemaNode) appInfo).isAugmenting()) { + augSchema = findCorrespondingAugment(((DataSchemaNode) this.appInfo()), + ((DataSchemaNode) appInfo)); + } + + String uri = getUri(this, name, namespace); + node = new LeafNode(name, namespace, uri, this, + appInfo, type, value); + + if (augSchema != null && !isNamespaceAsParent(this, node)) { + addToAugmentations(augSchema, this, node); + } else { + children.put(name, ((T) node)); + } + return node; } @Override public PropertiesNode addChild(String index, String name, Namespace namespace, NodeType type, Object appInfo) throws SvcLogicException { - // TODO : to be implemented - return null; + String localname = resolveName(name); + PropertiesNode node = ((PropertiesNode) children.get(localname)); + if (node == null) { + String uri = getUri(this, name, namespace); + AugmentationSchemaNode augSchema = null; + if (((DataSchemaNode) appInfo).isAugmenting()) { + augSchema = findCorrespondingAugment(((DataSchemaNode) this.appInfo()), + ((DataSchemaNode) appInfo)); + node = getAugmentationNode(augSchema, this, localname); + } + + if (node == null) { + node = new ListHolderNode(localname, namespace, uri, + this, appInfo, MULTI_INSTANCE_HOLDER_NODE); + } + + if (augSchema != null && !isNamespaceAsParent(this, node)) { + addToAugmentations(augSchema, this, node); + } else { + children.put(localname, ((T) node)); + } + node = node.addChild(index, localname, namespace, type, appInfo); + } else if (node instanceof ListHolderNode) { + ListHolderChild child = ((ListHolderNode) node).child(index); + node = (child != null ? ((MultiInstanceNode) child) : + node.addChild(index, localname, namespace, type, appInfo)); + } else { + throw new SvcLogicException("Duplicate node exist with same node"); + } + return node; } @Override @@ -85,7 +168,37 @@ public class RootNode extends PropertiesNode { Namespace namespace, NodeType type, String value, Namespace valueNs, Object appInfo) throws SvcLogicException { - // TODO : to be implemented - return null; + String localName = resolveName(name); + PropertiesNode node = ((PropertiesNode) children.get(localName)); + if (node == null) { + String uri = getUri(this, name, namespace); + AugmentationSchemaNode augSchema = null; + if (((DataSchemaNode) appInfo).isAugmenting()) { + augSchema = findCorrespondingAugment(((DataSchemaNode) this.appInfo()), + ((DataSchemaNode) appInfo)); + node = getAugmentationNode(augSchema, this, localName); + } + + if (node == null) { + node = new LeafListHolderNode(localName, namespace, uri, this, + appInfo, MULTI_INSTANCE_LEAF_HOLDER_NODE); + } + + if (augSchema != null && !isNamespaceAsParent(this, node)) { + addToAugmentations(augSchema, this, node); + } else { + children.put(localName, ((T) node)); + } + node = node.addChild(index, localName, namespace, type, value, null, appInfo); + } else if (node instanceof LeafListHolderNode) { + LeafNode child = ((LeafNode) ((HolderNode) node).child(index)); + node = (child != null ? child : node.addChild(index, localName, + namespace, type, + value, null, + appInfo)); + } else { + throw new SvcLogicException("Duplicate node exist with same node"); + } + return node; } } -- cgit From 06f4a6531b11b1e841f4c63b968d2b8a7a65eaf6 Mon Sep 17 00:00:00 2001 From: janani b Date: Fri, 17 Aug 2018 15:32:26 +0530 Subject: Outline code for Restconf Api Call Node Initial level implementation for Restconf api call node Issue-ID: CCSDK-372 Change-Id: I9d77f4c7806b0e239a3ecb134424f4fc09d6865e Signed-off-by: janani b --- restconf-client/provider/pom.xml | 20 ++++- .../yangserializers/dfserializer/Annotation.java | 7 ++ .../yangserializers/dfserializer/DataFormat.java | 8 ++ .../dfserializer/DataFormatSerializer.java | 19 +++-- .../dfserializer/DataFormatSerializerContext.java | 52 ++++++++++--- .../dfserializer/DefaultJsonListener.java | 71 ++++++++++++++++++ .../dfserializer/DefaultJsonWalker.java | 60 +++++++++++++++ .../dfserializer/DefaultXmlListener.java | 58 +++++++++++++++ .../dfserializer/DefaultXmlWalker.java | 34 +++++++++ .../dfserializer/DfListenerFactory.java | 74 ++++++++++++++++++ .../dfserializer/DfSerializerFactory.java | 75 +++++++++++++++++++ .../yangserializers/dfserializer/JsonListener.java | 51 +++++++++++++ .../dfserializer/JsonSerializer.java | 12 ++- .../yangserializers/dfserializer/JsonWalker.java | 41 ++++++++++ .../dfserializer/MdsalSerializerHelper.java | 58 ++++++++++----- .../yangserializers/dfserializer/NodeType.java | 31 -------- .../dfserializer/PropertiesNodeJsonListener.java | 70 +++++++++++++++++ .../dfserializer/PropertiesNodeXmlListener.java | 80 ++++++++++++++++++++ .../dfserializer/SerializerHelper.java | 86 ++++++++++++--------- .../yangserializers/dfserializer/XmlListener.java | 49 ++++++++++++ .../yangserializers/dfserializer/XmlNodeType.java | 37 +++++++++ .../dfserializer/XmlSerializer.java | 12 ++- .../yangserializers/dfserializer/XmlWalker.java | 41 ++++++++++ .../dfserializer/YangParameters.java | 41 ++++++++++ .../pnserializer/DefaultPropertiesNodeWalker.java | 87 ++++++++++++++++++++++ .../pnserializer/PropertiesNodeListener.java | 55 ++++++++++++++ .../pnserializer/PropertiesNodeWalker.java | 35 +++++++++ 27 files changed, 1157 insertions(+), 107 deletions(-) create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonListener.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonWalker.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlListener.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlWalker.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfListenerFactory.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerFactory.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonListener.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonWalker.java delete mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/NodeType.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeJsonListener.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeXmlListener.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlListener.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlNodeType.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlWalker.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/YangParameters.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeWalker.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeListener.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeWalker.java diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 46e000094..8995f1dd3 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -75,6 +75,24 @@ yang-data-impl 2.0.3 - + + com.fasterxml.jackson.core + jackson-databind + + + dom4j + dom4j + 1.6.1 + + + com.google.code.gson + gson + 2.7 + + + org.onap.ccsdk.sli.plugins + restapi-call-node-provider + 0.3.0-SNAPSHOT + diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/Annotation.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/Annotation.java index 7271c3d71..185f70ba0 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/Annotation.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/Annotation.java @@ -25,7 +25,14 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; */ public class Annotation { + /** + * Name of the annotation. + */ private String name; + + /** + * Value of the annotation. + */ private String value; /** diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormat.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormat.java index 6fb11e70f..c692f1dd2 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormat.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormat.java @@ -24,6 +24,14 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; * Representation of data format. */ public enum DataFormat { + + /** + * XML data format. + */ XML, + + /** + * JSON data format. + */ JSON } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializer.java index e703b1732..57280e2e9 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializer.java @@ -29,19 +29,26 @@ import java.util.Map; */ public abstract class DataFormatSerializer { + /** + * Data format type of the serializer. + */ private DataFormat dataFormat; + + /** + * Data format serializer context. + */ private DataFormatSerializerContext serializerContext; /** * Creates an instance of data format serializer. * - * @param dataFormat type of data format - * @param serializerContext data format serializer context + * @param d type of data format + * @param s data format serializer context */ - protected DataFormatSerializer(DataFormat dataFormat, - DataFormatSerializerContext serializerContext) { - this.dataFormat = dataFormat; - this.serializerContext = serializerContext; + protected DataFormatSerializer(DataFormat d, + DataFormatSerializerContext s) { + this.dataFormat = d; + this.serializerContext = s; } /** diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerContext.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerContext.java index e2ead53fb..919e82af3 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerContext.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerContext.java @@ -20,6 +20,8 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNodeSerializer; + import java.util.Map; /** @@ -27,26 +29,45 @@ import java.util.Map; */ public class DataFormatSerializerContext { + /** + * Data format listener. + */ private Listener listener; + + /** + * URI corresponding to the instance identifier. + */ private String uri; + + /** + * Protocol annotation. + */ private Map protocolAnnotation; + /** + * Properties node serializer. + */ + private PropertiesNodeSerializer propNodeSerializer; + /** * Creates an instance of data format serializer context. * - * @param listener data format listener - * @param uri URI corresponding to instance identifier - * @param protocolAnnotation protocol annotations + * @param l data format listener + * @param u URI corresponding to instance identifier + * @param p protocol annotations + * @param s properties node serializer */ - public DataFormatSerializerContext(Listener listener, String uri, - Map protocolAnnotation) { - this.listener = listener; - this.uri = uri; - this.protocolAnnotation = protocolAnnotation; + public DataFormatSerializerContext(Listener l, String u, + Map p, + PropertiesNodeSerializer s) { + listener = l; + uri = u; + protocolAnnotation = p; + propNodeSerializer = s; } /** - * Retruns data format listener. + * Returns the data format listener. * * @return data format listener */ @@ -55,7 +76,7 @@ public class DataFormatSerializerContext { } /** - * Returns URI. + * Returns the URI. * * @return URI */ @@ -64,11 +85,20 @@ public class DataFormatSerializerContext { } /** - * Returns protocol annotations. + * Returns the protocol annotations. * * @return protocol annotations */ public Map getProtocolAnnotation() { return protocolAnnotation; } + + /** + * Returns the properties node serializer. + * + * @return properties node serializer + */ + public PropertiesNodeSerializer getPropNodeSerializer() { + return propNodeSerializer; + } } \ No newline at end of file diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonListener.java new file mode 100644 index 000000000..5e71eea3b --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonListener.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import com.fasterxml.jackson.databind.JsonNode; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType; + + +/** + * Representation of default implementation of JSON listener. + */ +public class DefaultJsonListener implements JsonListener { + + /** + * Serializer helper to convert to properties node. + */ + private SerializerHelper serializerHelper; + + /** + * Name of the current JSON node. + */ + private String name; + + /** + * Module name of the current JSON node. + */ + private String modName; + + /** + * Creates an instance of default json listener with its serializer helper. + * + * @param serializerHelper serializer helper + */ + public DefaultJsonListener(SerializerHelper serializerHelper) { + this.serializerHelper = serializerHelper; + } + + @Override + public void enterJsonNode(String nodeName, JsonNode node, NodeType nodeType) { + //TODO: Implementation code. + } + + @Override + public void exitJsonNode(JsonNode node) { + //TODO: Implementation code. + } + + @Override + public SerializerHelper serializerHelper() { + return serializerHelper; + } + +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonWalker.java new file mode 100644 index 000000000..20d4fa772 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonWalker.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Implementation of JSON walker to walk through the nodes and process it. + */ +public class DefaultJsonWalker implements JsonWalker { + + @Override + public void walk(JsonListener listener, JsonNode jsonNode) { + //TODO: Implementation code. + } + + /** + * Processes single instance node or leaf, by adding the node to from + * JSON and walking through all its children recursively. + * + * @param key JSON name + * @param value JSON node + * @param listener JSON listener + */ + private void processSingleNode(String key, JsonNode value, + JsonListener listener) { + //TODO: Implementation code. + } + + /** + * Processes multi instance node or leaf, by adding the node to from JSON + * and walking through all its instance recursively. + * + * @param key JSON name + * @param value JSON node + * @param listener JSON listener + */ + private void processMultiNodes(String key, JsonNode value, + JsonListener listener) { + //TODO: Implementation code. + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlListener.java new file mode 100644 index 000000000..7946d8d0d --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlListener.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import org.dom4j.Element; + +/** + * Representation of default implementation of XML listener. + */ +public class DefaultXmlListener implements XmlListener { + + /** + * Serializer helper to convert to properties node. + */ + private SerializerHelper serializerHelper; + + /** + * Creates an instance of default XML listener with its serializer helper. + * + * @param serializerHelper serializer helper + */ + public DefaultXmlListener(SerializerHelper serializerHelper) { + this.serializerHelper = serializerHelper; + } + + @Override + public void enterXmlElement(Element element, XmlNodeType nodeType) { + //TODO: Implementation code. + } + + @Override + public void exitXmlElement(Element element) { + //TODO: Implementation code. + } + + @Override + public SerializerHelper serializerHelper() { + return serializerHelper; + } + } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlWalker.java new file mode 100644 index 000000000..cd2a3d494 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlWalker.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import org.dom4j.Element; + +/** + * Implementation of XML walker to walk through the nodes and process it. + */ +public class DefaultXmlWalker implements XmlWalker { + + @Override + public void walk(XmlListener listener, Element xmlElement) { + //TODO: Implementation code. + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfListenerFactory.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfListenerFactory.java new file mode 100644 index 000000000..851f1b488 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfListenerFactory.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +/** + * Represents the data format listener factory which will return JSON or XML + * listener according to the serializer helper. + */ +public final class DfListenerFactory { + + /** + * Returns the instance of the data format listener factory. + * + * @return instance of the data format listener factory + */ + public static DfListenerFactory instance() { + return DfListenerFactory.LazyHolder.INSTANCE; + } + + /** + * Bill pugh singleton pattern. Instance will not be instantiated until + * the lazy holder class is loaded via a call to the instance of method + * below. + */ + private static class LazyHolder { + private static final DfListenerFactory INSTANCE = + new DfListenerFactory(); + } + + /** + * Returns the data format listener by deciding it based on the format of + * the parameter. + * + * @param serHelper serializer helper + * @param params parameters + * @return data format listener + */ + public Listener getListener(SerializerHelper serHelper, + YangParameters params) { + Listener listener; + switch (params.format) { + case JSON: + listener = new DefaultJsonListener(serHelper); + break; + + case XML: + listener = new DefaultXmlListener(serHelper); + break; + + //TODO: DataFormat Exception code to be added. + default: + throw new IllegalArgumentException("In correct format"); + } + return listener; + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerFactory.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerFactory.java new file mode 100644 index 000000000..25b23fe26 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerFactory.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +/** + * Represents the data format serializer factory which will return JSON or XML + * serializer according to the serializer context. + */ +public final class DfSerializerFactory { + + /** + * Returns the instance of the data format serializer factory. + * + * @return instance of the data format serializer factory + */ + public static DfSerializerFactory instance() { + return DfSerializerFactory.LazyHolder.INSTANCE; + } + + /** + * Bill pugh singleton pattern. Instance will not be instantiated until + * the lazy holder class is loaded via a call to the instance of method + * below. + */ + private static class LazyHolder { + private static final DfSerializerFactory INSTANCE = + new DfSerializerFactory(); + } + + /** + * Returns the data format serializer by deciding it based on the format of + * the parameter. + * + * @param serCtx serializer context + * @param params parameters + * @return data format serializer + */ + public DataFormatSerializer getSerializer(DataFormatSerializerContext + serCtx, + YangParameters params) { + DataFormatSerializer serializer; + switch (params.format) { + case JSON: + serializer = new JsonSerializer(serCtx); + break; + + case XML: + serializer = new XmlSerializer(serCtx); + break; + + //TODO: DataFormat Exception code to be added. + default: + throw new IllegalArgumentException("In correct format"); + } + return serializer; + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonListener.java new file mode 100644 index 000000000..2a9220ac1 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonListener.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import com.fasterxml.jackson.databind.JsonNode; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType; + +/** + * Abstraction of an entity which provides call back methods, which in turn + * are called by JSON walker while walking the JSON tree. This interface + * needs to be implemented by protocol, implementing listener based call + * while doing JSON walk. + */ +public interface JsonListener extends Listener { + + /** + * Call back invoked during JSON node entry. All other related + * information can be obtained from the JSON node. + * + * @param nodeName JSON node name + * @param node JSON node + * @param nodeType JSON node type + */ + void enterJsonNode(String nodeName, JsonNode node, NodeType nodeType); + + /** + * Call back invoked during JSON node exit. All the related information + * can be obtained from the JSON node. + * + * @param node JSON node + */ + void exitJsonNode(JsonNode node); +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java index 6013664cb..b562e71db 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java @@ -23,8 +23,11 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; import java.util.List; import java.util.Map; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormat.JSON; + /** - * Representation of JSON serializer. + * Representation of JSON serializer which encodes properties to JSON and + * decodes properties from JSON with the data format serializer. */ public class JsonSerializer extends DataFormatSerializer { @@ -34,16 +37,19 @@ public class JsonSerializer extends DataFormatSerializer { * @param serializerContext data format serializer context */ protected JsonSerializer(DataFormatSerializerContext serializerContext) { - super(DataFormat.JSON, serializerContext); + super(JSON, serializerContext); } @Override - public String encode(Map param, Map> annotations) { + public String encode(Map param, + Map> annotations) { + //TODO: Implementation code. return null; } @Override public Map decode(String dataFormatBody) { + //TODO: Implementation code. return null; } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonWalker.java new file mode 100644 index 000000000..e3fb4d513 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonWalker.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Abstraction of an entity which provides interface for JSON walk. This + * interface serves as a common tool for anyone who needs to parse the JSON + * node with depth-first algorithm. + */ +public interface JsonWalker { + + /** + * Walks the JSON data tree. Protocols implement JSON listener service + * and walks the JSON tree with input as implemented object. JSON walker + * provides call back to the implemented methods. + * + * @param listener JSON listener implemented by the protocol + * @param jsonNode root node of the JSON data tree + */ + void walk(JsonListener listener, JsonNode jsonNode); +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java index 311fc2d6b..1f8195e2d 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java @@ -20,48 +20,70 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; -import java.util.Map; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaNode; /** - * Representation of MDSAL based schema helper. + * Representation of MDSAL based serializer helper, which adds properties + * node to the properties tree based on its types. */ -public class MdsalSerializerHelper extends SerializerHelper { +public class MdsalSerializerHelper extends SerializerHelper { - protected MdsalSerializerHelper(SchemaNode node, String uri) { - super(node, uri); - } + /** + * Current properties node. + */ + private PropertiesNode propNode; - @Override - public SchemaNode getRootContext() { - return null; + /** + * Current schema node. + */ + private SchemaNode curSchemaNode; + + + /** + * Creates MDSAL serializer helper with root schema node, schema context + * and URI. + * + * @param n schema node of the URI's last node + * @param c schema context + * @param u URI of the request + */ + protected MdsalSerializerHelper(SchemaNode n, SchemaContext c, + String u) { + super(n, c, u); } @Override - public SchemaNode getCurContext() { - return null; + protected SchemaNode getSchemaNode() { + return schemaNode; } @Override - public SchemaNode getChildContext(SchemaNode schemaNode, String name, String namespace) { - return null; + protected SchemaContext getSchemaCtx() { + return schemaCtx; } @Override - public NodeType getNodeType(SchemaNode schemaNode) { - return null; + protected SchemaNode getCurSchema() { + return curSchemaNode; } @Override - public void addNode(String name, String namespace, String value, String valNamespace, NodeType type) { + protected void addNode(String name, String nameSpace, String value, + String valNameSpace, NodeType type) { + //TODO: Implementation code. } @Override - public void exitNode() { + protected void exitNode() { + //TODO: Implementation code. } @Override - public Map getProperties() { + protected PropertiesNode getPropertiesNode() { + //TODO: Implementation code. return null; } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/NodeType.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/NodeType.java deleted file mode 100644 index ffa35e2b6..000000000 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/NodeType.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; - -/** - * Representation of type of data node. - */ -public enum NodeType { - SINGLE_INSTANCE, - MULTI_INSTANCE, - SINGLE_INSTANCE_LEAF, - MULTI_INSTANCE_LEAF -} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeJsonListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeJsonListener.java new file mode 100644 index 000000000..ec1306731 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeJsonListener.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import com.google.gson.stream.JsonWriter; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNodeListener; + +import java.io.Writer; + +/** + * Representation of JSON implementation of properties node listener. + */ +public class PropertiesNodeJsonListener implements PropertiesNodeListener{ + + /** + * JSON writer to write the JSON data format. + */ + private JsonWriter jsonWriter; + + /** + * Writer to write the JSON. + */ + private Writer writer; + + /** + * Creates the properties node JSON listener by instantiating and + * indenting the writer. + */ + public PropertiesNodeJsonListener() { + } + + @Override + public void start(PropertiesNode node) { + //TODO: Implementation code. + } + + @Override + public void end(PropertiesNode node) { + //TODO: Implementation code. + } + + @Override + public void enterPropertiesNode(PropertiesNode node) { + //TODO: Implementation code. + } + + @Override + public void exitPropertiesNode(PropertiesNode node) { + //TODO: Implementation code. + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeXmlListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeXmlListener.java new file mode 100644 index 000000000..cfc59ca10 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeXmlListener.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import org.dom4j.Element; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNodeListener; + +import java.io.Writer; +import java.util.Stack; + +/** + * Representation of XML implementation of properties node listener. + */ +public class PropertiesNodeXmlListener implements PropertiesNodeListener { + + /** + * XML data from the element. + */ + private String xmlData; + + /** + * Root element of the XML document. + */ + private Element rootElement; + + /** + * Writer to write the XML. + */ + private Writer writer; + + /** + * XML element stack to store the elements. + */ + private final Stack elementStack = new Stack<>(); + + /** + * Creates the properties node XML listener. + */ + public PropertiesNodeXmlListener() { + } + + @Override + public void start(PropertiesNode node) { + //TODO: Implementation code. + } + + @Override + public void end(PropertiesNode node) { + //TODO: Implementation code. + } + + @Override + public void enterPropertiesNode(PropertiesNode node) { + //TODO: Implementation code. + } + + @Override + public void exitPropertiesNode(PropertiesNode node) { + //TODO: Implementation code. + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/SerializerHelper.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/SerializerHelper.java index 4e6d2944d..2466023fa 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/SerializerHelper.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/SerializerHelper.java @@ -20,74 +20,92 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; -import java.util.Map; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; /** * Abstraction of an entity which helps the data format serializers to obtain * schema context details and to build properties from data. * * @param type of schema node + * @param

type of schema context */ -public abstract class SerializerHelper { +public abstract class SerializerHelper { - private T rootSchema; - private String rootURI; + /** + * Schema node of the last element in the URI. + */ + protected T schemaNode; - protected SerializerHelper(T t, String uri) { - rootSchema = t; - } + /** + * Root schema context. + */ + protected P schemaCtx; + + /** + * Root URI. + */ + protected String rootUri; /** - * Returns root schema context node. + * Creates an instance of the serializer helper with the schema node, + * schema context and the URI. * - * @return root schema context node + * @param t schema node + * @param p schema context + * @param u root URI */ - protected abstract T getRootContext(); + protected SerializerHelper(T t, P p, String u) { + schemaNode = t; + schemaCtx = p; + rootUri = u; + } /** - * Returns current schema context node. + * Returns schema node of the last element in the URI. * - * @return current schema context node + * @return schema node */ - protected abstract T getCurContext(); + protected abstract T getSchemaNode(); /** - * Returns child schema context node. + * Returns the root schema context. * - * @return child schema context node + * @return schema context */ - protected abstract T getChildContext(T t, String name, String namespace); + protected abstract P getSchemaCtx(); /** - * Returns type of node - * @param t node - * @return node type + * Returns the current schema context node. + * + * @return current schema context node */ - protected abstract NodeType getNodeType(T t); + protected abstract T getCurSchema(); /** - * Adds a node to current tree. + * Adds a node to the properties node tree. * - * @param name name of node - * @param namespace namespace of node, it can be either module name or - * namespace, null indicates parent namespace - * @param value value of node, in case it's leaf/leaf-list node - * @param valNamespace value namespace for identityref, could be module - * name or namespace - * @param type type of node if known like in case of JSON + * @param name name of the node + * @param nameSpace name space of the node, it can be either module + * name or namespace; null indicates parent namespace + * @param value value of the node; applicable for leaf/leaf-list node + * @param valNameSpace value namespace for identityref, could be module + * name or namespace + * @param type type of node if known like in case of JSON */ - protected abstract void addNode(String name, String namespace, String value, - String valNamespace, NodeType type); + protected abstract void addNode(String name, String nameSpace, String value, + String valNameSpace, NodeType type); /** - * Exits the node, in case if it's leaf node add to properties map. + * Exits the node, in case if it's leaf node then it adds to the properties + * map. */ protected abstract void exitNode(); /** - * Returns the properties built corresponding to data. + * Returns the built properties corresponding to the data. * - * @return properties map + * @return properties node. */ - protected abstract Map getProperties(); + protected abstract PropertiesNode getPropertiesNode(); } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlListener.java new file mode 100644 index 000000000..0fbf4c338 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlListener.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import org.dom4j.Element; + +/** + * Abstraction of an entity which provides call back methods, which in turn + * are called by XML walker while walking the XML tree. This interface needs + * to be implemented by protocol implementing listener based call while doing + * XML walk. + */ +public interface XmlListener extends Listener { + + /** + * Callback invoked during a node entry. All the related information + * about the node can be obtained from the element. + * + * @param element current XML element + * @param nodeType node type of the element + */ + void enterXmlElement(Element element, XmlNodeType nodeType); + + /** + * Callback invoked during a node exit. All the related information about + * the node can be obtained from the element. + * + * @param element current xml element. + */ + void exitXmlElement(Element element); +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlNodeType.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlNodeType.java new file mode 100644 index 000000000..7a6db3c86 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlNodeType.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +/** + * Represents the XML node type. + */ +public enum XmlNodeType { + + /** + * Object XML node type. + */ + OBJECT_NODE, + + /** + * Text XML node type. + */ + TEXT_NODE +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java index 0cfb4d17f..516470059 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java @@ -23,8 +23,11 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; import java.util.List; import java.util.Map; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormat.XML; + /** - * Representation of XML serializer. + * Representation of XML serializer which encodes properties to XML and + * decodes properties from XML with the data format serializer. */ public class XmlSerializer extends DataFormatSerializer { @@ -34,16 +37,19 @@ public class XmlSerializer extends DataFormatSerializer { * @param serializerContext data format serializer context */ protected XmlSerializer(DataFormatSerializerContext serializerContext) { - super(DataFormat.XML, serializerContext); + super(XML, serializerContext); } @Override - public String encode(Map param, Map> annotations) { + public String encode(Map param, + Map> annotations) { + //TODO: Implementation code. return null; } @Override public Map decode(String dataFormatBody) { + //TODO: Implementation code. return null; } } \ No newline at end of file diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlWalker.java new file mode 100644 index 000000000..6fed510a3 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlWalker.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import org.dom4j.Element; + +/** + * Abstraction of an entity which provides interface for XML walk. This + * interface serves as a common tool for anyone who needs to parse the XML + * node with depth-first algorithm. + */ +public interface XmlWalker { + + /** + * Walks the XML data tree. Protocols implement XML listener service and + * walks the XML tree with input as implemented object. XML walker + * provides call back to the implemented methods. + * + * @param listener XML listener implemented by the protocol + * @param xmlElement root element of the XML data tree + */ + void walk(XmlListener listener, Element xmlElement); +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/YangParameters.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/YangParameters.java new file mode 100644 index 000000000..c94a22975 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/YangParameters.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import org.onap.ccsdk.sli.plugins.restapicall.Parameters; + +/** + * Representation of the YANG parameters for the restconf api call node. + */ +public class YangParameters extends Parameters { + + /** + * Creates an instance of the YANG parameters. + */ + public YangParameters() { + super(); + } + + /** + * Directory path of the YANG file. + */ + public String dirPath; +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeWalker.java new file mode 100644 index 000000000..041210f22 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeWalker.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +import java.util.Map; + +/** + * Implementation of properties node walker which helps in forming a new tree from properties node. + * + * @param node child of properties node. + */ +public class DefaultPropertiesNodeWalker implements PropertiesNodeWalker { + + @Override + public void walk(PropertiesNodeListener listener, + PropertiesNode propertiesNode) { + listener.start(propertiesNode); + walkChildNode(listener, propertiesNode); + listener.end(propertiesNode); + } + + /** + * Walks the children node from the parent node. + * + * @param listener properties node listener + * @param propertiesNode properties node + */ + public void walkChildNode(PropertiesNodeListener listener, + PropertiesNode propertiesNode) { + Map children = getChildren(propertiesNode); + if (children != null) { + for (Map.Entry entry : children.entrySet()) { + PropertiesNode node = ((PropertiesNode) entry.getValue()); + listener.enterPropertiesNode(node); + walkChildNode(listener, node); + listener.exitPropertiesNode(node); + } + } + } + + /** + * Returns the children node according to the property node type. + * + * @param value property node + * @return property node children + */ + private Map getChildren(PropertiesNode value) { + if (value instanceof RootNode) { + return ((RootNode) value).children(); + } + switch (value.nodeType()) { + case SINGLE_INSTANCE_NODE: + return ((InnerNode) value).children(); + case MULTI_INSTANCE_HOLDER_NODE: + return ((Map) ((ListHolderNode) value).children()); + case MULTI_INSTANCE_NODE: + return ((Map) ((MultiInstanceNode) value) + .children()); + case MULTI_INSTANCE_LEAF_HOLDER_NODE: + return ((Map) ((LeafListHolderNode) value) + .children()); + case SINGLE_INSTANCE_LEAF_NODE: + case MULTI_INSTANCE_LEAF_NODE: + return null; + default: + throw new IllegalArgumentException("No more types allowed"); + } + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeListener.java new file mode 100644 index 000000000..5bf7fe9dc --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeListener.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +/** + * Abstraction of properties node listener. + */ +public interface PropertiesNodeListener { + + /** + * Pre-configurations required before starting the walking. + * + * @param node properties node + */ + void start(PropertiesNode node); + + /** + * Post-configurations required after starting the walking. + * + * @param node properties node + */ + void end(PropertiesNode node); + + /** + * Enters the properties node. + * + * @param node properties node + */ + void enterPropertiesNode(PropertiesNode node); + + /** + * Enters the properties node. + * + * @param node properties node + */ + void exitPropertiesNode(PropertiesNode node); +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeWalker.java new file mode 100644 index 000000000..48433e2b2 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeWalker.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +/** + * Abstraction of properties node walker + */ +public interface PropertiesNodeWalker { + + /** + * Walks the properties node with the listener. + * + * @param listener properties node listener. + * @param propertiesNode properties node + */ + void walk(PropertiesNodeListener listener, PropertiesNode propertiesNode); +} -- cgit From 224d394cda8a832f8d8c9db03795343ac82f7058 Mon Sep 17 00:00:00 2001 From: Vidyashree Rama Date: Fri, 17 Aug 2018 17:15:20 +0530 Subject: Unit test and decode implementation properties node serializer decode implementation and unit test cases Issue-ID: CCSDK-378 Change-Id: I586fd534f441eb361e8d75af18cc778f7ad4cc67 Signed-off-by: Vidyashree Rama --- restconf-client/provider/pom.xml | 18 + .../DefaultPropertiesNodeListener.java | 95 ++ .../yangserializers/pnserializer/InnerNode.java | 7 +- .../pnserializer/LeafListHolderNode.java | 1 + .../MdsalPropertiesNodeSerializer.java | 7 +- .../yangserializers/pnserializer/RootNode.java | 4 +- .../pnserializer/PropertiesSerializerTest.java | 1090 ++++++++++++++++++++ .../src/test/resources/yang/test-augment.yang | 85 ++ .../src/test/resources/yang/test-yang.yang | 231 +++++ 9 files changed, 1532 insertions(+), 6 deletions(-) create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java create mode 100644 restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java create mode 100644 restconf-client/provider/src/test/resources/yang/test-augment.yang create mode 100644 restconf-client/provider/src/test/resources/yang/test-yang.yang diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 8995f1dd3..2b5be877a 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -94,5 +94,23 @@ restapi-call-node-provider 0.3.0-SNAPSHOT + + org.hamcrest + hamcrest-library + 1.3 + test + + + org.opendaylight.yangtools + yang-test-util + 2.0.3 + test + + + org.opendaylight.netconf + restconf-nb-rfc8040 + 1.7.4-SNAPSHOT + test + diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java new file mode 100644 index 000000000..a8a9b4935 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java @@ -0,0 +1,95 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_LEAF_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.SINGLE_INSTANCE_LEAF_NODE; + +/** + * Represents implementation of PropertiesNodeListener. + */ +public class DefaultPropertiesNodeListener implements PropertiesNodeListener { + + private Map params = new HashMap<>(); + + @Override + public void start(PropertiesNode node) { + // do nothing + } + + @Override + public void end(PropertiesNode node) { + exitPropertiesNode(node); + } + + @Override + public void enterPropertiesNode(PropertiesNode node) { + /* + * Only if it is leaf node or leaf-list node, + * then create a property entry and add to map + */ + if (node.nodeType() == SINGLE_INSTANCE_LEAF_NODE + || node.nodeType() == MULTI_INSTANCE_LEAF_NODE) { + params.put(node.uri(), ((LeafNode) node).value()); + } + } + + @Override + public void exitPropertiesNode(PropertiesNode node) { + if (!node.augmentations().isEmpty()) { + for (Map.Entry> augmentationTochild + : node.augmentations().asMap().entrySet()) { + Collection childsFromAugmentations = augmentationTochild + .getValue(); + if (!childsFromAugmentations.isEmpty()) { + PropertiesNodeWalker walker = new DefaultPropertiesNodeWalker<>(); + for (PropertiesNode pNode : childsFromAugmentations) { + enterPropertiesNode(pNode); + walker.walk(this, pNode); + exitPropertiesNode(pNode); + } + } + } + } + } + + /** + * Returns properties. + * + * @return properties + */ + public Map params() { + return params; + } + + /** + * Sets properties. + * + * @param params properties + */ + public void params(Map params) { + this.params = params; + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java index 063c3d050..0711a7cff 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java @@ -104,7 +104,7 @@ public abstract class InnerNode extends PropertiesNode { @Override public PropertiesNode addChild(String name, Namespace namespace, NodeType type, String value, - Namespace valuens, + Namespace valueNs, Object appInfo) throws SvcLogicException { LeafNode node = ((LeafNode) children.get(name)); if (node != null) { @@ -120,6 +120,7 @@ public abstract class InnerNode extends PropertiesNode { String uri = getUri(this, name, namespace); node = new LeafNode(name, namespace, uri, this, appInfo, type, value); + node.valueNs(valueNs); if (augSchema != null && !isNamespaceAsParent(this, node)) { addToAugmentations(augSchema, this, node); @@ -196,12 +197,12 @@ public abstract class InnerNode extends PropertiesNode { children.put(localName, ((T) node)); } - node = node.addChild(index, localName, namespace, type, value, null, appInfo); + node = node.addChild(index, localName, namespace, type, value, valueNs, appInfo); } else if (node instanceof LeafListHolderNode) { LeafNode child = ((LeafNode) ((HolderNode) node).child(index)); node = (child != null ? child : node.addChild(index, localName, namespace, type, - value, null, + value, valueNs, appInfo)); } else { throw new SvcLogicException("Duplicate node exist with same node"); diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java index 94892dcac..985bc1da1 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java @@ -82,6 +82,7 @@ public class LeafListHolderNode extends HolderNode implemen String uri = this.uri() + "[" + index + "]"; node = (node != null) ? node : new LeafNode(name, namespace, uri, this, appInfo, type, value); + node.valueNs(valueNs); children().put(index, node); return node; } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java index 405e24127..146e581fa 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java @@ -86,7 +86,10 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer decode(PropertiesNode propertiesNode) { - return null; + PropertiesNodeWalker walker = new DefaultPropertiesNodeWalker<>(); + DefaultPropertiesNodeListener listener = new DefaultPropertiesNodeListener(); + walker.walk(listener, propertiesNode); + return listener.params(); } private RootNode createRootNode(String lastNodeName, String rootUri) { @@ -128,6 +131,8 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer extends PropertiesNode { } else { children.put(localName, ((T) node)); } - node = node.addChild(index, localName, namespace, type, value, null, appInfo); + node = node.addChild(index, localName, namespace, type, value, valueNs, appInfo); } else if (node instanceof LeafListHolderNode) { LeafNode child = ((LeafNode) ((HolderNode) node).child(index)); node = (child != null ? child : node.addChild(index, localName, namespace, type, - value, null, + value, valueNs, appInfo)); } else { throw new SvcLogicException("Duplicate node exist with same node"); diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java new file mode 100644 index 000000000..fddfe2d40 --- /dev/null +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java @@ -0,0 +1,1090 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +import org.junit.Before; +import org.junit.Test; + +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.opendaylight.restconf.common.context.InstanceIdentifierContext; +import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertTrue; + +public final class PropertiesSerializerTest { + private SchemaContext context; + + @Before + public void initialization() throws FileNotFoundException { + context = compileYangFile(); + } + + @Test + public void testBasicConstructs() throws SvcLogicException { + String uri = "test-yang:cont1/cont2"; + Map params = new HashMap<>(); + params.put("test-yang:cont1.cont2.cont3.leaf10", "abc"); + params.put("test-yang:cont1.cont2.list1[0].leaf1", "abc"); + params.put("test-yang:cont1.cont2.list1[0].leaf2", "abc"); + params.put("test-yang:cont1.cont2.list1[0].leaf3", "abc"); + params.put("test-yang:cont1.cont2.list1[0].ll1[0]", "abc"); + params.put("test-yang:cont1.cont2.list1[0].ll1[1]", "abc"); + params.put("test-yang:cont1.cont2.list1[0].ll2[0]", "abc"); + params.put("test-yang:cont1.cont2.list1[0].ll2[1]", "abc"); + params.put("test-yang:cont1.cont2.list1[0].cont4.leaf11", "abc"); + params.put("test-yang:cont1.cont2.list1[0].list4[0].leaf8", "abc"); + params.put("test-yang:cont1.cont2.list1[0].list4[1].leaf8", "abc"); + params.put("test-yang:cont1.cont2.list1[0].list5[0].leaf9", "abc"); + params.put("test-yang:cont1.cont2.list1[0].list5[1].leaf9", "abc"); + params.put("test-yang:cont1.cont2.list1[1].leaf1", "abc"); + params.put("test-yang:cont1.cont2.list1[1].leaf2", "abc"); + params.put("test-yang:cont1.cont2.list1[1].leaf3", "abc"); + params.put("test-yang:cont1.cont2.list1[1].ll1[0]", "abc"); + params.put("test-yang:cont1.cont2.list1[1].ll1[1]", "abc"); + params.put("test-yang:cont1.cont2.list1[1].ll2[0]", "abc"); + params.put("test-yang:cont1.cont2.list1[1].ll2[1]", "abc"); + params.put("test-yang:cont1.cont2.list1[1].cont4.leaf11", "abc"); + params.put("test-yang:cont1.cont2.list1[1].list4[0].leaf8", "abc"); + params.put("test-yang:cont1.cont2.list1[1].list4[1].leaf8", "abc"); + params.put("test-yang:cont1.cont2.list1[1].list5[0].leaf9", "abc"); + params.put("test-yang:cont1.cont2.list1[1].list5[1].leaf9", "abc"); + params.put("test-yang:cont1.cont2.list2[0].leaf4", "abc"); + params.put("test-yang:cont1.cont2.list2[1].leaf4", "abc"); + params.put("test-yang:cont1.cont2.leaf5", "abc"); + params.put("test-yang:cont1.cont2.leaf6", "abc"); + params.put("test-yang:cont1.cont2.ll3[0]", "abc"); + params.put("test-yang:cont1.cont2.ll3[1]", "abc"); + params.put("test-yang:cont1.cont2.ll4[0]", "abc"); + params.put("test-yang:cont1.cont2.ll4[1]", "abc"); + InstanceIdentifierContext iCtx = ParserIdentifier + .toInstanceIdentifier(uri, context, null); + + PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer( + iCtx.getSchemaNode(), context, uri); + PropertiesNode node = ser.encode(params); + + Map childNodes = ((RootNode) node).children(); + + assertThat(childNodes.containsKey("cont3"), is(true)); + SingleInstanceNode cont3 = ((SingleInstanceNode) childNodes.get("cont3")); + assertThat(cont3.uri(), is("test-yang:cont1.cont2.cont3")); + assertThat(cont3.children().containsKey("leaf10"), is(true)); + + assertThat(childNodes.containsKey("list1"), is(true)); + HolderNode list1Holder = ((ListHolderNode) childNodes.get("list1")); + assertThat(list1Holder.uri(), is("test-yang:cont1.cont2.list1")); + MultiInstanceNode list10 = ((MultiInstanceNode) list1Holder.child("0")); + assertThat(list10.uri(), is("test-yang:cont1.cont2.list1[0]")); + Map list10Child = list10.children(); + assertThat(list10Child.containsKey("leaf1"), is(true)); + LeafNode l = ((LeafNode) list10Child.get("leaf1")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].leaf1")); + assertThat(list10Child.containsKey("leaf2"), is(true)); + l = ((LeafNode) list10Child.get("leaf2")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].leaf2")); + assertThat(list10Child.containsKey("leaf2"), is(true)); + l = ((LeafNode) list10Child.get("leaf3")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].leaf3")); + + LeafListHolderNode ll1Holder = ((LeafListHolderNode) list10Child.get("ll1")); + assertThat(ll1Holder.uri(), is("test-yang:cont1.cont2.list1[0].ll1")); + assertThat(ll1Holder.children().containsKey("0"), is(true)); + l = ((LeafNode) ll1Holder.child("0")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].ll1[0]")); + assertThat(ll1Holder.children().containsKey("1"), is(true)); + l = ((LeafNode) ll1Holder.child("1")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].ll1[1]")); + + LeafListHolderNode ll2Holder = ((LeafListHolderNode) list10Child.get("ll2")); + assertThat(ll2Holder.uri(), is("test-yang:cont1.cont2.list1[0].ll2")); + assertThat(ll2Holder.children().containsKey("0"), is(true)); + l = ((LeafNode) ll2Holder.child("0")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].ll2[0]")); + assertThat(ll2Holder.children().containsKey("1"), is(true)); + l = ((LeafNode) ll2Holder.child("1")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].ll2[1]")); + + SingleInstanceNode cont4 = ((SingleInstanceNode) list10Child.get("cont4")); + assertThat(cont4.uri(), is("test-yang:cont1.cont2.list1[0].cont4")); + assertThat(cont4.children().containsKey("leaf11"), is(true)); + l = ((LeafNode) cont4.children().get("leaf11")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].cont4.leaf11")); + + HolderNode list4Holder = ((HolderNode) list10Child.get("list4")); + assertThat(list4Holder.uri(), is("test-yang:cont1.cont2.list1[0].list4")); + Map c = list4Holder.children(); + MultiInstanceNode list40 = ((MultiInstanceNode) c.get("0")); + assertThat(list40.uri(), is("test-yang:cont1.cont2.list1[0].list4[0]")); + assertThat(list40.children().containsKey("leaf8"), is(true)); + l = ((LeafNode) list40.children().get("leaf8")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].list4[0].leaf8")); + MultiInstanceNode list41 = ((MultiInstanceNode) c.get("1")); + assertThat(list41.uri(), is("test-yang:cont1.cont2.list1[0].list4[1]")); + assertThat(list41.children().containsKey("leaf8"), is(true)); + l = ((LeafNode) list41.children().get("leaf8")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].list4[1].leaf8")); + + HolderNode list5Holder = ((HolderNode) list10Child.get("list5")); + assertThat(list5Holder.uri(), is("test-yang:cont1.cont2.list1[0].list5")); + c = list5Holder.children(); + MultiInstanceNode list50 = ((MultiInstanceNode) c.get("0")); + assertThat(list50.uri(), is("test-yang:cont1.cont2.list1[0].list5[0]")); + assertThat(list50.children().containsKey("leaf9"), is(true)); + l = ((LeafNode) list50.children().get("leaf9")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].list5[0].leaf9")); + MultiInstanceNode list51 = ((MultiInstanceNode) c.get("1")); + assertThat(list51.uri(), is("test-yang:cont1.cont2.list1[0].list5[1]")); + assertThat(list51.children().containsKey("leaf9"), is(true)); + l = ((LeafNode) list51.children().get("leaf9")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].list5[1].leaf9")); + + MultiInstanceNode list11 = ((MultiInstanceNode) list1Holder.child("1")); + assertThat(list11.uri(), is("test-yang:cont1.cont2.list1[1]")); + Map list11Child = list11.children(); + assertThat(list11Child.containsKey("leaf1"), is(true)); + l = ((LeafNode) list11Child.get("leaf1")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].leaf1")); + assertThat(list11Child.containsKey("leaf2"), is(true)); + l = ((LeafNode) list11Child.get("leaf2")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].leaf2")); + assertThat(list11Child.containsKey("leaf3"), is(true)); + l = ((LeafNode) list11Child.get("leaf3")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].leaf3")); + + ll1Holder = ((LeafListHolderNode) list11Child.get("ll1")); + assertThat(ll1Holder.uri(), is("test-yang:cont1.cont2.list1[1].ll1")); + assertThat(ll1Holder.children().containsKey("0"), is(true)); + l = ((LeafNode) ll1Holder.children().get("0")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].ll1[0]")); + assertThat(ll1Holder.children().containsKey("1"), is(true)); + l = ((LeafNode) ll1Holder.children().get("1")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].ll1[1]")); + + ll2Holder = ((LeafListHolderNode) list11Child.get("ll2")); + assertThat(ll2Holder.uri(), is("test-yang:cont1.cont2.list1[1].ll2")); + assertThat(ll2Holder.children().containsKey("0"), is(true)); + l = ((LeafNode) ll2Holder.children().get("0")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].ll2[0]")); + assertThat(ll2Holder.children().containsKey("1"), is(true)); + l = ((LeafNode) ll2Holder.children().get("1")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].ll2[1]")); + + cont4 = ((SingleInstanceNode) list11Child.get("cont4")); + assertThat(cont4.uri(), is("test-yang:cont1.cont2.list1[1].cont4")); + assertThat(cont4.children().containsKey("leaf11"), is(true)); + l = ((LeafNode) cont4.children().get("leaf11")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].cont4.leaf11")); + + list4Holder = ((HolderNode) list11Child.get("list4")); + assertThat(list4Holder.uri(), is("test-yang:cont1.cont2.list1[1].list4")); + c = list4Holder.children(); + list40 = ((MultiInstanceNode) c.get("0")); + assertThat(list40.uri(), is("test-yang:cont1.cont2.list1[1].list4[0]")); + assertThat(list40.children().containsKey("leaf8"), is(true)); + l = ((LeafNode) list40.children().get("leaf8")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].list4[0].leaf8")); + list41 = ((MultiInstanceNode) c.get("1")); + assertThat(list41.uri(), is("test-yang:cont1.cont2.list1[1].list4[1]")); + assertThat(list41.children().containsKey("leaf8"), is(true)); + l = ((LeafNode) list41.children().get("leaf8")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].list4[1].leaf8")); + + list5Holder = ((HolderNode) list11Child.get("list5")); + assertThat(list5Holder.uri(), is("test-yang:cont1.cont2.list1[1].list5")); + c = list5Holder.children(); + list50 = ((MultiInstanceNode) c.get("0")); + assertThat(list50.uri(), is("test-yang:cont1.cont2.list1[1].list5[0]")); + assertThat(list50.children().containsKey("leaf9"), is(true)); + l = ((LeafNode) list50.children().get("leaf9")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].list5[0].leaf9")); + list51 = ((MultiInstanceNode) c.get("1")); + assertThat(list51.uri(), is("test-yang:cont1.cont2.list1[1].list5[1]")); + assertThat(list51.children().containsKey("leaf9"), is(true)); + l = ((LeafNode) list51.children().get("leaf9")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].list5[1].leaf9")); + + assertThat(childNodes.containsKey("list2"), is(true)); + HolderNode list2Holder = ((HolderNode) childNodes.get("list2")); + assertThat(list2Holder.uri(), is("test-yang:cont1.cont2.list2")); + InnerNode list20 = ((InnerNode) list2Holder.children().get("0")); + assertThat(list20.uri(), is("test-yang:cont1.cont2.list2[0]")); + assertThat(list20.children().containsKey("leaf4"), is(true)); + l = ((LeafNode) list20.children().get("leaf4")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list2[0].leaf4")); + InnerNode list21 = ((InnerNode) list2Holder.children().get("1")); + assertThat(list21.uri(), is("test-yang:cont1.cont2.list2[1]")); + assertThat(list21.children().containsKey("leaf4"), is(true)); + l = ((LeafNode) list21.children().get("leaf4")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list2[1].leaf4")); + + assertThat(childNodes.containsKey("leaf5"), is(true)); + l = ((LeafNode) childNodes.get("leaf5")); + assertThat(l.uri(), is("test-yang:cont1.cont2.leaf5")); + assertThat(childNodes.containsKey("leaf6"), is(true)); + l = ((LeafNode) childNodes.get("leaf6")); + assertThat(l.uri(), is("test-yang:cont1.cont2.leaf6")); + + HolderNode ll3Holder = ((HolderNode) childNodes.get("ll3")); + assertThat(ll3Holder.uri(), is("test-yang:cont1.cont2.ll3")); + assertThat(((LeafNode) ll3Holder.children().get("0")).name(), is("ll3")); + l = ((LeafNode) ll3Holder.children().get("0")); + assertThat(l.uri(), is("test-yang:cont1.cont2.ll3[0]")); + assertThat(((LeafNode) ll3Holder.children().get("1")).name(), is("ll3")); + l = ((LeafNode) ll3Holder.children().get("1")); + assertThat(l.uri(), is("test-yang:cont1.cont2.ll3[1]")); + + HolderNode ll4Holder = ((HolderNode) childNodes.get("ll4")); + assertThat(ll4Holder.uri(), is("test-yang:cont1.cont2.ll4")); + assertThat(((LeafNode) ll4Holder.children().get("0")).name(), is("ll4")); + l = ((LeafNode) ll4Holder.children().get("0")); + assertThat(l.uri(), is("test-yang:cont1.cont2.ll4[0]")); + assertThat(((LeafNode) ll4Holder.children().get("1")).name(), is("ll4")); + l = ((LeafNode) ll4Holder.children().get("1")); + assertThat(l.uri(), is("test-yang:cont1.cont2.ll4[1]")); + + Map output = ser.decode(node); + assertThat(output.size(), is(params.size())); + for (Map.Entry entry : output.entrySet()) { + assertTrue(params.containsKey(entry.getKey())); + } + } + + @Test + public void testAugment() throws SvcLogicException { + String uri = "test-yang:cont1/cont2"; + Map params = new HashMap<>(); + params.put("test-yang:cont1.cont2.cont4.leaf10", "abc"); + params.put("test-yang:cont1.cont2.cont4.test-augment:cont5.leaf13", "abc"); + params.put("test-yang:cont1.cont2.cont4.test-augment:list7[0].leaf14", "abc"); + params.put("test-yang:cont1.cont2.cont4.test-augment:list7[1].leaf14", "abc"); + params.put("test-yang:cont1.cont2.cont4.test-augment:leaf15", "abc"); + params.put("test-yang:cont1.cont2.cont4.test-augment:ll6[0]", "abc"); + params.put("test-yang:cont1.cont2.cont4.test-augment:ll6[1]", "abc"); + params.put("test-yang:cont1.cont2.list6[0].leaf11", "abc"); + params.put("test-yang:cont1.cont2.list6[1].leaf11", "abc"); + params.put("test-yang:cont1.cont2.leaf12", "abc"); + params.put("test-yang:cont1.cont2.ll5[0]", "abc"); + params.put("test-yang:cont1.cont2.ll5[1]", "abc"); + + InstanceIdentifierContext iCtx = ParserIdentifier + .toInstanceIdentifier(uri, context, null); + PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer( + iCtx.getSchemaNode(), context, uri); + PropertiesNode node = ser.encode(params); + + Map childNodes = ((RootNode) node).children(); + + assertThat(childNodes.containsKey("cont4"), is(true)); + SingleInstanceNode cont4 = ((SingleInstanceNode) childNodes.get("cont4")); + for (Map.Entry> augToChild + : cont4.augmentations().asMap().entrySet()) { + Collection child = augToChild.getValue(); + if (!child.isEmpty()) { + List expectedNodes = new LinkedList<>(); + expectedNodes.add("test-yang:cont1.cont2.cont4.test-augment:cont5"); + expectedNodes.add("test-yang:cont1.cont2.cont4.test-augment:list7"); + expectedNodes.add("test-yang:cont1.cont2.cont4.test-augment:leaf15"); + expectedNodes.add("test-yang:cont1.cont2.cont4.test-augment:ll6"); + assertThat(expectedNodes.size(), is(child.size())); + for (PropertiesNode pNode : child) { + assertThat(expectedNodes.contains(pNode.uri()), is(true)); + if (pNode.uri().equals("test-yang:cont1.cont2.cont4.test-augment:cont5")) { + assertThat(((SingleInstanceNode) pNode).children().containsKey("leaf13"), is(true)); + LeafNode l = ((LeafNode) ((SingleInstanceNode) pNode).children().get("leaf13")); + assertThat(l.uri(), is("test-yang:cont1.cont2.cont4.test-augment:cont5.leaf13")); + } else if (pNode.uri().equals("test-yang:cont1.cont2.cont4.test-augment:list7")) { + ListHolderNode list7Holder = ((ListHolderNode) pNode); + MultiInstanceNode list7 = ((MultiInstanceNode) list7Holder.child("0")); + assertThat(list7.uri(), is("test-yang:cont1.cont2.cont4.test-augment:list7[0]")); + Map list7Child = list7.children(); + assertThat(list7Child.containsKey("leaf14"), is(true)); + LeafNode l = ((LeafNode) list7Child.get("leaf14")); + assertThat(l.uri(), is("test-yang:cont1.cont2.cont4.test-augment:list7[0].leaf14")); + list7 = ((MultiInstanceNode) list7Holder.child("1")); + assertThat(list7.uri(), is("test-yang:cont1.cont2.cont4.test-augment:list7[1]")); + list7Child = list7.children(); + assertThat(list7Child.containsKey("leaf14"), is(true)); + l = ((LeafNode) list7Child.get("leaf14")); + assertThat(l.uri(), is("test-yang:cont1.cont2.cont4.test-augment:list7[1].leaf14")); + } else if (pNode.uri().equals("test-yang:cont1.cont2.cont4.test-augment:leaf15")) { + LeafNode leaf15 = ((LeafNode) pNode); + assertThat(leaf15.name(), is("leaf15")); + assertThat(leaf15.uri(), is("test-yang:cont1.cont2.cont4.test-augment:leaf15")); + } else if (pNode.uri().equals("test-yang:cont1.cont2.cont4.test-augment:ll6")) { + LeafListHolderNode ll6Holder = ((LeafListHolderNode) pNode); + assertThat(ll6Holder.children().containsKey("0"), is(true)); + LeafNode l = ((LeafNode) ll6Holder.children().get("0")); + assertThat(l.uri(), is("test-yang:cont1.cont2.cont4.test-augment:ll6[0]")); + assertThat(ll6Holder.children().containsKey("1"), is(true)); + l = ((LeafNode) ll6Holder.children().get("1")); + assertThat(l.uri(), is("test-yang:cont1.cont2.cont4.test-augment:ll6[1]")); + } + } + } + } + assertThat(cont4.uri(), is("test-yang:cont1.cont2.cont4")); + assertThat(cont4.children().containsKey("leaf10"), is(true)); + LeafNode l = ((LeafNode) cont4.children().get("leaf10")); + assertThat(l.uri(), is("test-yang:cont1.cont2.cont4.leaf10")); + + assertThat(childNodes.containsKey("list6"), is(true)); + HolderNode list6Holder = ((ListHolderNode) childNodes.get("list6")); + assertThat(list6Holder.uri(), is("test-yang:cont1.cont2.list6")); + MultiInstanceNode list6 = ((MultiInstanceNode) list6Holder.child("0")); + assertThat(list6.uri(), is("test-yang:cont1.cont2.list6[0]")); + Map list6Child = list6.children(); + assertThat(list6Child.containsKey("leaf11"), is(true)); + l = ((LeafNode) list6Child.get("leaf11")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list6[0].leaf11")); + list6 = ((MultiInstanceNode) list6Holder.child("1")); + assertThat(list6.uri(), is("test-yang:cont1.cont2.list6[1]")); + list6Child = list6.children(); + assertThat(list6Child.containsKey("leaf11"), is(true)); + l = ((LeafNode) list6Child.get("leaf11")); + assertThat(l.uri(), is("test-yang:cont1.cont2.list6[1].leaf11")); + + assertThat(childNodes.containsKey("leaf12"), is(true)); + LeafNode leaf12 = ((LeafNode) childNodes.get("leaf12")); + assertThat(leaf12.name(), is("leaf12")); + assertThat(leaf12.uri(), is("test-yang:cont1.cont2.leaf12")); + + LeafListHolderNode ll5Holder = ((LeafListHolderNode) childNodes.get("ll5")); + assertThat(ll5Holder.uri(), is("test-yang:cont1.cont2.ll5")); + assertThat(ll5Holder.children().containsKey("0"), is(true)); + l = ((LeafNode) ll5Holder.children().get("0")); + assertThat(l.uri(), is("test-yang:cont1.cont2.ll5[0]")); + assertThat(ll5Holder.children().containsKey("1"), is(true)); + l = ((LeafNode) ll5Holder.children().get("1")); + assertThat(l.uri(), is("test-yang:cont1.cont2.ll5[1]")); + + Map output = ser.decode(node); + for (Map.Entry entry : output.entrySet()) { + assertTrue(params.containsKey(entry.getKey())); + } + } + + @Test + public void testChoiceCase1() throws SvcLogicException { + String uri = "test-yang:cont8"; + Map params = new HashMap<>(); + params.put("test-yang:cont8.cont6.leaf16", "abc"); + params.put("test-yang:cont8.list8[0].leaf18", "abc"); + params.put("test-yang:cont8.list8[1].leaf18", "abc"); + params.put("test-yang:cont8.leaf19", "abc"); + params.put("test-yang:cont8.ll7[0]", "abc"); + params.put("test-yang:cont8.ll7[1]", "abc"); + + InstanceIdentifierContext iCtx = ParserIdentifier + .toInstanceIdentifier(uri, context, null); + PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer( + iCtx.getSchemaNode(), context, uri); + PropertiesNode node = ser.encode(params); + + Map childNodes = ((RootNode) node).children(); + + assertThat(childNodes.containsKey("cont6"), is(true)); + SingleInstanceNode cont6 = ((SingleInstanceNode) childNodes.get("cont6")); + assertThat(cont6.uri(), is("test-yang:cont8.cont6")); + assertThat(cont6.children().containsKey("leaf16"), is(true)); + LeafNode l = ((LeafNode) cont6.children().get("leaf16")); + assertThat(l.uri(), is("test-yang:cont8.cont6.leaf16")); + + assertThat(childNodes.containsKey("list8"), is(true)); + HolderNode list6Holder = ((ListHolderNode) childNodes.get("list8")); + assertThat(list6Holder.uri(), is("test-yang:cont8.list8")); + MultiInstanceNode list6 = ((MultiInstanceNode) list6Holder.child("0")); + assertThat(list6.uri(), is("test-yang:cont8.list8[0]")); + Map list6Child = list6.children(); + assertThat(list6Child.containsKey("leaf18"), is(true)); + l = ((LeafNode) list6Child.get("leaf18")); + assertThat(l.uri(), is("test-yang:cont8.list8[0].leaf18")); + list6 = ((MultiInstanceNode) list6Holder.child("1")); + list6Child = list6.children(); + assertThat(list6Child.containsKey("leaf18"), is(true)); + l = ((LeafNode) list6Child.get("leaf18")); + assertThat(l.uri(), is("test-yang:cont8.list8[1].leaf18")); + + assertThat(childNodes.containsKey("leaf19"), is(true)); + LeafNode leaf12 = ((LeafNode) childNodes.get("leaf19")); + assertThat(leaf12.name(), is("leaf19")); + assertThat(leaf12.uri(), is("test-yang:cont8.leaf19")); + + LeafListHolderNode ll5Holder = ((LeafListHolderNode) childNodes.get("ll7")); + assertThat(ll5Holder.uri(), is("test-yang:cont8.ll7")); + assertThat(ll5Holder.children().containsKey("0"), is(true)); + l = ((LeafNode) ll5Holder.children().get("0")); + assertThat(l.uri(), is("test-yang:cont8.ll7[0]")); + assertThat(ll5Holder.children().containsKey("1"), is(true)); + l = ((LeafNode) ll5Holder.children().get("1")); + assertThat(l.uri(), is("test-yang:cont8.ll7[1]")); + + Map output = ser.decode(node); + assertThat(output.size(), is(params.size())); + for (Map.Entry entry : output.entrySet()) { + assertTrue(params.containsKey(entry.getKey())); + } + } + + @Test + public void testChoiceCase2() throws SvcLogicException { + String uri = "test-yang:cont9"; + Map params = new HashMap<>(); + params.put("test-yang:cont9.leaf20", "abc"); + params.put("test-yang:cont9.ll8[0]", "abc"); + params.put("test-yang:cont9.cont11.leaf25", "abc"); + + InstanceIdentifierContext iCtx = ParserIdentifier + .toInstanceIdentifier(uri, context, null); + PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer( + iCtx.getSchemaNode(), context, uri); + PropertiesNode node = ser.encode(params); + + Map childNodes = ((RootNode) node).children(); + + assertThat(childNodes.containsKey("cont11"), is(true)); + SingleInstanceNode cont4 = ((SingleInstanceNode) childNodes.get("cont11")); + assertThat(cont4.uri(), is("test-yang:cont9.cont11")); + assertThat(cont4.children().containsKey("leaf25"), is(true)); + LeafNode l = ((LeafNode) cont4.children().get("leaf25")); + assertThat(l.uri(), is("test-yang:cont9.cont11.leaf25")); + + assertThat(childNodes.containsKey("leaf20"), is(true)); + l = ((LeafNode) childNodes.get("leaf20")); + assertThat(l.uri(), is("test-yang:cont9.leaf20")); + + LeafListHolderNode ll5Holder = ((LeafListHolderNode) childNodes.get("ll8")); + assertThat(ll5Holder.uri(), is("test-yang:cont9.ll8")); + assertThat(ll5Holder.children().containsKey("0"), is(true)); + l = ((LeafNode) ll5Holder.children().get("0")); + assertThat(l.uri(), is("test-yang:cont9.ll8[0]")); + + Map output = ser.decode(node); + assertThat(output.size(), is(params.size())); + for (Map.Entry entry : output.entrySet()) { + assertTrue(params.containsKey(entry.getKey())); + } + } + + @Test + public void testChoiceCase3() throws SvcLogicException { + String uri = "test-yang:cont8/cont6"; + Map params = new HashMap<>(); + params.put("test-yang:cont8.cont6.test-augment:leaf21", "abc"); + + InstanceIdentifierContext iCtx = ParserIdentifier + .toInstanceIdentifier(uri, context, null); + PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer( + iCtx.getSchemaNode(), context, uri); + PropertiesNode node = ser.encode(params); + + for (Map.Entry> augToChild + : node.augmentations().asMap().entrySet()) { + Collection child = augToChild.getValue(); + if (!child.isEmpty()) { + List expectedNodes = new LinkedList<>(); + expectedNodes.add("test-yang:cont8.cont6.test-augment:leaf21"); + assertThat(expectedNodes.size(), is(child.size())); + for (PropertiesNode pNode : child) { + assertThat(expectedNodes.contains(pNode.uri()), is(true)); + } + } + } + + Map childNodes = ((RootNode) node).children(); + + assertThat(childNodes.containsKey("leaf21"), is(true)); + LeafNode leaf12 = ((LeafNode) childNodes.get("leaf21")); + assertThat(leaf12.name(), is("leaf21")); + assertThat(leaf12.uri(), is("test-yang:cont8.cont6.test-augment:leaf21")); + + Map output = ser.decode(node); + assertThat(output.size(), is(params.size())); + for (Map.Entry entry : output.entrySet()) { + assertTrue(params.containsKey(entry.getKey())); + } + } + + @Test + public void testGrouping() throws SvcLogicException { + String uri = "test-yang:cont13"; + Map params = new HashMap<>(); + params.put("test-yang:cont13.cont12.leaf26", "abc"); + params.put("test-yang:cont13.list9[0].leaf27", "abc"); + params.put("test-yang:cont13.leaf28", "abc"); + params.put("test-yang:cont13.ll9[0]", "abc"); + + InstanceIdentifierContext iCtx = ParserIdentifier + .toInstanceIdentifier(uri, context, null); + PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer( + iCtx.getSchemaNode(), context, uri); + PropertiesNode node = ser.encode(params); + + Map childNodes = ((RootNode) node).children(); + + assertThat(childNodes.containsKey("cont12"), is(true)); + SingleInstanceNode cont4 = ((SingleInstanceNode) childNodes.get("cont12")); + assertThat(cont4.uri(), is("test-yang:cont13.cont12")); + assertThat(cont4.children().containsKey("leaf26"), is(true)); + LeafNode l = ((LeafNode) cont4.children().get("leaf26")); + assertThat(l.uri(), is("test-yang:cont13.cont12.leaf26")); + + assertThat(childNodes.containsKey("list9"), is(true)); + HolderNode list6Holder = ((ListHolderNode) childNodes.get("list9")); + assertThat(list6Holder.uri(), is("test-yang:cont13.list9")); + MultiInstanceNode list6 = ((MultiInstanceNode) list6Holder.child("0")); + assertThat(list6.uri(), is("test-yang:cont13.list9[0]")); + Map list6Child = list6.children(); + assertThat(list6Child.containsKey("leaf27"), is(true)); + l = ((LeafNode) list6Child.get("leaf27")); + assertThat(l.uri(), is("test-yang:cont13.list9[0].leaf27")); + + assertThat(childNodes.containsKey("leaf28"), is(true)); + LeafNode leaf12 = ((LeafNode) childNodes.get("leaf28")); + assertThat(leaf12.name(), is("leaf28")); + assertThat(leaf12.uri(), is("test-yang:cont13.leaf28")); + + LeafListHolderNode ll5Holder = ((LeafListHolderNode) childNodes.get("ll9")); + assertThat(ll5Holder.children().containsKey("0"), is(true)); + + Map output = ser.decode(node); + assertThat(output.size(), is(params.size())); + for (Map.Entry entry : output.entrySet()) { + assertTrue(params.containsKey(entry.getKey())); + } + } + + @Test + public void testGrouping2() throws SvcLogicException { + String uri = "test-yang:cont9/cont11"; + Map params = new HashMap<>(); + params.put("test-yang:cont9.cont11.leaf25", "abc"); + params.put("test-yang:cont9.cont11.cont13.cont12.leaf26", "abc"); + params.put("test-yang:cont9.cont11.cont13.list9[0].leaf27", "abc"); + params.put("test-yang:cont9.cont11.cont13.leaf28", "abc"); + params.put("test-yang:cont9.cont11.cont13.ll9[0]", "abc"); + InstanceIdentifierContext iCtx = ParserIdentifier + .toInstanceIdentifier(uri, context, null); + PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer( + iCtx.getSchemaNode(), context, uri); + PropertiesNode node = ser.encode(params); + + Map childNodes = ((RootNode) node).children(); + + assertThat(childNodes.containsKey("cont13"), is(true)); + SingleInstanceNode cont13 = ((SingleInstanceNode) childNodes.get("cont13")); + assertThat(cont13.uri(), is("test-yang:cont9.cont11.cont13")); + SingleInstanceNode cont12 = ((SingleInstanceNode) cont13.children().get("cont12")); + assertThat(cont12.children().containsKey("leaf26"), is(true)); + assertThat(cont12.uri(), is("test-yang:cont9.cont11.cont13.cont12")); + assertThat(cont12.children().containsKey("leaf26"), is(true)); + LeafNode l = ((LeafNode) cont12.children().get("leaf26")); + assertThat(l.uri(), is("test-yang:cont9.cont11.cont13.cont12.leaf26")); + + assertThat(cont13.children().containsKey("list9"), is(true)); + HolderNode list6Holder = ((ListHolderNode) cont13.children().get("list9")); + assertThat(list6Holder.uri(), is("test-yang:cont9.cont11.cont13.list9")); + MultiInstanceNode list6 = ((MultiInstanceNode) list6Holder.child("0")); + assertThat(list6.uri(), is("test-yang:cont9.cont11.cont13.list9[0]")); + Map list6Child = list6.children(); + assertThat(list6Child.containsKey("leaf27"), is(true)); + l = ((LeafNode) list6Child.get("leaf27")); + assertThat(l.uri(), is("test-yang:cont9.cont11.cont13.list9[0].leaf27")); + + assertThat(cont13.children().containsKey("leaf28"), is(true)); + LeafNode leaf12 = ((LeafNode) cont13.children().get("leaf28")); + assertThat(leaf12.name(), is("leaf28")); + assertThat(leaf12.uri(), is("test-yang:cont9.cont11.cont13.leaf28")); + + LeafListHolderNode ll5Holder = ((LeafListHolderNode) cont13.children().get("ll9")); + assertThat(ll5Holder.uri(), is("test-yang:cont9.cont11.cont13.ll9")); + assertThat(ll5Holder.children().containsKey("0"), is(true)); + l = ((LeafNode) ll5Holder.children().get("0")); + assertThat(l.uri(), is("test-yang:cont9.cont11.cont13.ll9[0]")); + + Map output = ser.decode(node); + assertThat(output.size(), is(params.size())); + for (Map.Entry entry : output.entrySet()) { + assertTrue(params.containsKey(entry.getKey())); + } + } + + @Test + public void testGrouping3() throws SvcLogicException { + String uri = "test-augment:cont13"; + Map params = new HashMap<>(); + params.put("test-augment:cont13.cont12.leaf26", "abc"); + params.put("test-augment:cont13.list9[0].leaf27", "abc"); + params.put("test-augment:cont13.leaf28", "abc"); + params.put("test-augment:cont13.ll9[0]", "abc"); + InstanceIdentifierContext iCtx = ParserIdentifier + .toInstanceIdentifier(uri, context, null); + PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer( + iCtx.getSchemaNode(), context, uri); + PropertiesNode node = ser.encode(params); + + Map childNodes = ((RootNode) node).children(); + + assertThat(childNodes.containsKey("cont12"), is(true)); + SingleInstanceNode cont12 = ((SingleInstanceNode) childNodes.get("cont12")); + assertThat(cont12.uri(), is("test-augment:cont13.cont12")); + assertThat(cont12.children().containsKey("leaf26"), is(true)); + LeafNode l = ((LeafNode) cont12.children().get("leaf26")); + assertThat(l.uri(), is("test-augment:cont13.cont12.leaf26")); + + assertThat(childNodes.containsKey("list9"), is(true)); + HolderNode list6Holder = ((ListHolderNode) childNodes.get("list9")); + assertThat(list6Holder.uri(), is("test-augment:cont13.list9")); + MultiInstanceNode list6 = ((MultiInstanceNode) list6Holder.child("0")); + assertThat(list6.uri(), is("test-augment:cont13.list9[0]")); + Map list6Child = list6.children(); + assertThat(list6Child.containsKey("leaf27"), is(true)); + l = ((LeafNode) list6Child.get("leaf27")); + assertThat(l.uri(), is("test-augment:cont13.list9[0].leaf27")); + + assertThat(childNodes.containsKey("leaf28"), is(true)); + LeafNode leaf12 = ((LeafNode) childNodes.get("leaf28")); + assertThat(leaf12.name(), is("leaf28")); + assertThat(leaf12.uri(), is("test-augment:cont13.leaf28")); + + LeafListHolderNode ll5Holder = ((LeafListHolderNode) childNodes.get("ll9")); + assertThat(ll5Holder.uri(), is("test-augment:cont13.ll9")); + assertThat(ll5Holder.children().containsKey("0"), is(true)); + l = ((LeafNode) ll5Holder.children().get("0")); + assertThat(l.uri(), is("test-augment:cont13.ll9[0]")); + + Map output = ser.decode(node); + assertThat(output.size(), is(params.size())); + for (Map.Entry entry : output.entrySet()) { + assertTrue(params.containsKey(entry.getKey())); + } + } + + @Test + public void testGrouping4() throws SvcLogicException { + String uri = "test-yang:cont1/cont2/cont4"; + Map params = new HashMap<>(); + params.put("test-yang:cont1.cont2.cont4.test-augment:cont13.cont12.leaf26", "abc"); + params.put("test-yang:cont1.cont2.cont4.test-augment:cont13.list9[0].leaf27", "abc"); + params.put("test-yang:cont1.cont2.cont4.test-augment:cont13.leaf28", "abc"); + params.put("test-yang:cont1.cont2.cont4.test-augment:cont13.ll9[0]", "abc"); + + InstanceIdentifierContext iCtx = ParserIdentifier + .toInstanceIdentifier(uri, context, null); + PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer( + iCtx.getSchemaNode(), context, uri); + PropertiesNode node = ser.encode(params); + + for (Map.Entry> augToChild + : node.augmentations().asMap().entrySet()) { + Collection child = augToChild.getValue(); + if (!child.isEmpty()) { + List expectedNodes = new LinkedList<>(); + expectedNodes.add("test-yang:cont1.cont2.cont4.test-augment:cont13"); + assertThat(expectedNodes.size(), is(child.size())); + for (PropertiesNode pNode : child) { + assertThat(expectedNodes.contains(pNode.uri()), is(true)); + SingleInstanceNode cont13 = ((SingleInstanceNode) pNode); + assertThat(cont13.uri(), is("test-yang:cont1.cont2.cont4.test-augment:cont13")); + SingleInstanceNode cont12 = ((SingleInstanceNode) cont13.children().get("cont12")); + assertThat(cont12.children().containsKey("leaf26"), is(true)); + LeafNode l = ((LeafNode) cont12.children().get("leaf26")); + assertThat(l.uri(), is("test-yang:cont1.cont2.cont4.test-augment:cont13.cont12.leaf26")); + + assertThat(cont13.children().containsKey("list9"), is(true)); + HolderNode list6Holder = ((ListHolderNode) cont13.children().get("list9")); + assertThat(list6Holder.uri(), is("test-yang:cont1.cont2.cont4.test-augment:cont13.list9")); + MultiInstanceNode list6 = ((MultiInstanceNode) list6Holder.child("0")); + assertThat(list6.uri(), is("test-yang:cont1.cont2.cont4.test-augment:cont13.list9[0]")); + Map list6Child = list6.children(); + assertThat(list6Child.containsKey("leaf27"), is(true)); + l = ((LeafNode) list6Child.get("leaf27")); + assertThat(l.uri(), is("test-yang:cont1.cont2.cont4.test-augment:cont13.list9[0].leaf27")); + + assertThat(cont13.children().containsKey("leaf28"), is(true)); + LeafNode leaf12 = ((LeafNode) cont13.children().get("leaf28")); + assertThat(leaf12.name(), is("leaf28")); + assertThat(leaf12.uri(), is("test-yang:cont1.cont2.cont4.test-augment:cont13.leaf28")); + + LeafListHolderNode ll5Holder = ((LeafListHolderNode) cont13.children().get("ll9")); + assertThat(ll5Holder.uri(), is("test-yang:cont1.cont2.cont4.test-augment:cont13.ll9")); + assertThat(ll5Holder.children().containsKey("0"), is(true)); + l = ((LeafNode) ll5Holder.children().get("0")); + assertThat(l.uri(), is("test-yang:cont1.cont2.cont4.test-augment:cont13.ll9[0]")); + } + } + } + + Map output = ser.decode(node); + assertThat(output.size(), is(params.size())); + for (Map.Entry entry : output.entrySet()) { + assertTrue(params.containsKey(entry.getKey())); + } + } + + @Test + public void testRpcInput() throws SvcLogicException { + String uri = "test-yang:create-sfc"; + Map params = new HashMap<>(); + params.put("test-yang:create-sfc.input.cont14.leaf28", "abc"); + params.put("test-yang:create-sfc.input.list10[0].leaf29", "abc"); + params.put("test-yang:create-sfc.input.leaf30", "abc"); + params.put("test-yang:create-sfc.input.ll10[0]", "abc"); + params.put("test-yang:create-sfc.input.cont15.leaf31", "abc"); + params.put("test-yang:create-sfc.input.cont13.cont12.leaf26", "abc"); + params.put("test-yang:create-sfc.input.cont13.list9[0].leaf27", "abc"); + params.put("test-yang:create-sfc.input.cont13.leaf28", "abc"); + params.put("test-yang:create-sfc.input.cont13.ll9[0]", "abc"); + params.put("test-yang:create-sfc.input.test-augment:leaf36", "abc"); + + InstanceIdentifierContext iCtx = ParserIdentifier + .toInstanceIdentifier(uri, context, null); + PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer( + iCtx.getSchemaNode(), context, uri); + PropertiesNode node = ser.encode(params); + + Map childNodes = ((RootNode) node).children(); + + PropertiesNode input = childNodes.get("input"); + assertThat(input.uri(), is("test-yang:create-sfc.input")); + for (Map.Entry> augToChild + : node.augmentations().asMap().entrySet()) { + Collection child = augToChild.getValue(); + if (!child.isEmpty()) { + List expectedNodes = new LinkedList<>(); + expectedNodes.add("test-yang:create-sfc.input.test-augment:leaf36"); + assertThat(expectedNodes.size(), is(child.size())); + for (PropertiesNode pNode : child) { + assertThat(expectedNodes.contains(pNode.uri()), is(true)); + LeafNode leaf37 = ((LeafNode) pNode); + assertThat(leaf37.name(), is("leaf36")); + assertThat(leaf37.uri(), is("test-yang:create-sfc.input.test-augment:leaf36")); + } + } + } + childNodes = ((InnerNode) input).children(); + + assertThat(childNodes.containsKey("cont14"), is(true)); + SingleInstanceNode cont14 = ((SingleInstanceNode) childNodes.get("cont14")); + assertThat(cont14.uri(), is("test-yang:create-sfc.input.cont14")); + assertThat(cont14.children().containsKey("leaf28"), is(true)); + LeafNode l = ((LeafNode) cont14.children().get("leaf28")); + assertThat(l.uri(), is("test-yang:create-sfc.input.cont14.leaf28")); + + assertThat(childNodes.containsKey("list10"), is(true)); + HolderNode list10Holder = ((ListHolderNode) childNodes.get("list10")); + assertThat(list10Holder.uri(), is("test-yang:create-sfc.input.list10")); + MultiInstanceNode list10 = ((MultiInstanceNode) list10Holder.child("0")); + assertThat(list10.uri(), is("test-yang:create-sfc.input.list10[0]")); + Map list10Child = list10.children(); + assertThat(list10Child.containsKey("leaf29"), is(true)); + l = ((LeafNode) list10Child.get("leaf29")); + assertThat(l.uri(), is("test-yang:create-sfc.input.list10[0].leaf29")); + + assertThat(childNodes.containsKey("leaf30"), is(true)); + LeafNode leaf30 = ((LeafNode) childNodes.get("leaf30")); + assertThat(leaf30.name(), is("leaf30")); + assertThat(leaf30.uri(), is("test-yang:create-sfc.input.leaf30")); + + LeafListHolderNode ll10Holder = ((LeafListHolderNode) childNodes.get("ll10")); + assertThat(ll10Holder.uri(), is("test-yang:create-sfc.input.ll10")); + assertThat(ll10Holder.children().containsKey("0"), is(true)); + l = ((LeafNode) ll10Holder.children().get("0")); + assertThat(l.uri(), is("test-yang:create-sfc.input.ll10[0]")); + + assertThat(childNodes.containsKey("cont15"), is(true)); + SingleInstanceNode cont15 = ((SingleInstanceNode) childNodes.get("cont15")); + assertThat(cont15.uri(), is("test-yang:create-sfc.input.cont15")); + assertThat(cont15.children().containsKey("leaf31"), is(true)); + l = ((LeafNode) cont15.children().get("leaf31")); + assertThat(l.uri(), is("test-yang:create-sfc.input.cont15.leaf31")); + + assertThat(childNodes.containsKey("cont13"), is(true)); + SingleInstanceNode cont13 = ((SingleInstanceNode) childNodes.get("cont13")); + assertThat(cont13.uri(), is("test-yang:create-sfc.input.cont13")); + SingleInstanceNode cont12 = ((SingleInstanceNode) cont13.children().get("cont12")); + assertThat(cont12.uri(), is("test-yang:create-sfc.input.cont13.cont12")); + assertThat(cont12.children().containsKey("leaf26"), is(true)); + l = ((LeafNode) cont12.children().get("leaf26")); + assertThat(l.uri(), is("test-yang:create-sfc.input.cont13.cont12.leaf26")); + + assertThat(cont13.children().containsKey("list9"), is(true)); + HolderNode list9Holder = ((ListHolderNode) cont13.children().get("list9")); + assertThat(list9Holder.uri(), is("test-yang:create-sfc.input.cont13.list9")); + MultiInstanceNode list9 = ((MultiInstanceNode) list9Holder.child("0")); + assertThat(list9.uri(), is("test-yang:create-sfc.input.cont13.list9[0]")); + Map list6Child = list9.children(); + assertThat(list6Child.containsKey("leaf27"), is(true)); + l = ((LeafNode) list6Child.get("leaf27")); + assertThat(l.uri(), is("test-yang:create-sfc.input.cont13.list9[0].leaf27")); + + assertThat(cont13.children().containsKey("leaf28"), is(true)); + LeafNode leaf12 = ((LeafNode) cont13.children().get("leaf28")); + assertThat(leaf12.name(), is("leaf28")); + assertThat(leaf12.uri(), is("test-yang:create-sfc.input.cont13.leaf28")); + + LeafListHolderNode ll5Holder = ((LeafListHolderNode) cont13.children().get("ll9")); + assertThat(ll5Holder.uri(), is("test-yang:create-sfc.input.cont13.ll9")); + assertThat(ll5Holder.children().containsKey("0"), is(true)); + l = ((LeafNode) ll5Holder.children().get("0")); + assertThat(l.uri(), is("test-yang:create-sfc.input.cont13.ll9[0]")); + + Map output = ser.decode(node); + assertThat(output.size(), is(params.size())); + for (Map.Entry entry : output.entrySet()) { + assertTrue(params.containsKey(entry.getKey())); + } + } + + @Test + public void testRpcOutput() throws SvcLogicException { + String uri = "test-yang:create-sfc"; + Map params = new HashMap<>(); + params.put("test-yang:create-sfc.output.cont16.leaf32", "abc"); + params.put("test-yang:create-sfc.output.list11[0].leaf33", "abc"); + params.put("test-yang:create-sfc.output.leaf34", "abc"); + params.put("test-yang:create-sfc.output.ll11[0]", "abc"); + params.put("test-yang:create-sfc.output.cont17.leaf35", "abc"); + params.put("test-yang:create-sfc.output.cont13.cont12.leaf26", "abc"); + params.put("test-yang:create-sfc.output.cont13.list9[0].leaf27", "abc"); + params.put("test-yang:create-sfc.output.cont13.leaf28", "abc"); + params.put("test-yang:create-sfc.output.cont13.ll9[0]", "abc"); + params.put("test-yang:create-sfc.output.test-augment:leaf37", "abc"); + + InstanceIdentifierContext iCtx = ParserIdentifier + .toInstanceIdentifier(uri, context, null); + PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer( + iCtx.getSchemaNode(), context, uri); + PropertiesNode node = ser.encode(params); + + Map childNodes = ((RootNode) node).children(); + + PropertiesNode output = childNodes.get("output"); + assertThat(output.uri(), is("test-yang:create-sfc.output")); + for (Map.Entry> augmentationToChild : + node.augmentations().asMap().entrySet()) { + Collection c = augmentationToChild.getValue(); + if(!c.isEmpty()) { + List expectedNodes = new LinkedList<>(); + expectedNodes.add("test-yang:create-sfc.output.test-augment:leaf37"); + assertThat(expectedNodes.size(), is(expectedNodes)); + for (PropertiesNode pNode : c) { + assertThat(expectedNodes.contains(pNode.uri()), is(true)); + LeafNode leaf37 = ((LeafNode) pNode); + assertThat(leaf37.name(), is("leaf37")); + assertThat(leaf37.uri(), is("test-yang:create-sfc.output.test-augment:leaf37")); + } + } + } + childNodes = ((InnerNode) output).children(); + + assertThat(childNodes.containsKey("cont16"), is(true)); + SingleInstanceNode cont16 = ((SingleInstanceNode) childNodes.get("cont16")); + assertThat(cont16.uri(), is("test-yang:create-sfc.output.cont16")); + assertThat(cont16.children().containsKey("leaf32"), is(true)); + LeafNode l = ((LeafNode) cont16.children().get("leaf32")); + assertThat(l.uri(), is("test-yang:create-sfc.output.cont16.leaf32")); + + assertThat(childNodes.containsKey("list11"), is(true)); + HolderNode list11Holder = ((ListHolderNode) childNodes.get("list11")); + assertThat(list11Holder.uri(), is("test-yang:create-sfc.output.list11")); + MultiInstanceNode list11 = ((MultiInstanceNode) list11Holder.child("0")); + assertThat(list11.uri(), is("test-yang:create-sfc.output.list11[0]")); + Map list11Child = list11.children(); + assertThat(list11Child.containsKey("leaf33"), is(true)); + l = ((LeafNode) list11Child.get("leaf33")); + assertThat(l.uri(), is("test-yang:create-sfc.output.list11[0].leaf33")); + + assertThat(childNodes.containsKey("leaf34"), is(true)); + LeafNode leaf34 = ((LeafNode) childNodes.get("leaf34")); + assertThat(leaf34.name(), is("leaf34")); + assertThat(leaf34.uri(), is("test-yang:create-sfc.output.leaf34")); + + LeafListHolderNode ll10Holder = ((LeafListHolderNode) childNodes.get("ll11")); + assertThat(ll10Holder.uri(), is("test-yang:create-sfc.output.ll11")); + assertThat(ll10Holder.children().containsKey("0"), is(true)); + l = ((LeafNode) ll10Holder.children().get("0")); + assertThat(l.uri(), is("test-yang:create-sfc.output.ll11[0]")); + + assertThat(childNodes.containsKey("cont17"), is(true)); + SingleInstanceNode cont17 = ((SingleInstanceNode) childNodes.get("cont17")); + assertThat(cont17.uri(), is("test-yang:create-sfc.output.cont17")); + assertThat(cont17.children().containsKey("leaf35"), is(true)); + l = ((LeafNode) cont17.children().get("leaf35")); + assertThat(l.uri(), is("test-yang:create-sfc.output.cont17.leaf35")); + + assertThat(childNodes.containsKey("cont13"), is(true)); + SingleInstanceNode cont13 = ((SingleInstanceNode) childNodes.get("cont13")); + assertThat(cont13.uri(), is("test-yang:create-sfc.output.cont13")); + SingleInstanceNode cont12 = ((SingleInstanceNode) cont13.children().get("cont12")); + assertThat(cont12.uri(), is("test-yang:create-sfc.output.cont13.cont12")); + assertThat(cont12.children().containsKey("leaf26"), is(true)); + l = ((LeafNode) cont12.children().get("leaf26")); + assertThat(l.uri(), is("test-yang:create-sfc.output.cont13.cont12.leaf26")); + + assertThat(cont13.children().containsKey("list9"), is(true)); + HolderNode list9Holder = ((ListHolderNode) cont13.children().get("list9")); + assertThat(list9Holder.uri(), is("test-yang:create-sfc.output.cont13.list9")); + MultiInstanceNode list9 = ((MultiInstanceNode) list9Holder.child("0")); + assertThat(list9.uri(), is("test-yang:create-sfc.output.cont13.list9[0]")); + Map list6Child = list9.children(); + assertThat(list6Child.containsKey("leaf27"), is(true)); + l = ((LeafNode) list6Child.get("leaf27")); + assertThat(l.uri(), is("test-yang:create-sfc.output.cont13.list9[0].leaf27")); + + assertThat(cont13.children().containsKey("leaf28"), is(true)); + LeafNode leaf12 = ((LeafNode) cont13.children().get("leaf28")); + assertThat(leaf12.name(), is("leaf28")); + assertThat(leaf12.uri(), is("test-yang:create-sfc.output.cont13.leaf28")); + + LeafListHolderNode ll5Holder = ((LeafListHolderNode) cont13.children().get("ll9")); + assertThat(ll5Holder.uri(), is("test-yang:create-sfc.output.cont13.ll9")); + assertThat(ll5Holder.children().containsKey("0"), is(true)); + l = ((LeafNode) ll5Holder.children().get("0")); + assertThat(l.uri(), is("test-yang:create-sfc.output.cont13.ll9[0]")); + + Map output1 = ser.decode(node); + assertThat(output1.size(), is(params.size())); + for (Map.Entry entry : output1.entrySet()) { + assertTrue(params.containsKey(entry.getKey())); + } + } + + @Test + public void testContainerSameName() throws SvcLogicException { + String uri = "test-yang:cont18"; + Map params = new HashMap<>(); + params.put("test-yang:cont18.cont18.list12[0].list12[0].leaf36", "abc"); + params.put("test-yang:cont18.cont18.list12[0].leaf36", "hi"); + params.put("test-yang:cont18.cont18.list12[1].list12[0].leaf36", "xyz"); + params.put("test-yang:cont18.cont18.list12[1].list12[1].leaf36", "hey!"); + + InstanceIdentifierContext iCtx = ParserIdentifier + .toInstanceIdentifier(uri, context, null); + PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer( + iCtx.getSchemaNode(), context, uri); + PropertiesNode node = ser.encode(params); + + Map childNodes = ((RootNode) node).children(); + + assertThat(childNodes.containsKey("cont18"), is(true)); + node = childNodes.get("cont18"); + assertThat(node.uri(), is("test-yang:cont18.cont18")); + childNodes = ((InnerNode) node).children(); + + assertThat(childNodes.containsKey("list12"), is(true)); + HolderNode holder = ((ListHolderNode) childNodes.get("list12")); + assertThat(holder.uri(), is("test-yang:cont18.cont18.list12")); + MultiInstanceNode node1 = ((MultiInstanceNode) holder.child("0")); + assertThat(node1.uri(), is("test-yang:cont18.cont18.list12[0]")); + Map list12Child = node1.children(); + + assertThat(list12Child.containsKey("leaf36"), is(true)); + LeafNode leaf = ((LeafNode) list12Child.get("leaf36")); + assertThat(leaf.value(), is("hi")); + assertThat(leaf.uri(), is("test-yang:cont18.cont18.list12[0].leaf36")); + + assertThat(list12Child.containsKey("list12"), is(true)); + HolderNode holder1 = ((ListHolderNode) list12Child.get("list12")); + assertThat(holder1.uri(), is("test-yang:cont18.cont18.list12[0].list12")); + node1 = ((MultiInstanceNode) holder1.child("0")); + assertThat(node1.uri(), is("test-yang:cont18.cont18.list12[0].list12[0]")); + list12Child = node1.children(); + assertThat(list12Child.containsKey("leaf36"), is(true)); + leaf = ((LeafNode) list12Child.get("leaf36")); + assertThat(leaf.value(), is("abc")); + assertThat(leaf.uri(), is("test-yang:cont18.cont18.list12[0].list12[0].leaf36")); + + node1 = ((MultiInstanceNode) holder.child("1")); + assertThat(node1.uri(), is("test-yang:cont18.cont18.list12[1]")); + list12Child = node1.children(); + assertThat(list12Child.containsKey("list12"), is(true)); + holder = ((ListHolderNode) list12Child.get("list12")); + assertThat(holder.uri(), is("test-yang:cont18.cont18.list12[1].list12")); + node1 = ((MultiInstanceNode) holder.child("0")); + assertThat(node1.uri(), is("test-yang:cont18.cont18.list12[1].list12[0]")); + assertThat(node1.children().containsKey("leaf36"), is(true)); + leaf = ((LeafNode) node1.children().get("leaf36")); + assertThat(leaf.value(), is("xyz")); + assertThat(leaf.uri(), is("test-yang:cont18.cont18.list12[1].list12[0].leaf36")); + + node1 = ((MultiInstanceNode) holder.child("1")); + assertThat(node1.uri(), is("test-yang:cont18.cont18.list12[1].list12[1]")); + assertThat(node1.children().containsKey("leaf36"), is(true)); + leaf = ((LeafNode) node1.children().get("leaf36")); + assertThat(leaf.value(), is("hey!")); + assertThat(leaf.uri(), is("test-yang:cont18.cont18.list12[1].list12[1].leaf36")); + + Map output1 = ser.decode(node); + assertThat(output1.size(), is(params.size())); + for (Map.Entry entry : output1.entrySet()) { + assertTrue(params.containsKey(entry.getKey())); + } + } + + @Test + public void testPropertiesWithoutSchema() throws SvcLogicException { + String uri = "test-yang:cont18"; + Map params = new HashMap<>(); + params.put("test-yang:cont18.leaf40", "abc"); + params.put("leaf41", "hi"); + params.put("test-yang:cont18.leaf41", "abc"); + + InstanceIdentifierContext iCtx = ParserIdentifier + .toInstanceIdentifier(uri, context, null); + PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer( + iCtx.getSchemaNode(), context, uri); + PropertiesNode node = ser.encode(params); + + Map childNodes = ((RootNode) node).children(); + assertThat(childNodes.containsKey("leaf40"), is(true)); + node = childNodes.get("leaf40"); + assertThat(node.uri(), is("test-yang:cont18.leaf40")); + } + + public static SchemaContext compileYangFile() throws FileNotFoundException { + String path = PropertiesSerializerTest.class.getResource("/yang").getPath(); + File dir = new File(path); + String[] fileList = dir.list(); + List yangFiles = new ArrayList(); + if (fileList == null) { + throw new FileNotFoundException("/yang"); + } + for (int i = 0; i < fileList.length; i++) { + final String fileName = fileList[i]; + if (new File(dir, fileName).isDirectory() == false) { + yangFiles.add(new File(dir, fileName)); + } + } + return YangParserTestUtils.parseYangFiles(yangFiles); + } +} \ No newline at end of file diff --git a/restconf-client/provider/src/test/resources/yang/test-augment.yang b/restconf-client/provider/src/test/resources/yang/test-augment.yang new file mode 100644 index 000000000..bac19171b --- /dev/null +++ b/restconf-client/provider/src/test/resources/yang/test-augment.yang @@ -0,0 +1,85 @@ +module test-augment { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:augment"; + prefix "hello"; + + import test-yang { + prefix t; + } + + revision "2015-01-05" { + description "Initial revision of hello model"; + } + + augment "/t:cont1/t:cont2/t:cont4" { + container cont5 { + leaf leaf13 { + type string; + } + } + list list7 { + leaf leaf14 { + type string; + } + } + leaf leaf15 { + type string; + } + leaf-list ll6 { + type string; + } + uses "t:g1"; + } + + uses "t:g1"; + augment "/t:ch1/t:c1/t:cont8/t:cont6" { + choice ch2 { + case c3 { + leaf leaf21 { + type string; + } + } + case c4 { + leaf leaf22 { + type string; + } + } + } + } + + augment "/t:ch1" { + case c5 { + container cont10 { + leaf leaf23 { + type string; + } + } + } + } + + augment "/t:ch1/t:c1" { + container cont7 { + leaf leaf24 { + type string; + } + } + } + + augment "/t:cont13/t:cont12" { + leaf leaf29 { + type string; + } + } + + augment "/t:create-sfc/t:input" { + leaf leaf36 { + type string; + } + } + + augment "/t:create-sfc/t:output" { + leaf leaf37 { + type string; + } + } +} \ No newline at end of file diff --git a/restconf-client/provider/src/test/resources/yang/test-yang.yang b/restconf-client/provider/src/test/resources/yang/test-yang.yang new file mode 100644 index 000000000..e99d87bf8 --- /dev/null +++ b/restconf-client/provider/src/test/resources/yang/test-yang.yang @@ -0,0 +1,231 @@ +module test-yang { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:test"; + prefix "hello"; + + revision "2015-01-05" { + description "Initial revision of hello model"; + } + + container cont1 { + container cont2 { + container cont3 { + leaf leaf10 { + type string; + } + } + list list1 { + key "leaf1 leaf2"; + leaf leaf1 { + type string; + } + leaf leaf2 { + type string; + } + leaf leaf3 { + type string; + } + leaf-list ll1 { + type string; + } + leaf-list ll2 { + type string; + } + container cont4 { + leaf leaf11 { + type string; + } + } + list list4 { + leaf leaf8 { + type string; + } + } + list list5 { + leaf leaf9 { + type string; + } + } + } + list list2 { + leaf leaf4 { + type string; + } + } + leaf leaf5 { + type string; + } + leaf leaf6 { + type string; + } + leaf-list ll3 { + type string; + } + leaf-list ll4 { + type string; + } + } + } + + augment "/cont1/cont2" { + container cont4 { + leaf leaf10 { + type string; + } + } + list list6 { + leaf leaf11 { + type string; + } + } + leaf leaf12 { + type string; + } + leaf-list ll5 { + type string; + } + } + + choice ch1 { + case c1 { + container cont8 { + container cont6 { + leaf leaf16 { + type string; + } + } + list list8 { + leaf leaf18 { + type string; + } + } + leaf leaf19 { + type string; + } + leaf-list ll7 { + type string; + } + } + } + case c2 { + container cont9 { + leaf leaf20 { + type string; + } + leaf-list ll8 { + type string; + } + container cont11 { + choice ch3 { + case c1 { + leaf leaf25 { + type string; + } + uses g1; + } + } + } + } + } + } + + grouping g1 { + container cont13 { + container cont12 { + leaf leaf26 { + type string; + } + } + list list9 { + leaf leaf27 { + type string; + } + } + leaf leaf28 { + type string; + } + leaf-list ll9 { + type string; + } + } + } + + uses g1; + + rpc create-sfc { + input { + container cont14 { + leaf leaf28 { + type string; + } + } + list list10 { + leaf leaf29 { + type string; + } + } + leaf leaf30 { + type string; + } + leaf-list ll10 { + type string; + } + choice ch3 { + case c1 { + container cont15 { + leaf leaf31 { + type string; + } + } + } + } + uses g1; + } + output { + container cont16 { + leaf leaf32 { + type string; + } + } + list list11 { + leaf leaf33 { + type string; + } + } + leaf leaf34 { + type string; + } + leaf-list ll11 { + type string; + } + choice ch4 { + case c1 { + container cont17 { + leaf leaf35 { + type string; + } + } + } + } + uses g1; + } + } + + container cont18 { + container cont18 { + list list12 { + list list12 { + leaf leaf36 { + type string; + } + } + leaf leaf36 { + type string; + } + } + } + leaf leaf40 { + type string; + } + } +} \ No newline at end of file -- cgit From 4633416831f2d98ca50668d4514cbd1905749201 Mon Sep 17 00:00:00 2001 From: Vidyashree Rama Date: Tue, 21 Aug 2018 13:47:16 +0530 Subject: Handling identity ref type Handling identity ref type in properties node serializer Issue-ID: CCSDK-378 Change-Id: Ie74088a5e2449c09f9712048f1856990b81d05e7 Signed-off-by: Vidyashree Rama --- .../MdsalPropertiesNodeSerializer.java | 8 ++- .../pnserializer/MdsalPropertiesNodeUtils.java | 56 ++++++++++++++++ .../pnserializer/PropertiesSerializerTest.java | 54 +++++++++++++++ .../src/test/resources/yang/identity-test.yang | 77 ++++++++++++++++++++++ .../test/resources/yang/identity-types-second.yang | 25 +++++++ .../src/test/resources/yang/identity-types.yang | 17 +++++ 6 files changed, 235 insertions(+), 2 deletions(-) create mode 100644 restconf-client/provider/src/test/resources/yang/identity-test.yang create mode 100644 restconf-client/provider/src/test/resources/yang/identity-types-second.yang create mode 100644 restconf-client/provider/src/test/resources/yang/identity-types.yang diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java index 146e581fa..20b06d0bc 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java @@ -34,6 +34,7 @@ import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPrope import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getNamespace; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getNodeType; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getRevision; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getValueNamespace; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.resolveName; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_LEAF_NODE; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_NODE; @@ -121,13 +122,16 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer r) { return (r.isPresent()) ? r.get().toString() : null; } + + /** + * Returns value namespace for leaf value. + * + * @param value value of the leaf + * @param ctx schema context + * @return value namespace + * @throws SvcLogicException if identity/module could not be found + */ + static Namespace getValueNamespace(String value, + SchemaContext ctx) + throws SvcLogicException { + String prefix = getPrefixFromValue(value); + if (prefix == null) { + return null; + } + + IdentitySchemaNode id = IdentityCodecUtil.parseIdentity(value, + ctx, + prefixToModule -> { + final Iterator modules = ctx.findModules(prefix).iterator(); + checkArgument(modules.hasNext(), "Could not find " + + "module %s", prefix); + return modules.next().getQNameModule(); + }); + + if (id == null) { + throw new SvcLogicException("Could not find identity"); + } + + return getModuleNamespace(id.getQName(), ctx); + } + + private static String getPrefixFromValue(String value) { + int lastIndexOfColon = value.lastIndexOf(":"); + if (lastIndexOfColon != -1) { + return value.substring(0, lastIndexOfColon); + } + return null; + } + + private static Namespace getModuleNamespace(QName qName, SchemaContext ctx) + throws SvcLogicException { + Optional module = ctx.findModule(qName.getModule()); + if (!module.isPresent()) { + throw new SvcLogicException("Could not find module node"); + } + Module m = module.get(); + return new Namespace(m.getName(), m.getQNameModule().getNamespace(), + getRevision(m.getRevision())); + } } diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java index fddfe2d40..dc0da6f7c 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java @@ -1071,6 +1071,60 @@ public final class PropertiesSerializerTest { assertThat(node.uri(), is("test-yang:cont18.leaf40")); } + @Test + public void testIdentityRef() throws SvcLogicException { + String uri = "identity-test:test"; + Map params = new HashMap<>(); + params.put("identity-test:test.con1.interface", "identity-types:physical"); + params.put("identity-test:test.con1.interfaces.int-list[0].iden", "identity-test:Giga"); + params.put("identity-test:test.con1.interfaces.int-list[0].available.ll[0]", "identity-types:Loopback"); + params.put("identity-test:test.con1.interfaces.int-list[0].available.leaf1", "identity-types-second:Ethernet"); + params.put("identity-test:test.con1.interfaces.int-list[0].available.leaf2", "identity-types-second:iden2"); + InstanceIdentifierContext iCtx = ParserIdentifier + .toInstanceIdentifier(uri, context, null); + + PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer( + iCtx.getSchemaNode(), context, uri); + PropertiesNode node = ser.encode(params); + Map childNodes = ((RootNode) node).children(); + assertThat(childNodes.containsKey("con1"), is(true)); + node = childNodes.get("con1"); + assertThat(node.uri(), is("identity-test:test.con1")); + LeafNode l = ((LeafNode) ((SingleInstanceNode) node).children().get("interface")); + assertThat(l.uri(), is("identity-test:test.con1.interface")); + assertThat(l.valueNs().moduleName(), is("identity-types")); + assertThat(l.valueNs().moduleNs().toString(), is("identity:list:ns:test:json:ser")); + + // identity type inside union + node = ((SingleInstanceNode) ((SingleInstanceNode) node).children().get("interfaces")); + node = ((ListHolderNode) ((SingleInstanceNode) node).children().get("int-list")); + node = ((MultiInstanceNode) ((ListHolderNode) node).children().get("0")); + l = ((LeafNode) ((MultiInstanceNode) node).children().get("iden")); + assertThat(l.uri(), is("identity-test:test.con1.interfaces.int-list[0].iden")); + assertThat(l.valueNs().moduleName(), is("identity-test")); + assertThat(l.valueNs().moduleNs().toString(), is("identity:ns:test:json:ser")); + + // leaf-list test + node = (SingleInstanceNode) ((MultiInstanceNode) node).children().get("available"); + LeafListHolderNode holder = (LeafListHolderNode) ((SingleInstanceNode) node).children().get("ll"); + l = ((LeafNode) holder.children().get("0")); + assertThat(l.uri(), is("identity-test:test.con1.interfaces.int-list[0].available.ll[0]")); + assertThat(l.valueNs().moduleName(), is("identity-types")); + assertThat(l.valueNs().moduleNs().toString(), is("identity:list:ns:test:json:ser")); + + // leaf-ref test + l = ((LeafNode) ((SingleInstanceNode) node).children().get("leaf1")); + assertThat(l.uri(), is("identity-test:test.con1.interfaces.int-list[0].available.leaf1")); + assertThat(l.valueNs().moduleName(), is("identity-types-second")); + assertThat(l.valueNs().moduleNs().toString(), is("identity:list:second:ns:test:json:ser")); + + // list of base identity test + l = ((LeafNode) ((SingleInstanceNode) node).children().get("leaf2")); + assertThat(l.uri(), is("identity-test:test.con1.interfaces.int-list[0].available.leaf2")); + assertThat(l.valueNs().moduleName(), is("identity-types-second")); + assertThat(l.valueNs().moduleNs().toString(), is("identity:list:second:ns:test:json:ser")); + } + public static SchemaContext compileYangFile() throws FileNotFoundException { String path = PropertiesSerializerTest.class.getResource("/yang").getPath(); File dir = new File(path); diff --git a/restconf-client/provider/src/test/resources/yang/identity-test.yang b/restconf-client/provider/src/test/resources/yang/identity-test.yang new file mode 100644 index 000000000..81d3f0a0b --- /dev/null +++ b/restconf-client/provider/src/test/resources/yang/identity-test.yang @@ -0,0 +1,77 @@ +module identity-test { + yang-version 1.1; + namespace "identity:ns:test:json:ser"; + prefix "id"; + + import identity-types { + prefix "type"; + } + + import identity-types-second { + prefix "sec"; + } + + revision "2013-07-15"; + + identity optical { + base type:int-type; + } + + identity Giga { + base type:physical; + } + + typedef available { + type identityref { + base "type:physical"; + } + } + + typedef typed{ + type union { + type int32; + type int8; + type identityref { + base type:int-type; + } + } + } + + container test { + leaf l { + type string; + } + container con1 { + leaf interface { + type identityref { + base "type:int-type"; + } + } + container interfaces { + list int-list { + key "iden"; + leaf iden { + type "id:typed"; + } + container available { + leaf-list ll { + type available; + } + leaf leaf1 { + type leafref { + path "../../iden"; + } + } + + leaf leaf2 { + type identityref { + base type:int-type; + base sec:iden1; + } + } + } + } + } + } + } +} diff --git a/restconf-client/provider/src/test/resources/yang/identity-types-second.yang b/restconf-client/provider/src/test/resources/yang/identity-types-second.yang new file mode 100644 index 000000000..ad752de31 --- /dev/null +++ b/restconf-client/provider/src/test/resources/yang/identity-types-second.yang @@ -0,0 +1,25 @@ +module identity-types-second{ + yang-version 1; + namespace "identity:list:second:ns:test:json:ser"; + prefix "sec"; + + import identity-types { + prefix "type"; + } + + revision "2013-07-15"; + + identity virtual { + base type:int-type; + } + + identity Ethernet { + base type:physical; + } + + identity iden1; + + identity iden2 { + base iden1; + } +} diff --git a/restconf-client/provider/src/test/resources/yang/identity-types.yang b/restconf-client/provider/src/test/resources/yang/identity-types.yang new file mode 100644 index 000000000..25c8fa54f --- /dev/null +++ b/restconf-client/provider/src/test/resources/yang/identity-types.yang @@ -0,0 +1,17 @@ +module identity-types { + yang-version 1; + namespace "identity:list:ns:test:json:ser"; + prefix "type"; + revision "2013-07-15"; + + identity int-type { + } + + identity physical { + base int-type; + } + + identity Loopback { + base physical; + } +} -- cgit From 8ac78c51adf88600babdd2813e8833c578fc247b Mon Sep 17 00:00:00 2001 From: gaurav Date: Tue, 21 Aug 2018 17:29:41 +0530 Subject: Add log files to ignore list Adding sshapi eelf log files to ignore list. Change-Id: Id4bdaef80eeaa729c5150cf82130503daf5731f4 Issue-ID: CCSDK-288 Signed-off-by: Gaurav Agrawal --- sshapi-call-node/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/sshapi-call-node/.gitignore b/sshapi-call-node/.gitignore index b73caf31e..3c30c3505 100755 --- a/sshapi-call-node/.gitignore +++ b/sshapi-call-node/.gitignore @@ -28,6 +28,7 @@ classes out/ .DS_STORE .metadata +*.log ## Folders which contain auto generated source code ## yang-gen-config -- cgit From 51608f7e35fdad0242b3d801f2015a9db5fa93a1 Mon Sep 17 00:00:00 2001 From: janani b Date: Thu, 23 Aug 2018 14:41:22 +0530 Subject: Implementation of Data Format serializer Data format serializer code Issue-ID: CCSDK-376 Change-Id: Ie1954e6237374411ce3f07039030027042581d33 Signed-off-by: janani b --- .../dfserializer/DataFormatSerializer.java | 9 +- .../dfserializer/DefaultJsonListener.java | 59 +++++- .../dfserializer/DefaultJsonWalker.java | 93 ++++++++- .../dfserializer/DefaultXmlListener.java | 31 ++- .../dfserializer/DefaultXmlWalker.java | 18 +- .../dfserializer/DfListenerFactory.java | 13 +- .../dfserializer/DfSerializerFactory.java | 16 +- .../dfserializer/DfSerializerUtil.java | 216 +++++++++++++++++++++ .../yangserializers/dfserializer/JsonListener.java | 8 +- .../dfserializer/JsonSerializer.java | 46 ++++- .../yangserializers/dfserializer/JsonWalker.java | 5 +- .../dfserializer/MdsalSerializerHelper.java | 192 +++++++++++++++++- .../dfserializer/PropertiesNodeJsonListener.java | 165 +++++++++++++++- .../dfserializer/PropertiesNodeXmlListener.java | 178 ++++++++++++++++- .../dfserializer/SerializerHelper.java | 9 +- .../yangserializers/dfserializer/XmlListener.java | 8 +- .../dfserializer/XmlSerializer.java | 45 ++++- .../yangserializers/dfserializer/XmlWalker.java | 5 +- .../DefaultPropertiesNodeListener.java | 7 +- .../pnserializer/DefaultPropertiesNodeWalker.java | 8 +- .../MdsalPropertiesNodeSerializer.java | 3 +- .../pnserializer/PropertiesNodeListener.java | 14 +- .../pnserializer/PropertiesNodeSerializer.java | 5 +- .../pnserializer/PropertiesNodeWalker.java | 7 +- .../yangserializers/pnserializer/RootNode.java | 10 +- 25 files changed, 1088 insertions(+), 82 deletions(-) create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerUtil.java diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializer.java index 57280e2e9..cab64391a 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializer.java @@ -20,6 +20,8 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + import java.util.List; import java.util.Map; @@ -57,17 +59,20 @@ public abstract class DataFormatSerializer { * @param param context memory parameter * @param annotations annotations * @return data format body + * @throws SvcLogicException when serialization fails */ public abstract String encode(Map param, - Map> annotations); + Map> annotations) throws SvcLogicException; /** * Decodes data format body to context memory parameters. * * @param dataFormatBody abstract node * @return context memory parameters + * @throws SvcLogicException when serialization fails */ - public abstract Map decode(String dataFormatBody); + public abstract Map decode(String dataFormatBody) + throws SvcLogicException; /** * Returns data format serializer context. diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonListener.java index 5e71eea3b..107585a72 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonListener.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonListener.java @@ -21,8 +21,16 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; import com.fasterxml.jackson.databind.JsonNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType; +import static java.lang.String.format; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.NODE_TYPE_ERR; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_LEAF_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.SINGLE_INSTANCE_LEAF_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.SINGLE_INSTANCE_NODE; + /** * Representation of default implementation of JSON listener. @@ -54,13 +62,40 @@ public class DefaultJsonListener implements JsonListener { } @Override - public void enterJsonNode(String nodeName, JsonNode node, NodeType nodeType) { - //TODO: Implementation code. + public void enterJsonNode(String nodeName, JsonNode node, + NodeType nodeType) throws SvcLogicException { + getNodeName(nodeName); + + switch (nodeType) { + case SINGLE_INSTANCE_LEAF_NODE: + serializerHelper.addNode(name, modName, node.asText(), null, + SINGLE_INSTANCE_LEAF_NODE); + break; + + case MULTI_INSTANCE_LEAF_NODE: + serializerHelper.addNode(name, modName, node.asText(), null, + MULTI_INSTANCE_LEAF_NODE); + break; + + case SINGLE_INSTANCE_NODE: + serializerHelper.addNode(name, modName, null, null, + SINGLE_INSTANCE_NODE); + break; + + case MULTI_INSTANCE_NODE: + serializerHelper.addNode(name, modName, null, null, + MULTI_INSTANCE_NODE); + break; + + default: + throw new SvcLogicException(format(NODE_TYPE_ERR, + nodeType.toString())); + } } @Override - public void exitJsonNode(JsonNode node) { - //TODO: Implementation code. + public void exitJsonNode(JsonNode node) throws SvcLogicException { + serializerHelper.exitNode(); } @Override @@ -68,4 +103,20 @@ public class DefaultJsonListener implements JsonListener { return serializerHelper; } + /** + * Parses the abstract JSON name and fills the node name and node + * namespace of the current JSON node. + * + * @param abstractName abstract JSON name + */ + private void getNodeName(String abstractName) { + String[] val = abstractName.split(":"); + if (val.length == 2) { + modName = val[0]; + name = val[1]; + } else { + name = val[0]; + } + } + } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonWalker.java index 20d4fa772..47cb8b292 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonWalker.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonWalker.java @@ -21,6 +21,20 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.JsonNodeType; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType; + +import java.util.Iterator; +import java.util.Map; + +import static com.fasterxml.jackson.databind.node.JsonNodeType.NUMBER; +import static com.fasterxml.jackson.databind.node.JsonNodeType.STRING; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_LEAF_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.SINGLE_INSTANCE_LEAF_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.SINGLE_INSTANCE_NODE; /** * Implementation of JSON walker to walk through the nodes and process it. @@ -28,8 +42,19 @@ import com.fasterxml.jackson.databind.JsonNode; public class DefaultJsonWalker implements JsonWalker { @Override - public void walk(JsonListener listener, JsonNode jsonNode) { - //TODO: Implementation code. + public void walk(JsonListener listener, JsonNode jsonNode) throws + SvcLogicException { + Iterator> children = jsonNode.fields(); + while (children.hasNext()) { + Map.Entry child = children.next(); + JsonNode value = child.getValue(); + String key = child.getKey(); + if (value.isArray()) { + processMultiNodes(key, value, listener); + } else { + processSingleNode(key, value, listener); + } + } } /** @@ -39,10 +64,18 @@ public class DefaultJsonWalker implements JsonWalker { * @param key JSON name * @param value JSON node * @param listener JSON listener + * @throws SvcLogicException when processing the node fails */ private void processSingleNode(String key, JsonNode value, - JsonListener listener) { - //TODO: Implementation code. + JsonListener listener) + throws SvcLogicException { + NodeType nodeType; + if (!value.isContainerNode()) { + nodeType = SINGLE_INSTANCE_LEAF_NODE; + } else { + nodeType = SINGLE_INSTANCE_NODE; + } + processNode(key, value, nodeType, listener); } /** @@ -52,9 +85,57 @@ public class DefaultJsonWalker implements JsonWalker { * @param key JSON name * @param value JSON node * @param listener JSON listener + * @throws SvcLogicException when processing a single instance fails */ private void processMultiNodes(String key, JsonNode value, - JsonListener listener) { - //TODO: Implementation code. + JsonListener listener) + throws SvcLogicException { + NodeType nodeType; + Iterator multiNodes = value.elements(); + while (multiNodes.hasNext()) { + if (isLeafListNode((ArrayNode) value)) { + nodeType = MULTI_INSTANCE_LEAF_NODE; + } else { + nodeType = MULTI_INSTANCE_NODE; + } + JsonNode multiNode = multiNodes.next(); + processNode(key, multiNode, nodeType, listener); + } + } + + /** + * Processes each node by first entering the JSON node through JSON + * listener, second a call back to walking the rest of the tree of the + * node and finally exiting the node. + * + * @param key JSON name + * @param node JSON node + * @param nodeType JSON node type + * @param listener JSON listener + * @throws SvcLogicException when entering a JSON node fails + */ + private void processNode(String key, JsonNode node, NodeType nodeType, + JsonListener listener) throws SvcLogicException { + listener.enterJsonNode(key, node, nodeType); + walk(listener, node); + listener.exitJsonNode(node); + } + + /** + * Returns true if the node corresponds to a leaf-list node; false + * otherwise. + * + * @param node JSON node + * @return true if node corresponds to leaf-list node; false otherwise + */ + private boolean isLeafListNode(ArrayNode node) { + Iterator children = node.elements(); + while (children.hasNext()) { + JsonNodeType type = children.next().getNodeType(); + if (type != STRING && type != NUMBER) { + return false; + } + } + return true; } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlListener.java index 7946d8d0d..57969146d 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlListener.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlListener.java @@ -21,6 +21,10 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; import org.dom4j.Element; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + +import static java.lang.String.format; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.NODE_TYPE_ERR; /** * Representation of default implementation of XML listener. @@ -42,17 +46,34 @@ public class DefaultXmlListener implements XmlListener { } @Override - public void enterXmlElement(Element element, XmlNodeType nodeType) { - //TODO: Implementation code. + public void enterXmlElement(Element element, XmlNodeType nodeType) + throws SvcLogicException { + switch (nodeType) { + case TEXT_NODE: + serializerHelper.addNode(element.getName(), + element.getNamespace().getURI(), + element.getText(), null, null); + break; + + case OBJECT_NODE: + serializerHelper.addNode(element.getName(), + element.getNamespace().getURI(), + null, null, null); + break; + + default: + throw new SvcLogicException(format(NODE_TYPE_ERR, + nodeType.toString())); + } } @Override - public void exitXmlElement(Element element) { - //TODO: Implementation code. + public void exitXmlElement(Element element) throws SvcLogicException { + serializerHelper.exitNode(); } @Override public SerializerHelper serializerHelper() { return serializerHelper; } - } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlWalker.java index cd2a3d494..cdc713f31 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlWalker.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlWalker.java @@ -21,6 +21,11 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; import org.dom4j.Element; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + +import java.util.Iterator; + +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.getXmlNodeType; /** * Implementation of XML walker to walk through the nodes and process it. @@ -28,7 +33,16 @@ import org.dom4j.Element; public class DefaultXmlWalker implements XmlWalker { @Override - public void walk(XmlListener listener, Element xmlElement) { - //TODO: Implementation code. + public void walk(XmlListener listener, Element xmlElement) throws + SvcLogicException { + listener.enterXmlElement(xmlElement, getXmlNodeType(xmlElement)); + if (xmlElement.hasContent() && !xmlElement.isTextOnly()) { + Iterator i = xmlElement.elementIterator(); + while (i.hasNext()) { + Element childElement = (Element) i.next(); + walk(listener, childElement); + } + } + listener.exitXmlElement(xmlElement); } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfListenerFactory.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfListenerFactory.java index 851f1b488..e10a085a6 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfListenerFactory.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfListenerFactory.java @@ -20,6 +20,11 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + +import static java.lang.String.format; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.FORMAT_ERR; + /** * Represents the data format listener factory which will return JSON or XML * listener according to the serializer helper. @@ -52,9 +57,11 @@ public final class DfListenerFactory { * @param serHelper serializer helper * @param params parameters * @return data format listener + * @throws SvcLogicException when the data format type is wrong */ public Listener getListener(SerializerHelper serHelper, - YangParameters params) { + YangParameters params) + throws SvcLogicException { Listener listener; switch (params.format) { case JSON: @@ -65,9 +72,9 @@ public final class DfListenerFactory { listener = new DefaultXmlListener(serHelper); break; - //TODO: DataFormat Exception code to be added. default: - throw new IllegalArgumentException("In correct format"); + throw new SvcLogicException(format(FORMAT_ERR, + params.format)); } return listener; } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerFactory.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerFactory.java index 25b23fe26..bd0285e8e 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerFactory.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerFactory.java @@ -20,6 +20,11 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + +import static java.lang.String.format; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.FORMAT_ERR; + /** * Represents the data format serializer factory which will return JSON or XML * serializer according to the serializer context. @@ -52,10 +57,11 @@ public final class DfSerializerFactory { * @param serCtx serializer context * @param params parameters * @return data format serializer + * @throws SvcLogicException when the data format type is wrong */ - public DataFormatSerializer getSerializer(DataFormatSerializerContext - serCtx, - YangParameters params) { + public DataFormatSerializer getSerializer(DataFormatSerializerContext serCtx, + YangParameters params) + throws SvcLogicException { DataFormatSerializer serializer; switch (params.format) { case JSON: @@ -66,9 +72,9 @@ public final class DfSerializerFactory { serializer = new XmlSerializer(serCtx); break; - //TODO: DataFormat Exception code to be added. default: - throw new IllegalArgumentException("In correct format"); + throw new SvcLogicException(format(FORMAT_ERR, + params.format)); } return serializer; } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerUtil.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerUtil.java new file mode 100644 index 000000000..6acb04a81 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerUtil.java @@ -0,0 +1,216 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import org.dom4j.Element; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.Namespace; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; +import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.SchemaNode; +import org.opendaylight.yangtools.yang.model.api.TypeDefinition; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.Writer; +import java.net.URI; +import java.net.URISyntaxException; + +import static javax.xml.transform.OutputKeys.INDENT; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.XmlNodeType.OBJECT_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.XmlNodeType.TEXT_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getRevision; + +/** + * Utilities for data format serializer. + */ +public final class DfSerializerUtil { + + static final String JSON_WRITE_ERR = "Unable to write to JSON from " + + "properties."; + + static final String NODE_TYPE_ERR = "The node type %s is not supported."; + + static final String JSON_LIS_ERR = "The JSON serializer doesn't have " + + "JSON listener"; + + static final String XML_LIS_ERR = "The XML serializer doesn't have XML " + + "listener"; + + static final String JSON_TREE_ERR = "Unable to form JSON tree object from" + + " the JSON body provided."; + + static final String XML_TREE_ERR = "Unable to form XML tree object from " + + "the XML body provided."; + + static final String FORMAT_ERR = "Only JSON and XML formats are supported" + + ". %s is not supported"; + + static final String PROP_NODE_ERR = "The property node doesn't have " + + "schema node bound to it."; + + static final String DF_ERR = "Type mismatch for the node %s. The schema " + + "node does not match with the data format node type %s."; + + static final String UTF_HEADER = ""; + + static final String XML_PREFIX = "yangid"; + + private static final String YES = "yes"; + + private static final String INDENT_XMLNS = "{http://xml.apache" + + ".org/xslt}indent-amount"; + + private static final String XML_PARSE_ERR = "Unable to parse the xml to " + + "document : \n"; + + private static final String URI_ERR = "Unable to parse the URI"; + + //No instantiation. + private DfSerializerUtil() { + } + + /** + * Returns the writer which contains the pretty formatted XML string. + * + * @param input input XML + * @param indent indentation level + * @return writer with XML + * @throws SvcLogicException when transformation of source fails + */ + static Writer getXmlWriter(String input, String indent) + throws SvcLogicException { + try { + Transformer transformer = TransformerFactory.newInstance() + .newTransformer(); + transformer.setOutputProperty(INDENT, YES); + transformer.setOutputProperty(INDENT_XMLNS, indent); + StreamResult result = new StreamResult(new StringWriter()); + DOMSource source = new DOMSource(parseXml(input)); + transformer.transform(source, result); + return result.getWriter(); + } catch (TransformerException e) { + throw new SvcLogicException(XML_PARSE_ERR + input, e); + } + } + + /** + * Parses the XML and converts it into dom document which can be used for + * formatting the XML. + * + * @param in input XML + * @return dom document of XML + * @throws SvcLogicException when document building fails + */ + private static Document parseXml(String in) throws SvcLogicException { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db; + try { + db = dbf.newDocumentBuilder(); + InputSource is = new InputSource(new StringReader(in)); + return db.parse(is); + } catch (SAXException | IOException | ParserConfigurationException e) { + throw new SvcLogicException(XML_PARSE_ERR + in, e); + } + } + + /** + * Returns the resolved namespace object from the input received from the + * abstract data format. + * + * @param mName module name + * @param curSchema current schema + * @param ctx schema context + * @param mUri module URI + * @param pNode properties node + * @return namespace + * @throws SvcLogicException when resolving namespace fails + */ + static Namespace getResolvedNamespace(String mName, SchemaNode curSchema, + SchemaContext ctx, String mUri, + PropertiesNode pNode) + throws SvcLogicException { + Module m = null; + URI namespace = curSchema.getQName().getNamespace(); + + if (mName != null) { + m = ctx.findModule(mName).get(); + namespace = m == null ? null : m.getNamespace(); + } + if (mUri != null) { + try { + m = ctx.findModule(new URI(mUri)).get(); + } catch (URISyntaxException e) { + throw new SvcLogicException(URI_ERR, e); + } + namespace = m == null ? null : m.getNamespace(); + mName = m.getName(); + } + + if (mName == null && mUri == null) { + return pNode.namespace(); + } + + return new Namespace(mName, namespace, getRevision(m.getRevision())); + } + + /** + * Returns the node type of a XML element. + * + * @param element XML element + * @return node type of the XML element + */ + static XmlNodeType getXmlNodeType(Element element) { + Element newElement = element.createCopy(); + newElement.remove(element.getNamespace()); + return newElement.hasContent() && newElement.isTextOnly() ? + TEXT_NODE : OBJECT_NODE; + } + + /** + * Resolves the super type to the base type from type definition. + * + * @param type super type + * @return base type definition + */ + static TypeDefinition resolveBaseTypeFrom(TypeDefinition type) { + TypeDefinition superType; + for(superType = type; superType.getBaseType() != null; + superType = superType.getBaseType()) { + } + return superType; + } + +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonListener.java index 2a9220ac1..89fd4c8c8 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonListener.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonListener.java @@ -21,6 +21,7 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; import com.fasterxml.jackson.databind.JsonNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType; /** @@ -38,14 +39,17 @@ public interface JsonListener extends Listener { * @param nodeName JSON node name * @param node JSON node * @param nodeType JSON node type + * @throws SvcLogicException when node type is of wrong format */ - void enterJsonNode(String nodeName, JsonNode node, NodeType nodeType); + void enterJsonNode(String nodeName, JsonNode node, NodeType nodeType) + throws SvcLogicException; /** * Call back invoked during JSON node exit. All the related information * can be obtained from the JSON node. * * @param node JSON node + * @throws SvcLogicException when JSON node exit doesn't happen */ - void exitJsonNode(JsonNode node); + void exitJsonNode(JsonNode node) throws SvcLogicException; } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java index b562e71db..1be1309bb 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java @@ -20,10 +20,20 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.DefaultPropertiesNodeWalker; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNodeWalker; + +import java.io.IOException; +import java.io.Writer; import java.util.List; import java.util.Map; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormat.JSON; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.*; /** * Representation of JSON serializer which encodes properties to JSON and @@ -42,14 +52,38 @@ public class JsonSerializer extends DataFormatSerializer { @Override public String encode(Map param, - Map> annotations) { - //TODO: Implementation code. - return null; + Map> annotations) + throws SvcLogicException { + PropertiesNode propNode = serializerContext().getPropNodeSerializer() + .encode(param); + PropertiesNodeWalker nodeWalker = new DefaultPropertiesNodeWalker<>(); + PropertiesNodeJsonListener jsonLis = new PropertiesNodeJsonListener(); + nodeWalker.walk(jsonLis, propNode); + Writer writer = jsonLis.getWriter(); + return writer.toString(); } @Override - public Map decode(String dataFormatBody) { - //TODO: Implementation code. - return null; + public Map decode(String dataFormatBody) + throws SvcLogicException { + if (!(serializerContext().listener() instanceof JsonListener)) { + throw new SvcLogicException(JSON_LIS_ERR); + } + + JsonListener listener = (JsonListener) serializerContext().listener(); + JsonWalker walker = new DefaultJsonWalker(); + ObjectMapper mapper = new ObjectMapper(); + JsonNode jsonNode; + + try { + jsonNode = mapper.readTree(dataFormatBody); + } catch (IOException e) { + throw new SvcLogicException(JSON_TREE_ERR, e); + } + + walker.walk(listener, jsonNode); + + return serializerContext().getPropNodeSerializer().decode( + listener.serializerHelper().getPropertiesNode()); } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonWalker.java index e3fb4d513..588070a12 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonWalker.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonWalker.java @@ -21,6 +21,7 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; import com.fasterxml.jackson.databind.JsonNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; /** * Abstraction of an entity which provides interface for JSON walk. This @@ -36,6 +37,8 @@ public interface JsonWalker { * * @param listener JSON listener implemented by the protocol * @param jsonNode root node of the JSON data tree + * @throws SvcLogicException when walking the JSON node fails */ - void walk(JsonListener listener, JsonNode jsonNode); + void walk(JsonListener listener, JsonNode jsonNode) + throws SvcLogicException; } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java index 1f8195e2d..a3e30c4b7 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java @@ -20,10 +20,36 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.Namespace; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.RootNode; +import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; +import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; +import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaNode; +import org.opendaylight.yangtools.yang.model.api.TypeDefinition; +import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition; + +import java.util.Deque; + +import static java.lang.String.format; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.DF_ERR; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.NODE_TYPE_ERR; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.PROP_NODE_ERR; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.getResolvedNamespace; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.resolveBaseTypeFrom; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getRevision; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_HOLDER_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_LEAF_HOLDER_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_LEAF_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.SINGLE_INSTANCE_LEAF_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.SINGLE_INSTANCE_NODE; +import static org.opendaylight.yangtools.yang.data.util.ParserStreamUtils.findSchemaNodeByNameAndNamespace; /** * Representation of MDSAL based serializer helper, which adds properties @@ -53,6 +79,12 @@ public class MdsalSerializerHelper extends SerializerHelper(n.getQName().getLocalName(), ns, + getSchemaNode(), u); + curSchemaNode = getSchemaNode(); } @Override @@ -72,18 +104,166 @@ public class MdsalSerializerHelper extends SerializerHelper baseType = resolveBaseTypeFrom(type); + if (baseType instanceof IdentityrefTypeDefinition) { + if (nodeType == null) { + ns = getResolvedNamespace(null,schemaNode, getSchemaCtx(), + valNs, propNode); + } else { + ns = getResolvedNamespace(valNs, schemaNode, getSchemaCtx(), + null, propNode); + } + } + } + return ns; + } + + /** + * Validates that the node type from the data format matches with that of + * the corresponding schema node. + * + * @param type node type from the abstract data format + * @throws SvcLogicException when the node type is wrong + */ + private void validateNodeType(NodeType type) throws SvcLogicException { + boolean verify; + switch (type) { + case SINGLE_INSTANCE_LEAF_NODE: + verify = curSchemaNode instanceof LeafSchemaNode; + break; + + case MULTI_INSTANCE_LEAF_NODE: + verify = curSchemaNode instanceof LeafListSchemaNode; + break; + + case MULTI_INSTANCE_NODE: + verify = curSchemaNode instanceof ListSchemaNode; + break; + + case SINGLE_INSTANCE_NODE: + verify = (!(curSchemaNode instanceof LeafSchemaNode) && + !(curSchemaNode instanceof LeafListSchemaNode) && + !(curSchemaNode instanceof ListSchemaNode)); + break; + + default: + throw new SvcLogicException(format(NODE_TYPE_ERR, + type.toString())); + } + if (!verify) { + throw new SvcLogicException(format(DF_ERR, curSchemaNode + .getQName().getLocalName(), type.toString())); + } + } + + /** + * Returns true if the child schema is present with the name and + * namespace inside the current schema node, if present updates the + * current schema node; false otherwise. + * + * @param name name of the child schema node + * @param namespace namespace of the child schema node + * @return returns true if the child schema is available; false otherwise + */ + private boolean isChildPresent(String name, Namespace namespace) { + Deque dataSchema = findSchemaNodeByNameAndNamespace( + (DataSchemaNode) curSchemaNode, name, namespace.moduleNs()); + if (dataSchema != null) { + DataSchemaNode node = dataSchema.pop(); + if (node != null) { + curSchemaNode = node; + return true; + } + } + return false; } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeJsonListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeJsonListener.java index ec1306731..e51ccf7a6 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeJsonListener.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeJsonListener.java @@ -21,10 +21,24 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; import com.google.gson.stream.JsonWriter; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.DefaultPropertiesNodeWalker; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.LeafNode; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.Namespace; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNodeListener; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.RootNode; +import java.io.IOException; +import java.io.StringWriter; import java.io.Writer; +import java.util.Collection; +import java.util.Map; + +import static com.google.common.base.Strings.repeat; +import static java.lang.String.format; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.JSON_WRITE_ERR; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.NODE_TYPE_ERR; /** * Representation of JSON implementation of properties node listener. @@ -46,25 +60,160 @@ public class PropertiesNodeJsonListener implements PropertiesNodeListener{ * indenting the writer. */ public PropertiesNodeJsonListener() { + writer = new StringWriter(); + jsonWriter = new JsonWriter(writer); + jsonWriter.setIndent(repeat(" ", 4)); } @Override - public void start(PropertiesNode node) { - //TODO: Implementation code. + public void start(PropertiesNode node) throws SvcLogicException { + try { + jsonWriter.beginObject(); + } catch (IOException e) { + throw new SvcLogicException(JSON_WRITE_ERR, e); + } } @Override - public void end(PropertiesNode node) { - //TODO: Implementation code. + public void end(PropertiesNode node) throws SvcLogicException { + try { + jsonWriter.endObject(); + jsonWriter.flush(); + } catch (IOException e) { + throw new SvcLogicException(JSON_WRITE_ERR, e); + } } @Override - public void enterPropertiesNode(PropertiesNode node) { - //TODO: Implementation code. + public void enterPropertiesNode(PropertiesNode node) + throws SvcLogicException { + String val; + String nodeName = getNodeName(node); + try { + switch (node.nodeType()) { + case SINGLE_INSTANCE_NODE: + jsonWriter.name(nodeName); + jsonWriter.beginObject(); + break; + + case MULTI_INSTANCE_NODE: + jsonWriter.beginObject(); + break; + + case SINGLE_INSTANCE_LEAF_NODE: + val = getValueWithNs((LeafNode) node); + jsonWriter.name(nodeName).value(val); + break; + + case MULTI_INSTANCE_HOLDER_NODE: + case MULTI_INSTANCE_LEAF_HOLDER_NODE: + jsonWriter.name(nodeName); + jsonWriter.beginArray(); + break; + + case MULTI_INSTANCE_LEAF_NODE: + val = getValueWithNs((LeafNode) node); + jsonWriter.value(val); + break; + + default: + throw new SvcLogicException(format( + NODE_TYPE_ERR, node.nodeType().toString())); + + } + } catch (IOException e) { + throw new SvcLogicException(JSON_WRITE_ERR, e); + } } @Override - public void exitPropertiesNode(PropertiesNode node) { - //TODO: Implementation code. + public void exitPropertiesNode(PropertiesNode node) throws SvcLogicException { + walkAugmentationNode(node); + try { + switch (node.nodeType()) { + case SINGLE_INSTANCE_NODE: + case MULTI_INSTANCE_NODE: + jsonWriter.endObject(); + break; + + case MULTI_INSTANCE_HOLDER_NODE: + case MULTI_INSTANCE_LEAF_HOLDER_NODE: + jsonWriter.endArray(); + break; + + case SINGLE_INSTANCE_LEAF_NODE: + case MULTI_INSTANCE_LEAF_NODE: + break; + + default: + throw new SvcLogicException(format( + NODE_TYPE_ERR, node.nodeType().toString())); + } + } catch (IOException e) { + throw new SvcLogicException(JSON_WRITE_ERR, e); + } + } + + /** + * Returns the writer. + * + * @return writer + */ + public Writer getWriter() { + return writer; + } + + /** + * Returns the abstract JSON node name to be used in JSON data format + * from the properties node. + * + * @param node properties node + * @return abstract JSON node + */ + private String getNodeName(PropertiesNode node) { + PropertiesNode parent = node.parent(); + if (parent instanceof RootNode || !parent.namespace().moduleName() + .equals(node.namespace().moduleName())) { + return node.namespace().moduleName() + ":" + node.name(); + } + return node.name(); + } + + /** + * Returns the value of JSON leaf node with module name if required. + * + * @param node properties node + * @return value with namespace + */ + private String getValueWithNs(LeafNode node) { + Namespace valNs = node.valueNs(); + String modName = (valNs == null) ? null : valNs.moduleName(); + if (modName != null) { + return modName + ":" + node.value(); + } + return node.value(); + } + + /** + * Gets all the augmentation of the given node and walks through it. + * + * @param node properties node + * @throws SvcLogicException when walking the properties node fails + */ + private void walkAugmentationNode(PropertiesNode node) + throws SvcLogicException { + for (Map.Entry> + augToChild : node.augmentations().asMap().entrySet()) { + Collection augChild = augToChild.getValue(); + if (!augChild.isEmpty()) { + DefaultPropertiesNodeWalker walker = new + DefaultPropertiesNodeWalker(); + for (PropertiesNode p : augChild) { + enterPropertiesNode(p); + walker.walkChildNode(this, p); + exitPropertiesNode(p); + } + } + } } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeXmlListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeXmlListener.java index cfc59ca10..cf59b7794 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeXmlListener.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeXmlListener.java @@ -20,13 +20,29 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; +import org.dom4j.Document; +import org.dom4j.DocumentHelper; import org.dom4j.Element; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.DefaultPropertiesNodeWalker; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.LeafNode; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.Namespace; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNodeListener; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.RootNode; import java.io.Writer; +import java.net.URI; +import java.util.Collection; +import java.util.Map; import java.util.Stack; +import static java.lang.String.format; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.NODE_TYPE_ERR; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.UTF_HEADER; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.XML_PREFIX; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.getXmlWriter; + /** * Representation of XML implementation of properties node listener. */ @@ -60,21 +76,169 @@ public class PropertiesNodeXmlListener implements PropertiesNodeListener { @Override public void start(PropertiesNode node) { - //TODO: Implementation code. + //Do Nothing. } @Override - public void end(PropertiesNode node) { - //TODO: Implementation code. + public void end(PropertiesNode node) throws SvcLogicException { + xmlData = UTF_HEADER + xmlData; + writer = getXmlWriter(xmlData, "4"); } @Override - public void enterPropertiesNode(PropertiesNode node) { - //TODO: Implementation code. + public void enterPropertiesNode(PropertiesNode node) + throws SvcLogicException { + Element element = null; + String ns = getNodeNamespace(node); + switch (node.nodeType()) { + case MULTI_INSTANCE_LEAF_HOLDER_NODE: + case MULTI_INSTANCE_HOLDER_NODE: + break; + + case SINGLE_INSTANCE_NODE: + case MULTI_INSTANCE_NODE: + element = addElement(ns, node); + break; + + case MULTI_INSTANCE_LEAF_NODE: + case SINGLE_INSTANCE_LEAF_NODE: + element = addElement(ns, node); + setValueWithNs(element, (LeafNode) node); + break; + + default: + throw new SvcLogicException(format( + NODE_TYPE_ERR, node.nodeType().toString())); + } + if (element != null) { + if (elementStack.isEmpty()) { + rootElement = element; + } + elementStack.push(element); + } } @Override - public void exitPropertiesNode(PropertiesNode node) { - //TODO: Implementation code. + public void exitPropertiesNode(PropertiesNode node) + throws SvcLogicException { + walkAugmentationNode(node); + switch (node.nodeType()) { + case MULTI_INSTANCE_LEAF_HOLDER_NODE: + case MULTI_INSTANCE_HOLDER_NODE: + break; + + case SINGLE_INSTANCE_NODE: + case MULTI_INSTANCE_NODE: + case MULTI_INSTANCE_LEAF_NODE: + case SINGLE_INSTANCE_LEAF_NODE: + if (!elementStack.isEmpty() && + elementStack.peek().equals(rootElement)) { + xmlData = rootElement.asXML(); + } else { + elementStack.pop(); + } + break; + + default: + throw new SvcLogicException(format( + NODE_TYPE_ERR, node.nodeType().toString())); + } + } + + /** + * Returns the writer. + * + * @return writer + */ + public Writer getWriter() { + return writer; + } + + /** + * Adds an XML element to the stack with namespace if present. If the + * stack is empty it creates new document and adds element else adds to + * the parent element. + * + * @param ns namespace of the element + * @param node properties node + * @return new added element + */ + private Element addElement(String ns, PropertiesNode node) { + Element element; + if (elementStack.isEmpty()) { + Document doc = DocumentHelper.createDocument(); + if (ns != null) { + element = doc.addElement(node.name(), ns); + } else { + element = doc.addElement(node.name()); + } + } else { + element = elementStack.peek(); + if (ns != null) { + element = element.addElement(node.name(), ns); + } else { + element = element.addElement(node.name()); + } + } + + return element; + } + + /** + * Returns the abstract XML namespace to be used in XML data format from + * the properties node. + * + * @param node properties node + * @return abstract XML namespace + */ + private String getNodeNamespace(PropertiesNode node) { + PropertiesNode parent = node.parent(); + if (parent instanceof RootNode || !parent.namespace().moduleName() + .equals(node.namespace().moduleName())) { + return node.namespace().moduleNs().toString(); + } + return null; + } + + /** + * Sets the value to the element for a leaf node and adds the value + * namespace if required. + * + * @param element XML element + * @param node leaf properties node + */ + private void setValueWithNs(Element element, LeafNode node) { + Namespace valNs = node.valueNs(); + URI modNs = (valNs == null) ? null : valNs.moduleNs(); + String val = node.value(); + if (modNs != null) { + element.addNamespace(XML_PREFIX, modNs.toString()); + element.setText(XML_PREFIX + ":" + val); + } else { + element.setText(val); + } + } + + /** + * Gets all the augmentation of the given node and walks through it. + * + * @param node properties node + * @throws SvcLogicException when walking the properties node fails + */ + private void walkAugmentationNode(PropertiesNode node) + throws SvcLogicException { + for (Map.Entry> + augToChild : node.augmentations().asMap().entrySet()) { + Collection augChild = augToChild.getValue(); + if (!augChild.isEmpty()) { + DefaultPropertiesNodeWalker walker = new + DefaultPropertiesNodeWalker(); + for (PropertiesNode p : augChild) { + enterPropertiesNode(p); + walker.walkChildNode(this, p); + exitPropertiesNode(p); + } + } + } } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/SerializerHelper.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/SerializerHelper.java index 2466023fa..db9befb21 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/SerializerHelper.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/SerializerHelper.java @@ -20,6 +20,7 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; @@ -92,15 +93,19 @@ public abstract class SerializerHelper { * @param valNameSpace value namespace for identityref, could be module * name or namespace * @param type type of node if known like in case of JSON + * @throws SvcLogicException when adding node fails */ protected abstract void addNode(String name, String nameSpace, String value, - String valNameSpace, NodeType type); + String valNameSpace, NodeType type) + throws SvcLogicException; /** * Exits the node, in case if it's leaf node then it adds to the properties * map. + * + * @throws SvcLogicException when properties node tree is improper */ - protected abstract void exitNode(); + protected abstract void exitNode() throws SvcLogicException; /** * Returns the built properties corresponding to the data. diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlListener.java index 0fbf4c338..784e7af1f 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlListener.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlListener.java @@ -21,6 +21,7 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; import org.dom4j.Element; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; /** * Abstraction of an entity which provides call back methods, which in turn @@ -36,14 +37,17 @@ public interface XmlListener extends Listener { * * @param element current XML element * @param nodeType node type of the element + * @throws SvcLogicException when node type is of wrong format */ - void enterXmlElement(Element element, XmlNodeType nodeType); + void enterXmlElement(Element element, XmlNodeType nodeType) + throws SvcLogicException; /** * Callback invoked during a node exit. All the related information about * the node can be obtained from the element. * * @param element current xml element. + * @throws SvcLogicException when XML node exit doesn't happen */ - void exitXmlElement(Element element); + void exitXmlElement(Element element) throws SvcLogicException; } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java index 516470059..6eeb4b82c 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java @@ -20,10 +20,21 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.DefaultPropertiesNodeWalker; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNodeWalker; + +import java.io.Writer; import java.util.List; import java.util.Map; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormat.XML; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.XML_LIS_ERR; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.XML_TREE_ERR; /** * Representation of XML serializer which encodes properties to XML and @@ -42,14 +53,36 @@ public class XmlSerializer extends DataFormatSerializer { @Override public String encode(Map param, - Map> annotations) { - //TODO: Implementation code. - return null; + Map> annotations) + throws SvcLogicException { + PropertiesNode propNode = serializerContext().getPropNodeSerializer() + .encode(param); + PropertiesNodeWalker nodeWalker = new DefaultPropertiesNodeWalker<>(); + PropertiesNodeXmlListener xmlListener = new PropertiesNodeXmlListener(); + nodeWalker.walk(xmlListener, propNode); + Writer writer = xmlListener.getWriter(); + return writer.toString(); } @Override - public Map decode(String dataFormatBody) { - //TODO: Implementation code. - return null; + public Map decode(String dataFormatBody) + throws SvcLogicException { + if (!(serializerContext().listener() instanceof XmlListener)) { + throw new SvcLogicException(XML_LIS_ERR); + } + + XmlListener listener = (XmlListener) serializerContext().listener(); + XmlWalker walker = new DefaultXmlWalker(); + Document document; + + try { + document = DocumentHelper.parseText(dataFormatBody); + } catch (DocumentException e) { + throw new SvcLogicException(XML_TREE_ERR, e); + } + walker.walk(listener, document.getRootElement()); + + return serializerContext().getPropNodeSerializer().decode( + listener.serializerHelper().getPropertiesNode()); } } \ No newline at end of file diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlWalker.java index 6fed510a3..3835faa7e 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlWalker.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlWalker.java @@ -21,6 +21,7 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; import org.dom4j.Element; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; /** * Abstraction of an entity which provides interface for XML walk. This @@ -36,6 +37,8 @@ public interface XmlWalker { * * @param listener XML listener implemented by the protocol * @param xmlElement root element of the XML data tree + * @throws SvcLogicException when walking the XML node fails */ - void walk(XmlListener listener, Element xmlElement); + void walk(XmlListener listener, Element xmlElement) throws + SvcLogicException; } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java index a8a9b4935..d91209121 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java @@ -20,6 +20,8 @@ package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -40,7 +42,7 @@ public class DefaultPropertiesNodeListener implements PropertiesNodeListener { } @Override - public void end(PropertiesNode node) { + public void end(PropertiesNode node) throws SvcLogicException { exitPropertiesNode(node); } @@ -57,7 +59,8 @@ public class DefaultPropertiesNodeListener implements PropertiesNodeListener { } @Override - public void exitPropertiesNode(PropertiesNode node) { + public void exitPropertiesNode(PropertiesNode node) throws + SvcLogicException { if (!node.augmentations().isEmpty()) { for (Map.Entry> augmentationTochild : node.augmentations().asMap().entrySet()) { diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeWalker.java index 041210f22..8497805c2 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeWalker.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeWalker.java @@ -20,6 +20,8 @@ package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + import java.util.Map; /** @@ -31,7 +33,7 @@ public class DefaultPropertiesNodeWalker implements Propert @Override public void walk(PropertiesNodeListener listener, - PropertiesNode propertiesNode) { + PropertiesNode propertiesNode) throws SvcLogicException { listener.start(propertiesNode); walkChildNode(listener, propertiesNode); listener.end(propertiesNode); @@ -42,9 +44,11 @@ public class DefaultPropertiesNodeWalker implements Propert * * @param listener properties node listener * @param propertiesNode properties node + * @throws SvcLogicException when properties node walking fails */ public void walkChildNode(PropertiesNodeListener listener, - PropertiesNode propertiesNode) { + PropertiesNode propertiesNode) + throws SvcLogicException { Map children = getChildren(propertiesNode); if (children != null) { for (Map.Entry entry : children.entrySet()) { diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java index 20b06d0bc..c24146267 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java @@ -86,7 +86,8 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer decode(PropertiesNode propertiesNode) { + public Map decode(PropertiesNode propertiesNode) + throws SvcLogicException { PropertiesNodeWalker walker = new DefaultPropertiesNodeWalker<>(); DefaultPropertiesNodeListener listener = new DefaultPropertiesNodeListener(); walker.walk(listener, propertiesNode); diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeListener.java index 5bf7fe9dc..7b97ffaf8 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeListener.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeListener.java @@ -20,6 +20,8 @@ package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + /** * Abstraction of properties node listener. */ @@ -29,27 +31,31 @@ public interface PropertiesNodeListener { * Pre-configurations required before starting the walking. * * @param node properties node + * @throws SvcLogicException when the pre-configuration fails */ - void start(PropertiesNode node); + void start(PropertiesNode node) throws SvcLogicException; /** * Post-configurations required after starting the walking. * * @param node properties node + * @throws SvcLogicException when the post-configuration fails */ - void end(PropertiesNode node); + void end(PropertiesNode node) throws SvcLogicException; /** * Enters the properties node. * * @param node properties node + * @throws SvcLogicException when entering the properties node fails */ - void enterPropertiesNode(PropertiesNode node); + void enterPropertiesNode(PropertiesNode node) throws SvcLogicException; /** * Enters the properties node. * * @param node properties node + * @throws SvcLogicException when exiting the properties node fails */ - void exitPropertiesNode(PropertiesNode node); + void exitPropertiesNode(PropertiesNode node) throws SvcLogicException; } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeSerializer.java index 3e3483721..fe6fed484 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeSerializer.java @@ -77,10 +77,11 @@ public abstract class PropertiesNodeSerializer { * Decodes from properties-node to properties map. * * @param propertiesNode properties-node - * @throws SvcLogicException fails to decode properties node to properties * @return parameter map + * @throws SvcLogicException fails to decode properties node to properties */ - public abstract Map decode(PropertiesNode propertiesNode) throws SvcLogicException; + public abstract Map decode(PropertiesNode propertiesNode) + throws SvcLogicException; /** * Returns the schema node of the property diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeWalker.java index 48433e2b2..36ee4dd9d 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeWalker.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesNodeWalker.java @@ -20,16 +20,19 @@ package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + /** * Abstraction of properties node walker */ public interface PropertiesNodeWalker { - /** * Walks the properties node with the listener. * * @param listener properties node listener. * @param propertiesNode properties node + * @throws SvcLogicException when walking the properties node fails */ - void walk(PropertiesNodeListener listener, PropertiesNode propertiesNode); + void walk(PropertiesNodeListener listener, PropertiesNode propertiesNode) + throws SvcLogicException; } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/RootNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/RootNode.java index 7d9035e06..c7f7340fd 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/RootNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/RootNode.java @@ -44,7 +44,15 @@ public class RootNode extends PropertiesNode { private Map children = new HashMap(); - protected RootNode(String name, Namespace namespace, + /** + * Creates an instance of the root node to build the properties. + * + * @param name name of the node + * @param namespace namespace of the node + * @param appInfo application info + * @param uri URI of the node + */ + public RootNode(String name, Namespace namespace, Object appInfo, String uri) { super(name, namespace, uri, null, appInfo, null); } -- cgit From 671c85f81d5263cc64309e4e97dd5c8a0ee1465c Mon Sep 17 00:00:00 2001 From: gaurav Date: Tue, 21 Aug 2018 19:00:55 +0530 Subject: Update 3rd party dependency version Updated 3rd party dependency version for RestconfClient. Change-Id: If5bf93030ae98ea5479ba1f70e1cb22e900a7f5d Issue-ID: CCSDK-325 Signed-off-by: Gaurav Agrawal --- restconf-client/provider/pom.xml | 59 ++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 2b5be877a..4183d48be 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 @@ -21,11 +22,6 @@ - - junit - junit - test - org.springframework spring-beans @@ -37,30 +33,13 @@ org.glassfish.jersey.media jersey-media-sse - 2.27 - provided + ${glassfish.version} javax.ws.rs javax.ws.rs-api 2.1 - - org.glassfish.jersey.inject - jersey-hk2 - 2.27 - - - org.glassfish.jersey.containers - jersey-container-servlet - 2.27 - - - org.glassfish.jersey.containers - jersey-container-grizzly2-http - 2.27 - test - org.onap.ccsdk.sli.core sli-common @@ -73,7 +52,7 @@ org.opendaylight.yangtools yang-data-impl - 2.0.3 + 2.0.6.1 com.fasterxml.jackson.core @@ -87,13 +66,39 @@ com.google.code.gson gson - 2.7 + ${gson.version} org.onap.ccsdk.sli.plugins restapi-call-node-provider 0.3.0-SNAPSHOT + + + + + junit + junit + test + + + org.glassfish.jersey.inject + jersey-hk2 + ${glassfish.version} + test + + + org.glassfish.jersey.containers + jersey-container-servlet + ${glassfish.version} + test + + + org.glassfish.jersey.containers + jersey-container-grizzly2-http + ${glassfish.version} + test + org.hamcrest hamcrest-library @@ -103,7 +108,7 @@ org.opendaylight.yangtools yang-test-util - 2.0.3 + 2.0.6.1 test -- cgit From c8a20b7cdc2b563e1ea86a9e25f4ac0e748995f9 Mon Sep 17 00:00:00 2001 From: janani b Date: Wed, 29 Aug 2018 11:52:41 +0530 Subject: Implementation for Restconf api call node Restconf Api Call Node Issue-ID: CCSDK-372 Change-Id: I1820e97d54e734ccf73c6f48a9afcc4b59dff549 Signed-off-by: janani b --- .../sli/plugins/restapicall/RestapiCallNode.java | 171 ++++++---- restconf-client/provider/pom.xml | 17 +- .../restconfapicall/RestconfApiCallNode.java | 362 +++++++++++++++++++++ .../plugins/restconfapicall/RestconfApiUtils.java | 213 ++++++++++++ .../restconfapicall/RestconfapiCallNode.java | 65 ---- .../restconfdiscovery/RestconfDiscoveryNode.java | 14 +- .../dfserializer/MdsalSerializerHelper.java | 4 +- .../META-INF/spring/restconf-client-context.xml | 4 +- .../spring/restconf-client-osgi-context.xml | 2 +- .../blueprint/restconf-client-blueprint.xml | 4 +- 10 files changed, 720 insertions(+), 136 deletions(-) create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java delete mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfapiCallNode.java diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 46c74ff8a..6a9e81bcc 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -21,8 +21,33 @@ package org.onap.ccsdk.sli.plugins.restapicall; +import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientHandlerException; +import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.client.config.DefaultClientConfig; +import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; +import com.sun.jersey.api.client.filter.HTTPDigestAuthFilter; +import com.sun.jersey.client.urlconnection.HTTPSProperties; +import com.sun.jersey.oauth.client.OAuthClientFilter; +import com.sun.jersey.oauth.signature.OAuthParameters; +import com.sun.jersey.oauth.signature.OAuthSecrets; +import org.apache.commons.lang3.StringUtils; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.ws.rs.core.EntityTag; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.UriBuilder; import java.io.FileInputStream; import java.io.IOException; import java.net.SocketException; @@ -40,34 +65,8 @@ import java.util.Map.Entry; import java.util.Properties; import java.util.Set; -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.ws.rs.core.EntityTag; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriBuilder; - -import org.apache.commons.lang3.StringUtils; -import org.codehaus.jettison.json.JSONException; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; -import com.sun.jersey.api.client.filter.HTTPDigestAuthFilter; -import com.sun.jersey.oauth.client.OAuthClientFilter; -import com.sun.jersey.oauth.signature.OAuthParameters; -import com.sun.jersey.oauth.signature.OAuthSecrets; -import com.sun.jersey.client.urlconnection.HTTPSProperties; +import static java.lang.Boolean.valueOf; +import static org.onap.ccsdk.sli.plugins.restapicall.AuthType.fromString; public class RestapiCallNode implements SvcLogicJavaPlugin { @@ -81,7 +80,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { protected static final String DEFAULT_PROPERTIES_DIR = "/opt/onap/ccsdk/data/properties"; protected static final String PROPERTIES_DIR_KEY = "SDNC_CONFIG_DIR"; - protected RetryPolicyStore getRetryPolicyStore() { + public RetryPolicyStore getRetryPolicyStore() { return retryPolicyStore; } @@ -154,7 +153,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { RetryPolicy retryPolicy = null; HttpResponse r = new HttpResponse(); try { - Parameters p = getParameters(paramMap); + Parameters p = getParameters(paramMap, new Parameters()); if (p.partner != null) { retryPolicy = retryPolicyStore.getRetryPolicy(p.partner); } @@ -245,49 +244,88 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); } - protected Parameters getParameters(Map paramMap) throws SvcLogicException { - Parameters p = new Parameters(); - p.templateFileName = parseParam(paramMap, "templateFileName", false, null); + /** + * Returns parameters from the parameter map. + * + * @param paramMap parameter map + * @param p parameters instance + * @return parameters filed instance + * @throws SvcLogicException when svc logic exception occurs + */ + public static Parameters getParameters(Map paramMap, + Parameters p) + throws SvcLogicException { + p.templateFileName = parseParam(paramMap, "templateFileName", + false, null); p.requestBody = parseParam(paramMap, "requestBody", false, null); p.restapiUrl = parseParam(paramMap, "restapiUrl", true, null); validateUrl(p.restapiUrl); p.restapiUser = parseParam(paramMap, "restapiUser", false, null); - p.restapiPassword = parseParam(paramMap, "restapiPassword", false, null); - p.oAuthConsumerKey = parseParam(paramMap, "oAuthConsumerKey", false, null); - p.oAuthConsumerSecret = parseParam(paramMap, "oAuthConsumerSecret", false, null); - p.oAuthSignatureMethod = parseParam(paramMap, "oAuthSignatureMethod", false, null); + p.restapiPassword = parseParam(paramMap, "restapiPassword", false, + null); + p.oAuthConsumerKey = parseParam(paramMap, "oAuthConsumerKey", + false, null); + p.oAuthConsumerSecret = parseParam(paramMap, "oAuthConsumerSecret", + false, null); + p.oAuthSignatureMethod = parseParam(paramMap, "oAuthSignatureMethod", + false, null); p.oAuthVersion = parseParam(paramMap, "oAuthVersion", false, null); p.contentType = parseParam(paramMap, "contentType", false, null); - p.format = Format.fromString(parseParam(paramMap, "format", false, "json")); - p.authtype = AuthType.fromString(parseParam(paramMap, "authType", false, "unspecified")); - p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post")); + p.format = Format.fromString(parseParam(paramMap, "format", false, + "json")); + p.authtype = fromString(parseParam(paramMap, "authType", false, + "unspecified")); + p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", + false, "post")); p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); p.listNameList = getListNameList(paramMap); String skipSendingStr = paramMap.get("skipSending"); p.skipSending = "true".equalsIgnoreCase(skipSendingStr); - p.convertResponse = Boolean.valueOf(parseParam(paramMap, "convertResponse", false, "true")); - p.trustStoreFileName = parseParam(paramMap, "trustStoreFileName", false, null); - p.trustStorePassword = parseParam(paramMap, "trustStorePassword", false, null); - p.keyStoreFileName = parseParam(paramMap, "keyStoreFileName", false, null); - p.keyStorePassword = parseParam(paramMap, "keyStorePassword", false, null); - p.ssl = p.trustStoreFileName != null && p.trustStorePassword != null && p.keyStoreFileName != null && - p.keyStorePassword != null; - p.customHttpHeaders = parseParam(paramMap, "customHttpHeaders", false, null); + p.convertResponse = valueOf(parseParam(paramMap, "convertResponse", + false, "true")); + p.trustStoreFileName = parseParam(paramMap, "trustStoreFileName", + false, null); + p.trustStorePassword = parseParam(paramMap, "trustStorePassword", + false, null); + p.keyStoreFileName = parseParam(paramMap, "keyStoreFileName", + false, null); + p.keyStorePassword = parseParam(paramMap, "keyStorePassword", + false, null); + p.ssl = p.trustStoreFileName != null && p.trustStorePassword != null + && p.keyStoreFileName != null && p.keyStorePassword != null; + p.customHttpHeaders = parseParam(paramMap, "customHttpHeaders", + false, null); p.partner = parseParam(paramMap, "partner", false, null); - p.dumpHeaders = Boolean.valueOf(parseParam(paramMap, "dumpHeaders", false, null)); - p.returnRequestPayload = Boolean.valueOf(parseParam(paramMap, "returnRequestPayload", false, null)); + p.dumpHeaders = valueOf(parseParam(paramMap, "dumpHeaders", + false, null)); + p.returnRequestPayload = valueOf(parseParam( + paramMap, "returnRequestPayload", false, null)); return p; } - private void validateUrl(String restapiUrl) throws SvcLogicException { + /** + * Validates the given URL in the parameters. + * + * @param restapiUrl rest api URL + * @throws SvcLogicException when URL validation fails + */ + private static void validateUrl(String restapiUrl) + throws SvcLogicException { try { URI.create(restapiUrl); } catch (IllegalArgumentException e) { - throw new SvcLogicException("Invalid input of url " + e.getLocalizedMessage(), e); + throw new SvcLogicException("Invalid input of url " + + e.getLocalizedMessage(), e); } } - protected Set getListNameList(Map paramMap) { + /** + * Returns the list of list name. + * + * @param paramMap parameters map + * @return list of list name + */ + private static Set getListNameList(Map paramMap) { Set ll = new HashSet<>(); for (Map.Entry entry : paramMap.entrySet()) if (entry.getKey().startsWith("listName")) @@ -295,7 +333,19 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { return ll; } - protected String parseParam(Map paramMap, String name, boolean required, String def) + /** + * Parses the parameter string map of property, validates if required, + * assigns default value if present and returns the value. + * + * @param paramMap string param map + * @param name name of the property + * @param required if value required + * @param def default value + * @return value of the property + * @throws SvcLogicException if required parameter value is empty + */ + public static String parseParam(Map paramMap, String name, + boolean required, String def) throws SvcLogicException { String s = paramMap.get(name); @@ -524,7 +574,16 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { return client; } - protected HttpResponse sendHttpRequest(String request, Parameters p) throws SvcLogicException { + /** + * Receives the http response for the http request sent. + * + * @param request request msg + * @param p parameters + * @return HTTP response + * @throws SvcLogicException when sending http request fails + */ + public HttpResponse sendHttpRequest(String request, Parameters p) + throws SvcLogicException { ClientConfig config = new DefaultClientConfig(); SSLContext ssl = null; @@ -693,7 +752,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { p.oAuthVersion = parseParam(paramMap, "oAuthVersion", false, null); p.oAuthConsumerSecret = parseParam(paramMap, "oAuthConsumerSecret", false, null); p.oAuthSignatureMethod = parseParam(paramMap, "oAuthSignatureMethod", false, null); - p.authtype = AuthType.fromString(parseParam(paramMap, "authType", false, "unspecified")); + p.authtype = fromString(parseParam(paramMap, "authType", false, "unspecified")); return p; } diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 4183d48be..099412642 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -114,8 +114,23 @@ org.opendaylight.netconf restconf-nb-rfc8040 - 1.7.4-SNAPSHOT + 1.7.3 test + + org.opendaylight.yangtools + yang-parser-impl + 2.0.6.1 + + + org.opendaylight.netconf + restconf-common + 1.7.3 + + + org.opendaylight.netconf + restconf-nb-bierman02 + 1.7.3 + diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java new file mode 100644 index 000000000..c5f73305b --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java @@ -0,0 +1,362 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.restconfapicall; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.plugins.restapicall.HttpResponse; +import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; +import org.onap.ccsdk.sli.plugins.restapicall.RetryException; +import org.onap.ccsdk.sli.plugins.restapicall.RetryPolicy; +import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatSerializer; +import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatSerializerContext; +import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerFactory; +import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.Listener; +import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.MdsalSerializerHelper; +import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.SerializerHelper; +import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.YangParameters; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeSerializer; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNodeSerializer; +import org.opendaylight.netconf.sal.restconf.impl.ControllerContext; +import org.opendaylight.restconf.common.context.InstanceIdentifierContext; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.ws.rs.core.UriBuilder; +import java.net.SocketException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static java.lang.String.format; +import static org.apache.commons.lang3.StringUtils.join; +import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.POST; +import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.PUT; +import static org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode.parseParam; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.ATTEMPTS_MSG; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.COMMA; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.COMM_FAIL; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.HEADER; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.HTTP_REQ; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.HTTP_RES; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.MAX_RETRY_ERR; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.NO_MORE_RETRY; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.REQ_ERR; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.REST_API_URL; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.RES_CODE; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.RES_MSG; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.RES_PRE; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.RETRY_COUNT; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.RETRY_FAIL; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.UPDATED_URL; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.getSchemaCtxFromDir; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.getYangParameters; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.parseUrl; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfListenerFactory.instance; +import static org.osgi.framework.FrameworkUtil.getBundle; + +/** + * Representation of a plugin to enable RESTCONF based CRUD operations from DG. + */ +public class RestconfApiCallNode implements SvcLogicJavaPlugin { + + /** + * Logger for the restconf api call node class. + */ + private static final Logger log = LoggerFactory.getLogger( + RestconfApiCallNode.class); + + /** + * Creates an instance of restconf api call node. + */ + public RestconfApiCallNode() { + } + + /** + * Sends the restconf request using the parameters map and the memory + * context. And this method allows the directed graphs to interact with + * the restconf api call node + * + * @param paramMap parameters map + * @param ctx service logic context + * @throws SvcLogicException when svc logic exception occurs + */ + public void sendRequest(Map paramMap, SvcLogicContext ctx) + throws SvcLogicException { + sendRequest(paramMap, ctx, 0); + } + + /** + * Sends the restconf request using the parameters map and the memory + * context along with the retry count. + * + * @param paramMap parameters map + * @param ctx service logic context + * @param retryCount number of retry counts + * @throws SvcLogicException when svc logic exception occurs + */ + public void sendRequest(Map paramMap, SvcLogicContext ctx, + Integer retryCount) throws SvcLogicException { + RestapiCallNode rest = new RestapiCallNode(); + RetryPolicy retryPolicy = null; + HttpResponse r = new HttpResponse(); + try { + YangParameters p = getYangParameters(paramMap); + if (p.partner != null) { + retryPolicy = rest.getRetryPolicyStore() + .getRetryPolicy(p.partner); + } + + String pp = p.responsePrefix != null ? p.responsePrefix + '.' : ""; + Map props = new HashMap<>((Map)ctx.toProperties()); + String uri = parseUrl(p.restapiUrl, p.httpMethod); + InstanceIdentifierContext insIdCtx = getInsIdCtx(p, uri); + + String req = null; + if (p.httpMethod == POST || p.httpMethod == PUT) { + req = serializeRequest(props, p, uri, insIdCtx); + } + if (req == null && p.requestBody != null) { + req = p.requestBody; + } + + r = rest.sendHttpRequest(req, p); + if (p.returnRequestPayload && req != null) { + ctx.setAttribute(pp + HTTP_REQ, req); + } + + String response = getResponse(ctx, p, pp, r); + if (response != null) { + Map resProp = serializeResponse( + p, uri, response, insIdCtx); + for (Map.Entry pro : resProp.entrySet()) { + ctx.setAttribute(pro.getKey(), pro.getValue()); + } + } + } catch (SvcLogicException e) { + boolean shouldRetry = false; + if (e.getCause().getCause() instanceof SocketException) { + shouldRetry = true; + } + + log.error(REQ_ERR + e.getMessage(), e); + String prefix = parseParam(paramMap, RES_PRE, false, null); + if (retryPolicy == null || shouldRetry == false) { + setFailureResponseStatus(ctx, prefix, e.getMessage(), r); + } else { + if (retryCount == null) { + retryCount = 0; + } + log.debug(format(ATTEMPTS_MSG, retryCount, + retryPolicy.getMaximumRetries())); + try { + retryCount = retryCount + 1; + if (retryCount < retryPolicy.getMaximumRetries() + 1) { + setRetryUri(paramMap, retryPolicy); + log.debug(format(RETRY_COUNT, retryCount, retryPolicy + .getMaximumRetries())); + sendRequest(paramMap, ctx, retryCount); + } else { + log.debug(MAX_RETRY_ERR); + setFailureResponseStatus(ctx, prefix, + e.getMessage(), r); + } + } catch (Exception ex) { + log.error(NO_MORE_RETRY, ex); + setFailureResponseStatus(ctx, prefix, RETRY_FAIL, r); + } + } + } + + if (r != null && r.code >= 300) { + throw new SvcLogicException( + String.valueOf(r.code) + ": " + r.message); + } + } + + /** + * Serializes the request message to JSON or XML from the properties. + * + * @param properties properties + * @param params YANG parameters + * @param uri URI + * @param insIdCtx instance identifier context + * @return JSON or XML message to be sent + * @throws SvcLogicException when serializing the request fails + */ + protected String serializeRequest(Map properties, + YangParameters params, String uri, + InstanceIdentifierContext insIdCtx) + throws SvcLogicException { + PropertiesNodeSerializer propSer = new MdsalPropertiesNodeSerializer( + insIdCtx.getSchemaNode(), insIdCtx.getSchemaContext(), uri); + DataFormatSerializerContext serCtx = new DataFormatSerializerContext( + null, uri, null, propSer); + DataFormatSerializer ser = DfSerializerFactory.instance() + .getSerializer(serCtx, params); + //TODO: Handling of XML annotations + return ser.encode(properties, null); + } + + /** + * Serializes the response message from JSON or XML to the properties. + * + * @param params YANG parameters + * @param uri URI + * @param response response message + * @param insIdCtx instance identifier context + * @return response message as properties + * @throws SvcLogicException when serializing the response fails + */ + protected Map serializeResponse(YangParameters params, + String uri, String response, + InstanceIdentifierContext insIdCtx) + throws SvcLogicException { + PropertiesNodeSerializer propSer = new MdsalPropertiesNodeSerializer( + insIdCtx.getSchemaNode(), insIdCtx.getSchemaContext(), uri); + SerializerHelper helper = new MdsalSerializerHelper( + insIdCtx.getSchemaNode(), insIdCtx.getSchemaContext(), uri); + Listener listener = instance().getListener(helper, params); + DataFormatSerializerContext serCtx = new DataFormatSerializerContext( + listener, uri, null, propSer); + DataFormatSerializer ser = DfSerializerFactory.instance() + .getSerializer(serCtx, params); + return ser.decode(response); + } + + /** + * Returns instance identifier context for a uri using the schema context. + * + * @param params YANG parameters + * @param uri URI + * @return instance identifier context + * @throws SvcLogicException when getting schema context fails + */ + private InstanceIdentifierContext getInsIdCtx(YangParameters params, + String uri) + throws SvcLogicException { + SchemaContext context = getSchemaContext(params); + ControllerContext contCtx = ControllerContext.getInstance(); + contCtx.onGlobalContextUpdated(context); + return contCtx.toInstanceIdentifier(uri); + } + + /** + * Returns the global schema context or schema context of particular YANG + * files present in a directory path. + * + * @param params YANG parameters + * @return schema context + * @throws SvcLogicException when schema context fetching fails + */ + private SchemaContext getSchemaContext(YangParameters params) + throws SvcLogicException { + if (params.dirPath != null) { + return getSchemaCtxFromDir(params.dirPath); + } + BundleContext bc = getBundle(SchemaContext.class).getBundleContext(); + SchemaContext schemaContext = null; + if (bc != null) { + ServiceReference reference = bc.getServiceReference( + SchemaContext.class); + if (reference != null) { + schemaContext = (SchemaContext) bc.getService(reference); + } + } + return schemaContext; + } + + /** + * Returns the response message body of a http response message. + * + * @param ctx svc logic context + * @param params parameters + * @param pre prefix to be appended + * @param res http response + * @return response message body + */ + private String getResponse(SvcLogicContext ctx, YangParameters params, + String pre, HttpResponse res) { + ctx.setAttribute(pre + RES_CODE, String.valueOf(res.code)); + ctx.setAttribute(pre + RES_MSG, res.message); + + if (params.dumpHeaders && res.headers != null) { + for (Map.Entry> a : res.headers.entrySet()) { + ctx.setAttribute(pre + HEADER + a.getKey(), + join(a.getValue(), COMMA)); + } + } + + if (res.body != null && res.body.trim().length() > 0) { + ctx.setAttribute(pre + HTTP_RES, res.body); + return res.body; + } + return null; + } + + /** + * Sets the failure response status in the context memory. + * + * @param ctx service logic context + * @param prefix prefix to be added + * @param errMsg error message + * @param res http response + */ + private void setFailureResponseStatus(SvcLogicContext ctx, String prefix, + String errMsg, HttpResponse res) { + res = new HttpResponse(); + res.code = 500; + res.message = errMsg; + ctx.setAttribute(prefix + RES_CODE, String.valueOf(res.code)); + ctx.setAttribute(prefix + RES_MSG, res.message); + } + + /** + * Sets the retry URI to the param map from the retry policies different + * host. + * + * @param paramMap parameter map + * @param retryPolicy retry policy + * @throws URISyntaxException when new URI creation fails + * @throws RetryException when retry policy cannot give another host + */ + private void setRetryUri(Map paramMap, + RetryPolicy retryPolicy) + throws URISyntaxException, RetryException { + URI uri = new URI(paramMap.get(REST_API_URL)); + String hostName = uri.getHost(); + String retryString = retryPolicy.getNextHostName(uri.toString()); + + URI uriTwo = new URI(retryString); + URI retryUri = UriBuilder.fromUri(uri).host(uriTwo.getHost()).port( + uriTwo.getPort()).scheme(uriTwo.getScheme()).build(); + + paramMap.put(REST_API_URL, retryUri.toString()); + log.debug(UPDATED_URL + retryUri.toString()); + log.debug(format(COMM_FAIL, hostName, retryString)); + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java new file mode 100644 index 000000000..e066671b1 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java @@ -0,0 +1,213 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.restconfapicall; + +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.restapicall.HttpMethod; +import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.YangParameters; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException; +import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource; +import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; +import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor; + +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.PUT; +import static org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode.getParameters; +import static org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode.parseParam; +import static org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode.DEFAULT_MODE; +import static org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource.forFile; +import static org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors.defaultReactor; +import static org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource.create; + +/** + * Utilities for restconf api call node. + */ +public final class RestconfApiUtils { + + static final String RES_CODE = "response-code"; + + static final String HTTP_REQ ="httpRequest"; + + static final String RES_PRE = "responsePrefix"; + + static final String RES_MSG = "response-message"; + + static final String HEADER = "header."; + + static final String COMMA = ","; + + static final String HTTP_RES = "httpResponse"; + + static final String REST_API_URL = "restapiUrl"; + + static final String UPDATED_URL = "URL was set to"; + + static final String COMM_FAIL = "Failed to communicate with host %s." + + "Request will be re-attempted using the host %s."; + + static final String RETRY_COUNT = "This is retry attempt %d out of %d"; + + static final String RETRY_FAIL = "Retry attempt has failed. No further " + + "retry shall be attempted, calling setFailureResponseStatus"; + + static final String NO_MORE_RETRY = "Could not attempt retry"; + + static final String MAX_RETRY_ERR = "Maximum retries reached, calling " + + "setFailureResponseStatus"; + + static final String ATTEMPTS_MSG = "%d attempts were made out of %d " + + "maximum retries"; + + static final String REQ_ERR = "Error sending the request: "; + + private static final String SLASH = "/"; + + private static final String DIR_PATH = "dirPath"; + + private static final String URL_SYNTAX = "The following URL cannot be " + + "parsed into URI : "; + + private static final String RESTCONF_PATH = "/restconf/operations/"; + + private static final String PUT_NODE_ERR = "The following URL does not " + + "contain minimum two nodes for PUT operation."; + + private static final String YANG = ".yang"; + + private static final String YANG_FILE_ERR = "Unable to parse the YANG " + + "file provided"; + + //No instantiation. + private RestconfApiUtils() { + } + + /** + * Returns the YANG parameters after parsing it from the map. + * + * @param paramMap parameters map + * @return YANG parameters + * @throws SvcLogicException when parsing of parameters map fail + */ + static YangParameters getYangParameters(Map paramMap) + throws SvcLogicException { + YangParameters param = (YangParameters) getParameters( + paramMap, new YangParameters()); + param.dirPath = parseParam(paramMap, DIR_PATH, false, null); + return param; + } + + /** + * Parses the restconf URL and gives the YANG path from it, which can be + * used to get schema node. If it is a PUT operation, then a node must be + * reduced from the url to make it always point to the parent. + * + * @param url restconf URL + * @param method HTTP operation + * @return YANG path pointing to parent + * @throws SvcLogicException when parsing the URL fails + */ + static String parseUrl(String url, HttpMethod method) + throws SvcLogicException { + URI uri; + try { + uri = new URI(url); + } catch (URISyntaxException e) { + throw new SvcLogicException(URL_SYNTAX + url, e); + } + + String path = uri.getPath(); + if (path.contains(RESTCONF_PATH)) { + path = path.replaceFirst(RESTCONF_PATH, ""); + } + if (method == PUT) { + if (!path.contains(SLASH)) { + throw new SvcLogicException(PUT_NODE_ERR + url); + } + path = path.substring(0, path.lastIndexOf(SLASH)); + } + return path; + } + + /** + * Returns the schema context of the YANG files present in a directory. + * + * @param di directory path + * @return YANG schema context + * @throws SvcLogicException when YANG file reading fails + */ + static SchemaContext getSchemaCtxFromDir(String di) + throws SvcLogicException { + Path d = Paths.get(di); + File dir = d.toFile(); + List yangFiles = new LinkedList<>(); + getYangFiles(dir, yangFiles); + final Collection sources = + new ArrayList<>(yangFiles.size()); + for (File file : yangFiles) { + try { + sources.add(create(forFile(file))); + } catch (IOException | YangSyntaxErrorException e) { + throw new SvcLogicException(YANG_FILE_ERR + e.getMessage(), e); + } + } + + final CrossSourceStatementReactor.BuildAction reactor = defaultReactor() + .newBuild(DEFAULT_MODE).addSources(sources); + try { + return reactor.buildEffective(); + } catch (ReactorException e) { + throw new SvcLogicException(YANG_FILE_ERR + e.getMessage(), e); + } + } + + /** + * Returns all the YANG files present in a directory recursively. + * + * @param dir path of the directory + * @param yangFiles list of YANG files + */ + private static void getYangFiles(File dir, List yangFiles) { + if (dir.exists()) { + File[] files = dir.listFiles(); + if (files != null) { + for (File file : files) { + if (file.isFile() && file.getName().endsWith(YANG)) { + yangFiles.add(file); + } else if (file.isDirectory()) { + getYangFiles(file, yangFiles); + } + } + } + } + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfapiCallNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfapiCallNode.java deleted file mode 100644 index 87cb92bc5..000000000 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfapiCallNode.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.restconfapicall; - -import java.util.Map; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; - -/** - * Representation of a plugin to enable RESTCONF based CRUD operations from DG. - */ -public class RestconfapiCallNode implements SvcLogicJavaPlugin { - - public RestconfapiCallNode() { - } - - /** - * Allows Directed Graphs the ability to interact with RESTCONF APIs. - * @param parameters HashMap of parameters passed by the DG to this function - *

parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/sshapi/templates/vnf_service-configuration-operation_minimal.json
UrlMandatoryurl to make the SSH connection request to.
PortMandatoryport to make the SSH connection request to.
UserOptionaluser name to use for ssh basic authenticationsdnc_ws
ExecTimeoutOptionalSSH command execution timeoutplain_key
RetryOptionalMake ssh connection with default retry policyplain_key
CmdMandatoryssh command to be executed on the server.get post put delete patch
ResponsePrefixOptionallocation the response will be written to in context memorytmp.sshapi.result
ResponseTypeOptionalIf we know the response is to be in a specific format (supported are JSON, XML and NONE) tmp.sshapi.result
ResponsePrefixOptionallocation the response will be written to in context memory
ResponseTypeOptionalIf we know the response is to be in a specific format (supported are JSON, XML and NONE)
listName[i]OptionalUsed for processing XML responses with repeating elements.
ConvertResponse Optionalwhether the response should be convertedtrue or false
AuthTypeOptionalType of authentiation to be used BASIC or sshKey basedtrue or false
- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to YANG directory that can be used to build a request/sdncopt/bvc/resconfapi/test
restapiUrlMandatoryurl to send the request tohttps://sdncodl:8543/restconf/operations/L3VNF-API:create-update-vnf-request
restapiUserOptionaluser name to use for http basic authenticationsdnc_ws
restapiPasswordOptionalunencrypted password to use for http basic authenticationplain_password
contentTypeOptionalhttp content type to set in the http headerusually application/json or application/xml
formatOptionalshould match request body formatjson or xml
httpMethodOptionalhttp method to use when sending the requestget post put delete patch
responsePrefixOptionallocation the response will be written to in context memorytmp.resconftapi.result
skipSendingOptionaltrue or false
convertResponse Optionalwhether the response should be convertedtrue or false
customHttpHeadersOptionala list additional http headers to be passed in, follow the format in the exampleX-CSI-MessageId=messageId,headerFieldName=headerFieldValue
dumpHeadersOptionalwhen true writes http header content to context memorytrue or false
- * @param ctx Reference to context memory - * @throws SvcLogicException - * @since 11.0.2 - * @see String#split(String, int) - */ - public void sendRequest(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { - //TODO - } - -} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java index 34bb2ee6e..0490b3a51 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java @@ -24,7 +24,7 @@ import org.glassfish.jersey.media.sse.EventSource; import org.glassfish.jersey.media.sse.SseFeature; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfapiCallNode; +import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,7 +46,7 @@ public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { private ExecutorService executor = Executors.newCachedThreadPool(); private Map runnableInfo = new ConcurrentHashMap<>(); - private RestconfapiCallNode restconfapiCallNode; + private RestconfApiCallNode restconfApiCallNode; private volatile Map subscriptionInfoMap = new ConcurrentHashMap<>(); private volatile LinkedBlockingQueue eventQueue = new LinkedBlockingQueue<>(); @@ -78,7 +78,7 @@ public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { throw new SvcLogicException("Subscriber Id is null"); } - restconfapiCallNode.sendRequest(paramMap, ctx); + restconfApiCallNode.sendRequest(paramMap, ctx); if (getResponseCode(paramMap.get(RESPONSE_PREFIX), ctx).equals(RESPONSE_CODE_200)) { // TODO: save subscription id and subscriber in MYSQL @@ -207,8 +207,8 @@ public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { * * @return restconfApiCallNode */ - protected RestconfapiCallNode restconfapiCallNode() { - return restconfapiCallNode; + protected RestconfApiCallNode restconfapiCallNode() { + return restconfApiCallNode; } /** @@ -216,8 +216,8 @@ public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { * * @param node restconfApiCallNode */ - void restconfapiCallNode(RestconfapiCallNode node) { - restconfapiCallNode = node; + void restconfapiCallNode(RestconfApiCallNode node) { + restconfApiCallNode = node; } Map subscriptionInfoMap() { diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java index a3e30c4b7..5a898dfc5 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java @@ -76,8 +76,8 @@ public class MdsalSerializerHelper extends SerializerHelper - + - + diff --git a/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-osgi-context.xml b/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-osgi-context.xml index d56e2fc11..5a9f22bed 100644 --- a/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-osgi-context.xml +++ b/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-osgi-context.xml @@ -26,7 +26,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - + diff --git a/restconf-client/provider/src/main/resources/org/opendaylight/blueprint/restconf-client-blueprint.xml b/restconf-client/provider/src/main/resources/org/opendaylight/blueprint/restconf-client-blueprint.xml index 149ed9fcf..91c31efc5 100755 --- a/restconf-client/provider/src/main/resources/org/opendaylight/blueprint/restconf-client-blueprint.xml +++ b/restconf-client/provider/src/main/resources/org/opendaylight/blueprint/restconf-client-blueprint.xml @@ -23,12 +23,12 @@ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" odl:use-default-for-reference-types="true"> - + - org.onap.ccsdk.sli.plugins.restconfapicall.RestconfapiCallNode + org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode -- cgit From 72e46e2c1d7ab69503a26a545ed7ef1a49f2fb43 Mon Sep 17 00:00:00 2001 From: gaurav Date: Tue, 11 Sep 2018 14:59:59 +0530 Subject: Fixed security issue of Restconf Client Removed the spring dependencies as they are not required. Change-Id: I4a95a26d5a615897527dbe543d938459c1651081 Issue-ID: CCSDK-444 Signed-off-by: Gaurav Agrawal --- .../features/src/main/resources/features.xml | 38 --- restconf-client/installer/pom.xml | 260 ++++++++++----------- restconf-client/provider/pom.xml | 8 - .../META-INF/spring/restconf-client-context.xml | 48 ---- .../spring/restconf-client-osgi-context.xml | 32 --- 5 files changed, 127 insertions(+), 259 deletions(-) delete mode 100644 restconf-client/features/src/main/resources/features.xml delete mode 100644 restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-context.xml delete mode 100644 restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-osgi-context.xml diff --git a/restconf-client/features/src/main/resources/features.xml b/restconf-client/features/src/main/resources/features.xml deleted file mode 100644 index c07cddffb..000000000 --- a/restconf-client/features/src/main/resources/features.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features - - - sdnc-sli - spring - spring-dm - mvn:org.onap.ccsdk.sli.plugins/properties-node-provider/0.3.0-SNAPSHOT - mvn:org.onap.ccsdk.sli.plugins/restconf-client-provider/0.3.0-SNAPSHOT - - - diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index ee632d434..b28cefde9 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -1,148 +1,142 @@ - - 4.0.0 + + 4.0.0 - - org.onap.ccsdk.parent - odlparent-lite - 1.1.0-SNAPSHOT - + + org.onap.ccsdk.parent + odlparent-lite + 1.1.0-SNAPSHOT + - org.onap.ccsdk.sli.plugins - restconf-client-installer - 0.3.0-SNAPSHOT - pom + org.onap.ccsdk.sli.plugins + restconf-client-installer + 0.3.0-SNAPSHOT + pom - ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} + ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} - - ccsdk-restconf-client - ${application.name} - mvn:org.onap.ccsdk.sli.plugins/${features.boot}/${project.version}/xml/features - false - + + ccsdk-restconf-client + ${application.name} + mvn:org.onap.ccsdk.sli.plugins/${features.boot}/${project.version}/xml/features + + false + - + - - org.onap.ccsdk.sli.plugins - ${application.name} - ${project.version} - xml - features - - - * - * - - - - - - org.onap.ccsdk.sli.plugins - restconf-client-provider - ${project.version} - - org.springframework - spring-beans + org.onap.ccsdk.sli.plugins + ${application.name} + ${project.version} + xml + features + + + * + * + + + - org.springframework - spring-context + org.onap.ccsdk.sli.plugins + restconf-client-provider + ${project.version} - + - - - - maven-assembly-plugin - 2.6 - - - maven-repo-zip - - single - - package - - true - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - true - - - - installer-zip - - single - - package - - true - ${application.name}-${project.version}-installer - - src/assembly/assemble_installer_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - false - ${project.build.directory}/assembly/system - false - true - true - true - false - false - org.onap.ccsdk.sli.core - provided - - - - - - maven-resources-plugin - 2.6 - - - copy-version - - copy-resources - - validate - - ${basedir}/target/stage - - - src/main/resources/scripts - - install-feature.sh - - true - - - - + + + + maven-assembly-plugin + 2.6 + + + maven-repo-zip + + single + + package + + true + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + true + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli.core + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + - - + + - - + + diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 099412642..c063c9bd1 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -22,14 +22,6 @@ - - org.springframework - spring-beans - - - org.springframework - spring-context - org.glassfish.jersey.media jersey-media-sse diff --git a/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-context.xml b/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-context.xml deleted file mode 100644 index f99f4f843..000000000 --- a/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-context.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - file:${SDNC_CONFIG_DIR}/ueb.properties - file:${SDNC_CONFIG_DIR}/dme2.properties - - - - - - - - - - - - - - - - - diff --git a/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-osgi-context.xml b/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-osgi-context.xml deleted file mode 100644 index 5a9f22bed..000000000 --- a/restconf-client/provider/src/main/resources/META-INF/spring/restconf-client-osgi-context.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - -- cgit From 056df35d0f9b894c1adf8ea9a2d9bdc21497a0e8 Mon Sep 17 00:00:00 2001 From: gaurav Date: Tue, 11 Sep 2018 15:43:16 +0530 Subject: Fix for sonar critical issues. Fixed sonar critical issues fixes for Restconf Client. Change-Id: If946c43ec98d31999da0829df41efb0a60ff5f7f Issue-ID: CCSDK-325 Signed-off-by: Gaurav Agrawal --- .../plugins/restconfapicall/RestconfApiCallNode.java | 5 ----- .../sli/plugins/restconfapicall/RestconfApiUtils.java | 18 +++++++++++------- .../sli/plugins/restconfdiscovery/EventHandler.java | 6 +----- .../sli/plugins/restconfdiscovery/EventProcessor.java | 17 +++++++++++------ .../restconfdiscovery/RestconfDiscoveryNode.java | 5 +++-- 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java index c5f73305b..42caf3685 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java @@ -90,11 +90,6 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { private static final Logger log = LoggerFactory.getLogger( RestconfApiCallNode.class); - /** - * Creates an instance of restconf api call node. - */ - public RestconfApiCallNode() { - } /** * Sends the restconf request using the parameters map and the memory diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java index e066671b1..0f9c9401c 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java @@ -200,13 +200,17 @@ public final class RestconfApiUtils { if (dir.exists()) { File[] files = dir.listFiles(); if (files != null) { - for (File file : files) { - if (file.isFile() && file.getName().endsWith(YANG)) { - yangFiles.add(file); - } else if (file.isDirectory()) { - getYangFiles(file, yangFiles); - } - } + processFiles(files, yangFiles); + } + } + } + + private static void processFiles(File[] files, List yangFiles) { + for (File file : files) { + if (file.isFile() && file.getName().endsWith(YANG)) { + yangFiles.add(file); + } else if (file.isDirectory()) { + getYangFiles(file, yangFiles); } } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventHandler.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventHandler.java index 155656e27..a76554d5a 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventHandler.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventHandler.java @@ -40,11 +40,7 @@ class EventHandler implements EventListener { public void onEvent(InboundEvent event) { String payload = event.readData(); if (!node.eventQueue().offer(payload)) { - log.error("Unable to process event " - + payload + "as processing queue is full"); - throw new RuntimeException("Unable to process event " - + payload - + "as processing queue is full"); + log.error("Unable to process event {} as processing queue is full", payload); } } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java index a85876cae..aae808155 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java @@ -53,17 +53,22 @@ class EventProcessor implements Runnable { String id = param.get(EVENT_SUBSCRIPTION_ID); SubscriptionInfo info = node.subscriptionInfoMap().get(id); if (info != null) { - SvcLogicContext ctx = new SvcLogicContext(); - for (Map.Entry entry : param.entrySet()) { - ctx.setAttribute(entry.getKey(), entry.getValue()); - } + SvcLogicContext ctx = setContext(param); SvcLogicGraphInfo callbackDG = info.callBackDG(); callbackDG.executeGraph(ctx); } } catch (InterruptedException | SvcLogicException e) { - log.error(e.getMessage()); - throw new RuntimeException(e.getMessage()); + log.error("Interrupted!", e); + Thread.currentThread().interrupt(); } } } + + private SvcLogicContext setContext(Map param) { + SvcLogicContext ctx = new SvcLogicContext(); + for (Map.Entry entry : param.entrySet()) { + ctx.setAttribute(entry.getKey(), entry.getValue()); + } + return ctx; + } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java index 0490b3a51..f5366a544 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java @@ -85,7 +85,7 @@ public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { establishPersistentConnection(paramMap, ctx, subscriberId); } else { - log.info("Failed to subscribe " + subscriberId); + log.info("Failed to subscribe {}", subscriberId); throw new SvcLogicException(ctx.getAttribute(RESPONSE_CODE)); } } @@ -131,7 +131,8 @@ public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { try { Thread.sleep(5000); } catch (InterruptedException e) { - log.error("Exception: " + e.getMessage()); + log.error("Interrupted!", e); + Thread.currentThread().interrupt(); } } eventSource.close(); -- cgit From 259eece936114ccacf9acc8f412eeed033fd10c4 Mon Sep 17 00:00:00 2001 From: janani b Date: Wed, 12 Sep 2018 18:30:28 +0530 Subject: UT and defect fixes for DF serializer UT and defect fixes Issue-ID: CCSDK-376 Change-Id: Ia5f04a0d7e07caad0e3b380fdfa6cc109ec43b4e Signed-off-by: janani b --- restconf-client/provider/pom.xml | 20 +- .../restconfapicall/RestconfApiCallNode.java | 39 +- .../dfserializer/DefaultJsonListener.java | 43 +- .../dfserializer/DefaultXmlListener.java | 41 ++ .../dfserializer/DfSerializerUtil.java | 46 +- .../dfserializer/MdsalSerializerHelper.java | 59 +- .../dfserializer/PropertiesNodeXmlListener.java | 8 +- .../DefaultPropertiesNodeListener.java | 6 +- .../MdsalPropertiesNodeSerializer.java | 15 +- .../pnserializer/MdsalPropertiesNodeUtils.java | 8 + .../blueprint/restconf-client-blueprint.xml | 10 +- .../dfserializer/DataFormatSerializerTest.java | 612 +++++++++++++++++++++ .../dfserializer/DataFormatUtilsTest.java | 504 +++++++++++++++++ .../src/test/resources/yang/identity-test.yang | 10 +- .../test/resources/yang/identity-types-second.yang | 2 +- .../src/test/resources/yang/test-augment.yang | 59 +- .../src/test/resources/yang/test-yang.yang | 114 ++-- 17 files changed, 1438 insertions(+), 158 deletions(-) create mode 100644 restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java create mode 100644 restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index c063c9bd1..db0bee061 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -73,6 +73,12 @@ junit test + + org.mockito + mockito-core + ${mockito.version} + test + org.glassfish.jersey.inject jersey-hk2 @@ -106,23 +112,13 @@ org.opendaylight.netconf restconf-nb-rfc8040 - 1.7.3 - test + ${odl.mdsal.version} org.opendaylight.yangtools yang-parser-impl 2.0.6.1 - - org.opendaylight.netconf - restconf-common - 1.7.3 - - - org.opendaylight.netconf - restconf-nb-bierman02 - 1.7.3 - + diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java index 42caf3685..f9a1ecbf3 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java @@ -36,8 +36,8 @@ import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.SerializerHelper; import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.YangParameters; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeSerializer; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNodeSerializer; -import org.opendaylight.netconf.sal.restconf.impl.ControllerContext; import org.opendaylight.restconf.common.context.InstanceIdentifierContext; +import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; @@ -90,6 +90,27 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { private static final Logger log = LoggerFactory.getLogger( RestconfApiCallNode.class); + /** + * Rest api call node service instance + */ + private RestapiCallNode restapiCallNode; + + /** + * Creates an instance of restconf api call node with restapi call node. + * + * @param r restapi call node + */ + public RestconfApiCallNode(RestapiCallNode r) { + this.restapiCallNode = r; + } + + /** + * Returns the restapi call node instance. + * @return + */ + public RestapiCallNode getRestapiCallNode() { + return restapiCallNode; + } /** * Sends the restconf request using the parameters map and the memory @@ -116,7 +137,7 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { */ public void sendRequest(Map paramMap, SvcLogicContext ctx, Integer retryCount) throws SvcLogicException { - RestapiCallNode rest = new RestapiCallNode(); + RestapiCallNode rest = getRestapiCallNode(); RetryPolicy retryPolicy = null; HttpResponse r = new HttpResponse(); try { @@ -203,7 +224,7 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { * @return JSON or XML message to be sent * @throws SvcLogicException when serializing the request fails */ - protected String serializeRequest(Map properties, + public String serializeRequest(Map properties, YangParameters params, String uri, InstanceIdentifierContext insIdCtx) throws SvcLogicException { @@ -227,9 +248,9 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { * @return response message as properties * @throws SvcLogicException when serializing the response fails */ - protected Map serializeResponse(YangParameters params, - String uri, String response, - InstanceIdentifierContext insIdCtx) + public Map serializeResponse(YangParameters params, + String uri, String response, + InstanceIdentifierContext insIdCtx) throws SvcLogicException { PropertiesNodeSerializer propSer = new MdsalPropertiesNodeSerializer( insIdCtx.getSchemaNode(), insIdCtx.getSchemaContext(), uri); @@ -255,9 +276,7 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { String uri) throws SvcLogicException { SchemaContext context = getSchemaContext(params); - ControllerContext contCtx = ControllerContext.getInstance(); - contCtx.onGlobalContextUpdated(context); - return contCtx.toInstanceIdentifier(uri); + return ParserIdentifier.toInstanceIdentifier(uri, context, null); } /** @@ -294,7 +313,7 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { * @param res http response * @return response message body */ - private String getResponse(SvcLogicContext ctx, YangParameters params, + public String getResponse(SvcLogicContext ctx, YangParameters params, String pre, HttpResponse res) { ctx.setAttribute(pre + RES_CODE, String.valueOf(res.code)); ctx.setAttribute(pre + RES_MSG, res.message); diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonListener.java index 107585a72..45317522a 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonListener.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultJsonListener.java @@ -52,6 +52,16 @@ public class DefaultJsonListener implements JsonListener { */ private String modName; + /** + * Value of the current JSON node. + */ + private String value; + + /** + * Value namespace of the current JSON node. + */ + private String valueNs; + /** * Creates an instance of default json listener with its serializer helper. * @@ -64,16 +74,18 @@ public class DefaultJsonListener implements JsonListener { @Override public void enterJsonNode(String nodeName, JsonNode node, NodeType nodeType) throws SvcLogicException { - getNodeName(nodeName); + getNodeName(nodeName, false); switch (nodeType) { case SINGLE_INSTANCE_LEAF_NODE: - serializerHelper.addNode(name, modName, node.asText(), null, + getNodeName(node.asText(), true); + serializerHelper.addNode(name, modName, value, valueNs, SINGLE_INSTANCE_LEAF_NODE); break; case MULTI_INSTANCE_LEAF_NODE: - serializerHelper.addNode(name, modName, node.asText(), null, + getNodeName(node.asText(), true); + serializerHelper.addNode(name, modName, value, valueNs, MULTI_INSTANCE_LEAF_NODE); break; @@ -105,18 +117,29 @@ public class DefaultJsonListener implements JsonListener { /** * Parses the abstract JSON name and fills the node name and node - * namespace of the current JSON node. + * namespace or value and value namespace of the current JSON node . * - * @param abstractName abstract JSON name + * @param abstractName full name value + * @param isVal if it is for value parsing */ - private void getNodeName(String abstractName) { + private void getNodeName(String abstractName, boolean isVal) { String[] val = abstractName.split(":"); if (val.length == 2) { - modName = val[0]; - name = val[1]; + if (isVal) { + valueNs = val[0]; + value = val[1]; + } else { + modName = val[0]; + name = val[1]; + } } else { - name = val[0]; + if (isVal) { + value = val[0]; + valueNs = null; + } else { + name = val[0]; + modName = null; + } } } - } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlListener.java index 57969146d..03abf44fd 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlListener.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DefaultXmlListener.java @@ -21,8 +21,11 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; import org.dom4j.Element; +import org.dom4j.Namespace; import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import java.util.List; + import static java.lang.String.format; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.NODE_TYPE_ERR; @@ -56,6 +59,11 @@ public class DefaultXmlListener implements XmlListener { break; case OBJECT_NODE: + List cont = element.content(); + if (cont != null && cont.size() == 2 && + isValueNsForLeaf(cont, element)) { + return; + } serializerHelper.addNode(element.getName(), element.getNamespace().getURI(), null, null, null); @@ -67,6 +75,39 @@ public class DefaultXmlListener implements XmlListener { } } + /** + * Returns true if element has value namespace and adds the node to + * property tree; false otherwise. + * + * @param cont content of the element + * @param element element + * @return true if element has value namespace; false otherwise + * @throws SvcLogicException + */ + private boolean isValueNsForLeaf(List cont, Element element) + throws SvcLogicException { + for (Object c : cont) { + if (c instanceof Namespace) { + String value = element.getText(); + if (value != null) { + String[] val = value.split(":"); + String valPrefix = val[0]; + String actVal = val[1]; + if (valPrefix != null && actVal != null && + valPrefix.equals(((Namespace) c).getPrefix())) { + serializerHelper.addNode( + element.getName(), + element.getNamespace().getURI(), + actVal, + ((Namespace) c).getURI(), null); + return true; + } + } + } + } + return false; + } + @Override public void exitXmlElement(Element element) throws SvcLogicException { serializerHelper.exitNode(); diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerUtil.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerUtil.java index 6acb04a81..598b08c1b 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerUtil.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerUtil.java @@ -26,7 +26,6 @@ import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.Namespace; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaNode; import org.opendaylight.yangtools.yang.model.api.TypeDefinition; import org.w3c.dom.Document; import org.xml.sax.InputSource; @@ -46,6 +45,7 @@ import java.io.StringWriter; import java.io.Writer; import java.net.URI; import java.net.URISyntaxException; +import java.util.Iterator; import static javax.xml.transform.OutputKeys.INDENT; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.XmlNodeType.OBJECT_NODE; @@ -150,40 +150,44 @@ public final class DfSerializerUtil { * Returns the resolved namespace object from the input received from the * abstract data format. * - * @param mName module name - * @param curSchema current schema - * @param ctx schema context - * @param mUri module URI - * @param pNode properties node + * @param mName module name + * @param mUri module URI + * @param ctx schema context + * @param parent parent properties node * @return namespace * @throws SvcLogicException when resolving namespace fails */ - static Namespace getResolvedNamespace(String mName, SchemaNode curSchema, - SchemaContext ctx, String mUri, - PropertiesNode pNode) + static Namespace getResolvedNamespace(String mName, String mUri, + SchemaContext ctx, + PropertiesNode parent) throws SvcLogicException { - Module m = null; - URI namespace = curSchema.getQName().getNamespace(); + if (mName == null && mUri == null) { + Namespace parentNs = parent.namespace(); + return new Namespace(parentNs.moduleName(), parentNs.moduleNs(), + parentNs.revision()); + } + Iterator it; + Module mod; if (mName != null) { - m = ctx.findModule(mName).get(); - namespace = m == null ? null : m.getNamespace(); - } - if (mUri != null) { + it = ctx.findModules(mName).iterator(); + } else { + URI modUri = null; try { - m = ctx.findModule(new URI(mUri)).get(); + modUri = new URI(mUri); } catch (URISyntaxException e) { throw new SvcLogicException(URI_ERR, e); } - namespace = m == null ? null : m.getNamespace(); - mName = m.getName(); + it = ctx.findModules(modUri).iterator(); } - if (mName == null && mUri == null) { - return pNode.namespace(); + if (!it.hasNext()) { + return null; } + mod = it.next(); - return new Namespace(mName, namespace, getRevision(m.getRevision())); + return new Namespace(mod.getName(), mod.getQNameModule().getNamespace(), + getRevision(mod.getRevision())); } /** diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java index 5a898dfc5..6f9f9070a 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java @@ -25,6 +25,9 @@ import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.Namespace; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.RootNode; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.Revision; +import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; @@ -49,6 +52,8 @@ import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.M import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_NODE; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.SINGLE_INSTANCE_LEAF_NODE; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.SINGLE_INSTANCE_NODE; +import static org.opendaylight.yangtools.yang.data.impl.schema.SchemaUtils.findDataChildSchemaByQName; +import static org.opendaylight.yangtools.yang.data.impl.schema.SchemaUtils.findSchemaForChild; import static org.opendaylight.yangtools.yang.data.util.ParserStreamUtils.findSchemaNodeByNameAndNamespace; /** @@ -108,14 +113,17 @@ public class MdsalSerializerHelper extends SerializerHelper baseType = resolveBaseTypeFrom(type); if (baseType instanceof IdentityrefTypeDefinition) { if (nodeType == null) { - ns = getResolvedNamespace(null,schemaNode, getSchemaCtx(), - valNs, propNode); + ns = getResolvedNamespace(null, valNs, getSchemaCtx(), + propNode); } else { - ns = getResolvedNamespace(valNs, schemaNode, getSchemaCtx(), - null, propNode); + ns = getResolvedNamespace(valNs, null, getSchemaCtx(), + propNode); } } } @@ -255,14 +268,28 @@ public class MdsalSerializerHelper extends SerializerHelper dataSchema = findSchemaNodeByNameAndNamespace( - (DataSchemaNode) curSchemaNode, name, namespace.moduleNs()); - if (dataSchema != null) { - DataSchemaNode node = dataSchema.pop(); - if (node != null) { - curSchemaNode = node; - return true; + QName qname = QName.create(namespace.moduleNs(), + Revision.of(namespace.revision()), name); + SchemaNode childNode = null; + if (curSchemaNode instanceof DataSchemaNode) { + Deque dataSchema = findSchemaNodeByNameAndNamespace( + (DataSchemaNode) curSchemaNode, name, namespace.moduleNs()); + if (dataSchema != null && !dataSchema.isEmpty()) { + childNode = dataSchema.pop(); + } + + if (!dataSchema.isEmpty()) { + childNode = findSchemaForChild(((ChoiceSchemaNode) childNode), + qname); } + + } else { + childNode = findDataChildSchemaByQName(curSchemaNode, qname); + } + + if (childNode != null) { + curSchemaNode = childNode; + return true; } return false; } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeXmlListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeXmlListener.java index cf59b7794..39a08e387 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeXmlListener.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeXmlListener.java @@ -42,6 +42,8 @@ import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializ import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.UTF_HEADER; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.XML_PREFIX; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.getXmlWriter; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_HOLDER_NODE; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_LEAF_HOLDER_NODE; /** * Representation of XML implementation of properties node listener. @@ -193,7 +195,11 @@ public class PropertiesNodeXmlListener implements PropertiesNodeListener { */ private String getNodeNamespace(PropertiesNode node) { PropertiesNode parent = node.parent(); - if (parent instanceof RootNode || !parent.namespace().moduleName() + if (parent.nodeType() == MULTI_INSTANCE_HOLDER_NODE || + parent.nodeType() == MULTI_INSTANCE_LEAF_HOLDER_NODE) { + parent = parent.parent(); + } + if (parent instanceof RootNode || ! parent.namespace().moduleName() .equals(node.namespace().moduleName())) { return node.namespace().moduleNs().toString(); } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java index d91209121..491dcb099 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java @@ -54,7 +54,11 @@ public class DefaultPropertiesNodeListener implements PropertiesNodeListener { */ if (node.nodeType() == SINGLE_INSTANCE_LEAF_NODE || node.nodeType() == MULTI_INSTANCE_LEAF_NODE) { - params.put(node.uri(), ((LeafNode) node).value()); + String val = ((LeafNode) node).value(); + if (((LeafNode) node).valueNs() != null) { + val = ((LeafNode) node).valueNs().moduleName() + ":" + val; + } + params.put(node.uri(), val); } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java index c24146267..13a5c5a01 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java @@ -33,6 +33,7 @@ import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPrope import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getListName; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getNamespace; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getNodeType; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getParsedValue; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getRevision; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getValueNamespace; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.resolveName; @@ -116,26 +117,32 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer - + + + + + + diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java new file mode 100644 index 000000000..0f46d625b --- /dev/null +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java @@ -0,0 +1,612 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.restapicall.HttpResponse; +import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; +import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode; +import org.opendaylight.restconf.common.context.InstanceIdentifierContext; + +import java.util.HashMap; +import java.util.Map; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doCallRealMethod; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.DECODE_FROM_JSON_RPC; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.DECODE_FROM_XML_RPC; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_ID; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_RPC; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_YANG; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_ID; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_RPC; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_YANG; + + +/** + * Unit test cases for data format serialization and restconf api call node. + */ +public class DataFormatSerializerTest { + + private Map p; + + private RestconfApiCallNode restconf; + + private RestapiCallNode restApi; + + private DfCaptor dfCaptor; + + /** + * Sets up the pre-requisite for each test case. + * + * @throws SvcLogicException when test case fails + */ + @Before + public void setUp() throws SvcLogicException { + p = new HashMap<>(); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + restApi = new RestapiCallNode(); + restconf = mock(RestconfApiCallNode.class); + dfCaptor = new DfCaptor(); + createMethodMocks(); + } + + /** + * Creates method mocks using mockito for RestconfApiCallNode class. + * + * @throws SvcLogicException when test case fails + */ + private void createMethodMocks() throws SvcLogicException { + doReturn(restApi).when(restconf).getRestapiCallNode(); + doCallRealMethod().when(restconf).sendRequest( + any(Map.class), any(SvcLogicContext.class)); + doCallRealMethod().when(restconf).sendRequest( + any(Map.class), any(SvcLogicContext.class), any(Integer.class)); + doAnswer(dfCaptor).when(restconf).serializeRequest( + any(Map.class), any(YangParameters.class), any(String.class), + any(InstanceIdentifierContext.class)); + } + + /** + * Creates mock using mockito with input data for decoding. + * + * @param decodeData input data + * @throws SvcLogicException when test case fails + */ + private void createMockForDecode(String decodeData) + throws SvcLogicException { + doReturn(decodeData).when(restconf).getResponse( + any(SvcLogicContext.class), any(YangParameters.class), + any(String.class), any(HttpResponse.class)); + doCallRealMethod().when(restconf).serializeResponse( + any(YangParameters.class), any(String.class), any(String.class), + any(InstanceIdentifierContext.class)); + } + + /** + * Verifies encoding of parameters to JSON data format with identity-ref + * and inter-file linking. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToJsonId() throws SvcLogicException { + String pre = "identity-test:test."; + SvcLogicContext ctx = createAttList(pre); + ctx.setAttribute(pre + "l", "abc"); + p.put("dirPath", "src/test/resources"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/identity-test:test"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_ID)); + } + + /** + * Verifies encoding of parameters to XML data format with identity-ref + * and inter-file linking. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToXmlId() throws SvcLogicException { + String pre = "identity-test:test."; + SvcLogicContext ctx = createAttList(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "xml"); + p.put("httpMethod", "post"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/identity-test:test"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_ID)); + } + + /** + * Verifies decoding of parameters from JSON data format with identity-ref + * and inter-file linking. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void decodeToJsonId() throws SvcLogicException { + createMockForDecode(ENCODE_TO_JSON_ID); + SvcLogicContext ctx = new SvcLogicContext(); + String pre = "identity-test:test."; + p.put("dirPath", "src/test/resources"); + p.put("format", "json"); + p.put("httpMethod", "get"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/identity-test:test"); + restconf.sendRequest(p, ctx); + assertThat(ctx.getAttribute(pre + "l"), is("abc")); + verifyAttList(ctx, pre); + } + + /** + * Verifies decoding of parameters from XML data format with identity-ref + * and inter-file linking. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void decodeToXmlId() throws SvcLogicException { + createMockForDecode(ENCODE_TO_XML_ID); + SvcLogicContext ctx = new SvcLogicContext(); + String pre = "identity-test:test."; + p.put("dirPath", "src/test/resources"); + p.put("format", "xml"); + p.put("httpMethod", "get"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/identity-test:test"); + restconf.sendRequest(p, ctx); + verifyAttList(ctx, pre); + } + + /** + * Verifies encoding of parameters to JSON data format with containers, + * grouping and augment. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToJsonYang() throws SvcLogicException { + String pre = "test-yang:cont1.cont2."; + SvcLogicContext ctx = createAttListYang(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/test-yang:cont1"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG)); + } + + /** + * Verifies decoding of parameters from JSON data format with containers, + * grouping and augment. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void decodeToJsonYang() throws SvcLogicException { + createMockForDecode(ENCODE_TO_JSON_YANG); + SvcLogicContext ctx = new SvcLogicContext(); + String pre = "test-yang:cont1.cont2."; + p.put("dirPath", "src/test/resources"); + p.put("format", "json"); + p.put("httpMethod", "get"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/test-yang:cont1"); + restconf.sendRequest(p, ctx); + verifyAttListYang(ctx, pre); + } + + /** + * Verifies encoding of parameters to XML data format with containers, + * grouping and augment. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToXmlYang() throws SvcLogicException { + String pre = "test-yang:cont1.cont2."; + SvcLogicContext ctx = createAttListYang(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "xml"); + p.put("httpMethod", "post"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/test-yang:cont1"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG)); + } + + /** + * Verifies decoding of parameters from XML data format with containers, + * grouping and augment. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void decodeToXmlYang() throws SvcLogicException { + createMockForDecode(ENCODE_TO_XML_YANG); + SvcLogicContext ctx = new SvcLogicContext(); + String pre = "test-yang:cont1.cont2."; + p.put("dirPath", "src/test/resources"); + p.put("format", "xml"); + p.put("httpMethod", "get"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/test-yang:cont1"); + restconf.sendRequest(p, ctx); + verifyAttListYang(ctx, pre); + } + + /** + * Verifies encoding of and decoding from, JSON respectively for data + * format with containers, grouping and augment. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void codecToJsonRpc() throws SvcLogicException { + createMockForDecode(DECODE_FROM_JSON_RPC); + String inPre = "test-yang:create-sfc.input."; + String outPre = "test-yang:create-sfc.output."; + SvcLogicContext ctx = createAttListRpc(inPre); + p.put("dirPath", "src/test/resources"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/test-yang:create-sfc"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_RPC)); + verifyAttListRpc(ctx, outPre); + } + + /** + * Verifies encoding of and decoding from, XML respectively for data + * format with containers, grouping and augment. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void codecToXmlRpc() throws SvcLogicException { + createMockForDecode(DECODE_FROM_XML_RPC); + String inPre = "test-yang:create-sfc.input."; + String outPre = "test-yang:create-sfc.output."; + SvcLogicContext ctx = createAttListRpc(inPre); + p.put("dirPath", "src/test/resources"); + p.put("format", "xml"); + p.put("httpMethod", "post"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/test-yang:create-sfc"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_RPC)); + verifyAttListRpc(ctx, outPre); + } + + /** + * Creates attribute list for encoding JSON or XML with identity-ref YANG + * file. + * + * @param pre prefix + * @return service logic context + */ + private SvcLogicContext createAttList(String pre) { + SvcLogicContext ctx = new SvcLogicContext(); + String pre1 = pre + "con1.interfaces."; + ctx.setAttribute(pre + "con1.interface", "identity-types:physical"); + ctx.setAttribute(pre1 + "int-list[0].iden", "optical"); + ctx.setAttribute(pre1 + "int-list[0].available.ll[0]", "Giga"); + ctx.setAttribute(pre1 + "int-list[0].available.ll[1]", + "identity-types:Loopback"); + ctx.setAttribute(pre1 + "int-list[0].available.ll[2]", + "identity-types-second:Ethernet"); + ctx.setAttribute(pre1 + "int-list[0].available.leaf1", "58"); + ctx.setAttribute(pre1 + "int-list[0].available.leaf2", + "identity-types-second:iden2"); + + ctx.setAttribute(pre1 + "int-list[1].iden", "214748364"); + ctx.setAttribute(pre1 + "int-list[1].available.ll[0]", "Giga"); + ctx.setAttribute(pre1 + "int-list[1].available.ll[1]", + "identity-types:Loopback"); + ctx.setAttribute(pre1 + "int-list[1].available.ll[2]", + "identity-types-second:Ethernet"); + ctx.setAttribute(pre1 + "int-list[1].available.leaf1", + "8888"); + ctx.setAttribute(pre1 + "int-list[1].available.leaf2", + "identity-types-second:iden2"); + return ctx; + } + + /** + * Creates attribute list for encoding JSON or XML with container, + * grouping and augmented YANG file. + * + * @param pre prefix + * @return service logic context + */ + private SvcLogicContext createAttListYang(String pre) { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute(pre + "cont3.leaf10", "abc"); + ctx.setAttribute(pre + "list1[0].leaf1", "true"); + ctx.setAttribute(pre + "list1[0].leaf2", "abc"); + ctx.setAttribute(pre + "list1[0].leaf3", "abc"); + ctx.setAttribute(pre + "list1[0].ll1[0]", "abc"); + ctx.setAttribute(pre + "list1[0].ll1[1]", "abc"); + ctx.setAttribute(pre + "list1[0].ll2[0]", "abc"); + ctx.setAttribute(pre + "list1[0].ll2[1]", "abc"); + ctx.setAttribute(pre + "list1[0].cont4.leaf11", "abc"); + ctx.setAttribute(pre + "list1[0].list4[0].leaf8", "abc"); + ctx.setAttribute(pre + "list1[0].list4[1].leaf8", "abc"); + ctx.setAttribute(pre + "list1[0].list5[0].leaf9", "abc"); + ctx.setAttribute(pre + "list1[0].list5[1].leaf9", "abc"); + ctx.setAttribute(pre + "list1[1].leaf1", "true"); + ctx.setAttribute(pre + "list1[1].leaf2", "abc"); + ctx.setAttribute(pre + "list1[1].leaf3", "abc"); + ctx.setAttribute(pre + "list1[1].ll1[0]", "abc"); + ctx.setAttribute(pre + "list1[1].ll1[1]", "abc"); + ctx.setAttribute(pre + "list1[1].ll2[0]", "abc"); + ctx.setAttribute(pre + "list1[1].ll2[1]", "abc"); + ctx.setAttribute(pre + "list1[1].cont4.leaf11", "abc"); + ctx.setAttribute(pre + "list1[1].list4[0].leaf8", "abc"); + ctx.setAttribute(pre + "list1[1].list4[1].leaf8", "abc"); + ctx.setAttribute(pre + "list1[1].list5[0].leaf9", "abc"); + ctx.setAttribute(pre + "list1[1].list5[1].leaf9", "abc"); + ctx.setAttribute(pre + "list2[0].leaf4", "abc"); + ctx.setAttribute(pre + "list2[1].leaf4", "abc"); + ctx.setAttribute(pre + "leaf5", "abc"); + ctx.setAttribute(pre + "leaf6", "abc"); + ctx.setAttribute(pre + "ll3[0]", "abc"); + ctx.setAttribute(pre + "ll3[1]", "abc"); + ctx.setAttribute(pre + "ll4[0]", "abc"); + ctx.setAttribute(pre + "ll4[1]", "abc"); + ctx.setAttribute(pre + "cont4.leaf10", "abc"); + ctx.setAttribute(pre + "list6[0].leaf11", "abc"); + ctx.setAttribute(pre + "list6[1].leaf11", "abc"); + ctx.setAttribute(pre + "leaf12", "abc"); + ctx.setAttribute(pre + "ll5[0]", "abc"); + ctx.setAttribute(pre + "ll5[1]", "abc"); + ctx.setAttribute(pre + "cont4.test-augment:cont5.leaf13", "true"); + ctx.setAttribute(pre + "cont4.test-augment:list7[0].leaf14", "test"); + ctx.setAttribute(pre + "cont4.test-augment:list7[1].leaf14", "create"); + ctx.setAttribute(pre + "cont4.test-augment:leaf15", "abc"); + ctx.setAttribute(pre + "cont4.test-augment:ll6[0]", "unbounded"); + ctx.setAttribute(pre + "cont4.test-augment:ll6[1]", "8"); + ctx.setAttribute(pre + "cont4.test-augment:cont13.cont12.leaf26", + "abc"); + ctx.setAttribute(pre + "cont4.test-augment:cont13.list9[0].leaf27", + "abc"); + ctx.setAttribute(pre + "cont4.test-augment:cont13.list9[1].leaf27", + "abc"); + ctx.setAttribute(pre + "cont4.test-augment:cont13.leaf28", "abc"); + ctx.setAttribute(pre + "cont4.test-augment:cont13.ll9[0]", "abc"); + ctx.setAttribute(pre + "cont4.test-augment:cont13.ll9[1]", "abc"); + return ctx; + } + + /** + * Creates attribute list for encoding JSON or XML with RPC YANG file. + * + * @param pre prefix + * @return service logic context + */ + private SvcLogicContext createAttListRpc(String pre) { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute(pre + "cont14.leaf28", "abc"); + ctx.setAttribute(pre + "list10[0].leaf29", "abc"); + ctx.setAttribute(pre + "list10[1].leaf29", "abc"); + ctx.setAttribute(pre + "leaf30", "abc"); + ctx.setAttribute(pre + "ll10[0]", "abc"); + ctx.setAttribute(pre + "ll10[1]", "abc"); + ctx.setAttribute(pre + "cont15.leaf31", "abc"); + ctx.setAttribute(pre + "cont13.list9[0].leaf27", "abc"); + ctx.setAttribute(pre + "cont13.list9[1].leaf27", "abc"); + ctx.setAttribute(pre + "cont13.leaf28", "abc"); + ctx.setAttribute(pre + "cont13.ll9[0]", "abc"); + ctx.setAttribute(pre + "cont13.ll9[1]", "abc"); + return ctx; + } + + /** + * Verifies the attribute list for decoding from JSON or XML with + * identity-ref YANG file. + * + * @param ctx service logic context + * @param pre prefix + */ + private void verifyAttList(SvcLogicContext ctx, String pre) { + String pre1 = pre + "con1.interfaces."; + assertThat(ctx.getAttribute(pre + "con1.interface"), is( + "identity-types:physical")); + assertThat(ctx.getAttribute(pre + "con1.interface"), is( + "identity-types:physical")); + assertThat(ctx.getAttribute(pre1 + "int-list[0].iden"), is("optical")); + assertThat(ctx.getAttribute(pre1 + "int-list[0].available.ll[0]"), is( + "Giga")); + assertThat(ctx.getAttribute(pre1 + "int-list[0].available.ll[1]"), is( + "identity-types:Loopback")); + assertThat(ctx.getAttribute(pre1 + "int-list[0].available.ll[2]"), is( + "identity-types-second:Ethernet")); + assertThat(ctx.getAttribute(pre1 + "int-list[0].available.leaf1"), is( + "58")); + assertThat(ctx.getAttribute(pre1 + "int-list[0].available.leaf2"), is( + "identity-types-second:iden2")); + + assertThat(ctx.getAttribute(pre1 + "int-list[1].iden"), is( + "214748364")); + assertThat(ctx.getAttribute(pre1 + "int-list[1].available.ll[0]"), is( + "Giga")); + assertThat(ctx.getAttribute(pre1 + "int-list[1].available.ll[1]"), is( + "identity-types:Loopback")); + assertThat(ctx.getAttribute(pre1 + "int-list[1].available.ll[2]"), is( + "identity-types-second:Ethernet")); + assertThat(ctx.getAttribute(pre1 + "int-list[1].available.leaf1"), is( + "8888")); + assertThat(ctx.getAttribute(pre1 + "int-list[1].available.leaf2"), is( + "identity-types-second:iden2")); + } + + /** + * Verifies the attribute list for decoding from JSON or XML with + * container, grouping and augmented file. + * + * @param ctx service logic context + * @param pre prefix + */ + private void verifyAttListYang(SvcLogicContext ctx, String pre) { + assertThat(ctx.getAttribute(pre + "cont3.leaf10"), is("abc")); + assertThat(ctx.getAttribute(pre + "list1[0].leaf1"), is("true")); + assertThat(ctx.getAttribute(pre + "list1[0].leaf2"), is("abc")); + assertThat(ctx.getAttribute(pre + "list1[0].leaf3"), is("abc")); + assertThat(ctx.getAttribute(pre + "list1[0].ll1[0]"), is("abc")); + assertThat(ctx.getAttribute(pre + "list1[0].ll1[1]"), is("abc")); + assertThat(ctx.getAttribute(pre + "list1[0].ll2[0]"), is("abc")); + assertThat(ctx.getAttribute(pre + "list1[0].ll2[1]"), is("abc")); + assertThat(ctx.getAttribute(pre + "list1[0].cont4.leaf11"), is("abc")); + assertThat(ctx.getAttribute(pre + "list1[0].list4[0].leaf8"), + is("abc")); + assertThat(ctx.getAttribute(pre + "list1[0].list4[1].leaf8"), + is("abc")); + assertThat(ctx.getAttribute(pre + "list1[0].list5[0].leaf9"), + is("abc")); + assertThat(ctx.getAttribute(pre + "list1[0].list5[1].leaf9"), + is("abc")); + assertThat(ctx.getAttribute(pre + "list1[1].leaf1"), is("true")); + assertThat(ctx.getAttribute(pre + "list1[1].leaf2"), is("abc")); + assertThat(ctx.getAttribute(pre + "list1[1].leaf3"), is("abc")); + assertThat(ctx.getAttribute(pre + "list1[1].ll1[0]"), is("abc")); + assertThat(ctx.getAttribute(pre + "list1[1].ll1[1]"), is("abc")); + assertThat(ctx.getAttribute(pre + "list1[1].ll2[0]"), is("abc")); + assertThat(ctx.getAttribute(pre + "list1[1].ll2[1]"), is("abc")); + assertThat(ctx.getAttribute(pre + "list1[1].cont4.leaf11"), is("abc")); + assertThat(ctx.getAttribute(pre + "list1[1].list4[0].leaf8"), + is("abc")); + assertThat(ctx.getAttribute(pre + "list1[1].list4[1].leaf8"), + is("abc")); + assertThat(ctx.getAttribute(pre + "list1[1].list5[0].leaf9"), + is("abc")); + assertThat(ctx.getAttribute(pre + "list1[1].list5[1].leaf9"), + is("abc")); + assertThat(ctx.getAttribute(pre + "list2[0].leaf4"), is("abc")); + assertThat(ctx.getAttribute(pre + "list2[1].leaf4"), is("abc")); + assertThat(ctx.getAttribute(pre + "leaf5"), is("abc")); + assertThat(ctx.getAttribute(pre + "leaf6"), is("abc")); + assertThat(ctx.getAttribute(pre + "ll3[0]"), is("abc")); + assertThat(ctx.getAttribute(pre + "ll3[1]"), is("abc")); + assertThat(ctx.getAttribute(pre + "ll4[0]"), is("abc")); + assertThat(ctx.getAttribute(pre + "ll4[1]"), is("abc")); + assertThat(ctx.getAttribute(pre + "cont4.leaf10"), is( "abc")); + assertThat(ctx.getAttribute(pre + "list6[0].leaf11"), is("abc")); + assertThat(ctx.getAttribute(pre + "list6[1].leaf11"), is("abc")); + assertThat(ctx.getAttribute(pre + "leaf12"), is("abc")); + assertThat(ctx.getAttribute(pre + "ll5[0]"), is("abc")); + assertThat(ctx.getAttribute(pre + "ll5[1]"), is("abc")); + assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont5.leaf13"), + is("true")); + assertThat(ctx.getAttribute(pre + "cont4.test-augment:list7[0].leaf14"), + is("test")); + assertThat(ctx.getAttribute(pre + "cont4.test-augment:list7[1].leaf14"), + is("create")); + assertThat(ctx.getAttribute(pre + "cont4.test-augment:leaf15"), + is("abc")); + assertThat(ctx.getAttribute(pre + "cont4.test-augment:ll6[0]"), + is("unbounded")); + assertThat(ctx.getAttribute(pre + "cont4.test-augment:ll6[1]"), + is("8")); + assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13" + + ".cont12.leaf26"), is("abc")); + assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.list9[0]" + + ".leaf27"), is("abc")); + assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.list9[1]" + + ".leaf27"), is("abc")); + assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.leaf28"), + is("abc")); + assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.ll9[0]"), + is("abc")); + assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.ll9[1]"), + is("abc")); + } + + /** + * Verifies the attribute list for decoding from JSON or XML with + * RPC YANG file. + * + * @param ctx service logic context + * @param pre prefix + */ + private void verifyAttListRpc(SvcLogicContext ctx, String pre) { + assertThat(ctx.getAttribute(pre + "cont16.leaf32"), is("abc")); + assertThat(ctx.getAttribute(pre + "list11[0].leaf33"), is("abc")); + assertThat(ctx.getAttribute(pre + "list11[1].leaf33"), is("abc")); + assertThat(ctx.getAttribute(pre + "leaf34"), is("abc")); + assertThat(ctx.getAttribute(pre + "ll11[0]"), is("abc")); + assertThat(ctx.getAttribute(pre + "ll11[1]"), is("abc")); + assertThat(ctx.getAttribute(pre + "cont17.leaf35"), is("abc")); + assertThat(ctx.getAttribute(pre + "cont13.cont12.leaf26"), is("abc")); + assertThat(ctx.getAttribute(pre + "cont13.list9[0].leaf27"), is("abc")); + assertThat(ctx.getAttribute(pre + "cont13.list9[1].leaf27"), is("abc")); + assertThat(ctx.getAttribute(pre + "cont13.ll9[0]"), is("abc")); + assertThat(ctx.getAttribute(pre + "cont13.ll9[1]"), is("abc")); + assertThat(ctx.getAttribute(pre + "cont13.leaf28"), is("abc")); + } + + /** + * Captures the data format messages by mocking it, which can be used in + * testing the value. + * + * @param capturing data format + */ + public class DfCaptor implements Answer { + + private String result; + + /** + * Returns the captured data format message. + * + * @return data format message. + */ + public String getResult() { + return result; + } + + @Override + public String answer(InvocationOnMock invocationOnMock) + throws Throwable { + result = (String) invocationOnMock.callRealMethod(); + return result; + } + } + +} diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java new file mode 100644 index 000000000..c7efdeb37 --- /dev/null +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java @@ -0,0 +1,504 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +/** + * Unit test case utilities for data format serializer and restconf api call + * node. + */ +public final class DataFormatUtilsTest { + + static final String ENCODE_TO_JSON_ID = "{\n" + + " \"identity-test:con1\": {\n" + + " \"interfaces\": {\n" + + " \"int-list\": [\n" + + " {\n" + + " \"iden\": \"optical\",\n" + + " \"available\": {\n" + + " \"ll\": [\n" + + " \"Giga\",\n" + + " \"identity-types:Loopback\",\n" + + " \"identity-types-second:Ethernet" + + "\"\n" + + " ],\n" + + " \"leaf1\": \"58\",\n" + + " \"leaf2\": \"identity-types-second:iden" + + "2\"\n" + + " }\n" + + " },\n" + + " {\n" + + " \"iden\": \"214748364\",\n" + + " \"available\": {\n" + + " \"ll\": [\n" + + " \"Giga\",\n" + + " \"identity-types:Loopback\",\n" + + " \"identity-types-second:Ethernet" + + "\"\n" + + " ],\n" + + " \"leaf1\": \"8888\",\n" + + " \"leaf2\": \"identity-types-second:ide" + + "n2\"\n" + + " }\n" + + " }\n" + + " ]\n" + + " },\n" + + " \"interface\": \"identity-types:physical\"\n" + + " },\n" + + " \"identity-test:l\": \"abc\"\n" + + "}"; + + static final String ENCODE_TO_XML_ID = "\n" + + "\n" + + " \n" + + " \n" + + " optical\n" + + " \n" + + " Giga\n" + + " yangid:Loopback\n" + + " yangid:Ethernet\n" + + " 58\n" + + " yangid:iden2\n" + + " \n" + + " \n" + + " \n" + + " 214748364\n" + + " \n" + + " Giga\n" + + " yangid:Loopback\n" + + " yangid:Ethernet\n" + + " 8888\n" + + " yangid:iden2\n" + + " \n" + + " \n" + + " \n" + + " " + + "yangid:physical\n" + + "\n"; + + static final String ENCODE_TO_JSON_YANG = "{\n" + + " \"test-yang:cont2\": {\n" + + " \"list1\": [\n" + + " {\n" + + " \"ll1\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"leaf1\": \"true\",\n" + + " \"ll2\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"list5\": [\n" + + " {\n" + + " \"leaf9\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"leaf9\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"leaf3\": \"abc\",\n" + + " \"leaf2\": \"abc\",\n" + + " \"list4\": [\n" + + " {\n" + + " \"leaf8\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"leaf8\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"cont4\": {\n" + + " \"leaf11\": \"abc\"\n" + + " }\n" + + " },\n" + + " {\n" + + " \"ll1\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"leaf1\": \"true\",\n" + + " \"ll2\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"leaf3\": \"abc\",\n" + + " \"list5\": [\n" + + " {\n" + + " \"leaf9\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"leaf9\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"list4\": [\n" + + " {\n" + + " \"leaf8\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"leaf8\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"leaf2\": \"abc\",\n" + + " \"cont4\": {\n" + + " \"leaf11\": \"abc\"\n" + + " }\n" + + " }\n" + + " ],\n" + + " \"ll3\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"ll5\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"cont4\": {\n" + + " \"leaf10\": \"abc\",\n" + + " \"test-augment:cont13\": {\n" + + " \"ll9\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"list9\": [\n" + + " {\n" + + " \"leaf27\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"leaf27\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"leaf28\": \"abc\",\n" + + " \"cont12\": {\n" + + " \"leaf26\": \"abc\"\n" + + " }\n" + + " },\n" + + " \"test-augment:list7\": [\n" + + " {\n" + + " \"leaf14\": \"test\"\n" + + " },\n" + + " {\n" + + " \"leaf14\": \"create\"\n" + + " }\n" + + " ],\n" + + " \"test-augment:leaf15\": \"abc\",\n" + + " \"test-augment:ll6\": [\n" + + " \"unbounded\",\n" + + " \"8\"\n" + + " ],\n" + + " \"test-augment:cont5\": {\n" + + " \"leaf13\": \"true\"\n" + + " }\n" + + " },\n" + + " \"ll4\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"cont3\": {\n" + + " \"leaf10\": \"abc\"\n" + + " },\n" + + " \"leaf5\": \"abc\",\n" + + " \"list2\": [\n" + + " {\n" + + " \"leaf4\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"leaf4\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"leaf12\": \"abc\",\n" + + " \"leaf6\": \"abc\",\n" + + " \"list6\": [\n" + + " {\n" + + " \"leaf11\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"leaf11\": \"abc\"\n" + + " }\n" + + " ]\n" + + " }\n" + + "}"; + + static final String ENCODE_TO_XML_YANG = "\n" + + "\n" + + " \n" + + " abc\n" + + " abc\n" + + " true\n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " \n" + + " abc\n" + + " abc\n" + + " true\n" + + " abc\n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " abc\n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " \n" + + " test\n" + + " \n" + + " \n" + + " create\n" + + " \n" + + " abc\n" + + " unbounded\n" + + " 8\n" + + " \n" + + " true\n" + + " \n" + + " \n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + "\n"; + + + static final String ENCODE_TO_JSON_RPC = "{\n" + + " \"test-yang:input\": {\n" + + " \"leaf30\": \"abc\",\n" + + " \"list10\": [\n" + + " {\n" + + " \"leaf29\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"leaf29\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"cont15\": {\n" + + " \"leaf31\": \"abc\"\n" + + " },\n" + + " \"cont14\": {\n" + + " \"leaf28\": \"abc\"\n" + + " },\n" + + " \"cont13\": {\n" + + " \"list9\": [\n" + + " {\n" + + " \"leaf27\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"leaf27\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"ll9\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"leaf28\": \"abc\"\n" + + " },\n" + + " \"ll10\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ]\n" + + " }\n" + + "}"; + + static final String DECODE_FROM_JSON_RPC = "{\n" + + " \"test-yang:output\": {\n" + + " \"cont16\": {\n" + + " \"leaf32\": \"abc\"\n" + + " },\n" + + " \"list11\": [\n" + + " {\n" + + " \"leaf33\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"leaf33\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"leaf34\": \"abc\",\n" + + " \"ll11\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"cont17\": {\n" + + " \"leaf35\": \"abc\"\n" + + " },\n" + + " \"cont13\": {\n" + + " \"cont12\": {\n" + + " \"leaf26\": \"abc\"\n" + + " },\n" + + " \"list9\": [\n" + + " {\n" + + " \"leaf27\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"leaf27\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"ll9\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"leaf28\": \"abc\"\n" + + " }\n" + + " }\n" + + "}"; + + static final String ENCODE_TO_XML_RPC = "\n" + + "\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " abc\n" + + "\n"; + + static final String DECODE_FROM_XML_RPC = "\n" + + "\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " abc\n" + + " abc\n" + + " \n" + + ""; +} diff --git a/restconf-client/provider/src/test/resources/yang/identity-test.yang b/restconf-client/provider/src/test/resources/yang/identity-test.yang index 81d3f0a0b..12ef717f6 100644 --- a/restconf-client/provider/src/test/resources/yang/identity-test.yang +++ b/restconf-client/provider/src/test/resources/yang/identity-test.yang @@ -58,16 +58,16 @@ module identity-test { type available; } leaf leaf1 { - type leafref { - path "../../iden"; - } + type leafref { + path "../../iden"; + } } leaf leaf2 { - type identityref { + type identityref { base type:int-type; base sec:iden1; - } + } } } } diff --git a/restconf-client/provider/src/test/resources/yang/identity-types-second.yang b/restconf-client/provider/src/test/resources/yang/identity-types-second.yang index ad752de31..98d6a6e60 100644 --- a/restconf-client/provider/src/test/resources/yang/identity-types-second.yang +++ b/restconf-client/provider/src/test/resources/yang/identity-types-second.yang @@ -1,4 +1,4 @@ -module identity-types-second{ +module identity-types-second { yang-version 1; namespace "identity:list:second:ns:test:json:ser"; prefix "sec"; diff --git a/restconf-client/provider/src/test/resources/yang/test-augment.yang b/restconf-client/provider/src/test/resources/yang/test-augment.yang index bac19171b..795000d39 100644 --- a/restconf-client/provider/src/test/resources/yang/test-augment.yang +++ b/restconf-client/provider/src/test/resources/yang/test-augment.yang @@ -14,19 +14,24 @@ module test-augment { augment "/t:cont1/t:cont2/t:cont4" { container cont5 { leaf leaf13 { - type string; + type empty; } } list list7 { - leaf leaf14 { - type string; - } + leaf leaf14 { + type instance-identifier; + } } leaf leaf15 { type string; } leaf-list ll6 { - type string; + type union { + type int32; + type enumeration { + enum "unbounded"; + } + } } uses "t:g1"; } @@ -34,16 +39,22 @@ module test-augment { uses "t:g1"; augment "/t:ch1/t:c1/t:cont8/t:cont6" { choice ch2 { - case c3 { - leaf leaf21 { - type string; - } - } - case c4 { - leaf leaf22 { - type string; - } - } + case c3 { + leaf leaf21 { + type string; + } + } + case c4 { + leaf leaf22 { + type enumeration { + enum zero; + enum one; + enum seven { + value 7; + } + } + } + } } } @@ -72,14 +83,24 @@ module test-augment { } augment "/t:create-sfc/t:input" { - leaf leaf36 { - type string; - } + leaf leaf36 { + type bits { + bit angle { + position 0; + } + bit degree { + position 1; + } + bit movement { + position 2; + } + } + } } augment "/t:create-sfc/t:output" { leaf leaf37 { - type string; + type boolean; } } } \ No newline at end of file diff --git a/restconf-client/provider/src/test/resources/yang/test-yang.yang b/restconf-client/provider/src/test/resources/yang/test-yang.yang index e99d87bf8..b2bf06003 100644 --- a/restconf-client/provider/src/test/resources/yang/test-yang.yang +++ b/restconf-client/provider/src/test/resources/yang/test-yang.yang @@ -17,7 +17,7 @@ module test-yang { list list1 { key "leaf1 leaf2"; leaf leaf1 { - type string; + type empty; } leaf leaf2 { type string; @@ -87,66 +87,66 @@ module test-yang { } choice ch1 { - case c1 { - container cont8 { - container cont6 { - leaf leaf16 { - type string; - } - } - list list8 { - leaf leaf18 { - type string; - } - } - leaf leaf19 { - type string; - } - leaf-list ll7 { - type string; - } - } - } - case c2 { - container cont9 { - leaf leaf20 { - type string; - } - leaf-list ll8 { - type string; - } - container cont11 { - choice ch3 { - case c1 { - leaf leaf25 { + case c1 { + container cont8 { + container cont6 { + leaf leaf16 { type string; - } - uses g1; - } - } - } - } - } + } + } + list list8 { + leaf leaf18 { + type string; + } + } + leaf leaf19 { + type string; + } + leaf-list ll7 { + type string; + } + } + } + case c2 { + container cont9 { + leaf leaf20 { + type string; + } + leaf-list ll8 { + type string; + } + container cont11 { + choice ch3 { + case c1 { + leaf leaf25 { + type string; + } + uses g1; + } + } + } + } + } } grouping g1 { - container cont13 { - container cont12 { - leaf leaf26 { - type string; - } - } - list list9 { - leaf leaf27 { - type string; - } - } - leaf leaf28 { - type string; - } - leaf-list ll9 { - type string; - } + container cont13 { + container cont12 { + leaf leaf26 { + type string; + } + } + list list9 { + leaf leaf27 { + type string; + } + } + leaf leaf28 { + type string; + } + leaf-list ll9 { + type string; + } } } -- cgit From 6a8381e0f724955e520ef03b775024b4e515d837 Mon Sep 17 00:00:00 2001 From: gaurav Date: Mon, 10 Sep 2018 18:21:44 +0530 Subject: Dependency management for Restconf Client Changes includes: - Upgrade Restapicallnode implementation to use latest version of JAX-RS and sun.jersey versions to align with RestconfClient which is using latest versions for SSE support. This solve problem 1 as specified in the JIRA. Change-Id: If641acbca247f8ad0e804161fb97f88c293ba43a Issue-ID: CCSDK-567 Signed-off-by: Gaurav Agrawal --- restapi-call-node/provider/pom.xml | 42 +- .../sli/plugins/restapicall/RestapiCallNode.java | 816 +++++++++++---------- 2 files changed, 454 insertions(+), 404 deletions(-) diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 6670cfd8c..942c4f32f 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 @@ -21,9 +22,9 @@ - junit - junit - test + javax.ws.rs + javax.ws.rs-api + 2.1 org.onap.ccsdk.sli.core @@ -38,22 +39,35 @@ slf4j-api - com.sun.jersey - jersey-client + org.glassfish.jersey.security + oauth1-signature + ${glassfish.version} - com.sun.jersey.contribs.jersey-oauth - oauth-signature - ${jersey.version} - - - com.sun.jersey.contribs.jersey-oauth - oauth-client - ${jersey.version} + org.glassfish.jersey.security + oauth1-client + ${glassfish.version} org.codehaus.jettison jettison + + org.glassfish.jersey.core + jersey-client + ${glassfish.version} + + + org.glassfish.jersey.inject + jersey-hk2 + ${glassfish.version} + + + + + junit + junit + test + diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 6a9e81bcc..e5503435b 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -21,33 +21,10 @@ package org.onap.ccsdk.sli.plugins.restapicall; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientHandlerException; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.UniformInterfaceException; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; -import com.sun.jersey.api.client.filter.HTTPDigestAuthFilter; -import com.sun.jersey.client.urlconnection.HTTPSProperties; -import com.sun.jersey.oauth.client.OAuthClientFilter; -import com.sun.jersey.oauth.signature.OAuthParameters; -import com.sun.jersey.oauth.signature.OAuthSecrets; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import static java.lang.Boolean.valueOf; +import static javax.ws.rs.client.Entity.entity; +import static org.onap.ccsdk.sli.plugins.restapicall.AuthType.fromString; -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.ws.rs.core.EntityTag; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriBuilder; import java.io.FileInputStream; import java.io.IOException; import java.net.SocketException; @@ -64,29 +41,42 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Properties; import java.util.Set; - -import static java.lang.Boolean.valueOf; -import static org.onap.ccsdk.sli.plugins.restapicall.AuthType.fromString; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.ws.rs.ProcessingException; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.Invocation; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.EntityTag; +import javax.ws.rs.core.Feature; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; +import org.apache.commons.lang3.StringUtils; +import org.glassfish.jersey.client.ClientProperties; +import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; +import org.glassfish.jersey.client.oauth1.ConsumerCredentials; +import org.glassfish.jersey.client.oauth1.OAuth1ClientSupport; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RestapiCallNode implements SvcLogicJavaPlugin { - private static final Logger log = LoggerFactory.getLogger(RestapiCallNode.class); - - private String uebServers; - private String defaultUebTemplateFileName = "/opt/bvc/restapi/templates/default-ueb-message.json"; - protected RetryPolicyStore retryPolicyStore; protected static final String DME2_PROPERTIES_FILE_NAME = "dme2.properties"; protected static final String UEB_PROPERTIES_FILE_NAME = "ueb.properties"; protected static final String DEFAULT_PROPERTIES_DIR = "/opt/onap/ccsdk/data/properties"; protected static final String PROPERTIES_DIR_KEY = "SDNC_CONFIG_DIR"; - public RetryPolicyStore getRetryPolicyStore() { - return retryPolicyStore; - } - - public void setRetryPolicyStore(RetryPolicyStore retryPolicyStore) { - this.retryPolicyStore = retryPolicyStore; - } + private static final Logger log = LoggerFactory.getLogger(RestapiCallNode.class); + protected RetryPolicyStore retryPolicyStore; + private String uebServers; + private String defaultUebTemplateFileName = "/opt/bvc/restapi/templates/default-ueb-message.json"; public RestapiCallNode() { String configDir = System.getProperty(PROPERTIES_DIR_KEY, DEFAULT_PROPERTIES_DIR); @@ -111,7 +101,157 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } } - /** + /** + * Returns parameters from the parameter map. + * + * @param paramMap parameter map + * @param p parameters instance + * @return parameters filed instance + * @throws SvcLogicException when svc logic exception occurs + */ + public static Parameters getParameters(Map paramMap, + Parameters p) + throws SvcLogicException { + p.templateFileName = parseParam(paramMap, "templateFileName", + false, null); + p.requestBody = parseParam(paramMap, "requestBody", false, null); + p.restapiUrl = parseParam(paramMap, "restapiUrl", true, null); + validateUrl(p.restapiUrl); + p.restapiUser = parseParam(paramMap, "restapiUser", false, null); + p.restapiPassword = parseParam(paramMap, "restapiPassword", false, + null); + p.oAuthConsumerKey = parseParam(paramMap, "oAuthConsumerKey", + false, null); + p.oAuthConsumerSecret = parseParam(paramMap, "oAuthConsumerSecret", + false, null); + p.oAuthSignatureMethod = parseParam(paramMap, "oAuthSignatureMethod", + false, null); + p.oAuthVersion = parseParam(paramMap, "oAuthVersion", false, null); + p.contentType = parseParam(paramMap, "contentType", false, null); + p.format = Format.fromString(parseParam(paramMap, "format", false, + "json")); + p.authtype = fromString(parseParam(paramMap, "authType", false, + "unspecified")); + p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", + false, "post")); + p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); + p.listNameList = getListNameList(paramMap); + String skipSendingStr = paramMap.get("skipSending"); + p.skipSending = "true".equalsIgnoreCase(skipSendingStr); + p.convertResponse = valueOf(parseParam(paramMap, "convertResponse", + false, "true")); + p.trustStoreFileName = parseParam(paramMap, "trustStoreFileName", + false, null); + p.trustStorePassword = parseParam(paramMap, "trustStorePassword", + false, null); + p.keyStoreFileName = parseParam(paramMap, "keyStoreFileName", + false, null); + p.keyStorePassword = parseParam(paramMap, "keyStorePassword", + false, null); + p.ssl = p.trustStoreFileName != null && p.trustStorePassword != null + && p.keyStoreFileName != null && p.keyStorePassword != null; + p.customHttpHeaders = parseParam(paramMap, "customHttpHeaders", + false, null); + p.partner = parseParam(paramMap, "partner", false, null); + p.dumpHeaders = valueOf(parseParam(paramMap, "dumpHeaders", + false, null)); + p.returnRequestPayload = valueOf(parseParam( + paramMap, "returnRequestPayload", false, null)); + return p; + } + + /** + * Validates the given URL in the parameters. + * + * @param restapiUrl rest api URL + * @throws SvcLogicException when URL validation fails + */ + private static void validateUrl(String restapiUrl) + throws SvcLogicException { + try { + URI.create(restapiUrl); + } catch (IllegalArgumentException e) { + throw new SvcLogicException("Invalid input of url " + + e.getLocalizedMessage(), e); + } + } + + /** + * Returns the list of list name. + * + * @param paramMap parameters map + * @return list of list name + */ + private static Set getListNameList(Map paramMap) { + Set ll = new HashSet<>(); + for (Map.Entry entry : paramMap.entrySet()) { + if (entry.getKey().startsWith("listName")) { + ll.add(entry.getValue()); + } + } + return ll; + } + + /** + * Parses the parameter string map of property, validates if required, + * assigns default value if present and returns the value. + * + * @param paramMap string param map + * @param name name of the property + * @param required if value required + * @param def default value + * @return value of the property + * @throws SvcLogicException if required parameter value is empty + */ + public static String parseParam(Map paramMap, String name, + boolean required, String def) + throws SvcLogicException { + String s = paramMap.get(name); + + if (s == null || s.trim().length() == 0) { + if (!required) { + return def; + } + throw new SvcLogicException("Parameter " + name + " is required in RestapiCallNode"); + } + + s = s.trim(); + StringBuilder value = new StringBuilder(); + int i = 0; + int i1 = s.indexOf('%'); + while (i1 >= 0) { + int i2 = s.indexOf('%', i1 + 1); + if (i2 < 0) { + break; + } + + String varName = s.substring(i1 + 1, i2); + String varValue = System.getenv(varName); + if (varValue == null) { + varValue = "%" + varName + "%"; + } + + value.append(s.substring(i, i1)); + value.append(varValue); + + i = i2 + 1; + i1 = s.indexOf('%', i); + } + value.append(s.substring(i)); + + log.info("Parameter {}: [{}]", name, value); + return value.toString(); + } + + public RetryPolicyStore getRetryPolicyStore() { + return retryPolicyStore; + } + + public void setRetryPolicyStore(RetryPolicyStore retryPolicyStore) { + this.retryPolicyStore = retryPolicyStore; + } + + /** * Allows Directed Graphs the ability to interact with REST APIs. * @param paramMap HashMap of parameters passed by the DG to this function * @@ -148,7 +288,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } public void sendRequest(Map paramMap, SvcLogicContext ctx, Integer retryCount) - throws SvcLogicException { + throws SvcLogicException { RetryPolicy retryPolicy = null; HttpResponse r = new HttpResponse(); @@ -174,9 +314,9 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { ctx.setAttribute(pp + "header." + a.getKey(), StringUtils.join(a.getValue(), ",")); } } - + if (p.returnRequestPayload && req != null) { - ctx.setAttribute(pp + "httpRequest", req); + ctx.setAttribute(pp + "httpRequest", req); } if (r.body != null && r.body.trim().length() > 0) { @@ -184,14 +324,17 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { if (p.convertResponse) { Map mm = null; - if (p.format == Format.XML) + if (p.format == Format.XML) { mm = XmlParser.convertToProperties(r.body, p.listNameList); - else if (p.format == Format.JSON) + } else if (p.format == Format.JSON) { mm = JsonParser.convertToProperties(r.body); + } - if (mm != null) - for (Map.Entry entry : mm.entrySet()) + if (mm != null) { + for (Map.Entry entry : mm.entrySet()) { ctx.setAttribute(pp + entry.getKey(), entry.getValue()); + } + } } } } catch (SvcLogicException e) { @@ -209,7 +352,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { retryCount = 0; } String retryMessage = retryCount + " attempts were made out of " + retryPolicy.getMaximumRetries() + - " maximum retries."; + " maximum retries."; log.debug(retryMessage); try { retryCount = retryCount + 1; @@ -219,7 +362,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { String retryString = retryPolicy.getNextHostName(uri.toString()); URI uriTwo = new URI(retryString); URI retryUri = UriBuilder.fromUri(uri).host(uriTwo.getHost()).port(uriTwo.getPort()).scheme( - uriTwo.getScheme()).build(); + uriTwo.getScheme()).build(); paramMap.put("restapiUrl", retryUri.toString()); log.debug("URL was set to {}", retryUri.toString()); log.debug("Failed to communicate with host {}. Request will be re-attempted using the host {}.", @@ -233,152 +376,16 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } catch (Exception ex) { log.error("Could not attempt retry.", ex); String retryErrorMessage = - "Retry attempt has failed. No further retry shall be attempted, calling " + - "setFailureResponseStatus."; + "Retry attempt has failed. No further retry shall be attempted, calling " + + "setFailureResponseStatus."; setFailureResponseStatus(ctx, prefix, retryErrorMessage, r); } } } - if (r != null && r.code >= 300) + if (r != null && r.code >= 300) { throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); - } - - /** - * Returns parameters from the parameter map. - * - * @param paramMap parameter map - * @param p parameters instance - * @return parameters filed instance - * @throws SvcLogicException when svc logic exception occurs - */ - public static Parameters getParameters(Map paramMap, - Parameters p) - throws SvcLogicException { - p.templateFileName = parseParam(paramMap, "templateFileName", - false, null); - p.requestBody = parseParam(paramMap, "requestBody", false, null); - p.restapiUrl = parseParam(paramMap, "restapiUrl", true, null); - validateUrl(p.restapiUrl); - p.restapiUser = parseParam(paramMap, "restapiUser", false, null); - p.restapiPassword = parseParam(paramMap, "restapiPassword", false, - null); - p.oAuthConsumerKey = parseParam(paramMap, "oAuthConsumerKey", - false, null); - p.oAuthConsumerSecret = parseParam(paramMap, "oAuthConsumerSecret", - false, null); - p.oAuthSignatureMethod = parseParam(paramMap, "oAuthSignatureMethod", - false, null); - p.oAuthVersion = parseParam(paramMap, "oAuthVersion", false, null); - p.contentType = parseParam(paramMap, "contentType", false, null); - p.format = Format.fromString(parseParam(paramMap, "format", false, - "json")); - p.authtype = fromString(parseParam(paramMap, "authType", false, - "unspecified")); - p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", - false, "post")); - p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); - p.listNameList = getListNameList(paramMap); - String skipSendingStr = paramMap.get("skipSending"); - p.skipSending = "true".equalsIgnoreCase(skipSendingStr); - p.convertResponse = valueOf(parseParam(paramMap, "convertResponse", - false, "true")); - p.trustStoreFileName = parseParam(paramMap, "trustStoreFileName", - false, null); - p.trustStorePassword = parseParam(paramMap, "trustStorePassword", - false, null); - p.keyStoreFileName = parseParam(paramMap, "keyStoreFileName", - false, null); - p.keyStorePassword = parseParam(paramMap, "keyStorePassword", - false, null); - p.ssl = p.trustStoreFileName != null && p.trustStorePassword != null - && p.keyStoreFileName != null && p.keyStorePassword != null; - p.customHttpHeaders = parseParam(paramMap, "customHttpHeaders", - false, null); - p.partner = parseParam(paramMap, "partner", false, null); - p.dumpHeaders = valueOf(parseParam(paramMap, "dumpHeaders", - false, null)); - p.returnRequestPayload = valueOf(parseParam( - paramMap, "returnRequestPayload", false, null)); - return p; - } - - /** - * Validates the given URL in the parameters. - * - * @param restapiUrl rest api URL - * @throws SvcLogicException when URL validation fails - */ - private static void validateUrl(String restapiUrl) - throws SvcLogicException { - try { - URI.create(restapiUrl); - } catch (IllegalArgumentException e) { - throw new SvcLogicException("Invalid input of url " - + e.getLocalizedMessage(), e); - } - } - - /** - * Returns the list of list name. - * - * @param paramMap parameters map - * @return list of list name - */ - private static Set getListNameList(Map paramMap) { - Set ll = new HashSet<>(); - for (Map.Entry entry : paramMap.entrySet()) - if (entry.getKey().startsWith("listName")) - ll.add(entry.getValue()); - return ll; - } - - /** - * Parses the parameter string map of property, validates if required, - * assigns default value if present and returns the value. - * - * @param paramMap string param map - * @param name name of the property - * @param required if value required - * @param def default value - * @return value of the property - * @throws SvcLogicException if required parameter value is empty - */ - public static String parseParam(Map paramMap, String name, - boolean required, String def) - throws SvcLogicException { - String s = paramMap.get(name); - - if (s == null || s.trim().length() == 0) { - if (!required) - return def; - throw new SvcLogicException("Parameter " + name + " is required in RestapiCallNode"); } - - s = s.trim(); - StringBuilder value = new StringBuilder(); - int i = 0; - int i1 = s.indexOf('%'); - while (i1 >= 0) { - int i2 = s.indexOf('%', i1 + 1); - if (i2 < 0) - break; - - String varName = s.substring(i1 + 1, i2); - String varValue = System.getenv(varName); - if (varValue == null) - varValue = "%" + varName + "%"; - - value.append(s.substring(i, i1)); - value.append(varValue); - - i = i2 + 1; - i1 = s.indexOf('%', i); - } - value.append(s.substring(i)); - - log.info("Parameter {}: [{}]", name, value); - return value.toString(); } protected String buildXmlJsonRequest(SvcLogicContext ctx, String template, Format format) @@ -389,8 +396,9 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { template = expandRepeats(ctx, template, 1); Map mm = new HashMap<>(); - for (String s : ctx.getAttributeKeySet()) + for (String s : ctx.getAttributeKeySet()) { mm.put(s, ctx.getAttribute(s)); + } StringBuilder ss = new StringBuilder(); int i = 0; @@ -402,8 +410,9 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } int i2 = template.indexOf('}', i1 + 2); - if (i2 < 0) + if (i2 < 0) { throw new SvcLogicException("Template error: Matching } not found"); + } String var1 = template.substring(i1 + 2, i2); String value1 = format == Format.XML ? XmlJsonUtil.getXml(mm, var1) : XmlJsonUtil.getJson(mm, var1); @@ -411,14 +420,17 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { if (value1 == null || value1.trim().length() == 0) { // delete the whole element (line) int i3 = template.lastIndexOf('\n', i1); - if (i3 < 0) + if (i3 < 0) { i3 = 0; + } int i4 = template.indexOf('\n', i1); - if (i4 < 0) + if (i4 < 0) { i4 = template.length(); + } - if (i < i3) + if (i < i3) { ss.append(template.substring(i, i3)); + } i = i4; } else { ss.append(template.substring(i, i1)).append(value1); @@ -427,10 +439,11 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } String req = format == Format.XML - ? XmlJsonUtil.removeEmptyStructXml(ss.toString()) : XmlJsonUtil.removeEmptyStructJson(ss.toString()); + ? XmlJsonUtil.removeEmptyStructXml(ss.toString()) : XmlJsonUtil.removeEmptyStructJson(ss.toString()); - if (format == Format.JSON) + if (format == Format.JSON) { req = XmlJsonUtil.removeLastCommaJson(req); + } long t2 = System.currentTimeMillis(); log.info("Building {} completed. Time: {}", format, (t2 - t1)); @@ -449,9 +462,10 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } int i2 = template.indexOf(':', i1 + 9); - if (i2 < 0) + if (i2 < 0) { throw new SvcLogicException( - "Template error: Context variable name followed by : is required after repeat"); + "Template error: Context variable name followed by : is required after repeat"); + } // Find the closing }, store in i3 int nn = 1; @@ -459,8 +473,9 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { int i = i2; while (nn > 0 && i < template.length()) { i3 = template.indexOf('}', i); - if (i3 < 0) + if (i3 < 0) { throw new SvcLogicException("Template error: Matching } not found"); + } int i32 = template.indexOf('{', i); if (i32 >= 0 && i32 < i3) { nn++; @@ -489,8 +504,9 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { String ss = rpt.replaceAll("\\[\\$\\{" + level + "\\}\\]", "[" + ii + "]"); if (ii == n - 1 && ss.trim().endsWith(",")) { int i4 = ss.lastIndexOf(','); - if (i4 > 0) + if (i4 > 0) { ss = ss.substring(0, i4) + ss.substring(i4 + 1); + } } newTemplate.append(ss); } @@ -498,8 +514,9 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { k = i3 + 1; } - if (k == 0) + if (k == 0) { return newTemplate.toString(); + } return expandRepeats(ctx, newTemplate.toString(), level + 1); } @@ -522,52 +539,47 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { p.oAuthConsumerSecret = fp.oAuthConsumerSecret; p.oAuthSignatureMethod = fp.oAuthSignatureMethod; p.authtype = fp.authtype; - return addAuthType(c,p); + return addAuthType(c, p); } protected Client addAuthType(Client client, Parameters p) throws SvcLogicException { - if (p.authtype == AuthType.Unspecified){ - if (p.restapiUser != null && p.restapiPassword != null) - client.addFilter(new HTTPBasicAuthFilter(p.restapiUser, p.restapiPassword)); - else if(p.oAuthConsumerKey != null && p.oAuthConsumerSecret != null - && p.oAuthSignatureMethod != null) { - OAuthParameters params = new OAuthParameters() - .signatureMethod(p.oAuthSignatureMethod) - .consumerKey(p.oAuthConsumerKey) - .version(p.oAuthVersion); - - OAuthSecrets secrets = new OAuthSecrets() - .consumerSecret(p.oAuthConsumerSecret); - client.addFilter(new OAuthClientFilter(client.getProviders(), params, secrets)); + if (p.authtype == AuthType.Unspecified) { + if (p.restapiUser != null && p.restapiPassword != null) { + client.register(HttpAuthenticationFeature.basic(p.restapiUser, p.restapiPassword)); + } else if (p.oAuthConsumerKey != null && p.oAuthConsumerSecret != null + && p.oAuthSignatureMethod != null) { + Feature oAuth1Feature = OAuth1ClientSupport + .builder(new ConsumerCredentials(p.oAuthConsumerKey, p.oAuthConsumerSecret)) + .version(p.oAuthVersion).signatureMethod(p.oAuthSignatureMethod).feature().build(); + client.register(oAuth1Feature); } } else { if (p.authtype == AuthType.DIGEST) { if (p.restapiUser != null && p.restapiPassword != null) { - client.addFilter(new HTTPDigestAuthFilter(p.restapiUser, p.restapiPassword)); + client.register(HttpAuthenticationFeature.digest(p.restapiUser, p.restapiPassword)); } else { - throw new SvcLogicException("oAUTH authentication type selected but all restapiUser and restapiPassword " + - "parameters doesn't exist", new Throwable()); + throw new SvcLogicException( + "oAUTH authentication type selected but all restapiUser and restapiPassword " + + "parameters doesn't exist", new Throwable()); } - } else if (p.authtype == AuthType.BASIC){ + } else if (p.authtype == AuthType.BASIC) { if (p.restapiUser != null && p.restapiPassword != null) { - client.addFilter(new HTTPBasicAuthFilter(p.restapiUser, p.restapiPassword)); + client.register(HttpAuthenticationFeature.basic(p.restapiUser, p.restapiPassword)); } else { - throw new SvcLogicException("oAUTH authentication type selected but all restapiUser and restapiPassword " + - "parameters doesn't exist", new Throwable()); + throw new SvcLogicException( + "oAUTH authentication type selected but all restapiUser and restapiPassword " + + "parameters doesn't exist", new Throwable()); } - } else if(p.authtype == AuthType.OAUTH ) { - if(p.oAuthConsumerKey != null && p.oAuthConsumerSecret != null && p.oAuthSignatureMethod != null) { - OAuthParameters params = new OAuthParameters() - .signatureMethod(p.oAuthSignatureMethod) - .consumerKey(p.oAuthConsumerKey) - .version(p.oAuthVersion); - - OAuthSecrets secrets = new OAuthSecrets() - .consumerSecret(p.oAuthConsumerSecret); - client.addFilter(new OAuthClientFilter(client.getProviders(), params, secrets)); + } else if (p.authtype == AuthType.OAUTH) { + if (p.oAuthConsumerKey != null && p.oAuthConsumerSecret != null && p.oAuthSignatureMethod != null) { + Feature oAuth1Feature = OAuth1ClientSupport + .builder(new ConsumerCredentials(p.oAuthConsumerKey, p.oAuthConsumerSecret)) + .version(p.oAuthVersion).signatureMethod(p.oAuthSignatureMethod).feature().build(); + client.register(oAuth1Feature); } else { - throw new SvcLogicException("oAUTH authentication type selected but all oAuthConsumerKey, oAuthConsumerSecret " + - "and oAuthSignatureMethod parameters doesn't exist", new Throwable()); + throw new SvcLogicException( + "oAUTH authentication type selected but all oAuthConsumerKey, oAuthConsumerSecret " + + "and oAuthSignatureMethod parameters doesn't exist", new Throwable()); } } } @@ -583,24 +595,25 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { * @throws SvcLogicException when sending http request fails */ public HttpResponse sendHttpRequest(String request, Parameters p) - throws SvcLogicException { + throws SvcLogicException { - ClientConfig config = new DefaultClientConfig(); SSLContext ssl = null; - if (p.ssl && p.restapiUrl.startsWith("https")) + if (p.ssl && p.restapiUrl.startsWith("https")) { ssl = createSSLContext(p); - if (ssl != null) { - HostnameVerifier hostnameVerifier = (hostname, session) -> true; - - config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, - new HTTPSProperties(hostnameVerifier, ssl)); } + Client client; - logProperties(config.getProperties()); + if (ssl != null) { + HttpsURLConnection.setDefaultSSLSocketFactory(ssl.getSocketFactory()); + client = ClientBuilder.newBuilder().sslContext(ssl).hostnameVerifier((s, sslSession) -> true) + .build(); + } else { + client = ClientBuilder.newBuilder().hostnameVerifier((s, sslSession) -> true) + .build(); + } + client.property(ClientProperties.CONNECT_TIMEOUT, 5000); - Client client = Client.create(config); - client.setConnectTimeout(5000); - WebResource webResource = addAuthType(client,p).resource(p.restapiUrl); + WebTarget webTarget = addAuthType(client, p).target(p.restapiUrl); log.info("Sending request:"); log.info(request); @@ -617,38 +630,41 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { tt1 = p.contentType; } - WebResource.Builder webResourceBuilder = webResource.accept(tt).type(tt1); - if(p.format == Format.NONE){ - webResourceBuilder = webResource.header("",""); + Invocation.Builder invocationBuilder = webTarget.request(tt1).accept(tt); + + if (p.format == Format.NONE) { + invocationBuilder.header("", ""); } if (p.customHttpHeaders != null && p.customHttpHeaders.length() > 0) { String[] keyValuePairs = p.customHttpHeaders.split(","); for (String singlePair : keyValuePairs) { int equalPosition = singlePair.indexOf('='); - webResourceBuilder.header(singlePair.substring(0, equalPosition), - singlePair.substring(equalPosition + 1, singlePair.length())); + invocationBuilder.header(singlePair.substring(0, equalPosition), + singlePair.substring(equalPosition + 1, singlePair.length())); } } - webResourceBuilder.header("X-ECOMP-RequestID",org.slf4j.MDC.get("X-ECOMP-RequestID")); + invocationBuilder.header("X-ECOMP-RequestID", org.slf4j.MDC.get("X-ECOMP-RequestID")); - ClientResponse response; + Response response; try { - response = webResourceBuilder.method(p.httpMethod.toString(), ClientResponse.class, request); - } catch (UniformInterfaceException | ClientHandlerException e) { - throw new SvcLogicException("Exception while sending http request to client " - + e.getLocalizedMessage(), e); + response = invocationBuilder.method(p.httpMethod.toString(), entity(request, tt1)); + } catch (ProcessingException | IllegalStateException e) { + throw new SvcLogicException("Exception while posting http request to client " + + e.getLocalizedMessage(), e); } r.code = response.getStatus(); - r.headers = response.getHeaders(); + r.headers = response.getStringHeaders(); EntityTag etag = response.getEntityTag(); - if (etag != null) + if (etag != null) { r.message = etag.getValue(); - if (response.hasEntity() && r.code != 204) - r.body = response.getEntity(String.class); + } + if (response.hasEntity() && r.code != 204) { + r.body = response.readEntity(String.class); + } } long t2 = System.currentTimeMillis(); @@ -718,24 +734,9 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { setResponseStatus(ctx, prefix, r); } - if (r != null && r.code >= 300) + if (r != null && r.code >= 300) { throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); - } - - private static class FileParam { - - public String fileName; - public String url; - public String user; - public String password; - public HttpMethod httpMethod; - public String responsePrefix; - public boolean skipSending; - public String oAuthConsumerKey; - public String oAuthConsumerSecret; - public String oAuthSignatureMethod; - public String oAuthVersion; - public AuthType authtype; + } } private FileParam getFileParameters(Map paramMap) throws SvcLogicException { @@ -756,11 +757,51 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { return p; } + public void postMessageOnUeb(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { + HttpResponse r; + try { + UebParam p = getUebParameters(paramMap); + + String pp = p.responsePrefix != null ? p.responsePrefix + '.' : ""; + + String req; + + if (p.templateFileName == null) { + log.info("No template file name specified. Using default UEB template: {}", defaultUebTemplateFileName); + p.templateFileName = defaultUebTemplateFileName; + } + + String reqTemplate = readFile(p.templateFileName); + reqTemplate = reqTemplate.replaceAll("rootVarName", p.rootVarName); + req = buildXmlJsonRequest(ctx, reqTemplate, Format.JSON); + + r = postOnUeb(req, p); + setResponseStatus(ctx, p.responsePrefix, r); + if (r.body != null) { + ctx.setAttribute(pp + "httpResponse", r.body); + } + + } catch (SvcLogicException e) { + log.error("Error sending the request: {}", e.getMessage(), e); + + r = new HttpResponse(); + r.code = 500; + r.message = e.getMessage(); + String prefix = parseParam(paramMap, "responsePrefix", false, null); + setResponseStatus(ctx, prefix, r); + } + + if (r.code >= 300) { + throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); + } + } + protected HttpResponse sendHttpData(byte[] data, FileParam p) throws SvcLogicException { - Client client = Client.create(); - client.setConnectTimeout(5000); - client.setFollowRedirects(true); - WebResource webResource = addAuthType(client,p).resource(p.url); + + Client client = ClientBuilder.newBuilder().build(); + client.property(ClientProperties.CONNECT_TIMEOUT, 5000); + client.property(ClientProperties.FOLLOW_REDIRECTS, true); + WebTarget webTarget = addAuthType(client, p).target(p.url); log.info("Sending file"); long t1 = System.currentTimeMillis(); @@ -770,53 +811,62 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { if (!p.skipSending) { String tt = "application/octet-stream"; + Invocation.Builder invocationBuilder = webTarget.request(tt).accept(tt); + + Response response; - ClientResponse response; try { - if (p.httpMethod == HttpMethod.POST) - response = webResource.accept(tt).type(tt).post(ClientResponse.class, data); - else if (p.httpMethod == HttpMethod.PUT) - response = webResource.accept(tt).type(tt).put(ClientResponse.class, data); - else + if (p.httpMethod == HttpMethod.POST) { + response = invocationBuilder.post(Entity.entity(data, tt)); + } else if (p.httpMethod == HttpMethod.PUT) { + response = invocationBuilder.put(Entity.entity(data, tt)); + } else { throw new SvcLogicException("Http operation" + p.httpMethod + "not supported"); - } catch (UniformInterfaceException | ClientHandlerException e) { - throw new SvcLogicException("Exception while sending http request to client " + + } + } catch (ProcessingException e) { + throw new SvcLogicException("Exception while posting http request to client " + e.getLocalizedMessage(), e); } r.code = response.getStatus(); - r.headers = response.getHeaders(); + r.headers = response.getStringHeaders(); EntityTag etag = response.getEntityTag(); - if (etag != null) + if (etag != null) { r.message = etag.getValue(); - if (response.hasEntity() && r.code != 204) - r.body = response.getEntity(String.class); + } + if (response.hasEntity() && r.code != 204) { + r.body = response.readEntity(String.class); + } if (r.code == 301) { - String newUrl = response.getHeaders().getFirst("Location"); + String newUrl = response.getStringHeaders().getFirst("Location"); log.info("Got response code 301. Sending same request to URL: {}", newUrl); - webResource = client.resource(newUrl); + webTarget = client.target(newUrl); + invocationBuilder = webTarget.request(tt).accept(tt); try { - if (p.httpMethod == HttpMethod.POST) - response = webResource.accept(tt).type(tt).post(ClientResponse.class, data); - else if (p.httpMethod == HttpMethod.PUT) - response = webResource.accept(tt).type(tt).put(ClientResponse.class, data); - else + if (p.httpMethod == HttpMethod.POST) { + response = invocationBuilder.post(Entity.entity(data, tt)); + } else if (p.httpMethod == HttpMethod.PUT) { + response = invocationBuilder.put(Entity.entity(data, tt)); + } else { throw new SvcLogicException("Http operation" + p.httpMethod + "not supported"); - } catch (UniformInterfaceException | ClientHandlerException e) { - throw new SvcLogicException("Exception while sending http request to client " + + } + } catch (ProcessingException e) { + throw new SvcLogicException("Exception while posting http request to client " + e.getLocalizedMessage(), e); } r.code = response.getStatus(); etag = response.getEntityTag(); - if (etag != null) + if (etag != null) { r.message = etag.getValue(); - if (response.hasEntity() && r.code != 204) - r.body = response.getEntity(String.class); + } + if (response.hasEntity() && r.code != 204) { + r.body = response.readEntity(String.class); + } } } @@ -830,52 +880,6 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { return r; } - public void postMessageOnUeb(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { - HttpResponse r; - try { - UebParam p = getUebParameters(paramMap); - - String pp = p.responsePrefix != null ? p.responsePrefix + '.' : ""; - - String req; - - if (p.templateFileName == null) { - log.info("No template file name specified. Using default UEB template: {}", defaultUebTemplateFileName); - p.templateFileName = defaultUebTemplateFileName; - } - - String reqTemplate = readFile(p.templateFileName); - reqTemplate = reqTemplate.replaceAll("rootVarName", p.rootVarName); - req = buildXmlJsonRequest(ctx, reqTemplate, Format.JSON); - - r = postOnUeb(req, p); - setResponseStatus(ctx, p.responsePrefix, r); - if (r.body != null) - ctx.setAttribute(pp + "httpResponse", r.body); - - } catch (SvcLogicException e) { - log.error("Error sending the request: {}", e.getMessage(), e); - - r = new HttpResponse(); - r.code = 500; - r.message = e.getMessage(); - String prefix = parseParam(paramMap, "responsePrefix", false, null); - setResponseStatus(ctx, prefix, r); - } - - if (r.code >= 300) - throw new SvcLogicException(String.valueOf(r.code) + ": " + r.message); - } - - private static class UebParam { - - public String topic; - public String templateFileName; - public String rootVarName; - public String responsePrefix; - public boolean skipSending; - } - private UebParam getUebParameters(Map paramMap) throws SvcLogicException { UebParam p = new UebParam(); p.topic = parseParam(paramMap, "topic", true, null); @@ -887,17 +891,49 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { return p; } + protected void logProperties(Map mm) { + List 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, String.valueOf(mm.get(name))); + } + } + + protected void logHeaders(MultivaluedMap mm) { + log.info("HTTP response headers:"); + + if (mm == null) { + return; + } + + List ll = new ArrayList<>(); + for (Object o : mm.keySet()) { + ll.add((String) o); + } + Collections.sort(ll); + + for (String name : ll) { + log.info("--- {}:{}", name, String.valueOf(mm.get(name))); + } + } + protected HttpResponse postOnUeb(String request, UebParam p) throws SvcLogicException { String[] urls = uebServers.split(" "); for (int i = 0; i < urls.length; i++) { - if (!urls[i].endsWith("/")) + if (!urls[i].endsWith("/")) { urls[i] += "/"; + } urls[i] += "events/" + p.topic; } - Client client = Client.create(); - client.setConnectTimeout(5000); - WebResource webResource = client.resource(urls[0]); + Client client = ClientBuilder.newBuilder().build(); + client.property(ClientProperties.CONNECT_TIMEOUT, 5000); + WebTarget webTarget = client.target(urls[0]); log.info("UEB URL: {}", urls[0]); log.info("Sending request:"); @@ -911,19 +947,20 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { String tt = "application/json"; String tt1 = tt + ";charset=UTF-8"; - ClientResponse response; + Response response; + Invocation.Builder invocationBuilder = webTarget.request(tt1).accept(tt); try { - response = webResource.accept(tt).type(tt1).post(ClientResponse.class, request); - } catch (UniformInterfaceException | ClientHandlerException e) { + response = invocationBuilder.post(Entity.entity(request, tt1)); + } catch (ProcessingException e) { throw new SvcLogicException("Exception while posting http request to client " + e.getLocalizedMessage(), e); } - r.code = response.getStatus(); - r.headers = response.getHeaders(); - if (response.hasEntity()) - r.body = response.getEntity(String.class); + r.headers = response.getStringHeaders(); + if (response.hasEntity()) { + r.body = response.readEntity(String.class); + } } long t2 = System.currentTimeMillis(); @@ -935,37 +972,36 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { return r; } - protected void logProperties(Map mm) { - List 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, String.valueOf(mm.get(name))); + public void setUebServers(String uebServers) { + this.uebServers = uebServers; } - protected void logHeaders(MultivaluedMap mm) { - log.info("HTTP response headers:"); - - if (mm == null) - return; + public void setDefaultUebTemplateFileName(String defaultUebTemplateFileName) { + this.defaultUebTemplateFileName = defaultUebTemplateFileName; + } - List ll = new ArrayList<>(); - for (Object o : mm.keySet()) - ll.add((String) o); - Collections.sort(ll); + private static class FileParam { - for (String name : ll) - log.info("--- {}:{}", name, String.valueOf(mm.get(name))); + public String fileName; + public String url; + public String user; + public String password; + public HttpMethod httpMethod; + public String responsePrefix; + public boolean skipSending; + public String oAuthConsumerKey; + public String oAuthConsumerSecret; + public String oAuthSignatureMethod; + public String oAuthVersion; + public AuthType authtype; } - public void setUebServers(String uebServers) { - this.uebServers = uebServers; - } + private static class UebParam { - public void setDefaultUebTemplateFileName(String defaultUebTemplateFileName) { - this.defaultUebTemplateFileName = defaultUebTemplateFileName; + public String topic; + public String templateFileName; + public String rootVarName; + public String responsePrefix; + public boolean skipSending; } -} +} \ No newline at end of file -- cgit From 2092b7c383f1a3280da05b71517fae6521b73327 Mon Sep 17 00:00:00 2001 From: janani b Date: Wed, 19 Sep 2018 21:10:17 +0530 Subject: Issue fix for RestconfApiCallNode Sonar and Issue fix Issue-ID: CCSDK-325 Change-Id: I469fcc5c4da2ec26c3a39b48d52736d45c1718d4 Signed-off-by: janani b --- .../restconfapicall/RestconfApiCallNode.java | 18 ++++---- .../plugins/restconfapicall/RestconfApiUtils.java | 29 ++++++++++--- .../dfserializer/MdsalSerializerHelper.java | 3 +- .../dfserializer/DataFormatSerializerTest.java | 49 ++++++++++++++++++++++ 4 files changed, 83 insertions(+), 16 deletions(-) diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java index f9a1ecbf3..91ce3338a 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java @@ -54,6 +54,7 @@ import java.util.Map; import static java.lang.String.format; import static org.apache.commons.lang3.StringUtils.join; +import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.PATCH; import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.POST; import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.PUT; import static org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode.parseParam; @@ -153,7 +154,8 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { InstanceIdentifierContext insIdCtx = getInsIdCtx(p, uri); String req = null; - if (p.httpMethod == POST || p.httpMethod == PUT) { + if (p.httpMethod == POST || p.httpMethod == PUT + || p.httpMethod == PATCH) { req = serializeRequest(props, p, uri, insIdCtx); } if (req == null && p.requestBody != null) { @@ -181,8 +183,8 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { log.error(REQ_ERR + e.getMessage(), e); String prefix = parseParam(paramMap, RES_PRE, false, null); - if (retryPolicy == null || shouldRetry == false) { - setFailureResponseStatus(ctx, prefix, e.getMessage(), r); + if (retryPolicy == null || !shouldRetry) { + setFailureResponseStatus(ctx, prefix, e.getMessage()); } else { if (retryCount == null) { retryCount = 0; @@ -198,12 +200,11 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { sendRequest(paramMap, ctx, retryCount); } else { log.debug(MAX_RETRY_ERR); - setFailureResponseStatus(ctx, prefix, - e.getMessage(), r); + setFailureResponseStatus(ctx, prefix, e.getMessage()); } } catch (Exception ex) { log.error(NO_MORE_RETRY, ex); - setFailureResponseStatus(ctx, prefix, RETRY_FAIL, r); + setFailureResponseStatus(ctx, prefix, RETRY_FAIL); } } } @@ -338,11 +339,10 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { * @param ctx service logic context * @param prefix prefix to be added * @param errMsg error message - * @param res http response */ private void setFailureResponseStatus(SvcLogicContext ctx, String prefix, - String errMsg, HttpResponse res) { - res = new HttpResponse(); + String errMsg) { + HttpResponse res = new HttpResponse(); res.code = 500; res.message = errMsg; ctx.setAttribute(prefix + RES_CODE, String.valueOf(res.code)); diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java index 0f9c9401c..b51272f7e 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java @@ -97,8 +97,6 @@ public final class RestconfApiUtils { private static final String URL_SYNTAX = "The following URL cannot be " + "parsed into URI : "; - private static final String RESTCONF_PATH = "/restconf/operations/"; - private static final String PUT_NODE_ERR = "The following URL does not " + "contain minimum two nodes for PUT operation."; @@ -136,7 +134,7 @@ public final class RestconfApiUtils { * @return YANG path pointing to parent * @throws SvcLogicException when parsing the URL fails */ - static String parseUrl(String url, HttpMethod method) + public static String parseUrl(String url, HttpMethod method) throws SvcLogicException { URI uri; try { @@ -146,9 +144,7 @@ public final class RestconfApiUtils { } String path = uri.getPath(); - if (path.contains(RESTCONF_PATH)) { - path = path.replaceFirst(RESTCONF_PATH, ""); - } + path = getParsedPath(path); if (method == PUT) { if (!path.contains(SLASH)) { throw new SvcLogicException(PUT_NODE_ERR + url); @@ -158,6 +154,27 @@ public final class RestconfApiUtils { return path; } + /** + * Returns the path which contains only the schema nodes. + * + * @param path path + * @return path representing schema + */ + private static String getParsedPath(String path) { + String firstHalf; + if (path.contains(":")) { + String[] p = path.split(":"); + if (p[0].contains(SLASH)) { + int slash = p[0].lastIndexOf(SLASH); + firstHalf = p[0].substring(slash + 1); + } else { + firstHalf = p[0]; + } + return firstHalf + ":" + p[1]; + } + return path; + } + /** * Returns the schema context of the YANG files present in a directory. * diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java index 6f9f9070a..1fd0d2dee 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/MdsalSerializerHelper.java @@ -274,11 +274,12 @@ public class MdsalSerializerHelper extends SerializerHelper dataSchema = findSchemaNodeByNameAndNamespace( (DataSchemaNode) curSchemaNode, name, namespace.moduleNs()); + if (dataSchema != null && !dataSchema.isEmpty()) { childNode = dataSchema.pop(); } - if (!dataSchema.isEmpty()) { + if (dataSchema != null && !dataSchema.isEmpty()) { childNode = findSchemaForChild(((ChoiceSchemaNode) childNode), qname); } diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java index 0f46d625b..6c11206c9 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java @@ -41,6 +41,10 @@ import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doCallRealMethod; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; +import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.GET; +import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.POST; +import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.PUT; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.parseUrl; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.DECODE_FROM_JSON_RPC; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.DECODE_FROM_XML_RPC; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_ID; @@ -316,6 +320,51 @@ public class DataFormatSerializerTest { verifyAttListRpc(ctx, outPre); } + /** + * Verifies URL parser returning path with only schema information for all + * kind of URL. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void validateUrlParser() throws SvcLogicException { + String actVal = "identity-test:test"; + String url1 = "http://echo.getpostman.com/restconf/operations/" + + actVal; + String url2 = "http://echo.getpostman.com/restconf/data/" + actVal; + String url3 = "https://echo.getpostman.com/restconf/operations/" + + actVal; + String url4 = "https://echo.getpostman.com/restconf/data/" + actVal + + "/for-put"; + String url5 = "http://localhost:8282/restconf/operations/" + actVal; + String url6 = "https://localhost:8282/restconf/operations/" + actVal; + String url7 = "http://localhost:8282/restconf/data/" + actVal + + "/for-put"; + String url8 = "https://localhost:8282/restconf/data/" + actVal; + String url9 = "http://182.2.61.24:2250/restconf/data/" + actVal; + String url10 = "https://182.2.61.24:2250/restconf/operations/" + actVal; + String val1 = parseUrl(url1, POST); + String val2 = parseUrl(url2, GET); + String val3 = parseUrl(url3, POST); + String val4 = parseUrl(url4, PUT); + String val5 = parseUrl(url5, GET); + String val6 = parseUrl(url6, POST); + String val7 = parseUrl(url7, PUT); + String val8 = parseUrl(url8, POST); + String val9 = parseUrl(url9, GET); + String val10 = parseUrl(url10, POST); + assertThat(val1, is(actVal)); + assertThat(val2, is(actVal)); + assertThat(val3, is(actVal)); + assertThat(val4, is(actVal)); + assertThat(val5, is(actVal)); + assertThat(val6, is(actVal)); + assertThat(val7, is(actVal)); + assertThat(val8, is(actVal)); + assertThat(val9, is(actVal)); + assertThat(val10, is(actVal)); + } + /** * Creates attribute list for encoding JSON or XML with identity-ref YANG * file. -- cgit From 00182e7710a239e871c33a42cf9eaf9a12d90ecb Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 26 Sep 2018 10:44:42 -0400 Subject: Prepare for release build Update for release build : (a) Remove -STAGING tag from release version in version.properties (b) Update to use released version of parent poms (c) Disable single-feature-test (which does not work with released dependencies from ONAP) Change-Id: I97ecca353e8e2b4e96699980c90fda9047d22791 Issue-ID: CCSDK-597 Signed-off-by: Timoney, Dan (dt5972) --- features/ccsdk-sli-plugins-all/pom.xml | 7 ++++++- features/features-sli-plugins/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- pom.xml | 2 +- properties-node/features/ccsdk-properties-node/pom.xml | 7 ++++++- properties-node/features/features-properties-node/pom.xml | 2 +- properties-node/features/pom.xml | 2 +- properties-node/installer/pom.xml | 2 +- properties-node/pom.xml | 2 +- properties-node/provider/pom.xml | 2 +- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 7 ++++++- restapi-call-node/features/features-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/pom.xml | 2 +- restapi-call-node/installer/pom.xml | 2 +- restapi-call-node/pom.xml | 2 +- restapi-call-node/provider/pom.xml | 2 +- restconf-client/features/ccsdk-restconf-client/pom.xml | 7 ++++++- restconf-client/features/features-restconf-client/pom.xml | 2 +- restconf-client/features/pom.xml | 2 +- restconf-client/installer/pom.xml | 2 +- restconf-client/pom.xml | 2 +- restconf-client/provider/pom.xml | 2 +- sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml | 7 ++++++- sshapi-call-node/features/features-sshapi-call-node/pom.xml | 2 +- sshapi-call-node/features/pom.xml | 2 +- sshapi-call-node/installer/pom.xml | 2 +- sshapi-call-node/pom.xml | 2 +- sshapi-call-node/provider/pom.xml | 2 +- template-node/features/ccsdk-template-node/pom.xml | 2 +- template-node/features/features-template-node/pom.xml | 2 +- template-node/features/pom.xml | 2 +- template-node/installer/pom.xml | 2 +- template-node/pom.xml | 2 +- template-node/provider/pom.xml | 2 +- version.properties | 2 +- 36 files changed, 61 insertions(+), 36 deletions(-) diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index 051f3a463..b053dcb5b 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0-SNAPSHOT + 1.1.0 @@ -17,6 +17,11 @@ feature ccsdk-sli-plugins :: features :: ${project.artifactId} + + + true + + diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index 0b43d1a0d..c1758f8c4 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 050d3e9d5..c81c6a275 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/features/pom.xml b/features/pom.xml index 3ac87bf6b..d342ee8a8 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/pom.xml b/pom.xml index a41f2311c..376433d52 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index fd38cb224..b2dc224a8 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0-SNAPSHOT + 1.1.0 @@ -17,6 +17,11 @@ ccsdk-sli-plugins :: properties-node :: ${project.artifactId} + + true + + + diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index e8f168e2b..1d0535d43 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index dd0e824f0..9cccc4991 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 965bdbb77..bff0978ce 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/properties-node/pom.xml b/properties-node/pom.xml index eb7dcbb51..73098287b 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index a9a3c94d5..ad9a8fe6c 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 822a6d1e7..a73a14286 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0-SNAPSHOT + 1.1.0 @@ -18,6 +18,11 @@ ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} + + + true + + diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index dfcef32f4..507b86628 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index 14e9ae022..fb23ebda1 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 8e2f402eb..24c5f44ec 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 641bcc863..3333dc546 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 6670cfd8c..844a6b5e7 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index 1877f19d8..64b8216b4 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0-SNAPSHOT + 1.1.0 @@ -18,6 +18,11 @@ ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} + + + true + + diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml index 8ee5e7e21..13be4bb5d 100644 --- a/restconf-client/features/features-restconf-client/pom.xml +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml index c94be00be..cd58d20e1 100755 --- a/restconf-client/features/pom.xml +++ b/restconf-client/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index b28cefde9..c71d5dad5 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index fecbd2b93..af55f8037 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index db0bee061..35944f4f4 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index 7b74d6de9..fd0dacaed 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0-SNAPSHOT + 1.1.0 @@ -18,6 +18,11 @@ ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} + + true + + + diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml index a37ac6172..7435e602a 100644 --- a/sshapi-call-node/features/features-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/features-sshapi-call-node/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml index 49b96e3fd..5ff6cceb5 100755 --- a/sshapi-call-node/features/pom.xml +++ b/sshapi-call-node/features/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index 51bed972f..d33ecb58a 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index 91b52e123..b2aa2b9c4 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index d37972efc..0cb0294c2 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index fd3a92457..166b74674 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml index c352ba514..ef58da04c 100644 --- a/template-node/features/features-template-node/pom.xml +++ b/template-node/features/features-template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml index 1abcdbe3e..25e6cb904 100644 --- a/template-node/features/pom.xml +++ b/template-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index 1e4d24cd3..c21ffcf9f 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/template-node/pom.xml b/template-node/pom.xml index 21ab127f3..e1f08b4a4 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index 936f76f37..28beb9dc8 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0-SNAPSHOT + 1.1.0 org.onap.ccsdk.sli.plugins diff --git a/version.properties b/version.properties index 53760c8c7..ba4200853 100644 --- a/version.properties +++ b/version.properties @@ -11,6 +11,6 @@ feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} -release_version=${base_version}-STAGING +release_version=${base_version} snapshot_version=${base_version}-SNAPSHOT -- cgit From 85737499b931441be3013831d7ce76a5c4734032 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 26 Sep 2018 15:33:59 -0400 Subject: Roll to next snapshot Roll to next snapshot release Change-Id: I179602134b518295b4b6a1d53cea8136ad0ba666 Issue-ID: CCSDK-597 Signed-off-by: Timoney, Dan (dt5972) --- features/ccsdk-sli-plugins-all/pom.xml | 7 ++----- features/features-sli-plugins/pom.xml | 4 ++-- features/installer/pom.xml | 4 ++-- features/pom.xml | 4 ++-- pom.xml | 4 ++-- properties-node/features/ccsdk-properties-node/pom.xml | 7 ++----- properties-node/features/features-properties-node/pom.xml | 4 ++-- properties-node/features/pom.xml | 4 ++-- properties-node/installer/pom.xml | 4 ++-- properties-node/pom.xml | 4 ++-- properties-node/provider/pom.xml | 4 ++-- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 7 ++----- restapi-call-node/features/features-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/pom.xml | 4 ++-- restapi-call-node/installer/pom.xml | 4 ++-- restapi-call-node/pom.xml | 4 ++-- restapi-call-node/provider/pom.xml | 4 ++-- restconf-client/features/ccsdk-restconf-client/pom.xml | 7 ++----- restconf-client/features/features-restconf-client/pom.xml | 4 ++-- restconf-client/features/pom.xml | 4 ++-- restconf-client/installer/pom.xml | 4 ++-- restconf-client/pom.xml | 4 ++-- restconf-client/provider/pom.xml | 8 ++++---- sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml | 7 ++----- sshapi-call-node/features/features-sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/features/pom.xml | 4 ++-- sshapi-call-node/installer/pom.xml | 4 ++-- sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/provider/pom.xml | 4 ++-- template-node/features/ccsdk-template-node/pom.xml | 7 ++----- template-node/features/features-template-node/pom.xml | 4 ++-- template-node/features/pom.xml | 4 ++-- template-node/installer/pom.xml | 4 ++-- template-node/pom.xml | 4 ++-- template-node/provider/pom.xml | 4 ++-- version.properties | 4 ++-- 36 files changed, 74 insertions(+), 92 deletions(-) diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index b053dcb5b..d4715be62 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -7,20 +7,17 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins-all - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} - - true - diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index c1758f8c4..b3333b600 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins features-sli-plugins - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index c81c6a275..c2b77d0fd 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins sliplugins-features-installer - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index d342ee8a8..257627da4 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins sliplugins-feature-aggregator - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-plugins :: features diff --git a/pom.xml b/pom.xml index 376433d52..7a0f84a9f 100755 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index b2dc224a8..744d6d892 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,21 +5,18 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-properties-node - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} - - true - diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index 1d0535d43..0f1b28c88 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins features-properties-node - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 9cccc4991..32e139b4f 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-features - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index bff0978ce..0a6918a3e 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-installer - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 73098287b..25c2cf225 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-plugins :: properties-node diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index ad9a8fe6c..7f9352341 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-provider - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT bundle ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index a73a14286..2c616a298 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -7,21 +7,18 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restapi-call-node - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} - - true - diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index 507b86628..8160611dd 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins features-restapi-call-node - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index fb23ebda1..55e0945e7 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-features - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 24c5f44ec..acb6ae899 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-installer - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 3333dc546..f704647ab 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 844a6b5e7..84b4131c7 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT bundle ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index 64b8216b4..03d935296 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -7,21 +7,18 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restconf-client - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} - - true - diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml index 13be4bb5d..166ddc53d 100644 --- a/restconf-client/features/features-restconf-client/pom.xml +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins features-restconf-client - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml index cd58d20e1..6aa3fde88 100755 --- a/restconf-client/features/pom.xml +++ b/restconf-client/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-features - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index c71d5dad5..fd675c80a 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -6,12 +6,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-installer - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index af55f8037..fccd697bb 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 35944f4f4..ac5c4cc32 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -6,12 +6,12 @@ org.onap.ccsdk.parent binding-parent - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-provider - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT bundle ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} @@ -39,7 +39,7 @@ org.onap.ccsdk.sli.plugins properties-node-provider - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT org.opendaylight.yangtools @@ -63,7 +63,7 @@ org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index fd0dacaed..9220b1f78 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -7,20 +7,17 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sshapi-call-node - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} - - true - diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml index 7435e602a..dc924244a 100644 --- a/sshapi-call-node/features/features-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/features-sshapi-call-node/pom.xml @@ -7,13 +7,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins features-sshapi-call-node - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml index 5ff6cceb5..82e69b9b6 100755 --- a/sshapi-call-node/features/pom.xml +++ b/sshapi-call-node/features/pom.xml @@ -7,12 +7,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-features - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index d33ecb58a..9d570fd36 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-installer - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index b2aa2b9c4..7dda908e5 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index 0cb0294c2..e4619ca04 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-provider - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT bundle ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index 166b74674..b7d329e59 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -5,18 +5,15 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-template-node - 0.3.3-SNAPSHOT + 0.3.1-SNAPSHOT feature - - true - diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml index ef58da04c..021e5921b 100644 --- a/template-node/features/features-template-node/pom.xml +++ b/template-node/features/features-template-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins features-template-node - 0.3.3-SNAPSHOT + 0.3.1-SNAPSHOT feature diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml index 25e6cb904..c918417ca 100644 --- a/template-node/features/pom.xml +++ b/template-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-features - 0.3.3-SNAPSHOT + 0.3.1-SNAPSHOT pom diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index c21ffcf9f..f588f49ce 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-installer - 0.3.3-SNAPSHOT + 0.3.1-SNAPSHOT pom diff --git a/template-node/pom.xml b/template-node/pom.xml index e1f08b4a4..c2668f869 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins template-node - 0.3.3-SNAPSHOT + 0.3.1-SNAPSHOT pom diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index 28beb9dc8..fa2ba9d91 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.1.0 + 1.1.1-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-provider - 0.3.3-SNAPSHOT + 0.3.1-SNAPSHOT bundle diff --git a/version.properties b/version.properties index ba4200853..1c849dae1 100644 --- a/version.properties +++ b/version.properties @@ -7,10 +7,10 @@ release_name=0 sprint_number=3 -feature_revision=0 +feature_revision=1 base_version=${release_name}.${sprint_number}.${feature_revision} -release_version=${base_version} +release_version=${base_version}-STAGING snapshot_version=${base_version}-SNAPSHOT -- cgit From c8e5aa9f493ec5f80e4444285816ceed27b1752b Mon Sep 17 00:00:00 2001 From: janani b Date: Thu, 27 Sep 2018 15:26:39 +0530 Subject: Issue fixes for Restconf discovery node i) Adding constructor param ii) execute dg param order fix iii) Constants value fix. Issue-ID: CCSDK-325 Change-Id: I5aaf4b66b3982e4a1d3736362be3a5e8d7ab6d00 Signed-off-by: janani b --- .../plugins/restconfdiscovery/EventProcessor.java | 9 ++++--- .../restconfdiscovery/RestconfDiscoveryNode.java | 18 ++++++++----- .../restconfdiscovery/SvcLogicGraphInfo.java | 2 +- .../blueprint/restconf-client-blueprint.xml | 4 ++- .../TestRestconfDiscoveryNode.java | 31 ++++++++++++++-------- 5 files changed, 41 insertions(+), 23 deletions(-) diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java index aae808155..e46e47a9b 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java @@ -28,17 +28,18 @@ import org.slf4j.LoggerFactory; import java.util.Map; import static org.onap.ccsdk.sli.plugins.prop.JsonParser.convertToProperties; +import static org.slf4j.LoggerFactory.getLogger; /** * Processes the events from event queue and executes callback DG. */ class EventProcessor implements Runnable { - private static final Logger log = LoggerFactory.getLogger(EventProcessor.class); + + private static final Logger log = getLogger(EventProcessor.class); private RestconfDiscoveryNode node; - private static final String EVENT_SUBSCRIPTION_ID = "ietf-notification:notification" + - ".ietf-yang-push:push-change-update" + - ".subscription-id"; + private static final String EVENT_SUBSCRIPTION_ID = "ietf-restconf:" + + "notification.ietf-yang-push:push-change-update.subscription-id"; public EventProcessor(RestconfDiscoveryNode node) { this.node = node; diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java index f5366a544..111d62847 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java @@ -26,7 +26,6 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode; import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; @@ -37,12 +36,15 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; +import static org.slf4j.LoggerFactory.getLogger; + /** * Representation of a plugin to subscribe for notification and then * to handle the received notifications. */ public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { - private static final Logger log = LoggerFactory.getLogger(RestconfDiscoveryNode.class); + + private static final Logger log = getLogger(RestconfDiscoveryNode.class); private ExecutorService executor = Executors.newCachedThreadPool(); private Map runnableInfo = new ConcurrentHashMap<>(); @@ -54,15 +56,19 @@ public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { private static final String SUBSCRIBER_ID = "subscriberId"; private static final String RESPONSE_CODE = "response-code"; private static final String RESPONSE_PREFIX = "responsePrefix"; - private static final String OUTPUT_IDENTIFIER = "ietf-subscribed-notifications:output.identifier"; + private static final String OUTPUT_IDENTIFIER = "ietf-subscribed-notif" + + "ications:establish-subscription.output.identifier"; private static final String RESPONSE_CODE_200 = "200"; private static final String SSE_URL = "sseConnectURL"; /** - * Creates an instance of RestconfDiscoveryNode and - * starts processing of event. + * Creates an instance of RestconfDiscoveryNode and starts processing of + * event. + * + * @param r restconf api call node */ - public RestconfDiscoveryNode() { + public RestconfDiscoveryNode(RestconfApiCallNode r) { + this.restconfApiCallNode = r; ExecutorService e = Executors.newFixedThreadPool(20); EventProcessor p = new EventProcessor(this); for (int i = 0; i < 20; ++i) { diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicGraphInfo.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicGraphInfo.java index 725826bda..1cc6261ab 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicGraphInfo.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SvcLogicGraphInfo.java @@ -142,7 +142,7 @@ class SvcLogicGraphInfo { SvcLogicStore store = service.getStore(); if (store != null) { - SvcLogicGraph subGraph = store.fetch(module, rpc, version, mode); + SvcLogicGraph subGraph = store.fetch(module, rpc, mode, version); if (subGraph != null) { ctx.setAttribute("subGraph", subGraph.toString()); service.execute(subGraph, ctx); diff --git a/restconf-client/provider/src/main/resources/org/opendaylight/blueprint/restconf-client-blueprint.xml b/restconf-client/provider/src/main/resources/org/opendaylight/blueprint/restconf-client-blueprint.xml index c8f2dc4c9..45c335b13 100755 --- a/restconf-client/provider/src/main/resources/org/opendaylight/blueprint/restconf-client-blueprint.xml +++ b/restconf-client/provider/src/main/resources/org/opendaylight/blueprint/restconf-client-blueprint.xml @@ -32,7 +32,9 @@ - + + + diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java index db878f0af..b2094ca73 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java @@ -20,16 +20,19 @@ package org.onap.ccsdk.sli.plugins.restconfdiscovery; -import java.net.URI; -import java.util.HashMap; -import java.util.Map; - import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; import org.glassfish.jersey.media.sse.SseFeature; import org.glassfish.jersey.server.ResourceConfig; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; +import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode; + +import java.net.URI; +import java.util.HashMap; +import java.util.Map; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; @@ -47,13 +50,15 @@ public class TestRestconfDiscoveryNode { ctx.setAttribute("prop.encoding-json", "encoding-json"); ctx.setAttribute("restapi-result.response-code", "200"); ctx.setAttribute("restapi-result.ietf-subscribed-notifications" + - ":output.identifier", "100"); + ":establish-subscription.output.identifier", + "100"); Map p = new HashMap<>(); p.put("sseConnectURL", "http://localhost:8080/events"); p.put("subscriberId", "networkId"); p.put("responsePrefix", "restapi-result"); - RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(); + RestconfDiscoveryNode rdn = new RestconfDiscoveryNode( + new RestconfApiCallNode(new RestapiCallNode())); rdn.establishPersistentConnection(p, ctx, "networkId"); Thread.sleep(2000); rdn.deleteSubscription(p, ctx); @@ -75,7 +80,8 @@ public class TestRestconfDiscoveryNode { throws SvcLogicException{ SvcLogicContext ctx = new SvcLogicContext(); Map p = new HashMap<>(); - RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(); + RestconfDiscoveryNode rdn = new RestconfDiscoveryNode( + new RestconfApiCallNode(new RestapiCallNode())); rdn.establishSubscription(p, ctx); } @@ -84,7 +90,8 @@ public class TestRestconfDiscoveryNode { SvcLogicContext ctx = new SvcLogicContext(); ctx.setAttribute("restapi-result.response-code", "200"); ctx.setAttribute("response-code", "404"); - RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(); + RestconfDiscoveryNode rdn = new RestconfDiscoveryNode( + new RestconfApiCallNode(new RestapiCallNode())); assertThat(rdn.getResponseCode("restapi-result", ctx), is("200")); assertThat(rdn.getResponseCode(null, ctx), @@ -95,10 +102,12 @@ public class TestRestconfDiscoveryNode { public void testOutputIdentifier() { SvcLogicContext ctx = new SvcLogicContext(); ctx.setAttribute("restapi-result.ietf-subscribed-notifications:" + - "output.identifier", "89"); - ctx.setAttribute("ietf-subscribed-notifications:output.identifier", + "establish-subscription.output.identifier", "89"); - RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(); + ctx.setAttribute("ietf-subscribed-notifications:establish-subscripti" + + "on.output.identifier", "89"); + RestconfDiscoveryNode rdn = new RestconfDiscoveryNode( + new RestconfApiCallNode(new RestapiCallNode())); assertThat(rdn.getOutputIdentifier("restapi-result", ctx), is("89")); } -- cgit From 2c99dfb113ca8a960b08de00b90165f0c1565836 Mon Sep 17 00:00:00 2001 From: gaurav Date: Fri, 14 Sep 2018 14:36:21 +0530 Subject: Dependency management for Restconf Client Changes includes: - Disable karaf.feature.test to pass SingleFeatureTest as there is no problem in running env. - Removed Restconf Client from plugins-all to pass SingleFeatureTest. Will submit seperate patch to add Restconf client to boot features list in DockerFile directly. Change-Id: I6193284e9e3c3f9a816133255611df03339937f9 Issue-ID: CCSDK-567 Signed-off-by: Gaurav Agrawal --- features/ccsdk-sli-plugins-all/pom.xml | 7 ------- .../features/ccsdk-restconf-client/pom.xml | 14 +++++++++----- restconf-client/provider/pom.xml | 22 ++++++++++------------ 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index d4715be62..714ad58a5 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -60,12 +60,5 @@ xml features - - ${project.groupId} - ccsdk-restconf-client - ${project.version} - xml - features - diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index 03d935296..462036e73 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -16,6 +16,10 @@ 0.3.1-SNAPSHOT feature + + true + + ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} @@ -48,10 +52,10 @@ xml features - - - - - + + ${project.groupId} + restconf-client-provider + ${project.version} + diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index ac5c4cc32..43c9d1737 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -65,7 +65,16 @@ restapi-call-node-provider 0.3.1-SNAPSHOT - + + org.opendaylight.netconf + restconf-nb-rfc8040 + ${odl.mdsal.version} + + + org.opendaylight.yangtools + yang-parser-impl + 2.0.6.1 + @@ -109,16 +118,5 @@ 2.0.6.1 test - - org.opendaylight.netconf - restconf-nb-rfc8040 - ${odl.mdsal.version} - - - org.opendaylight.yangtools - yang-parser-impl - 2.0.6.1 - - -- cgit From 87850a15d93c7a1162d30c129e0dc76cd1b66f94 Mon Sep 17 00:00:00 2001 From: "shashikanth.vh" Date: Thu, 4 Oct 2018 10:40:18 +0530 Subject: Add mandatory empty construct to json template Restapicallnode remove empty parameter from json template, if template mandates empty parameter to be present then it should not be removed. Change-Id: I075e0858f956eb3aff87d2a7387b55caa3310568 Issue-ID: CCSDK-607 Signed-off-by: shashikanth.vh --- .../sli/plugins/restapicall/RestapiCallNode.java | 3 +- .../ccsdk/sli/plugins/restapicall/XmlJsonUtil.java | 11 +++-- .../plugins/sshapicall/TestRestapiCallNode.java | 55 ++++++++++++++++++++++ .../sli/plugins/sshapicall/TestXmlJsonUtil.java | 2 +- .../provider/src/test/resources/sdwan-site.json | 10 ++++ .../src/test/resources/sdwan-vpn-topology.json | 23 +++++++++ 6 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 restapi-call-node/provider/src/test/resources/sdwan-site.json create mode 100644 restapi-call-node/provider/src/test/resources/sdwan-vpn-topology.json diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index e5503435b..9a89af6b5 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -392,6 +392,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { throws SvcLogicException { log.info("Building {} started", format); long t1 = System.currentTimeMillis(); + String originalTemplate = template; template = expandRepeats(ctx, template, 1); @@ -439,7 +440,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } String req = format == Format.XML - ? XmlJsonUtil.removeEmptyStructXml(ss.toString()) : XmlJsonUtil.removeEmptyStructJson(ss.toString()); + ? XmlJsonUtil.removeEmptyStructXml(ss.toString()) : XmlJsonUtil.removeEmptyStructJson(originalTemplate, ss.toString()); if (format == Format.JSON) { req = XmlJsonUtil.removeLastCommaJson(req); diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java index 8a0ca8d94..4712b4298 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java @@ -272,7 +272,7 @@ public final class XmlJsonUtil { return sb.toString(); } - public static String removeEmptyStructJson(String s) { + public static String removeEmptyStructJson(String template, String s) { int k = 0; while (k < s.length()) { boolean curly = true; @@ -304,8 +304,13 @@ public final class XmlJsonUtil { if (i5 < 0) i5 = s.length(); - s = s.substring(0, i4) + s.substring(i5); - k = 0; + /*If template mandates empty construct to be present, those should not be removed.*/ + if ((template != null) && template.contains(s.substring(i4))) { + k = i1 + 1; + } else { + s = s.substring(0, i4) + s.substring(i5); + k = 0; + } } else k = i1 + 1; } else diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestRestapiCallNode.java index 5c6c4e279..4008c56c7 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestRestapiCallNode.java @@ -51,6 +51,61 @@ public class TestRestapiCallNode { rcn.sendRequest(p, ctx); } + @Test + public void testJsonSdwanVpnTopologyTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + ctx.setAttribute("prop.topology", "topoType"); + + ctx.setAttribute("prop.roles_length", "1"); + ctx.setAttribute("prop.roles[0]", "role1"); + + ctx.setAttribute("prop.siteAttachement_length", "2"); + + ctx.setAttribute("prop.siteAttachement[0].siteId", "site1"); + ctx.setAttribute("prop.siteAttachement[0].roles_length", "0"); + ctx.setAttribute("prop.siteAttachement[0].roles[0]", "role1"); + ctx.setAttribute("prop.siteAttachement[0].roles[1]", "role3"); + + ctx.setAttribute("prop.siteAttachement[1].siteId", "site2"); + ctx.setAttribute("prop.siteAttachement[1].roles_length", "1"); + ctx.setAttribute("prop.siteAttachement[1].roles[0]", "role2"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/sdwan-vpn-topology.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testJsonSdwanSiteTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + ctx.setAttribute("prop.name", "site1"); + + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/sdwan-site.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + @Test public void testJsonTemplate() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java index bd9ff1c98..31fa2f9f9 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java @@ -254,7 +254,7 @@ public class TestXmlJsonUtil { "}\r\n" + ""; - String xmlout = XmlJsonUtil.removeEmptyStructJson(xmlin); + String xmlout = XmlJsonUtil.removeEmptyStructJson(null, xmlin); log.info(xmlout); Assert.assertEquals(xmloutexpected, xmlout); diff --git a/restapi-call-node/provider/src/test/resources/sdwan-site.json b/restapi-call-node/provider/src/test/resources/sdwan-site.json new file mode 100644 index 000000000..238ec7642 --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/sdwan-site.json @@ -0,0 +1,10 @@ +{ + "sites": [ + { + "name": ${prop.name}, + "controlPoints": [] + } + ] +} + + diff --git a/restapi-call-node/provider/src/test/resources/sdwan-vpn-topology.json b/restapi-call-node/provider/src/test/resources/sdwan-vpn-topology.json new file mode 100644 index 000000000..4260d2fc1 --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/sdwan-vpn-topology.json @@ -0,0 +1,23 @@ +{ + "vpnId": ${prop.vpn1Id}, + "areas": [ + { + "name": "area1", + "areaType": "leaf", + "topologyType": ${prop.topology}, + "siteAttachements": [${repeat:prop.siteAttachement_length: + { + "siteId": ${prop.siteAttachement[${1}].siteId}, + "role": [${repeat:prop.siteAttachement[${1}].roles_length: + ${prop.siteAttachement[${1}].roles[${2}]}, + } + ], + "workMode": "with-interconnection", + "sitePriority": "active", + "borders": "null" + }, + } + ] + } + ] +} \ No newline at end of file -- cgit From 769622040a1fa819d2708c50d4904ac24b867a38 Mon Sep 17 00:00:00 2001 From: janani b Date: Mon, 8 Oct 2018 14:17:51 +0530 Subject: Resolving root level augment nodes Issue fix for root level augment nodes being added to the data format Issue-ID: CCSDK-324 Change-Id: I1c69f97739c6cb56c74b5f22bc4283f2f927719b Signed-off-by: janani b --- .../pnserializer/DefaultPropertiesNodeWalker.java | 27 +++++++ .../dfserializer/DataFormatSerializerTest.java | 20 +++++ .../dfserializer/DataFormatUtilsTest.java | 92 ++++++++++++++-------- 3 files changed, 104 insertions(+), 35 deletions(-) diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeWalker.java index 8497805c2..f23452653 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeWalker.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeWalker.java @@ -22,6 +22,7 @@ package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer; import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import java.util.Collection; import java.util.Map; /** @@ -58,6 +59,32 @@ public class DefaultPropertiesNodeWalker implements Propert listener.exitPropertiesNode(node); } } + if (propertiesNode instanceof RootNode) { + processAugments(propertiesNode, listener); + } + } + + /** + * Processes the augments present in the root node. + * + * @param node root node + * @param listener properties node listener + * @throws SvcLogicException when augment node walking fails + */ + private void processAugments(PropertiesNode node, + PropertiesNodeListener listener) + throws SvcLogicException { + for (Map.Entry> + augToChild : node.augmentations().asMap().entrySet()) { + Collection child = augToChild.getValue(); + if (!child.isEmpty()) { + for (PropertiesNode p : child) { + listener.enterPropertiesNode(p); + walkChildNode(listener, p); + listener.exitPropertiesNode(p); + } + } + } } /** diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java index 6c11206c9..40f4c4b1b 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java @@ -50,6 +50,7 @@ import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormat import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_ID; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_RPC; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_YANG; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_YANG_AUG_POST; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_ID; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_RPC; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_YANG; @@ -217,6 +218,25 @@ public class DataFormatSerializerTest { assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG)); } + /** + * Verifies encoding of parameters to JSON data format with augment as + * root child. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToJsonWithAugAsRootChild() throws SvcLogicException { + String pre = "test-yang:cont1.cont2."; + SvcLogicContext ctx = createAttListYang(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/test-yang:cont1/cont2/cont4"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_AUG_POST)); + } + /** * Verifies decoding of parameters from JSON data format with containers, * grouping and augment. diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java index c7efdeb37..7e6445fcd 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java @@ -100,6 +100,46 @@ public final class DataFormatUtilsTest { "yangid:physical\n" + "\n"; + static final String ENCODE_TO_JSON_YANG_COMMON = "\n " + + "\"test-augment:cont13\": {\n" + + " \"ll9\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"list9\": [\n" + + " {\n" + + " \"leaf27\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"leaf27\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"leaf28\": \"abc\",\n" + + " \"cont12\": {\n" + + " \"leaf26\": \"abc\"\n" + + " }\n" + + " },\n" + + " \"test-augment:list7\": [\n" + + " {\n" + + " \"leaf14\": \"test\"\n" + + " },\n" + + " {\n" + + " \"leaf14\": \"create\"\n" + + " }\n" + + " ],\n" + + " \"test-augment:leaf15\": \"abc\",\n" + + " \"test-augment:ll6\": [\n" + + " \"unbounded\",\n" + + " \"8\"\n" + + " ],\n" + + " \"test-augment:cont5\": {\n" + + " \"leaf13\": \"true\"\n" + + " }"; + + static final String ENCODE_TO_JSON_YANG_AUG_POST = "{\n" + + " \"test-yang:leaf10\": \"abc\"," + + ENCODE_TO_JSON_YANG_COMMON + "\n}"; + static final String ENCODE_TO_JSON_YANG = "{\n" + " \"test-yang:cont2\": {\n" + " \"list1\": [\n" + @@ -177,41 +217,8 @@ public final class DataFormatUtilsTest { " \"abc\"\n" + " ],\n" + " \"cont4\": {\n" + - " \"leaf10\": \"abc\",\n" + - " \"test-augment:cont13\": {\n" + - " \"ll9\": [\n" + - " \"abc\",\n" + - " \"abc\"\n" + - " ],\n" + - " \"list9\": [\n" + - " {\n" + - " \"leaf27\": \"abc\"\n" + - " },\n" + - " {\n" + - " \"leaf27\": \"abc\"\n" + - " }\n" + - " ],\n" + - " \"leaf28\": \"abc\",\n" + - " \"cont12\": {\n" + - " \"leaf26\": \"abc\"\n" + - " }\n" + - " },\n" + - " \"test-augment:list7\": [\n" + - " {\n" + - " \"leaf14\": \"test\"\n" + - " },\n" + - " {\n" + - " \"leaf14\": \"create\"\n" + - " }\n" + - " ],\n" + - " \"test-augment:leaf15\": \"abc\",\n" + - " \"test-augment:ll6\": [\n" + - " \"unbounded\",\n" + - " \"8\"\n" + - " ],\n" + - " \"test-augment:cont5\": {\n" + - " \"leaf13\": \"true\"\n" + - " }\n" + + " \"leaf10\": \"abc\"," + + addSpace(ENCODE_TO_JSON_YANG_COMMON, 8) + "\n" + " },\n" + " \"ll4\": [\n" + " \"abc\",\n" + @@ -501,4 +508,19 @@ public final class DataFormatUtilsTest { " abc\n" + " \n" + ""; + + /** + * Adds the specified number of space required for a req in each line. + * + * @param req request message + * @param i number of space + * @return space appended string + */ + private static String addSpace(String req, int i) { + StringBuilder space = new StringBuilder(""); + for (int sp = 0; sp < i; sp++) { + space = space.append(" "); + } + return req.replaceAll("\n", "\n" + space.toString()); + } } -- cgit From da54fc49d3f16d7028a42cd90ad1500973814790 Mon Sep 17 00:00:00 2001 From: janani b Date: Mon, 8 Oct 2018 16:13:36 +0530 Subject: Appending dummy root node to XML data format To hold all the children in XML message a dummy root node is added Issue-ID: CCSDK-324 Change-Id: I7cf0266d15e6bfaa2b9207e77d8bd5372a164b4f Signed-off-by: janani b --- .../dfserializer/DfSerializerUtil.java | 7 +- .../dfserializer/PropertiesNodeXmlListener.java | 12 ++-- .../dfserializer/XmlSerializer.java | 18 ++++- .../dfserializer/DataFormatSerializerTest.java | 20 ++++++ .../dfserializer/DataFormatUtilsTest.java | 78 ++++++++++++---------- 5 files changed, 87 insertions(+), 48 deletions(-) diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerUtil.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerUtil.java index 598b08c1b..fbebd2b2d 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerUtil.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerUtil.java @@ -210,11 +210,10 @@ public final class DfSerializerUtil { * @return base type definition */ static TypeDefinition resolveBaseTypeFrom(TypeDefinition type) { - TypeDefinition superType; - for(superType = type; superType.getBaseType() != null; - superType = superType.getBaseType()) { + TypeDefinition superType = type; + while (superType.getBaseType() != null) { + superType = superType.getBaseType(); } return superType; } - } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeXmlListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeXmlListener.java index 39a08e387..f098195e4 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeXmlListener.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeXmlListener.java @@ -78,11 +78,13 @@ public class PropertiesNodeXmlListener implements PropertiesNodeListener { @Override public void start(PropertiesNode node) { - //Do Nothing. + rootElement = addElement(null, node); + elementStack.push(rootElement); } @Override public void end(PropertiesNode node) throws SvcLogicException { + xmlData = rootElement.asXML(); xmlData = UTF_HEADER + xmlData; writer = getXmlWriter(xmlData, "4"); } @@ -113,9 +115,6 @@ public class PropertiesNodeXmlListener implements PropertiesNodeListener { NODE_TYPE_ERR, node.nodeType().toString())); } if (element != null) { - if (elementStack.isEmpty()) { - rootElement = element; - } elementStack.push(element); } } @@ -133,10 +132,7 @@ public class PropertiesNodeXmlListener implements PropertiesNodeListener { case MULTI_INSTANCE_NODE: case MULTI_INSTANCE_LEAF_NODE: case SINGLE_INSTANCE_LEAF_NODE: - if (!elementStack.isEmpty() && - elementStack.peek().equals(rootElement)) { - xmlData = rootElement.asXML(); - } else { + if (!elementStack.isEmpty()) { elementStack.pop(); } break; diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java index 6eeb4b82c..f3c6723e1 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/XmlSerializer.java @@ -61,7 +61,7 @@ public class XmlSerializer extends DataFormatSerializer { PropertiesNodeXmlListener xmlListener = new PropertiesNodeXmlListener(); nodeWalker.walk(xmlListener, propNode); Writer writer = xmlListener.getWriter(); - return writer.toString(); + return removeRootNode(writer.toString(), propNode.name()); } @Override @@ -85,4 +85,20 @@ public class XmlSerializer extends DataFormatSerializer { return serializerContext().getPropNodeSerializer().decode( listener.serializerHelper().getPropertiesNode()); } + + /** + * Removes root node from the XML data format message and makes the + * string to be pretty print. + * + * @param xml XML data format message + * @param rootName root node name + * @return pretty print format XML message + */ + private static String removeRootNode(String xml, String rootName) { + xml = xml.replace("\n<" + rootName + ">", "\n"); + xml = xml.replace("" + "\n", ""); + xml = xml.replaceAll("\n" + " ", "\n"); + xml = xml.replaceFirst("\n", ""); + return xml; + } } \ No newline at end of file diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java index 40f4c4b1b..1185eea1c 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java @@ -54,6 +54,7 @@ import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormat import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_ID; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_RPC; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_YANG; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_YANG_AUG_POST; /** @@ -276,6 +277,25 @@ public class DataFormatSerializerTest { assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG)); } + /** + * Verifies encoding of parameters to XML data format with augment as + * root child. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToXmlWithAugAsRootChild() throws SvcLogicException { + String pre = "test-yang:cont1.cont2."; + SvcLogicContext ctx = createAttListYang(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "xml"); + p.put("httpMethod", "post"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/test-yang:cont1/cont2/cont4"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_AUG_POST)); + } + /** * Verifies decoding of parameters from XML data format with containers, * grouping and augment. diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java index 7e6445fcd..a0a154bf3 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java @@ -249,6 +249,47 @@ public final class DataFormatUtilsTest { " }\n" + "}"; + static final String ENCODE_TO_XML_YANG_COMMON = "\n" + + "\n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + "\n" + + "\n" + + " test\n" + + "\n" + + "\n" + + " create\n" + + "\n" + + "abc\n" + + "unbounded\n" + + "8\n" + + "\n" + + " true\n" + + ""; + + static final String ENCODE_TO_XML_YANG_AUG_POST = "\n" + + "abc" + + "" + + ENCODE_TO_XML_YANG_COMMON + "\n"; + static final String ENCODE_TO_XML_YANG = "\n" + "\n" + @@ -305,40 +346,8 @@ public final class DataFormatUtilsTest { " abc\n" + " abc\n" + " \n" + - " abc\n" + - " \n" + - " abc\n" + - " abc\n" + - " \n" + - " abc\n" + - " \n" + - " \n" + - " abc\n" + - " \n" + - " abc\n" + - " \n" + - " abc\n" + - " \n" + - " \n" + - " \n" + - " test\n" + - " \n" + - " \n" + - " create\n" + - " \n" + - " abc\n" + - " unbounded\n" + - " 8\n" + - " \n" + - " true\n" + - " \n" + + " abc"+ + addSpace(ENCODE_TO_XML_YANG_COMMON, 8) + "\n" + " \n" + " abc\n" + " abc\n" + @@ -362,7 +371,6 @@ public final class DataFormatUtilsTest { " \n" + "\n"; - static final String ENCODE_TO_JSON_RPC = "{\n" + " \"test-yang:input\": {\n" + " \"leaf30\": \"abc\",\n" + -- cgit From bc2c9899ae7d71d0e4a970c146a5121822913ff9 Mon Sep 17 00:00:00 2001 From: janani b Date: Mon, 8 Oct 2018 19:11:02 +0530 Subject: PUT and PATCH operation support Changes to add a additional root node to the data format req to support PUT and PATCH operations in RestconfApiCallNode Issue-ID: CCSDK-614 Change-Id: If094810861f8152a2a6d6ee86e9f81c8812b8ad6 Signed-off-by: janani b --- .../restconfapicall/RestconfApiCallNode.java | 149 +++++++++++++++++- .../plugins/restconfapicall/RestconfApiUtils.java | 41 +++-- .../dfserializer/DfSerializerUtil.java | 38 +++-- .../pnserializer/MdsalPropertiesNodeUtils.java | 10 +- .../dfserializer/DataFormatSerializerTest.java | 173 ++++++++++++++++++++- .../dfserializer/DataFormatUtilsTest.java | 53 +++++-- 6 files changed, 415 insertions(+), 49 deletions(-) diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java index 91ce3338a..a76b27d0b 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java @@ -20,6 +20,14 @@ package org.onap.ccsdk.sli.plugins.restconfapicall; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.stream.JsonWriter; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; @@ -35,30 +43,39 @@ import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.MdsalSerializerHe import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.SerializerHelper; import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.YangParameters; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeSerializer; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.Namespace; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNodeSerializer; import org.opendaylight.restconf.common.context.InstanceIdentifierContext; import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier; import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.SchemaNode; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.core.UriBuilder; +import java.io.StringWriter; +import java.io.Writer; import java.net.SocketException; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; +import static com.google.common.base.Strings.repeat; import static java.lang.String.format; +import static java.lang.String.valueOf; import static org.apache.commons.lang3.StringUtils.join; +import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.DELETE; +import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.GET; import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.PATCH; -import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.POST; import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.PUT; import static org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode.parseParam; import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.ATTEMPTS_MSG; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.COLON; import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.COMMA; import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.COMM_FAIL; import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.HEADER; @@ -74,10 +91,16 @@ import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.RES_PR import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.RETRY_COUNT; import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.RETRY_FAIL; import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.UPDATED_URL; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.getUpdatedXmlReq; import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.getSchemaCtxFromDir; import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.getYangParameters; import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.parseUrl; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfListenerFactory.instance; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.FORMAT_ERR; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.UTF_HEADER; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.XML_TREE_ERR; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.getXmlWriter; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getModuleNamespace; import static org.osgi.framework.FrameworkUtil.getBundle; /** @@ -154,9 +177,11 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { InstanceIdentifierContext insIdCtx = getInsIdCtx(p, uri); String req = null; - if (p.httpMethod == POST || p.httpMethod == PUT - || p.httpMethod == PATCH) { + if (p.httpMethod != GET && p.httpMethod != DELETE) { req = serializeRequest(props, p, uri, insIdCtx); + if (p.httpMethod == PUT || p.httpMethod == PATCH) { + updateReq(req, p, insIdCtx); + } } if (req == null && p.requestBody != null) { req = p.requestBody; @@ -210,8 +235,8 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { } if (r != null && r.code >= 300) { - throw new SvcLogicException( - String.valueOf(r.code) + ": " + r.message); + throw new SvcLogicException(valueOf(r.code) + + COLON + " " + r.message); } } @@ -316,7 +341,7 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { */ public String getResponse(SvcLogicContext ctx, YangParameters params, String pre, HttpResponse res) { - ctx.setAttribute(pre + RES_CODE, String.valueOf(res.code)); + ctx.setAttribute(pre + RES_CODE, valueOf(res.code)); ctx.setAttribute(pre + RES_MSG, res.message); if (params.dumpHeaders && res.headers != null) { @@ -345,7 +370,7 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { HttpResponse res = new HttpResponse(); res.code = 500; res.message = errMsg; - ctx.setAttribute(prefix + RES_CODE, String.valueOf(res.code)); + ctx.setAttribute(prefix + RES_CODE, valueOf(res.code)); ctx.setAttribute(prefix + RES_MSG, res.message); } @@ -373,4 +398,114 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { log.debug(UPDATED_URL + retryUri.toString()); log.debug(format(COMM_FAIL, hostName, retryString)); } + + /** + * Updates request message for JSON and XML data format, when the HTTP + * method points it as PUT or PATCH. + * + * @param req current request message + * @param p YANG parameters + * @param insIdCtx instance identifier context + * @return update request message + * @throws SvcLogicException when the data format type is wrong + */ + public String updateReq(String req, YangParameters p, + InstanceIdentifierContext insIdCtx) + throws SvcLogicException { + + SchemaNode schemaNode = insIdCtx.getSchemaNode(); + Namespace modNs = getModuleNamespace(schemaNode.getQName(), + insIdCtx.getSchemaContext()); + String nodeName = schemaNode.getQName().getLocalName(); + + switch (p.format) { + case JSON: + return getUpdatedJsonReq(req, nodeName, modNs.moduleName()); + + case XML: + return getXmlReqForPutOp(req, nodeName, modNs.moduleNs()); + + default: + throw new SvcLogicException(format(FORMAT_ERR, p.format)); + } + } + + /** + * Returns the updated JSON request message, when the HTTP method + * points to PUT or PATCH. + * + * @param req current JSON request message + * @param nodeName root node name + * @param modName module name of the root node + * @return update JSON request message + */ + private String getUpdatedJsonReq(String req, String nodeName, + String modName) { + Writer writer = new StringWriter(); + JsonWriter jsonWriter = new JsonWriter(writer); + jsonWriter.setIndent(repeat(" ", 4)); + + JsonParser jsonParser = new JsonParser(); + JsonObject oldJson = (JsonObject)jsonParser.parse(req); + oldJson = remChildModName(oldJson, modName); + JsonObject newJson = new JsonObject(); + newJson.add(modName + COLON + nodeName, oldJson.deepCopy()); + + Gson gson= new Gson(); + gson.toJson(newJson, jsonWriter); + return writer.toString(); + } + + /** + * Removes module name from all the updated first level child node, if it + * is same as the root node added. + * + * @param oldJson JSON object for old request + * @param modName module name of root node + * @return JSON object for old request with updated child module name + */ + private JsonObject remChildModName(JsonObject oldJson, String modName) { + Iterator> it = oldJson.entrySet().iterator(); + Map m = new HashMap<>(); + while (it.hasNext()) { + Map.Entry jNode = it.next(); + if (jNode.getKey().contains(COLON)) { + String[] modArr = jNode.getKey().split(COLON); + if (modArr[0].equals(modName)) { + it.remove(); + m.put(modArr[1], jNode.getValue()); + } + } + } + if (!m.isEmpty()) { + for (Map.Entry element : m.entrySet()) { + oldJson.add(element.getKey(), element.getValue()); + } + } + return oldJson; + } + + /** + * Returns the updated XML request message, when the HTTP method points + * to PUT or PATCH. + * + * @param req current JSON request message + * @param nodeName root node name + * @param modNs module namespace of the root node + * @return update JSON request message + * @throws SvcLogicException when XML parsing fails + */ + private String getXmlReqForPutOp(String req, String nodeName, + URI modNs) throws SvcLogicException { + req = getUpdatedXmlReq(req, nodeName, modNs.toString()); + Document oldDoc; + try { + oldDoc = DocumentHelper.parseText(req); + } catch (DocumentException e) { + throw new SvcLogicException(XML_TREE_ERR, e); + } + Writer writer = getXmlWriter( + UTF_HEADER + oldDoc.getRootElement().asXML(), "4"); + return writer.toString(); + } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java index b51272f7e..3a0b5fb35 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java @@ -41,7 +41,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.PUT; import static org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode.getParameters; import static org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode.parseParam; import static org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode.DEFAULT_MODE; @@ -66,6 +65,8 @@ public final class RestconfApiUtils { static final String COMMA = ","; + static final String COLON = ":"; + static final String HTTP_RES = "httpResponse"; static final String REST_API_URL = "restapiUrl"; @@ -97,9 +98,6 @@ public final class RestconfApiUtils { private static final String URL_SYNTAX = "The following URL cannot be " + "parsed into URI : "; - private static final String PUT_NODE_ERR = "The following URL does not " + - "contain minimum two nodes for PUT operation."; - private static final String YANG = ".yang"; private static final String YANG_FILE_ERR = "Unable to parse the YANG " + @@ -145,12 +143,6 @@ public final class RestconfApiUtils { String path = uri.getPath(); path = getParsedPath(path); - if (method == PUT) { - if (!path.contains(SLASH)) { - throw new SvcLogicException(PUT_NODE_ERR + url); - } - path = path.substring(0, path.lastIndexOf(SLASH)); - } return path; } @@ -162,15 +154,15 @@ public final class RestconfApiUtils { */ private static String getParsedPath(String path) { String firstHalf; - if (path.contains(":")) { - String[] p = path.split(":"); + if (path.contains(COLON)) { + String[] p = path.split(COLON); if (p[0].contains(SLASH)) { int slash = p[0].lastIndexOf(SLASH); firstHalf = p[0].substring(slash + 1); } else { firstHalf = p[0]; } - return firstHalf + ":" + p[1]; + return firstHalf + COLON + p[1]; } return path; } @@ -222,6 +214,13 @@ public final class RestconfApiUtils { } } + /** + * Processes all the obtained files by isolating all the YANG files from + * all the directory of the given path recursively. + * + * @param files files in the given path + * @param yangFiles YANG files list + */ private static void processFiles(File[] files, List yangFiles) { for (File file : files) { if (file.isFile() && file.getName().endsWith(YANG)) { @@ -231,4 +230,20 @@ public final class RestconfApiUtils { } } } + + /** + * Returns the updated XML request message by adding root node to it. + * + * @param req XML request + * @param nodeName root node name + * @param modNs module namespace of the root node + * @return updated XML request message + */ + static String getUpdatedXmlReq(String req, String nodeName, String modNs) { + String rootNode = "\n<" + nodeName + " xmlns=\"" + modNs.toString() + + "\">\n"; + req = req.replaceFirst("\n", rootNode); + req = req + ""; + return req.replaceAll(">\\s+<", "><"); + } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerUtil.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerUtil.java index fbebd2b2d..707c29444 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerUtil.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerUtil.java @@ -68,24 +68,12 @@ public final class DfSerializerUtil { static final String XML_LIS_ERR = "The XML serializer doesn't have XML " + "listener"; - static final String JSON_TREE_ERR = "Unable to form JSON tree object from" + - " the JSON body provided."; - - static final String XML_TREE_ERR = "Unable to form XML tree object from " + - "the XML body provided."; - - static final String FORMAT_ERR = "Only JSON and XML formats are supported" + - ". %s is not supported"; - static final String PROP_NODE_ERR = "The property node doesn't have " + "schema node bound to it."; static final String DF_ERR = "Type mismatch for the node %s. The schema " + "node does not match with the data format node type %s."; - static final String UTF_HEADER = ""; - static final String XML_PREFIX = "yangid"; private static final String YES = "yes"; @@ -98,6 +86,30 @@ public final class DfSerializerUtil { private static final String URI_ERR = "Unable to parse the URI"; + /** + * Data format error message for unsupported types. + */ + public static final String FORMAT_ERR = "Only JSON and XML formats are " + + "supported. %s is not supported"; + + /** + * UTF header message for XML data format message. + */ + public static final String UTF_HEADER = ""; + + /** + * Error message when a JSON tree creation fails. + */ + public static final String JSON_TREE_ERR = "Unable to form JSON tree " + + "object from the JSON body provided."; + + /** + * Error message when a XML tree creation fails. + */ + public static final String XML_TREE_ERR = "Unable to form XML tree object" + + " from the XML body provided."; + //No instantiation. private DfSerializerUtil() { } @@ -110,7 +122,7 @@ public final class DfSerializerUtil { * @return writer with XML * @throws SvcLogicException when transformation of source fails */ - static Writer getXmlWriter(String input, String indent) + public static Writer getXmlWriter(String input, String indent) throws SvcLogicException { try { Transformer transformer = TransformerFactory.newInstance() diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeUtils.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeUtils.java index d7b4818b4..ccc4f2bdd 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeUtils.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeUtils.java @@ -340,7 +340,15 @@ public final class MdsalPropertiesNodeUtils { return null; } - private static Namespace getModuleNamespace(QName qName, SchemaContext ctx) + /** + * Returns module namespace from a given qName. + * + * @param qName qName of a node + * @param ctx schema context + * @return module namespace of the node + * @throws SvcLogicException when the module is not available + */ + public static Namespace getModuleNamespace(QName qName, SchemaContext ctx) throws SvcLogicException { Optional module = ctx.findModule(qName.getModule()); if (!module.isPresent()) { diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java index 1185eea1c..08fa33ee7 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java @@ -42,19 +42,24 @@ import static org.mockito.Mockito.doCallRealMethod; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.GET; +import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.PATCH; import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.POST; import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.PUT; import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.parseUrl; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.DECODE_FROM_JSON_RPC; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.DECODE_FROM_XML_RPC; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_ID; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_ID_PUT; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_RPC; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_YANG; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_YANG_AUG_POST; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_YANG_PUT; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_ID; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_ID_PUT; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_RPC; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_YANG; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_YANG_AUG_POST; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_YANG_PUT; /** @@ -102,6 +107,9 @@ public class DataFormatSerializerTest { doAnswer(dfCaptor).when(restconf).serializeRequest( any(Map.class), any(YangParameters.class), any(String.class), any(InstanceIdentifierContext.class)); + doAnswer(dfCaptor).when(restconf).updateReq( + any(String.class), any(YangParameters.class), + any(InstanceIdentifierContext.class)); } /** @@ -140,6 +148,46 @@ public class DataFormatSerializerTest { assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_ID)); } + /** + * Verifies encoding of parameters to JSON data format with identity-ref + * and inter-file linking for put operation-type. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToJsonIdWithPut() throws SvcLogicException { + String pre = "identity-test:test."; + SvcLogicContext ctx = createAttList(pre); + ctx.setAttribute(pre + "l", "abc"); + p.put("dirPath", "src/test/resources"); + p.put("format", "json"); + p.put("httpMethod", "put"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/identity-test:test"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_ID_PUT)); + } + + /** + * Verifies encoding of parameters to JSON data format with identity-ref + * and inter-file linking for patch operation-type. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToJsonIdWithPatch() throws SvcLogicException { + String pre = "identity-test:test."; + SvcLogicContext ctx = createAttList(pre); + ctx.setAttribute(pre + "l", "abc"); + p.put("dirPath", "src/test/resources"); + p.put("format", "json"); + p.put("httpMethod", "patch"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/identity-test:test"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_ID_PUT)); + } + /** * Verifies encoding of parameters to XML data format with identity-ref * and inter-file linking. @@ -159,6 +207,44 @@ public class DataFormatSerializerTest { assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_ID)); } + /** + * Verifies encoding of parameters to XML data format with identity-ref + * and inter-file linking for put operation-type. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToXmlIdWithPut() throws SvcLogicException { + String pre = "identity-test:test."; + SvcLogicContext ctx = createAttList(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "xml"); + p.put("httpMethod", "put"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/identity-test:test"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_ID_PUT)); + } + + /** + * Verifies encoding of parameters to XML data format with identity-ref + * and inter-file linking for patch operation-type. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToXmlIdWithPatch() throws SvcLogicException { + String pre = "identity-test:test."; + SvcLogicContext ctx = createAttList(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "xml"); + p.put("httpMethod", "patch"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/identity-test:test"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_ID_PUT)); + } + /** * Verifies decoding of parameters from JSON data format with identity-ref * and inter-file linking. @@ -219,6 +305,44 @@ public class DataFormatSerializerTest { assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG)); } + /** + * Verifies encoding of parameters to JSON data format with containers, + * grouping and augment for put operation-type. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToJsonYangWithPut() throws SvcLogicException { + String pre = "test-yang:cont1.cont2."; + SvcLogicContext ctx = createAttListYang(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "json"); + p.put("httpMethod", "put"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/test-yang:cont1/cont2/cont4"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_PUT)); + } + + /** + * Verifies encoding of parameters to JSON data format with containers, + * grouping and augment for patch operation-type. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToJsonYangWithPatch() throws SvcLogicException { + String pre = "test-yang:cont1.cont2."; + SvcLogicContext ctx = createAttListYang(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "json"); + p.put("httpMethod", "patch"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/test-yang:cont1/cont2/cont4"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_PUT)); + } + /** * Verifies encoding of parameters to JSON data format with augment as * root child. @@ -277,6 +401,44 @@ public class DataFormatSerializerTest { assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG)); } + /** + * Verifies encoding of parameters to XML data format with containers, + * grouping and augment for put operation-type + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToXmlYangWithPut() throws SvcLogicException { + String pre = "test-yang:cont1.cont2."; + SvcLogicContext ctx = createAttListYang(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "xml"); + p.put("httpMethod", "put"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/test-yang:cont1/cont2/cont4"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_PUT)); + } + + /** + * Verifies encoding of parameters to XML data format with containers, + * grouping and augment for patch operation-type + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToXmlYangWithPatch() throws SvcLogicException { + String pre = "test-yang:cont1.cont2."; + SvcLogicContext ctx = createAttListYang(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "xml"); + p.put("httpMethod", "put"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/test-yang:cont1/cont2/cont4"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_PUT)); + } + /** * Verifies encoding of parameters to XML data format with augment as * root child. @@ -369,23 +531,24 @@ public class DataFormatSerializerTest { @Test public void validateUrlParser() throws SvcLogicException { String actVal = "identity-test:test"; + String putId = "/for-put"; String url1 = "http://echo.getpostman.com/restconf/operations/" + actVal; String url2 = "http://echo.getpostman.com/restconf/data/" + actVal; String url3 = "https://echo.getpostman.com/restconf/operations/" + actVal; String url4 = "https://echo.getpostman.com/restconf/data/" + actVal + - "/for-put"; + putId; String url5 = "http://localhost:8282/restconf/operations/" + actVal; String url6 = "https://localhost:8282/restconf/operations/" + actVal; String url7 = "http://localhost:8282/restconf/data/" + actVal + - "/for-put"; + putId; String url8 = "https://localhost:8282/restconf/data/" + actVal; String url9 = "http://182.2.61.24:2250/restconf/data/" + actVal; String url10 = "https://182.2.61.24:2250/restconf/operations/" + actVal; String val1 = parseUrl(url1, POST); String val2 = parseUrl(url2, GET); - String val3 = parseUrl(url3, POST); + String val3 = parseUrl(url3, PATCH); String val4 = parseUrl(url4, PUT); String val5 = parseUrl(url5, GET); String val6 = parseUrl(url6, POST); @@ -396,10 +559,10 @@ public class DataFormatSerializerTest { assertThat(val1, is(actVal)); assertThat(val2, is(actVal)); assertThat(val3, is(actVal)); - assertThat(val4, is(actVal)); + assertThat(val4, is(actVal + putId)); assertThat(val5, is(actVal)); assertThat(val6, is(actVal)); - assertThat(val7, is(actVal)); + assertThat(val7, is(actVal + putId)); assertThat(val8, is(actVal)); assertThat(val9, is(actVal)); assertThat(val10, is(actVal)); diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java index a0a154bf3..027604480 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java @@ -26,9 +26,9 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; */ public final class DataFormatUtilsTest { - static final String ENCODE_TO_JSON_ID = "{\n" + - " \"identity-test:con1\": {\n" + - " \"interfaces\": {\n" + + static final String ENCODE_TO_JSON_ID_COMMON = "\n \"interfaces\"" + + ": " + + "{\n" + " \"int-list\": [\n" + " {\n" + " \"iden\": \"optical\",\n" + @@ -61,14 +61,23 @@ public final class DataFormatUtilsTest { " ]\n" + " },\n" + " \"interface\": \"identity-types:physical\"\n" + - " },\n" + + " }"; + + static final String ENCODE_TO_JSON_ID = "{\n" + + " \"identity-test:con1\": {" + ENCODE_TO_JSON_ID_COMMON + + ",\n" + " \"identity-test:l\": \"abc\"\n" + "}"; - static final String ENCODE_TO_XML_ID = "\n" + - "\n" + - " \n" + + static final String ENCODE_TO_JSON_ID_PUT = "{\n" + + " \"identity-test:test\": {\n" + + " \"con1\": {" + addSpace(ENCODE_TO_JSON_ID_COMMON, 4) + + ",\n" + + " \"l\": \"abc\"\n" + + " }\n" + + "}"; + + static final String ENCODE_TO_XML_ID_COMMON = "\n \n" + " \n" + " optical\n" + " \n" + @@ -97,8 +106,19 @@ public final class DataFormatUtilsTest { " \n" + " \n" + " " + - "yangid:physical\n" + - "\n"; + "yangid:physical"; + + static final String ENCODE_TO_XML_ID = "\n" + + "" + + ENCODE_TO_XML_ID_COMMON + "\n\n"; + + static final String ENCODE_TO_XML_ID_PUT = "\n" + + "\n" + + " " + addSpace(ENCODE_TO_XML_ID_COMMON, 4) + + "\n \n" + + "\n"; static final String ENCODE_TO_JSON_YANG_COMMON = "\n " + "\"test-augment:cont13\": {\n" + @@ -249,6 +269,13 @@ public final class DataFormatUtilsTest { " }\n" + "}"; + static final String ENCODE_TO_JSON_YANG_PUT = "{\n" + + " \"test-yang:cont4\": {" + addSpace( + ENCODE_TO_JSON_YANG_COMMON, 4) + ",\n" + + " \"leaf10\": \"abc\"\n" + + " }\n" + + "}"; + static final String ENCODE_TO_XML_YANG_COMMON = "\n" + "\n" + @@ -290,6 +317,12 @@ public final class DataFormatUtilsTest { "" + ENCODE_TO_XML_YANG_COMMON + "\n"; + static final String ENCODE_TO_XML_YANG_PUT = "\n" + + "\n" + + " abc" + + addSpace(ENCODE_TO_XML_YANG_COMMON, 4) + "\n\n"; + static final String ENCODE_TO_XML_YANG = "\n" + "\n" + -- cgit From 792a8cc436079f9667308a43786de015be0d1513 Mon Sep 17 00:00:00 2001 From: janani b Date: Mon, 8 Oct 2018 19:50:02 +0530 Subject: Issue fix Factory pattern constructor issue fix Issue-ID: CCSDK-614 Change-Id: I3aee79894cfddd47273289878e5ba079926b8054 Signed-off-by: janani b --- .../sli/plugins/yangserializers/dfserializer/DfListenerFactory.java | 6 ++++++ .../plugins/yangserializers/dfserializer/DfSerializerFactory.java | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfListenerFactory.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfListenerFactory.java index e10a085a6..06a811e15 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfListenerFactory.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfListenerFactory.java @@ -31,6 +31,12 @@ import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializ */ public final class DfListenerFactory { + /** + * Creates a new DfListenerFactory. + */ + private DfListenerFactory() { + } + /** * Returns the instance of the data format listener factory. * diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerFactory.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerFactory.java index bd0285e8e..4d95235e5 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerFactory.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DfSerializerFactory.java @@ -31,6 +31,12 @@ import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializ */ public final class DfSerializerFactory { + /** + * Creates a new DfSerializerFactory. + */ + private DfSerializerFactory() { + } + /** * Returns the instance of the data format serializer factory. * -- cgit From c7971703e0455c2ea71ac1b7072d4d1d2f99577f Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 11 Oct 2018 16:25:06 -0400 Subject: Prepare for RC0 release Update to prepare for RC0 release build: remove -STAGING tag from release version and use released parent poms. Change-Id: I4411cbd86164f0e2739196d78fd1670f92bc1edd Issue-ID: CCSDK-617 Signed-off-by: Timoney, Dan (dt5972) --- features/ccsdk-sli-plugins-all/pom.xml | 2 +- features/features-sli-plugins/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- pom.xml | 2 +- properties-node/features/ccsdk-properties-node/pom.xml | 2 +- properties-node/features/features-properties-node/pom.xml | 2 +- properties-node/features/pom.xml | 2 +- properties-node/installer/pom.xml | 2 +- properties-node/pom.xml | 2 +- properties-node/provider/pom.xml | 2 +- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/features-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/pom.xml | 2 +- restapi-call-node/installer/pom.xml | 2 +- restapi-call-node/pom.xml | 2 +- restapi-call-node/provider/pom.xml | 2 +- restconf-client/features/ccsdk-restconf-client/pom.xml | 2 +- restconf-client/features/features-restconf-client/pom.xml | 2 +- restconf-client/features/pom.xml | 2 +- restconf-client/installer/pom.xml | 2 +- restconf-client/pom.xml | 2 +- restconf-client/provider/pom.xml | 2 +- sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml | 2 +- sshapi-call-node/features/features-sshapi-call-node/pom.xml | 2 +- sshapi-call-node/features/pom.xml | 2 +- sshapi-call-node/installer/pom.xml | 2 +- sshapi-call-node/pom.xml | 2 +- sshapi-call-node/provider/pom.xml | 2 +- template-node/features/ccsdk-template-node/pom.xml | 2 +- template-node/features/features-template-node/pom.xml | 2 +- template-node/features/pom.xml | 2 +- template-node/installer/pom.xml | 2 +- template-node/pom.xml | 2 +- template-node/provider/pom.xml | 2 +- version.properties | 2 +- 36 files changed, 36 insertions(+), 36 deletions(-) diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index 714ad58a5..65c648ae6 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.1-SNAPSHOT + 1.1.1 diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index b3333b600..66519ef5d 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.1-SNAPSHOT + 1.1.1 diff --git a/features/installer/pom.xml b/features/installer/pom.xml index c2b77d0fd..d984bd80b 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1-SNAPSHOT + 1.1.1 diff --git a/features/pom.xml b/features/pom.xml index 257627da4..fae7a0e46 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1-SNAPSHOT + 1.1.1 diff --git a/pom.xml b/pom.xml index 7a0f84a9f..5cae3e7f8 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index 744d6d892..86af69f99 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.1-SNAPSHOT + 1.1.1 diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index 0f1b28c88..4d8610c7e 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.1-SNAPSHOT + 1.1.1 diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 32e139b4f..3c6f9b74b 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 0a6918a3e..ea0fd2db1 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 25c2cf225..4cb284bc9 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 7f9352341..5dd1a883e 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 2c616a298..885315131 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.1-SNAPSHOT + 1.1.1 diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index 8160611dd..aeb5ad6e1 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.1-SNAPSHOT + 1.1.1 diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index 55e0945e7..89458bf9a 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index acb6ae899..97214a702 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index f704647ab..674e5dd21 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 035f2fcf3..bdd980fec 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index 462036e73..1c45de213 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.1-SNAPSHOT + 1.1.1 diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml index 166ddc53d..bd42f8cf0 100644 --- a/restconf-client/features/features-restconf-client/pom.xml +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.1-SNAPSHOT + 1.1.1 diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml index 6aa3fde88..7c0a89ff7 100755 --- a/restconf-client/features/pom.xml +++ b/restconf-client/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index fd675c80a..965786427 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index fccd697bb..fbfdf0710 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 43c9d1737..cfa374548 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index 9220b1f78..1cd200c33 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.1-SNAPSHOT + 1.1.1 diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml index dc924244a..f566268fb 100644 --- a/sshapi-call-node/features/features-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/features-sshapi-call-node/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.1-SNAPSHOT + 1.1.1 diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml index 82e69b9b6..1327b7768 100755 --- a/sshapi-call-node/features/pom.xml +++ b/sshapi-call-node/features/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index 9d570fd36..86b3cb23b 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index 7dda908e5..9f2cb8955 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index e4619ca04..e6787d642 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index b7d329e59..e926a439e 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.1-SNAPSHOT + 1.1.1 diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml index 021e5921b..b6cf4cc9c 100644 --- a/template-node/features/features-template-node/pom.xml +++ b/template-node/features/features-template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.1-SNAPSHOT + 1.1.1 diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml index c918417ca..9c4cabd3e 100644 --- a/template-node/features/pom.xml +++ b/template-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index f588f49ce..fa07539b8 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/template-node/pom.xml b/template-node/pom.xml index c2668f869..40bb39da8 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index fa2ba9d91..a8e1de026 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.1-SNAPSHOT + 1.1.1 org.onap.ccsdk.sli.plugins diff --git a/version.properties b/version.properties index 1c849dae1..c5250c6c9 100644 --- a/version.properties +++ b/version.properties @@ -11,6 +11,6 @@ feature_revision=1 base_version=${release_name}.${sprint_number}.${feature_revision} -release_version=${base_version}-STAGING +release_version=${base_version} snapshot_version=${base_version}-SNAPSHOT -- cgit From 5b0d0173096c0ac635b0edef71acb3244386e51a Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 23 Oct 2018 08:46:38 -0400 Subject: Roll to initial Dublin snapshot Roll version to initial Dublin snapshot Change-Id: I48713fcb744f895842a52b2d48ba28cccd06817c Issue-ID: CCSDK-617 Signed-off-by: Timoney, Dan (dt5972) --- features/ccsdk-sli-plugins-all/pom.xml | 4 ++-- features/features-sli-plugins/pom.xml | 4 ++-- features/installer/pom.xml | 4 ++-- features/pom.xml | 4 ++-- pom.xml | 4 ++-- properties-node/features/ccsdk-properties-node/pom.xml | 4 ++-- properties-node/features/features-properties-node/pom.xml | 4 ++-- properties-node/features/pom.xml | 4 ++-- properties-node/installer/pom.xml | 4 ++-- properties-node/pom.xml | 4 ++-- properties-node/provider/pom.xml | 4 ++-- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/features-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/pom.xml | 4 ++-- restapi-call-node/installer/pom.xml | 4 ++-- restapi-call-node/pom.xml | 4 ++-- restapi-call-node/provider/pom.xml | 4 ++-- restconf-client/features/ccsdk-restconf-client/pom.xml | 4 ++-- restconf-client/features/features-restconf-client/pom.xml | 4 ++-- restconf-client/features/pom.xml | 4 ++-- restconf-client/installer/pom.xml | 4 ++-- restconf-client/pom.xml | 4 ++-- restconf-client/provider/pom.xml | 8 ++++---- sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/features/features-sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/features/pom.xml | 4 ++-- sshapi-call-node/installer/pom.xml | 4 ++-- sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/provider/pom.xml | 4 ++-- template-node/features/ccsdk-template-node/pom.xml | 4 ++-- template-node/features/features-template-node/pom.xml | 4 ++-- template-node/features/pom.xml | 4 ++-- template-node/installer/pom.xml | 4 ++-- template-node/pom.xml | 4 ++-- template-node/provider/pom.xml | 4 ++-- version.properties | 6 +++--- 36 files changed, 75 insertions(+), 75 deletions(-) diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index 65c648ae6..4d846bd1a 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -7,13 +7,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins-all - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index 66519ef5d..56d724285 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-sli-plugins - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index d984bd80b..ac8f620ba 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins sliplugins-features-installer - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index fae7a0e46..18dbfbfc1 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins sliplugins-feature-aggregator - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-plugins :: features diff --git a/pom.xml b/pom.xml index 5cae3e7f8..df1644572 100755 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index 86af69f99..84709fa4e 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-properties-node - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index 4d8610c7e..13d056f10 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-properties-node - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 3c6f9b74b..c510a3ac3 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-features - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index ea0fd2db1..c86901ee4 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-installer - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 4cb284bc9..0c167730f 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-plugins :: properties-node diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 5dd1a883e..da1ff21ea 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-provider - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT bundle ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 885315131..80dcc0ac0 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -7,13 +7,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restapi-call-node - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index aeb5ad6e1..d6b4a2635 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-restapi-call-node - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index 89458bf9a..36f9d28fe 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-features - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 97214a702..9bbcf2a08 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-installer - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 674e5dd21..cdfee6bf4 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index bdd980fec..5423292f1 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -6,12 +6,12 @@ org.onap.ccsdk.parent binding-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT bundle ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index 1c45de213..82eba3bd1 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -7,13 +7,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restconf-client - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml index bd42f8cf0..910e86574 100644 --- a/restconf-client/features/features-restconf-client/pom.xml +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-restconf-client - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml index 7c0a89ff7..df2abb123 100755 --- a/restconf-client/features/pom.xml +++ b/restconf-client/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-features - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index 965786427..23306c7cd 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -6,12 +6,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-installer - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index fbfdf0710..4a2609a9b 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index cfa374548..2618b5cca 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -6,12 +6,12 @@ org.onap.ccsdk.parent binding-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-provider - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT bundle ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} @@ -39,7 +39,7 @@ org.onap.ccsdk.sli.plugins properties-node-provider - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT org.opendaylight.yangtools @@ -63,7 +63,7 @@ org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT org.opendaylight.netconf diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index 1cd200c33..cb42fcf18 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -7,13 +7,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sshapi-call-node - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml index f566268fb..482c83f7b 100644 --- a/sshapi-call-node/features/features-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/features-sshapi-call-node/pom.xml @@ -7,13 +7,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-sshapi-call-node - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml index 1327b7768..25acf571d 100755 --- a/sshapi-call-node/features/pom.xml +++ b/sshapi-call-node/features/pom.xml @@ -7,12 +7,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-features - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index 86b3cb23b..3adfb69f4 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-installer - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index 9f2cb8955..88456c5ed 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index e6787d642..91ecfabca 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-provider - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT bundle ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index e926a439e..f544fb5a1 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-template-node - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml index b6cf4cc9c..7a61f8caa 100644 --- a/template-node/features/features-template-node/pom.xml +++ b/template-node/features/features-template-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-template-node - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml index 9c4cabd3e..3b9688ed2 100644 --- a/template-node/features/pom.xml +++ b/template-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-features - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index fa07539b8..fb1cd1f2f 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-installer - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom diff --git a/template-node/pom.xml b/template-node/pom.xml index 40bb39da8..8cfea743b 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index a8e1de026..456cb19c4 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-provider - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT bundle diff --git a/version.properties b/version.properties index c5250c6c9..c8f383798 100644 --- a/version.properties +++ b/version.properties @@ -6,11 +6,11 @@ # Comment release_name=0 -sprint_number=3 -feature_revision=1 +sprint_number=4 +feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} -release_version=${base_version} +release_version=${base_version}-STAGING snapshot_version=${base_version}-SNAPSHOT -- cgit From 69d612621915cf9793b5e8c5a4e9ec42187a557d Mon Sep 17 00:00:00 2001 From: Vidyashree Rama Date: Thu, 25 Oct 2018 14:50:31 +0530 Subject: Add authorization header in SSE request Add authorization header in SSE request to support https Issue-ID: CCSDK-628 Change-Id: I031cbed94e21e1f6d90bc0b00b2d70905d47bd69 Signed-off-by: Vidyashree Rama --- .../sli/plugins/restapicall/RestapiCallNode.java | 2 +- .../AdditionalHeaderWebTarget.java | 162 +++++++++++++++++++++ .../restconfdiscovery/RestconfDiscoveryNode.java | 75 +++++++++- .../plugins/restconfdiscovery/SseServerMock.java | 2 +- .../TestRestconfDiscoveryNode.java | 21 +++ 5 files changed, 255 insertions(+), 7 deletions(-) create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/AdditionalHeaderWebTarget.java diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 9a89af6b5..39399a25a 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -543,7 +543,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { return addAuthType(c, p); } - protected Client addAuthType(Client client, Parameters p) throws SvcLogicException { + public Client addAuthType(Client client, Parameters p) throws SvcLogicException { if (p.authtype == AuthType.Unspecified) { if (p.restapiUser != null && p.restapiPassword != null) { client.register(HttpAuthenticationFeature.basic(p.restapiUser, p.restapiPassword)); diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/AdditionalHeaderWebTarget.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/AdditionalHeaderWebTarget.java new file mode 100644 index 000000000..1a0ddbc5f --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/AdditionalHeaderWebTarget.java @@ -0,0 +1,162 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.restconfdiscovery; + +import javax.ws.rs.client.Invocation; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.Configuration; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriBuilder; +import java.net.URI; +import java.util.Map; + +/** + * Adds additional headers for SSE request. + */ +class AdditionalHeaderWebTarget implements WebTarget { + private WebTarget base; + private String token; + + public AdditionalHeaderWebTarget(WebTarget target, String token) { + base = target; + this.token = token; + } + + @Override + public Invocation.Builder request() { + return base.request().header("X-ACCESS-TOKEN", token); + } + + @Override + public Invocation.Builder request(String... acceptedResponseTypes) { + return base.request().header("X-ACCESS-TOKEN", token); + } + + @Override + public Invocation.Builder request(MediaType... acceptedResponseTypes) { + return base.request().header("X-ACCESS-TOKEN", token); + } + + @Override + public Configuration getConfiguration() { + return base.getConfiguration(); + } + + @Override + public URI getUri() { + return base.getUri(); + } + + @Override + public UriBuilder getUriBuilder() { + return base.getUriBuilder(); + } + + @Override + public WebTarget path(String path) { + return base.path(path); + } + + @Override + public WebTarget resolveTemplate(String name, Object value) { + return base.resolveTemplate(name, value); + } + + @Override + public WebTarget resolveTemplate(String name, Object value, boolean encodeSlashInPath) { + return base.resolveTemplate(name, value, encodeSlashInPath); + } + + @Override + public WebTarget resolveTemplateFromEncoded(String name, Object value) { + return base.resolveTemplateFromEncoded(name, value); + } + + @Override + public WebTarget resolveTemplates(Map templateValues) { + return base.resolveTemplates(templateValues); + } + + @Override + public WebTarget resolveTemplates(Map templateValues, boolean encodeSlashInPath) { + return base.resolveTemplates(templateValues, encodeSlashInPath); + } + + @Override + public WebTarget resolveTemplatesFromEncoded(Map templateValues) { + return base.resolveTemplatesFromEncoded(templateValues); + } + + @Override + public WebTarget matrixParam(String name, Object... values) { + return base.matrixParam(name, values); + } + + @Override + public WebTarget queryParam(String name, Object... values) { + return base.queryParam(name, values); + } + + @Override + public WebTarget property(String name, Object value) { + return base.property(name, value); + } + + @Override + public WebTarget register(Class componentClass) { + return base.register(componentClass); + } + + @Override + public WebTarget register(Class componentClass, int priority) { + return base.register(componentClass, priority); + } + + @Override + public WebTarget register(Class componentClass, Class... contracts) { + return base.register(componentClass, contracts); + } + + @Override + public WebTarget register(Class componentClass, Map, Integer> contracts) { + return base.register(componentClass, contracts); + } + + @Override + public WebTarget register(Object component) { + return base.register(component); + } + + @Override + public WebTarget register(Object component, int priority) { + return base.register(component, priority); + } + + @Override + public WebTarget register(Object component, Class... contracts) { + return base.register(component, contracts); + } + + @Override + public WebTarget register(Object component, Map, Integer> contracts) { + return base.register(component, contracts); + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java index 111d62847..5c7d695d9 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java @@ -24,12 +24,21 @@ import org.glassfish.jersey.media.sse.EventSource; import org.glassfish.jersey.media.sse.SseFeature; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.restapicall.Parameters; +import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode; import org.slf4j.Logger; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; @@ -115,9 +124,11 @@ public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { class PersistentConnection implements Runnable { private String url; private volatile boolean running = true; + private Map paramMap; - PersistentConnection(String url) { + PersistentConnection(String url, Map paramMap) { this.url = url; + this.paramMap = paramMap; } private void terminate() { @@ -126,15 +137,26 @@ public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { @Override public void run() { - Client client = ClientBuilder.newBuilder() - .register(SseFeature.class).build(); - WebTarget target = client.target(url); + Parameters p; + WebTarget target = null; + try { + RestapiCallNode restapi = restconfApiCallNode.getRestapiCallNode(); + p = restapi.getParameters(paramMap, new Parameters()); + Client client = ignoreSslClient().register(SseFeature.class); + target = restapi.addAuthType(client, p).target(url); + } catch (SvcLogicException e) { + log.error("Exception occured!", e); + Thread.currentThread().interrupt(); + } + + target = addToken(target, paramMap.get("customHttpHeaders")); EventSource eventSource = EventSource.target(target).build(); eventSource.register(new EventHandler(RestconfDiscoveryNode.this)); eventSource.open(); log.info("Connected to SSE source"); while (running) { try { + log.info("SSE state " + eventSource.isOpen()); Thread.sleep(5000); } catch (InterruptedException e) { log.error("Interrupted!", e); @@ -146,6 +168,49 @@ public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { } } + private Client ignoreSslClient() { + SSLContext sslcontext = null; + + try { + sslcontext = SSLContext.getInstance("TLS"); + sslcontext.init(null, new TrustManager[]{new X509TrustManager() { + @Override + public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { + } + + @Override + public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + } }, new java.security.SecureRandom()); + } catch (NoSuchAlgorithmException | KeyManagementException e) { + throw new IllegalStateException(e); + } + + return ClientBuilder.newBuilder().sslContext(sslcontext).hostnameVerifier((s1, s2) -> true).build(); + } + + protected String getTokenId(String customHttpHeaders) { + if (customHttpHeaders.contains("=")) { + String s[] = customHttpHeaders.split("="); + return s[1]; + } + return customHttpHeaders; + } + + protected WebTarget addToken(WebTarget target, String customHttpHeaders) { + if (customHttpHeaders == null) { + return target; + } + + return new AdditionalHeaderWebTarget( + target, getTokenId(customHttpHeaders)); + } + /** * Establishes a persistent between the client and server. * @@ -167,7 +232,7 @@ public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { subscriptionInfoMap.put(id, info); String url = paramMap.get(SSE_URL); - PersistentConnection connection = new PersistentConnection(url); + PersistentConnection connection = new PersistentConnection(url, paramMap); runnableInfo.put(id, connection); executor.execute(connection); } diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SseServerMock.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SseServerMock.java index 1b234a236..35ac221fb 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SseServerMock.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SseServerMock.java @@ -35,7 +35,7 @@ public class SseServerMock { @Produces(SseFeature.SERVER_SENT_EVENTS) public EventOutput getServerSentEvents() throws IOException { String data = "{" + - "\"ietf-notification:notification\" : {" + + "\"ietf-restconf:notification\" : {" + " \"eventTime\" : \"2017-10-25T08:22:33.44Z\"," + " \"ietf-yang-push:push-change-update\": {" + "\"subscription-id\":\"89\"," + diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java index b2094ca73..af354e9bf 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java @@ -57,6 +57,13 @@ public class TestRestconfDiscoveryNode { p.put("sseConnectURL", "http://localhost:8080/events"); p.put("subscriberId", "networkId"); p.put("responsePrefix", "restapi-result"); + p.put("restapiUser", "access"); + p.put("restapiPassword", "abc@123"); + p.put("customHttpHeaders", "X-ACCESS-TOKEN=x-ik2ps4ikvzupbx0486ft" + + "1ebzs7rt85futh9ho6eofy3wjsap7wqktemlqm4bbsmnar3vrtbyrzuk" + + "bv5itd6m1cftldpjarnyle3sdcqq9hftc4lebz464b5ffxmlbvg9"); + p.put("restapiUrl", "https://localhost:8080/restconf/operations/" + + "ietf-subscribed-notifications:establish-subscription"); RestconfDiscoveryNode rdn = new RestconfDiscoveryNode( new RestconfApiCallNode(new RestapiCallNode())); rdn.establishPersistentConnection(p, ctx, "networkId"); @@ -111,4 +118,18 @@ public class TestRestconfDiscoveryNode { assertThat(rdn.getOutputIdentifier("restapi-result", ctx), is("89")); } + + @Test + public void testGetTokenId() { + String customHttpHeaders = "X-ACCESS-TOKEN=x-ik2ps4ikvzupbx0486ft1ebzs7rt85" + + "futh9ho6eofy3wjsap7wqktemlqm4bbsmnar3vrtbyrzukbv5itd6m1cftldpjarny" + + "le3sdcqq9hftc4lebz464b5ffxmlbvg9"; + RestconfDiscoveryNode rdn = new RestconfDiscoveryNode( + new RestconfApiCallNode(new RestapiCallNode())); + + assertThat(rdn.getTokenId(customHttpHeaders), + is("x-ik2ps4ikvzupbx0486ft1ebzs7rt85futh9ho6eofy3wjsap7wqkt" + + "emlqm4bbsmnar3vrtbyrzukbv5itd6m1cftldpjarnyle3sdcqq9h" + + "ftc4lebz464b5ffxmlbvg9")); + } } -- cgit From fcb76a5d9f223831c2ec2012b7dd26aac53152a3 Mon Sep 17 00:00:00 2001 From: Parshad Patel Date: Mon, 5 Nov 2018 13:23:21 +0900 Subject: Fix sonar blocker issue in sli/plugins Fix use try with resources issue in PropertiesNode.java Issue-ID: CCSDK-647 Change-Id: I62f2c0ecae65efb9d53022518fe36931ba5991e3 Signed-off-by: Parshad Patel --- .../ccsdk/sli/plugins/prop/PropertiesNode.java | 60 +++++++++++----------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java index cefc9c23e..612592b58 100644 --- a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java +++ b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java @@ -45,19 +45,36 @@ public class PropertiesNode implements SvcLogicJavaPlugin { Properties prop = new Properties(); try { File file = new File(param.fileName); - InputStream in = new FileInputStream(file); - Map mm = null; - String pfx = param.contextPrefix != null ? param.contextPrefix + '.' : ""; - if(param.fileBasedParsing){ - byte[] data = new byte[(int) file.length()]; - if ("json".equalsIgnoreCase(getFileExtension(param.fileName))) { - in.read(data); - String str = new String(data, "UTF-8"); - mm = JsonParser.convertToProperties(str); - } else if ("xml".equalsIgnoreCase(getFileExtension(param.fileName))) { - in.read(data); - String str = new String(data, "UTF-8"); - mm = XmlParser.convertToProperties(str, param.listNameList); + try(InputStream in = new FileInputStream(file)){ + Map mm = null; + String pfx = param.contextPrefix != null ? param.contextPrefix + '.' : ""; + if(param.fileBasedParsing){ + byte[] data = new byte[(int) file.length()]; + if ("json".equalsIgnoreCase(getFileExtension(param.fileName))) { + in.read(data); + String str = new String(data, "UTF-8"); + mm = JsonParser.convertToProperties(str); + } else if ("xml".equalsIgnoreCase(getFileExtension(param.fileName))) { + in.read(data); + String str = new String(data, "UTF-8"); + mm = XmlParser.convertToProperties(str, param.listNameList); + } else { + prop.load(in); + for (Object key : prop.keySet()) { + String name = (String) key; + String value = prop.getProperty(name); + if (value != null && value.trim().length() > 0) { + ctx.setAttribute(pfx + name, value.trim()); + log.info("+++ " + pfx + name + ": [" + value + "]"); + } + } + } + if (mm != null){ + for (Map.Entry entry : mm.entrySet()){ + ctx.setAttribute(pfx + entry.getKey(), entry.getValue()); + log.info("+++ " + pfx + entry.getKey() + ": [" + entry.getValue() + "]"); + } + } } else { prop.load(in); for (Object key : prop.keySet()) { @@ -69,24 +86,7 @@ public class PropertiesNode implements SvcLogicJavaPlugin { } } } - if (mm != null){ - for (Map.Entry entry : mm.entrySet()){ - ctx.setAttribute(pfx + entry.getKey(), entry.getValue()); - log.info("+++ " + pfx + entry.getKey() + ": [" + entry.getValue() + "]"); - } - } - } else { - prop.load(in); - for (Object key : prop.keySet()) { - String name = (String) key; - String value = prop.getProperty(name); - if (value != null && value.trim().length() > 0) { - ctx.setAttribute(pfx + name, value.trim()); - log.info("+++ " + pfx + name + ": [" + value + "]"); - } - } } - in.close(); } catch (IOException e) { throw new SvcLogicException("Cannot read property file: " + param.fileName + ": " + e.getMessage(), e); } -- cgit From 01b11a8425a10e90b0259921b46357c1f9bd74ca Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Tue, 6 Nov 2018 16:22:19 +0000 Subject: template node packaging do not embed sli provider or sli common in template node Change-Id: I90c3e7c6ebee254823bb6b309792ba753a8e01b7 Issue-ID: CCSDK-652 Signed-off-by: Smokowski, Kevin (ks6305) --- template-node/provider/pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index 456cb19c4..d7d8d8f8b 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -22,14 +22,17 @@ org.onap.ccsdk.sli.core sli-common + provided org.onap.ccsdk.sli.core sli-provider + provided org.slf4j slf4j-api + provided org.apache.velocity -- cgit From 01de875afad6920a65b7ee266437595558d41395 Mon Sep 17 00:00:00 2001 From: "shashikanth.vh" Date: Tue, 13 Nov 2018 21:20:31 +0530 Subject: fixed restapicall JsonParser to handle : Fixed Restapicall JsonParser to process ":" if it exist in the response body, this change is required for casablanca too. Change-Id: I83b0769eb13eb8d286cc70adc0e85823d6517dcd Issue-ID: SDNC-519 Signed-off-by: shashikanth.vh --- .../ccsdk/sli/plugins/restapicall/JsonParser.java | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java index 4a1dfef50..189ddde31 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java @@ -55,12 +55,17 @@ public final class JsonParser { Iterator ii = json.keys(); while (ii.hasNext()) { String key1 = ii.next(); - wm.put(key1, json.get(key1)); + String[] subKey = key1.split(":"); + if (subKey.length == 2) { + wm.put(subKey[1], json.get(key1)); + } else { + wm.put(key1, json.get(key1)); + } } Map mm = new HashMap<>(); - while (!wm.isEmpty()) + while (!wm.isEmpty()) { for (String key : new ArrayList<>(wm.keySet())) { Object o = wm.get(key); wm.remove(key); @@ -74,7 +79,12 @@ public final class JsonParser { Iterator i = jo.keys(); while (i.hasNext()) { String key1 = i.next(); - wm.put(key + "." + key1, jo.get(key1)); + String[] subKey = key1.split(":"); + if (subKey.length == 2) { + wm.put(key + "." + subKey[1], jo.get(key1)); + } else { + wm.put(key + "." + key1, jo.get(key1)); + } } } else if (o instanceof JSONArray) { JSONArray ja = (JSONArray) o; @@ -82,10 +92,12 @@ public final class JsonParser { log.info("Added property: {}_length: {}", key, String.valueOf(ja.length())); - for (int i = 0; i < ja.length(); i++) + 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); -- cgit From 88628ba71be31e9a9863accd450472aa3f3c51f8 Mon Sep 17 00:00:00 2001 From: janani b Date: Mon, 26 Nov 2018 12:59:03 +0530 Subject: Restconf Discovery Node bug fix COLON removal while updating to ctx param from JSON reply of notification Issue-ID: CCSDK-745 Change-Id: I4af4de47a550a7f6b47216409484d9a0ab3acdfb Signed-off-by: janani b --- .../onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java index e46e47a9b..0eed42c64 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java @@ -27,7 +27,7 @@ import org.slf4j.LoggerFactory; import java.util.Map; -import static org.onap.ccsdk.sli.plugins.prop.JsonParser.convertToProperties; +import static org.onap.ccsdk.sli.plugins.restapicall.JsonParser.convertToProperties; import static org.slf4j.LoggerFactory.getLogger; /** @@ -38,8 +38,8 @@ class EventProcessor implements Runnable { private static final Logger log = getLogger(EventProcessor.class); private RestconfDiscoveryNode node; - private static final String EVENT_SUBSCRIPTION_ID = "ietf-restconf:" + - "notification.ietf-yang-push:push-change-update.subscription-id"; + private static final String EVENT_SUBSCRIPTION_ID = "notification." + + "push-change-update.subscription-id"; public EventProcessor(RestconfDiscoveryNode node) { this.node = node; -- cgit From d50787e5a9489bb69c28b4e40a3194ad713ef78e Mon Sep 17 00:00:00 2001 From: Jessica Wagantall Date: Wed, 5 Dec 2018 17:37:42 -0800 Subject: Update INFO.yaml file Remove Ryan Goulding Change-Id: I02032dcf5aa951f0e605be9ea2331062cb5326ce Issue-ID: CIMAN-134 Signed-off-by: Jessica Wagantall --- INFO.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/INFO.yaml b/INFO.yaml index aaea28b82..e93fecfd1 100644 --- a/INFO.yaml +++ b/INFO.yaml @@ -33,10 +33,9 @@ committers: company: 'ATT' id: 'jh245g' timezone: 'America/New York' - - name: 'Ryan Goulding' - email: 'ryandgoulding@gmail.com' - company: 'Inocybe Technologies' - id: 'rgoulding' - timezone: 'America/New York' tsc: approval: 'https://lists.onap.org/pipermail/onap-tsc' + changes: + - type: 'Deletion' + name: 'Ryan Goulding' + link: 'https://lists.onap.org/g/onap-tsc/message/4261' -- cgit From 22818d31e0d2cc606932afaa3e353c3da2a317a9 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Sat, 8 Dec 2018 11:15:53 +0530 Subject: Sonar Fix: XmlParser.java Fixed sonar issues/code-smells across this file. Issue-ID: CCSDK-800 Change-Id: I19a6ed3632201200b7d0e32885be6fb932bcd724 Signed-off-by: Arundathi Patil --- .../main/java/org/onap/ccsdk/sli/plugins/prop/XmlParser.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/XmlParser.java b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/XmlParser.java index c9581af55..0b308c2b4 100644 --- a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/XmlParser.java +++ b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/XmlParser.java @@ -2,8 +2,9 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * Modifications Copyright © 2018 IBM. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -76,6 +77,9 @@ public final class XmlParser { return properties; } + StringBuilder currentName = new StringBuilder(); + StringBuilder currentValue = new StringBuilder(); + public Handler(Set listNameList) { super(); this.listNameList = listNameList; @@ -83,9 +87,6 @@ public final class XmlParser { 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 { -- cgit From d5a662c40d5feb13810b2191eedcd34bde61fea3 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Sat, 8 Dec 2018 11:49:24 +0530 Subject: Sonar Fix: TemplateNode.java Fixed sonar issues/code-smells across this file Issue-ID: CCSDK-801 Change-Id: Ic1c7302faa64af37333335a8f4790af87195485d Signed-off-by: Arundathi Patil --- .../java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java b/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java index 8a9676817..0b5850a0a 100644 --- a/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java +++ b/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. + * Modifications Copyright © 2018 IBM. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,9 +38,9 @@ import org.slf4j.LoggerFactory; public class TemplateNode implements SvcLogicJavaPlugin { private static final Logger logger = LoggerFactory.getLogger(TemplateNode.class); - public final static String TEMPLATE_PATH = "templatePath"; - public final static String OUTPUT_PATH_KEY = "output"; - public final static String PREFIX_KEY = "prefix"; + public static final String TEMPLATE_PATH = "templatePath"; + public static final String OUTPUT_PATH_KEY = "output"; + public static final String PREFIX_KEY = "prefix"; public final static String REQUIRED_PARAMETERS_ERROR_MESSAGE = "templateName & outputPath are required fields"; protected static final String TEMPLATE_PROPERTIES_FILE_NAME = "template-node.properties"; protected static final String DEFAULT_PROPERTIES_DIR = "/opt/onap/ccsdk/data/properties"; -- cgit From f2cb0a21b9b7d4a48f25a34c9a57197cbec5dd79 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Sat, 8 Dec 2018 12:42:29 +0530 Subject: Sonar Fix: sshapi-call-node-provider-XmlParer.java Fixed sonar issues/code-smells across this file Issue-ID: CCSDK-802 Change-Id: I5be30cd2270cda66108489456ac6566b1aa6dec7 Signed-off-by: Arundathi Patil --- .../org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 index e31754bcd..f386d401a 100644 --- 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 @@ -3,6 +3,8 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * + * Modifications Copyright © 2018 IBM. * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. @@ -79,6 +81,9 @@ public final class XmlParser { return properties; } + StringBuilder currentName = new StringBuilder(); + StringBuilder currentValue = new StringBuilder(); + public Handler(Set listNameList) { super(); this.listNameList = listNameList; @@ -86,9 +91,6 @@ public final class XmlParser { 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 { -- cgit From 77a6c5f93ce5928dd3a0eb0e71a9120c6603fec6 Mon Sep 17 00:00:00 2001 From: Jessica Wagantall Date: Tue, 11 Dec 2018 12:24:10 -0800 Subject: Update INFO.yaml file - Add Gaurav Agrawal as committer - Add missing info sections - Fix indentation to pass verify Change-Id: Ie5149032b467f6bb9768142e6c9c37e6bce09cdc Issue-ID: CIMAN-134 Signed-off-by: Jessica Wagantall --- INFO.yaml | 62 ++++++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/INFO.yaml b/INFO.yaml index e93fecfd1..df82604b7 100644 --- a/INFO.yaml +++ b/INFO.yaml @@ -2,6 +2,7 @@ project: 'ccsdk-sli-plugins' project_creation_date: '2017-06-27' lifecycle_state: 'Incubation' +project_category: '' project_lead: &onap_releng_ptl name: 'Dan Timoney' email: 'dtimoney@att.com' @@ -13,29 +14,58 @@ issue_tracking: type: 'jira' url: 'https://jira.onap.org/projects/CCSDK' key: 'CCDSK' +mailing_list: + type: 'groups.io' + url: 'lists.onap.org' + tag: '<[sub-project_name]>' +realtime_discussion: '' meetings: - type: 'zoom' - agenda: 'https://wiki.onap.org/display/DW/Common+Controller+SDK+Project' - url: 'https://wiki.onap.org/display/DW/Common+Controller+SDK+Project#CommonControllerSDKProject-MeetingMinutes' - server: 'n/a' - channel: 'n/a' - repeats: 'weekly' - time: '13:00 UTC' + agenda: 'https://wiki.onap.org/display/DW/Common+Controller+SDK+Project' + url: 'https://wiki.onap.org/display/DW/Common+Controller+SDK+Project#CommonControllerSDKProject-MeetingMinutes' + server: 'n/a' + channel: 'n/a' + repeats: 'weekly' + time: '13:00 UTC' committers: - <<: *onap_releng_ptl - name: 'Jack Lucas' - email: 'jflucas@research.att.com' - company: 'ATT' - id: 'jackl' - timezone: 'America/New York' + email: 'jflucas@research.att.com' + company: 'ATT' + id: 'jackl' + timezone: 'America/New York' - name: 'Jun (Nicolas) Hu' - email: 'jh245g@att.com' - company: 'ATT' - id: 'jh245g' - timezone: 'America/New York' + email: 'jh245g@att.com' + company: 'ATT' + id: 'jh245g' + timezone: 'America/New York' + - name: 'Gaurav Agrawal' + email: 'gaurav.agrawal@huawei.com' + company: 'Huawei' + id: 'agrawalgaurav' + timezone: 'Asia/Kolkata' +repositories: + - ccsdk-apps + - ccsdk-cds + - ccsdk-distribution + - ccsdk-features + - ccsdk-parent + - ccsdk-platform-blueprints + - ccsdk-platform-plugins + - ccsdk-sli-adaptors + - ccsdk-sli-core + - ccsdk-sli-northbound + - ccsdk-sli-plugins + - ccsdk-storage-esaas + - ccsdk-utils tsc: approval: 'https://lists.onap.org/pipermail/onap-tsc' changes: - type: 'Deletion' - name: 'Ryan Goulding' - link: 'https://lists.onap.org/g/onap-tsc/message/4261' + name: 'Ryan Goulding' + link: 'https://lists.onap.org/g/onap-tsc/message/4261' + changes: + - type: 'Addition' + name: 'Gaurav Agrawal' + link: 'https://lists.onap.org/g/onap-tsc/message/4324' + -- cgit From 96856ed3a72873c8a2f2e8163a5e8dda60aafa7a Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Wed, 12 Dec 2018 20:21:13 +0530 Subject: Sonar Fix: HttpMethod.java Fixed sonar issues/code-smells across this file. Issue-ID: CCSDK-820 Change-Id: I495f35866607a1403536dfcebc366afd6d7c0ff7 Signed-off-by: Arundathi Patil --- .../org/onap/ccsdk/sli/plugins/restapicall/HttpMethod.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpMethod.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpMethod.java index 40dfa3714..b2f618a1c 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpMethod.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpMethod.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. + * Modifications Copyright © 2018 IBM. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,15 +28,15 @@ public enum HttpMethod { public static HttpMethod fromString(String s) { if (s == null) return null; - if (s.equalsIgnoreCase("get")) + if (("get").equalsIgnoreCase(s)) return GET; - if (s.equalsIgnoreCase("post")) + if (("post").equalsIgnoreCase(s)) return POST; - if (s.equalsIgnoreCase("put")) + if (("put").equalsIgnoreCase(s)) return PUT; - if (s.equalsIgnoreCase("delete")) + if (("delete").equalsIgnoreCase(s)) return DELETE; - if (s.equalsIgnoreCase("patch")) + if (("patch").equalsIgnoreCase(s)) return PATCH; throw new IllegalArgumentException("Invalid value for HTTP Method: " + s); } -- cgit From 66c306fc34c622574f89ff753c9489163c74475c Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Wed, 12 Dec 2018 20:47:24 +0530 Subject: Sonar Fix: RetryPolicy.java Fixed sonar issues/code-smells across this file Issue-ID: CCSDK-821 Change-Id: Ieac7de3d1bb542394bc876406a4ef0055f4c8ea0 Signed-off-by: Arundathi Patil --- .../onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java index 5cee07791..54c86fefc 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. + * Modifications Copyright © 2018 IBM * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +24,12 @@ package org.onap.ccsdk.sli.plugins.restapicall; public class RetryPolicy { private String[] hostnames; - private Integer maximumRetries; + private Integer maximumRetries; + + public RetryPolicy(String[] hostnames, Integer maximumRetries){ + this.hostnames = hostnames; + this.maximumRetries = maximumRetries; + } public Integer getMaximumRetries() { return maximumRetries; @@ -51,10 +57,4 @@ public class RetryPolicy { return hostnames[position]; } - public RetryPolicy(String[] hostnames, Integer maximumRetries){ - this.hostnames = hostnames; - this.maximumRetries = maximumRetries; - } - - } -- cgit From 9be85cf20aa93908596014a988c03446ad3e0dab Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Wed, 12 Dec 2018 22:08:55 +0530 Subject: Sonar Fix: XmlParser.java Fixed sonar issues/code-smells across this file. Issue-ID: CCSDK-822 Change-Id: Icf2de267282ad30b9235c9aa9dadd1761344c1aa Signed-off-by: Arundathi Patil --- .../org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java index 9aede5b7e..cf6af66f2 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. + * Modifications Copyright © 2018 IBM * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,9 +74,8 @@ public final class XmlParser { private Map properties = new HashMap<>(); - public Map getProperties() { - return properties; - } + StringBuilder currentName = new StringBuilder(); + StringBuilder currentValue = new StringBuilder(); public Handler(Set listNameList) { super(); @@ -84,8 +84,9 @@ public final class XmlParser { this.listNameList = new HashSet<>(); } - StringBuilder currentName = new StringBuilder(); - StringBuilder currentValue = new StringBuilder(); + public Map getProperties() { + return properties; + } @Override public void startElement(String uri, String localName, String qName, Attributes attributes) -- cgit From fb7fd136bdbab1799bb932f53feedf349715c39a Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Mon, 17 Dec 2018 17:33:51 +0530 Subject: Sonar Fix: RetryPolicyStore.java Fixed sonar issues/code-smellls across this file Issue-ID: CCSDK-845 Change-Id: I0a4a59ea875739839a692acec7f1feafb013d32e Signed-off-by: Arundathi Patil --- .../onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java index 775137fff..e4ba5fda6 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. + * Modifications Copyright © 2018 IBM. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,11 +28,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class RetryPolicyStore { - private static final Logger log = LoggerFactory.getLogger(RetryPolicyStore.class); - HashMap retryPolicies; public String proxyServers; + public RetryPolicyStore() { + retryPolicies = new HashMap<>(); + } + public String getProxyServers() { return proxyServers; } @@ -42,10 +45,6 @@ public class RetryPolicyStore { 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)); -- cgit From 6f43bd02d4851c97d857cf65efbd581a9078c3d8 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Mon, 17 Dec 2018 17:00:23 +0530 Subject: Sonar Fix: XmlParser.java Fixed sonar issues/code-smells across this file. Issue-ID: CCSDK-800 Change-Id: I7ed74ea9c8d37137e7e223d9488988e497d604b0 Signed-off-by: Arundathi Patil --- .../main/java/org/onap/ccsdk/sli/plugins/prop/XmlParser.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/XmlParser.java b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/XmlParser.java index 0b308c2b4..68b2f74ec 100644 --- a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/XmlParser.java +++ b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/XmlParser.java @@ -2,8 +2,7 @@ * ============LICENSE_START======================================================= * openECOMP : SDN-C * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * * Modifications Copyright © 2018 IBM. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -73,10 +72,6 @@ public final class XmlParser { private Map properties = new HashMap<>(); - public Map getProperties() { - return properties; - } - StringBuilder currentName = new StringBuilder(); StringBuilder currentValue = new StringBuilder(); @@ -87,6 +82,10 @@ public final class XmlParser { this.listNameList = new HashSet<>(); } + public Map getProperties() { + return properties; + } + @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { -- cgit From d0ecfcdedbf5bf2084d41580791fca34557ba2ee Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Mon, 17 Dec 2018 22:12:17 +0530 Subject: Sonar Fix: RestconfApiUtils.java Fixed sonar issues/code-smells across this file Issue-ID: CCSDK-847 Change-Id: I5e528e23d8691fffca9b3732b7ff5e68a4827162 Signed-off-by: Arundathi Patil --- .../org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java index 3a0b5fb35..c5c7a919b 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java @@ -3,6 +3,8 @@ * ONAP - CCSDK * ================================================================================ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * + * Modifications Copyright © 2018 IBM. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -240,7 +242,7 @@ public final class RestconfApiUtils { * @return updated XML request message */ static String getUpdatedXmlReq(String req, String nodeName, String modNs) { - String rootNode = "\n<" + nodeName + " xmlns=\"" + modNs.toString() + + String rootNode = "\n<" + nodeName + " xmlns=\"" + modNs + "\">\n"; req = req.replaceFirst("\n", rootNode); req = req + ""; -- cgit From aa781c2d2adf9b0c81506dd7de31fa3617c288e1 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Tue, 18 Dec 2018 15:39:41 +0530 Subject: Sonar fix: RetryPolicyStroe.java Fixed sonar issues/code-smells across this file Issue-ID: CCSDK-845 Change-Id: I25e16b7189fd8c063b8d33605dd55094e3ad5877 Signed-off-by: Arundathi Patil --- .../java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java index e4ba5fda6..f68b851d3 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java @@ -24,9 +24,6 @@ package org.onap.ccsdk.sli.plugins.restapicall; import java.util.HashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class RetryPolicyStore { HashMap retryPolicies; public String proxyServers; -- cgit From 2e0e98c12d384ed2ccdff85a543439f2b40f1f2f Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 18 Dec 2018 10:24:32 -0500 Subject: Add BOM for sli/plugins Add BOM for sli/plugins for ease of dependency specification. Change-Id: I7541cc4709a6f1cac278ec7f004abb5283567c61 Issue-ID: CCSDK-856 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ pom.xml | 3 +- 2 files changed, 108 insertions(+), 1 deletion(-) create mode 100755 artifacts/pom.xml diff --git a/artifacts/pom.xml b/artifacts/pom.xml new file mode 100755 index 000000000..b8c11c897 --- /dev/null +++ b/artifacts/pom.xml @@ -0,0 +1,106 @@ + + + 4.0.0 + + org.onap.ccsdk.sli.plugins + sli-plugins-artifacts + 0.4.0-SNAPSHOT + pom + + ccsdk-sli-plugins :: sli-plugins-artifacts + CCSDK plugins components Bill of Materials (BOM) + https://wiki.onap.org + + ONAP + + + + org.onap.ccsdk.parent + parent + 1.2.0-SNAPSHOT + + + + + + org.onap.ccsdk.sli.plugins + ccsdk-properties-node + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.plugins + ccsdk-restapi-call-node + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.plugins + ccsdk-restconf-client + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.plugins + ccsdk-template-node + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.plugins + fabric-discovery-plugin-provider + ${project.version} + + + org.onap.ccsdk.sli.plugins + fabric-discovery-plugin-installer + ${project.version} + + + org.onap.ccsdk.sli.plugins + properties-node-provider + ${project.version} + + + org.onap.ccsdk.sli.plugins + properties-node-installer + ${project.version} + + + org.onap.ccsdk.sli.plugins + restapi-call-node-provider + ${project.version} + + + org.onap.ccsdk.sli.plugins + restapi-call-node-installer + ${project.version} + + + org.onap.ccsdk.sli.plugins + restconf-client-provider + ${project.version} + + + org.onap.ccsdk.sli.plugins + restconf-client-installer + ${project.version} + + + org.onap.ccsdk.sli.plugins + template-node-provider + ${project.version} + + + org.onap.ccsdk.sli.plugins + template-node-installer + ${project.version} + + + + + diff --git a/pom.xml b/pom.xml index df1644572..1eb8b8bbf 100755 --- a/pom.xml +++ b/pom.xml @@ -25,8 +25,9 @@ restapi-call-node sshapi-call-node restconf-client - features template-node + features + artifacts -- cgit From 62e62331a294052109f02686e4529fe613355990 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Thu, 20 Dec 2018 23:04:44 +0530 Subject: Sonar fix: AdditionalHeaderWebTarget.java Fixed sonar issues/code-smells across this file Issue-ID: CCSDK-868 Change-Id: I9a6d0d7791838bf8bc524c7b108df3752cc1a24c Signed-off-by: Arundathi Patil --- .../plugins/restconfdiscovery/AdditionalHeaderWebTarget.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/AdditionalHeaderWebTarget.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/AdditionalHeaderWebTarget.java index 1a0ddbc5f..3213cae15 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/AdditionalHeaderWebTarget.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/AdditionalHeaderWebTarget.java @@ -3,6 +3,8 @@ * ONAP - CCSDK * ================================================================================ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * + * Modifications Copyright © 2018 IBM * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +37,8 @@ class AdditionalHeaderWebTarget implements WebTarget { private WebTarget base; private String token; + private String accessToken = "X-ACCESS-TOKEN"; + public AdditionalHeaderWebTarget(WebTarget target, String token) { base = target; this.token = token; @@ -42,17 +46,17 @@ class AdditionalHeaderWebTarget implements WebTarget { @Override public Invocation.Builder request() { - return base.request().header("X-ACCESS-TOKEN", token); + return base.request().header(accessToken, token); } @Override public Invocation.Builder request(String... acceptedResponseTypes) { - return base.request().header("X-ACCESS-TOKEN", token); + return base.request().header(accessToken, token); } @Override public Invocation.Builder request(MediaType... acceptedResponseTypes) { - return base.request().header("X-ACCESS-TOKEN", token); + return base.request().header(accessToken, token); } @Override -- cgit From 307d8592c1154cd91e1300da3803aa0d0c26e58a Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Thu, 20 Dec 2018 23:09:28 +0530 Subject: Sonar fix: EventProcessor.java Fixed sonar issues/code-smells across this file Issue-ID: CCSDK-869 Change-Id: I601cdcff37475c93f29a9d8b8fe4992f5fbb9a48 Signed-off-by: Arundathi Patil --- .../org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java index 0eed42c64..4f28072d3 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java @@ -3,6 +3,8 @@ * ONAP - CCSDK * ================================================================================ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * + * Modifications Copyright © 2018 IBM * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +25,6 @@ package org.onap.ccsdk.sli.plugins.restconfdiscovery; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.Map; -- cgit From e6e3164b0c4e583593d5d9bd10f2de2485a056f6 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Fri, 28 Dec 2018 23:36:14 +0530 Subject: Sonar fix: EventProcessor.java Fixed sonar issues/code-smells across this file Issue-ID: CCSDK-880 Change-Id: Icfb71fec369ec34944db7e57268e5d1e08af8c42 Signed-off-by: Arundathi Patil --- .../org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java index 0eed42c64..4f28072d3 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/EventProcessor.java @@ -3,6 +3,8 @@ * ONAP - CCSDK * ================================================================================ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * + * Modifications Copyright © 2018 IBM * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +25,6 @@ package org.onap.ccsdk.sli.plugins.restconfdiscovery; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.Map; -- cgit From a6ded88f4df6f21c2452af2d6079e5150a321a40 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Fri, 28 Dec 2018 23:49:12 +0530 Subject: Sonar fix: SshApiCallNode.java Fixed sonar issues/code-smells acros this file Issue-ID: CCSDK-881 Change-Id: Ie1a98a47cedd7781e1e965825b152a50b7912ab0 Signed-off-by: Arundathi Patil --- .../sli/plugins/sshapicall/SshApiCallNode.java | 24 +++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) 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 index 452d94785..146188fb9 100644 --- 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 @@ -6,7 +6,9 @@ * ============================================================================= * Copyright (C) 2018 Samsung Electronics. All rights reserved. -* * ================================================================================ + * ================================================================================ + * Modifications Copyright © 2018 IBM + * ================================================================================ * 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 @@ -24,16 +26,9 @@ package org.onap.ccsdk.sli.plugins.sshapicall; -//import com.fasterxml.jackson.databind.ObjectMapper; - import java.io.ByteArrayOutputStream; -import java.util.Collections; -import java.util.HashSet; import java.util.Map; -import java.util.Set; -import com.google.common.base.Strings; -import org.json.JSONObject; import org.onap.appc.adapter.ssh.SshAdapter; import org.onap.appc.adapter.ssh.SshConnection; import org.onap.ccsdk.sli.core.sli.SvcLogicException; @@ -77,6 +72,10 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { */ private int DEF_SUCCESS_STATUS = 0; + + + private SshAdapter sshAdapter; + /** * Used for jUnit test and testing interface */ @@ -88,8 +87,6 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { PARAM_TEST_MODE = false; } - private SshAdapter sshAdapter; - public void setSshAdapter(SshAdapter sshAdapter) { this.sshAdapter = sshAdapter; } @@ -138,7 +135,8 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { int status = -1; ByteArrayOutputStream stdout = new ByteArrayOutputStream(); ByteArrayOutputStream stderr = new ByteArrayOutputStream(); - String stdoutRes = "", stderrRes = ""; + String stdoutRes = ""; + String stderrRes = ""; try { if (!PARAM_TEST_MODE) { sshConnection = getSshConnection(p); @@ -156,7 +154,7 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { stderrRes = stderr.toString(); } else { - if (params.get("TestFail").equalsIgnoreCase("true")) + if (("true").equalsIgnoreCase(params.get("TestFail"))) status = 202; else status = DEF_SUCCESS_STATUS; @@ -183,11 +181,9 @@ public class SshApiCallNode implements SvcLogicJavaPlugin { return sshAdapter.getConnection(p.sshapiUrl, p.sshapiPort, p.sshapiUser, p.sshapiPassword); // This is not supported yet in the API, patch has already been added to APPC else if (p.authtype == AuthType.KEY){ - //return sshAdapter.getConnection(p.sshapiUrl, p.sshapiPort, p.sshKey); throw new SvcLogicException("SSH Key based Auth method not supported"); } else if (p.authtype == AuthType.NONE){ - //return sshAdapter.getConnection(p.sshapiUrl, p.sshapiPort, p.sshKey); throw new SvcLogicException("SSH Auth type required, BASIC auth in support"); } else if (p.authtype == AuthType.UNSPECIFIED){ -- cgit From 565e49329424de19e35a142e54d1ee7f5c7c57ef Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Fri, 28 Dec 2018 23:23:39 +0530 Subject: Sonar Fix: RestapiCallNode.java Fixed sonar issues/code-smells across this file Issue-ID: CCSDK-879 Change-Id: I037ff59f5cb1b6855b62db434236fc2e567608a9 Signed-off-by: Arundathi Patil --- .../sli/plugins/restapicall/RestapiCallNode.java | 55 ++++++++++++---------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 39399a25a..83b12c767 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. + * Modifications Copyright © 2018 IBM. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,6 +79,13 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { private String uebServers; private String defaultUebTemplateFileName = "/opt/bvc/restapi/templates/default-ueb-message.json"; + private String responseReceivedMessage = "Response received. Time: {}"; + private String responseHttpCodeMessage = "HTTP response code: {}"; + private String requestPostingException = "Exception while posting http request to client "; + private static String skipSendingMessage = "skipSending"; + private static String responsePrefix = "responsePrefix"; + private static String restapiUrlString = "restapiUrl"; + public RestapiCallNode() { String configDir = System.getProperty(PROPERTIES_DIR_KEY, DEFAULT_PROPERTIES_DIR); @@ -115,7 +123,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { p.templateFileName = parseParam(paramMap, "templateFileName", false, null); p.requestBody = parseParam(paramMap, "requestBody", false, null); - p.restapiUrl = parseParam(paramMap, "restapiUrl", true, null); + p.restapiUrl = parseParam(paramMap, restapiUrlString, true, null); validateUrl(p.restapiUrl); p.restapiUser = parseParam(paramMap, "restapiUser", false, null); p.restapiPassword = parseParam(paramMap, "restapiPassword", false, @@ -134,9 +142,9 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { "unspecified")); p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post")); - p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); + p.responsePrefix = parseParam(paramMap, responsePrefix, false, null); p.listNameList = getListNameList(paramMap); - String skipSendingStr = paramMap.get("skipSending"); + String skipSendingStr = paramMap.get(skipSendingMessage); p.skipSending = "true".equalsIgnoreCase(skipSendingStr); p.convertResponse = valueOf(parseParam(paramMap, "convertResponse", false, "true")); @@ -344,8 +352,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } log.error("Error sending the request: " + e.getMessage(), e); - String prefix = parseParam(paramMap, "responsePrefix", false, null); - if (retryPolicy == null || shouldRetry == false) { + String prefix = parseParam(paramMap, responsePrefix, false, null); + if (retryPolicy == null || !shouldRetry) { setFailureResponseStatus(ctx, prefix, e.getMessage(), r); } else { if (retryCount == null) { @@ -357,13 +365,13 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { try { retryCount = retryCount + 1; if (retryCount < retryPolicy.getMaximumRetries() + 1) { - URI uri = new URI(paramMap.get("restapiUrl")); + URI uri = new URI(paramMap.get(restapiUrlString)); String hostname = uri.getHost(); String retryString = retryPolicy.getNextHostName(uri.toString()); URI uriTwo = new URI(retryString); URI retryUri = UriBuilder.fromUri(uri).host(uriTwo.getHost()).port(uriTwo.getPort()).scheme( uriTwo.getScheme()).build(); - paramMap.put("restapiUrl", retryUri.toString()); + paramMap.put(restapiUrlString, retryUri.toString()); log.debug("URL was set to {}", retryUri.toString()); log.debug("Failed to communicate with host {}. Request will be re-attempted using the host {}.", hostname, retryString); @@ -417,7 +425,6 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { String var1 = template.substring(i1 + 2, i2); String value1 = format == Format.XML ? XmlJsonUtil.getXml(mm, var1) : XmlJsonUtil.getJson(mm, var1); - // log.info(" " + var1 + ": " + value1); if (value1 == null || value1.trim().length() == 0) { // delete the whole element (line) int i3 = template.lastIndexOf('\n', i1); @@ -653,7 +660,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { try { response = invocationBuilder.method(p.httpMethod.toString(), entity(request, tt1)); } catch (ProcessingException | IllegalStateException e) { - throw new SvcLogicException("Exception while posting http request to client " + + throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e); } @@ -669,8 +676,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } long t2 = System.currentTimeMillis(); - log.info("Response received. Time: {}", (t2 - t1)); - log.info("HTTP response code: {}", r.code); + log.info(responseReceivedMessage, (t2 - t1)); + log.info(responseHttpCodeMessage, r.code); log.info("HTTP response message: {}", r.message); logHeaders(r.headers); log.info("HTTP response: {}", r.body); @@ -731,7 +738,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { r = new HttpResponse(); r.code = 500; r.message = e.getMessage(); - String prefix = parseParam(paramMap, "responsePrefix", false, null); + String prefix = parseParam(paramMap, responsePrefix, false, null); setResponseStatus(ctx, prefix, r); } @@ -747,8 +754,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { p.user = parseParam(paramMap, "user", false, null); p.password = parseParam(paramMap, "password", false, null); p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post")); - p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); - String skipSendingStr = paramMap.get("skipSending"); + p.responsePrefix = parseParam(paramMap, responsePrefix, false, null); + String skipSendingStr = paramMap.get(skipSendingMessage); p.skipSending = "true".equalsIgnoreCase(skipSendingStr); p.oAuthConsumerKey = parseParam(paramMap, "oAuthConsumerKey", false, null); p.oAuthVersion = parseParam(paramMap, "oAuthVersion", false, null); @@ -788,7 +795,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { r = new HttpResponse(); r.code = 500; r.message = e.getMessage(); - String prefix = parseParam(paramMap, "responsePrefix", false, null); + String prefix = parseParam(paramMap, responsePrefix, false, null); setResponseStatus(ctx, prefix, r); } @@ -825,7 +832,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { throw new SvcLogicException("Http operation" + p.httpMethod + "not supported"); } } catch (ProcessingException e) { - throw new SvcLogicException("Exception while posting http request to client " + + throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e); } @@ -856,7 +863,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { throw new SvcLogicException("Http operation" + p.httpMethod + "not supported"); } } catch (ProcessingException e) { - throw new SvcLogicException("Exception while posting http request to client " + + throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e); } @@ -872,8 +879,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } long t2 = System.currentTimeMillis(); - log.info("Response received. Time: {}", (t2 - t1)); - log.info("HTTP response code: {}", r.code); + log.info(responseReceivedMessage, (t2 - t1)); + log.info(responseHttpCodeMessage, r.code); log.info("HTTP response message: {}", r.message); logHeaders(r.headers); log.info("HTTP response: {}", r.body); @@ -886,8 +893,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { p.topic = parseParam(paramMap, "topic", true, null); p.templateFileName = parseParam(paramMap, "templateFileName", false, null); p.rootVarName = parseParam(paramMap, "rootVarName", false, null); - p.responsePrefix = parseParam(paramMap, "responsePrefix", false, null); - String skipSendingStr = paramMap.get("skipSending"); + p.responsePrefix = parseParam(paramMap, responsePrefix, false, null); + String skipSendingStr = paramMap.get(skipSendingMessage); p.skipSending = "true".equalsIgnoreCase(skipSendingStr); return p; } @@ -954,7 +961,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { try { response = invocationBuilder.post(Entity.entity(request, tt1)); } catch (ProcessingException e) { - throw new SvcLogicException("Exception while posting http request to client " + + throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e); } r.code = response.getStatus(); @@ -965,8 +972,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } long t2 = System.currentTimeMillis(); - log.info("Response received. Time: {}", (t2 - t1)); - log.info("HTTP response code: {}", r.code); + log.info(responseReceivedMessage, (t2 - t1)); + log.info(responseHttpCodeMessage, r.code); logHeaders(r.headers); log.info("HTTP response:\n {}", r.body); -- cgit From 98a18cb948cad4e8490ae89a4ba6a5a4e0dcc99c Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Fri, 28 Dec 2018 23:58:07 +0530 Subject: Sonar fix: JsonParser.java Fixed sonar issues/code-smells across this file Issue-ID: CCSDK-882 Change-Id: I9e3dbe8407553b83d6885579bad9dbe06e04ba72 Signed-off-by: Arundathi Patil --- .../java/org/onap/ccsdk/sli/plugins/sshapicall/model/JsonParser.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 index 296192a5b..3d48a790f 100644 --- 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 @@ -7,6 +7,8 @@ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. * ================================================================================ + * Modifications Copyright © 2018 IBM + * ================================================================================ * 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 @@ -33,7 +35,6 @@ 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; -- cgit From 8674ebef24904d6a6acdb3918241fc0576fdea6e Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Sat, 29 Dec 2018 00:02:42 +0530 Subject: Sonar fix: ParseParam.java Fixed sonar issues/code-smells across this file Issue-ID: CCSDK-883 Change-Id: I69b08b1b9bd94df2815f8957f2f50527ac8b67fc Signed-off-by: Arundathi Patil --- .../org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java index a72bc7bbe..35c1087d8 100644 --- a/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java +++ b/sshapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/model/ParseParam.java @@ -7,6 +7,8 @@ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. * ================================================================================ + * Modifications Copyright © 2018 IBM + * ================================================================================ * 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 @@ -32,12 +34,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.HashSet; -- cgit From f6503a043bd4fb848d28d2f5d4aa45224041e099 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Sat, 29 Dec 2018 00:08:23 +0530 Subject: Sonar fix: XmlParser.java Fixed sonar issues/code-smells across this file Issue-ID: CCSDK-800 Change-Id: I8d00a6e07bedeee7d5f3afebed982453fe0a4c2d Signed-off-by: Arundathi Patil --- .../org/onap/ccsdk/sli/plugins/sshapicall/model/XmlParser.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 index f386d401a..6ea770ad9 100644 --- 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 @@ -77,10 +77,6 @@ public final class XmlParser { private Map properties = new HashMap<>(); - public Map getProperties() { - return properties; - } - StringBuilder currentName = new StringBuilder(); StringBuilder currentValue = new StringBuilder(); @@ -91,6 +87,10 @@ public final class XmlParser { this.listNameList = new HashSet<>(); } + public Map getProperties() { + return properties; + } + @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { -- cgit From 0e6f5ba747a53d366924337a73a3140fc2619433 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Tue, 1 Jan 2019 12:20:31 +0530 Subject: Sonar fix: TemplateNode.java Fixed sonar issues/code-smells across this file Issue-ID: CCSDK-801 Change-Id: I26e767a409634c5541244d05dc5a11a56295984b Signed-off-by: Arundathi Patil --- .../src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java b/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java index 0b5850a0a..3d72ce7b9 100644 --- a/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java +++ b/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java @@ -41,7 +41,7 @@ public class TemplateNode implements SvcLogicJavaPlugin { public static final String TEMPLATE_PATH = "templatePath"; public static final String OUTPUT_PATH_KEY = "output"; public static final String PREFIX_KEY = "prefix"; - public final static String REQUIRED_PARAMETERS_ERROR_MESSAGE = "templateName & outputPath are required fields"; + public static final String REQUIRED_PARAMETERS_ERROR_MESSAGE = "templateName & outputPath are required fields"; protected static final String TEMPLATE_PROPERTIES_FILE_NAME = "template-node.properties"; protected static final String DEFAULT_PROPERTIES_DIR = "/opt/onap/ccsdk/data/properties"; protected static final String PROPERTIES_DIR_KEY = "SDNC_CONFIG_DIR"; -- cgit From d2a1f4b8723a7c0205e3b70dc5e819416a7f97a3 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Tue, 1 Jan 2019 12:27:52 +0530 Subject: Sonar Fix: YangParameters.java Fixed sonar issues/code-smells across this file Issue-ID: CCSDK-884 Change-Id: I20949cb665dfd4c1a28cce5fb629a30057a80dbc Signed-off-by: Arundathi Patil --- .../plugins/yangserializers/dfserializer/YangParameters.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/YangParameters.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/YangParameters.java index c94a22975..8eb3fb6e8 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/YangParameters.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/YangParameters.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ + * Modifications Copyright © 2018 IBM + * ================================================================================ * 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 @@ -26,6 +28,10 @@ import org.onap.ccsdk.sli.plugins.restapicall.Parameters; * Representation of the YANG parameters for the restconf api call node. */ public class YangParameters extends Parameters { + /** + * Directory path of the YANG file. + */ + public String dirPath; /** * Creates an instance of the YANG parameters. @@ -33,9 +39,4 @@ public class YangParameters extends Parameters { public YangParameters() { super(); } - - /** - * Directory path of the YANG file. - */ - public String dirPath; } -- cgit From 57fd31e090909d55a36f957e45a84d9295254d44 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Thu, 3 Jan 2019 22:00:51 +0000 Subject: create a directive for the template node The directive is called hideNullJson, it hides json when it is null to deal with optional json attributes Change-Id: I0b7a2c2f19e6f83e0d8c8c6f3552889c83dc997f Issue-ID: CCSDK-903 Signed-off-by: Smokowski, Kevin (ks6305) --- .../ccsdk/sli/plugins/template/HideNullJson.java | 98 ++++++++++++++++++++++ .../ccsdk/sli/plugins/template/TemplateNode.java | 6 ++ .../sli/plugins/template/HideNullJsonTest.java | 46 ++++++++++ .../provider/src/test/resources/HideNullJson.vtl | 22 +++++ 4 files changed, 172 insertions(+) create mode 100755 template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/HideNullJson.java mode change 100644 => 100755 template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java create mode 100755 template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/HideNullJsonTest.java create mode 100755 template-node/provider/src/test/resources/HideNullJson.vtl diff --git a/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/HideNullJson.java b/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/HideNullJson.java new file mode 100755 index 000000000..d39d7e405 --- /dev/null +++ b/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/HideNullJson.java @@ -0,0 +1,98 @@ + +package org.onap.ccsdk.sli.plugins.template; + +import java.io.IOException; +import java.io.Writer; + +import org.apache.velocity.context.InternalContextAdapter; +import org.apache.velocity.exception.MethodInvocationException; +import org.apache.velocity.exception.ParseErrorException; +import org.apache.velocity.exception.ResourceNotFoundException; +import org.apache.velocity.runtime.directive.Directive; +import org.apache.velocity.runtime.parser.node.Node; + +// This directive can be used when handling optional json attributes in a template +// If an attribute value is null the entire name-value pair will not be rendered +// If an attribute value is not null the name-value pair will be rendered +// Additional optional parameters decide which values are quoted and if a comma and or newline should be appended +public class HideNullJson extends Directive { + + public String getName() { + return "hideNullJson"; + } + + public int getType() { + return BLOCK; + } + + // The first parameter is the json key + // The second parameter is the json value + // This directive handles placing the colon between the json key and json value + // The third parameter is a boolean, when true the json key is surrounded in double quotes by this directive + // The third parameter is true by default and is optional + // The fourth parameter is a boolean when true the json value is surrounded in double quotes by this directive + // The fourth parameter is true by default and is optional + // The fifth parameter is a boolean when true a comma is appended to the end + // The fifth parameter is true by default and is optional + // The sixth parameter is a boolean when true a newline is appended to the end + // The sixth parameter is true by default and is optional + public boolean render(InternalContextAdapter context, Writer writer, Node node) + throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { + String tagValue = null; + Object tagValueObject = node.jjtGetChild(1).value(context); + if (tagValueObject == null) { + return true; + } + tagValue = String.valueOf(tagValueObject); + + String tagName = String.valueOf(node.jjtGetChild(0).value(context)); + + Boolean quoteTagName = getBooleanParameter(true,node,2,context); + Boolean quoteTagValue = getBooleanParameter(true,node,3,context); + Boolean appendComma = getBooleanParameter(true,node,4,context); + Boolean appendNewLine = getBooleanParameter(true,node,5,context); + + StringBuilder sb = new StringBuilder(); + + if (quoteTagName) { + appendQuotedString(tagName,sb); + }else { + sb.append(tagName); + } + + sb.append(":"); + + if (quoteTagValue) { + appendQuotedString(tagValue,sb); + }else { + sb.append(tagValue); + } + + if(appendComma) { + sb.append(","); + } + + if(appendNewLine) { + sb.append("\n"); + } + writer.write(sb.toString()); + return true; + } + + private Boolean getBooleanParameter(Boolean defaultBool, Node node, int parameterPostion, InternalContextAdapter context) { + if (node.jjtGetNumChildren() > parameterPostion && node.jjtGetChild(parameterPostion) != null) { + Object val = node.jjtGetChild(parameterPostion).value(context); + if (val != null) { + return (Boolean) val; + } + } + return defaultBool; + } + + private void appendQuotedString(String str, StringBuilder sb) { + sb.append("\""); + sb.append(str); + sb.append("\""); + } + +} \ No newline at end of file diff --git a/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java b/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java old mode 100644 new mode 100755 index 0b5850a0a..6c0686c05 --- a/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java +++ b/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java @@ -25,6 +25,7 @@ package org.onap.ccsdk.sli.plugins.template; import java.io.FileInputStream; import java.io.StringWriter; import java.util.Map; +import java.util.Map.Entry; import java.util.Properties; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; @@ -52,6 +53,7 @@ public class TemplateNode implements SvcLogicJavaPlugin { ve = new VelocityEngine(); setProperties(); ve.init(); + ve.loadDirective("org.onap.ccsdk.sli.plugins.template.HideNullJson"); } protected void setProperties() { @@ -97,6 +99,10 @@ public class TemplateNode implements SvcLogicJavaPlugin { VelocityContext context = new VelocityContext(); context.put("ctx", ctx); context.put("params", params); + //Adding these values directly to context makes working with the values cleaner + for (Entry entry : params.entrySet()) { + context.put(entry.getKey(), entry.getValue()); + } StringWriter sw = new StringWriter(); template.merge(context, sw); ctx.setAttribute(outputPath, sw.toString()); diff --git a/template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/HideNullJsonTest.java b/template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/HideNullJsonTest.java new file mode 100755 index 000000000..1fb1f676f --- /dev/null +++ b/template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/HideNullJsonTest.java @@ -0,0 +1,46 @@ +package org.onap.ccsdk.sli.plugins.template; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; + +public class HideNullJsonTest { + + @Test + public void testSampleTemplate() throws Exception { + TemplateNode t = new MockTemplateNode(); + + Map params = new HashMap(); + params.put(TemplateNode.PREFIX_KEY, "output"); + params.put(TemplateNode.OUTPUT_PATH_KEY, "mycontainer"); + params.put(TemplateNode.TEMPLATE_PATH, "src/test/resources/HideNullJson.vtl"); + + //Setup sample data to feed into the directive + params.put("service-type", "\"VPN\""); //the value is quoted to test an override + params.put("svc-request-id", "REQ001"); + params.put("svc-action", "CREATE"); + params.put("service-instance-id", "SVC001"); + params.put("customerNameTag", "customer-name"); + params.put("customer-name", "TestCust"); + params.put("siidTag", "\"service-instance-id\""); //the value is quoted to test an override + + SvcLogicContext ctx = new SvcLogicContext(); + t.evaluateTemplate(params, ctx); + String result = ctx.getAttribute("output.mycontainer"); + assertTrue(result.contains("\"svc-request-id\":\"REQ001\",")); + assertTrue(result.contains("\"svc-action\":\"CREATE\"")); + assertFalse(result.contains("\"svc-action\":\"CREATE\",")); // there should be no trailing comma + assertTrue(result.contains("\"service-type\":\"VPN\",")); + assertTrue(result.contains("\"customer-name\":\"TestCust\",")); + assertTrue(result.contains("\"service-instance-id\":\"SVC001\"")); + assertFalse(result.contains("\"service-instance-id\":\"SVC001\",")); // there should be no trailing comma + //This should be hidden by the directive because the parameter was never populated + assertFalse(result.contains("customer-phone-number")); + } + +} \ No newline at end of file diff --git a/template-node/provider/src/test/resources/HideNullJson.vtl b/template-node/provider/src/test/resources/HideNullJson.vtl new file mode 100755 index 000000000..306679457 --- /dev/null +++ b/template-node/provider/src/test/resources/HideNullJson.vtl @@ -0,0 +1,22 @@ +## This is an example comment +## This velocity template is used to test the hideNullJson directive +{ + "input": { + "request-header": { +## by default the values parameters provided are surrounded in double quotes and separated by a colon + #hideNullJson("svc-request-id",$svc-request-id)#end +## override default settings so the comma isn't written + #hideNullJson("svc-action",$svc-action, true, true, false)#end + }, + "service-information": { +## if we look at the values in parameters we see service-type is already surrounded by quotes +## we override the default so the string isn't surrounded by excess quotes + #hideNullJson("service-type",$service-type,true,false,true)#end +## the first parameter doesn't need to be a literal + #hideNullJson($customerNameTag,$customer-name)#end +## if the first parameter already has already been quoted we can override the default + #hideNullJson($siidTag,$service-instance-id,false,true,false)#end + #hideNullJson("customer-phone-number",$customer-phone-number)#end + } + } +} \ No newline at end of file -- cgit From 970e528c4996b4994d3e40d1c3a2296af4760563 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Tue, 1 Jan 2019 12:44:46 +0530 Subject: Sonar fix: LeafNode.java Fixed sonar issues/code-smells across this file Issue-ID: CCSDK-886 Change-Id: I7a5b73549b98571e207e0ed70e49873785478e70 Signed-off-by: Arundathi Patil --- .../ccsdk/sli/plugins/yangserializers/pnserializer/LeafNode.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafNode.java index c9cf95ba3..041175ca7 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafNode.java @@ -3,6 +3,8 @@ * ONAP - CCSDK * ================================================================================ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * + * Modifications Copyright © 2018 IBM * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +31,7 @@ public class LeafNode extends PropertiesNode implements LeafListHolderChild, Dat private String value; private Namespace valueNs; + private static final String svcLogicException = "Leaf cannot hold child nodes"; /** * Creates an instance of leaf node. @@ -89,7 +92,7 @@ public class LeafNode extends PropertiesNode implements LeafListHolderChild, Dat public PropertiesNode addChild(String name, Namespace namespace, NodeType type, Object appInfo) throws SvcLogicException { - throw new SvcLogicException("Leaf cannot hold child nodes"); + throw new SvcLogicException(svcLogicException); } @Override @@ -97,7 +100,7 @@ public class LeafNode extends PropertiesNode implements LeafListHolderChild, Dat NodeType type, String value, Namespace valueNs, Object appInfo) throws SvcLogicException { - throw new SvcLogicException("Leaf cannot hold child nodes"); + throw new SvcLogicException(svcLogicException); } @Override @@ -105,7 +108,7 @@ public class LeafNode extends PropertiesNode implements LeafListHolderChild, Dat Namespace namespace, NodeType type, Object appInfo) throws SvcLogicException { - throw new SvcLogicException("Leaf cannot hold child nodes"); + throw new SvcLogicException(svcLogicException); } @Override -- cgit From 0aa220d048e03fea673d17e15423ffac60078b38 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Fri, 4 Jan 2019 15:03:29 +0000 Subject: TemplateNode update push parameter values into velocity context to simplify how parameters are used in templates Change-Id: Ic8b4c56ef303ed9447bb1a62300c04c4accb2d6a Issue-ID: CCSDK-911 Signed-off-by: Smokowski, Kevin (ks6305) --- .../java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java b/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java index 0b5850a0a..7310b3fbf 100644 --- a/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java +++ b/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java @@ -25,6 +25,7 @@ package org.onap.ccsdk.sli.plugins.template; import java.io.FileInputStream; import java.io.StringWriter; import java.util.Map; +import java.util.Map.Entry; import java.util.Properties; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; @@ -97,6 +98,10 @@ public class TemplateNode implements SvcLogicJavaPlugin { VelocityContext context = new VelocityContext(); context.put("ctx", ctx); context.put("params", params); + //Adding these values directly to context makes working with the values cleaner + for (Entry entry : params.entrySet()) { + context.put(entry.getKey(), entry.getValue()); + } StringWriter sw = new StringWriter(); template.merge(context, sw); ctx.setAttribute(outputPath, sw.toString()); @@ -106,4 +111,4 @@ public class TemplateNode implements SvcLogicJavaPlugin { } } -} \ No newline at end of file +} -- cgit From aab34607358d2a9f8f6dd1879dc3c5bc26e796b0 Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Tue, 1 Jan 2019 12:39:07 +0530 Subject: Sonar fix: LeafListHolderNode.java Fixed sonar isues/code-smells across this file Issue-ID: CCSDK-885 Change-Id: I6c49463b3d0fa387caecc8023e2fdcac5a2c98c2 Signed-off-by: Arundathi Patil --- .../yangserializers/pnserializer/LeafListHolderNode.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java index 985bc1da1..46ab5bb63 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/LeafListHolderNode.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ + * Modifications Copyright © 2018 IBM + * ================================================================================ * 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 @@ -28,6 +30,8 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicException; */ public class LeafListHolderNode extends HolderNode implements DataNodeChild { + private static final String node = " holder node"; + /** * Creates an instance of LeafListHolderNode. * @@ -50,7 +54,7 @@ public class LeafListHolderNode extends HolderNode implemen Namespace valueNs, Object appInfo) throws SvcLogicException { throw new SvcLogicException("Leaf cannot be child of leaf-list" + - " holder node"); + node); } @Override @@ -58,7 +62,7 @@ public class LeafListHolderNode extends HolderNode implemen NodeType type, Object appInfo) throws SvcLogicException { throw new SvcLogicException("Container cannot be child of leaf-list" + - " holder node"); + node); } @Override @@ -67,7 +71,7 @@ public class LeafListHolderNode extends HolderNode implemen NodeType type, Object appInfo) throws SvcLogicException { throw new SvcLogicException("List cannot be child of leaf-list" + - " holder node"); + node); } @Override -- cgit From 07b48a05b99aa8f8d26f6009b55c4f041fbaeec4 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Wed, 9 Jan 2019 16:42:33 -0500 Subject: Template-Node Intall Adding TemplateNode in sli plugin features, as it's not getting installed as a default feature install Change-Id: I4804a40c8078df9f183b7752f5306643dfe0e588 Issue-ID: CCSDK-924 Signed-off-by: Singal, Kapil (ks220y) --- features/ccsdk-sli-plugins-all/pom.xml | 7 + template-node/features/ccsdk-template-node/pom.xml | 5 +- .../features/features-template-node/pom.xml | 8 +- template-node/features/pom.xml | 34 +-- template-node/installer/pom.xml | 258 +++++++++++---------- .../src/assembly/assemble_installer_zip.xml | 57 +++-- .../src/assembly/assemble_mvnrepo_zip.xml | 37 ++- .../src/main/resources/scripts/install-feature.sh | 2 +- template-node/pom.xml | 37 +-- template-node/provider/pom.xml | 5 +- .../resources/OSGI-INF/blueprint/blueprint.xml | 6 +- 11 files changed, 241 insertions(+), 215 deletions(-) diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index 4d846bd1a..37692c0de 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -53,6 +53,13 @@ xml features + + ${project.groupId} + ccsdk-template-node + ${project.version} + xml + features + ${project.groupId} ccsdk-sshapi-call-node diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index f544fb5a1..30d8383af 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -1,5 +1,7 @@ - + 4.0.0 @@ -14,6 +16,7 @@ 0.4.0-SNAPSHOT feature + ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml index 7a61f8caa..058db5ca8 100644 --- a/template-node/features/features-template-node/pom.xml +++ b/template-node/features/features-template-node/pom.xml @@ -1,12 +1,14 @@ - + 4.0.0 org.onap.ccsdk.parent feature-repo-parent 1.2.0-SNAPSHOT - + org.onap.ccsdk.sli.plugins @@ -14,6 +16,8 @@ 0.4.0-SNAPSHOT feature + ccsdk-sli-plugins :: template-node :: ${project.artifactId} + ${project.groupId} diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml index 3b9688ed2..4056ab4e7 100644 --- a/template-node/features/pom.xml +++ b/template-node/features/pom.xml @@ -1,20 +1,24 @@ - - 4.0.0 + + 4.0.0 - - org.onap.ccsdk.parent - odlparent-lite - 1.2.0-SNAPSHOT - + + org.onap.ccsdk.parent + odlparent-lite + 1.2.0-SNAPSHOT + - org.onap.ccsdk.sli.plugins - template-node-features - 0.4.0-SNAPSHOT - pom + org.onap.ccsdk.sli.plugins + template-node-features + 0.4.0-SNAPSHOT + pom - - ccsdk-template-node - features-template-node - + ccsdk-sli-plugins :: template-node :: ${project.artifactId} + + + ccsdk-template-node + features-template-node + diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index fb1cd1f2f..a298828b1 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -1,136 +1,140 @@ - - 4.0.0 + + 4.0.0 - - org.onap.ccsdk.parent - odlparent-lite - 1.2.0-SNAPSHOT - + + org.onap.ccsdk.parent + odlparent-lite + 1.2.0-SNAPSHOT + - org.onap.ccsdk.sli.plugins - template-node-installer - 0.4.0-SNAPSHOT - pom + org.onap.ccsdk.sli.plugins + template-node-installer + 0.4.0-SNAPSHOT + pom - - ccsdk-template-node - ${application.name} - mvn:org.onap.ccsdk.sli.plugins/${features.boot}/${project.version}/xml/features - false - + ccsdk-sli-plugins :: template-node :: ${project.artifactId} - - - org.onap.ccsdk.sli.plugins - ${application.name} - ${project.version} - xml - features - - - * - * - - - - - org.onap.ccsdk.sli.plugins - template-node-provider - ${project.version} - - + + ccsdk-template-node + ${application.name} + mvn:org.onap.ccsdk.sli.plugins/${features.boot}/${project.version}/xml/features + false + - - - - maven-assembly-plugin - 2.6 - - - maven-repo-zip - - single - - package - - false - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - false - - - - installer-zip - - single - - package - - true - ${application.name}-${project.version}-installer - - src/assembly/assemble_installer_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - false - ${project.build.directory}/assembly/system - false - true - true - true - false - false - org.onap.ccsdk.sli.plugins,org.apache.velocity - provided - - - - - - maven-resources-plugin - 2.6 - - - copy-version - - copy-resources - - validate - - ${basedir}/target/stage - - - src/main/resources/scripts - - install-feature.sh - - true - - - - + + + org.onap.ccsdk.sli.plugins + ${application.name} + ${project.version} + xml + features + + + * + * + + + + + org.onap.ccsdk.sli.plugins + template-node-provider + ${project.version} + + - - + + + + maven-assembly-plugin + 2.6 + + + maven-repo-zip + + single + + package + + true + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + true + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli.plugins,org.apache.velocity + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + - - + + + + + diff --git a/template-node/installer/src/assembly/assemble_installer_zip.xml b/template-node/installer/src/assembly/assemble_installer_zip.xml index b6fd65582..d7a0a630d 100644 --- a/template-node/installer/src/assembly/assemble_installer_zip.xml +++ b/template-node/installer/src/assembly/assemble_installer_zip.xml @@ -22,37 +22,36 @@ - installer_zip - - zip - + xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> + installer_zip + + zip + - - false + + false - - - target/stage/ - ${application.name} - 755 - - *.sh - - - - target/stage/ - ${application.name} - 644 - - *.sh - - - + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + diff --git a/template-node/installer/src/assembly/assemble_mvnrepo_zip.xml b/template-node/installer/src/assembly/assemble_mvnrepo_zip.xml index 2ee224477..7500304e8 100644 --- a/template-node/installer/src/assembly/assemble_mvnrepo_zip.xml +++ b/template-node/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -22,27 +22,26 @@ - mvnrepo_zip - - zip - + xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> + repo + + zip + - - false + + false - - - target/assembly/ - . - - - - + + + target/assembly/ + . + + + + diff --git a/template-node/installer/src/main/resources/scripts/install-feature.sh b/template-node/installer/src/main/resources/scripts/install-feature.sh index 0eab001d5..98276a7e0 100644 --- a/template-node/installer/src/main/resources/scripts/install-feature.sh +++ b/template-node/installer/src/main/resources/scripts/install-feature.sh @@ -29,7 +29,7 @@ REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip if [ -f ${REPOZIP} ] then - unzip -d ${ODL_HOME} ${REPOZIP} + unzip -nd ${ODL_HOME} ${REPOZIP} else echo "ERROR : repo zip ($REPOZIP) not found" exit 1 diff --git a/template-node/pom.xml b/template-node/pom.xml index 8cfea743b..0c9187807 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -1,21 +1,26 @@ - - 4.0.0 + + 4.0.0 - - org.onap.ccsdk.parent - odlparent-lite - 1.2.0-SNAPSHOT - + + org.onap.ccsdk.parent + odlparent-lite + 1.2.0-SNAPSHOT + - org.onap.ccsdk.sli.plugins - template-node - 0.4.0-SNAPSHOT - pom + org.onap.ccsdk.sli.plugins + template-node + 0.4.0-SNAPSHOT + pom - - provider - features - installer - + ccsdk-sli-plugins :: template-node + This is an implementation of DG Execute Node that resolves a Velocity Template + + + provider + features + installer + diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index d7d8d8f8b..bf90d352d 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -13,6 +13,8 @@ 0.4.0-SNAPSHOT bundle + ccsdk-sli-plugins :: template-node :: ${project.artifactId} + junit @@ -22,17 +24,14 @@ org.onap.ccsdk.sli.core sli-common - provided org.onap.ccsdk.sli.core sli-provider - provided org.slf4j slf4j-api - provided org.apache.velocity diff --git a/template-node/provider/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/template-node/provider/src/main/resources/OSGI-INF/blueprint/blueprint.xml index a8006b9b0..60409c504 100644 --- a/template-node/provider/src/main/resources/OSGI-INF/blueprint/blueprint.xml +++ b/template-node/provider/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -1,8 +1,10 @@ - + - + \ No newline at end of file -- cgit From 1e3fada75a8990292c71878c13d9f8dd5a7c60f8 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 8 Jan 2019 12:39:26 -0500 Subject: Prepare for release build Prepare for release of early ODL-Oxygen based CCSDK Dublin Change-Id: I2ea09c398025c9578a2da8ff32360be9672292c7 Issue-ID: CCSDK-870 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 204 +++++++++-------- features/features-sli-plugins/pom.xml | 6 +- features/installer/pom.xml | 245 ++++++++++---------- features/pom.xml | 2 +- pom.xml | 2 +- .../features/ccsdk-properties-node/pom.xml | 19 +- .../features/features-properties-node/pom.xml | 46 ++-- properties-node/features/pom.xml | 44 ++-- properties-node/installer/pom.xml | 2 +- properties-node/pom.xml | 50 ++-- properties-node/provider/pom.xml | 103 ++++----- .../features/ccsdk-restapi-call-node/pom.xml | 112 ++++----- .../features/features-restapi-call-node/pom.xml | 46 ++-- restapi-call-node/features/pom.xml | 2 +- restapi-call-node/installer/pom.xml | 252 ++++++++++----------- restapi-call-node/pom.xml | 2 +- restapi-call-node/provider/pom.xml | 6 +- .../features/ccsdk-restconf-client/pom.xml | 117 +++++----- .../features/features-restconf-client/pom.xml | 46 ++-- restconf-client/features/pom.xml | 2 +- restconf-client/installer/pom.xml | 5 +- restconf-client/pom.xml | 2 +- restconf-client/provider/pom.xml | 6 +- .../features/ccsdk-sshapi-call-node/pom.xml | 12 +- .../features/features-sshapi-call-node/pom.xml | 10 +- sshapi-call-node/features/pom.xml | 6 +- sshapi-call-node/installer/pom.xml | 2 +- sshapi-call-node/pom.xml | 2 +- sshapi-call-node/provider/pom.xml | 3 +- version.properties | 2 +- 30 files changed, 692 insertions(+), 666 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index b8c11c897..8679f7fb0 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -1,106 +1,110 @@ - 4.0.0 + 4.0.0 - org.onap.ccsdk.sli.plugins - sli-plugins-artifacts - 0.4.0-SNAPSHOT - pom + org.onap.ccsdk.sli.plugins + sli-plugins-artifacts + 0.4.0-SNAPSHOT + pom - ccsdk-sli-plugins :: sli-plugins-artifacts - CCSDK plugins components Bill of Materials (BOM) - https://wiki.onap.org - - ONAP - - - - org.onap.ccsdk.parent - parent - 1.2.0-SNAPSHOT - - - - - - org.onap.ccsdk.sli.plugins - ccsdk-properties-node - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.plugins - ccsdk-restapi-call-node - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.plugins - ccsdk-restconf-client - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.plugins - ccsdk-template-node - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.plugins - fabric-discovery-plugin-provider - ${project.version} - - - org.onap.ccsdk.sli.plugins - fabric-discovery-plugin-installer - ${project.version} - - - org.onap.ccsdk.sli.plugins - properties-node-provider - ${project.version} - - - org.onap.ccsdk.sli.plugins - properties-node-installer - ${project.version} - - - org.onap.ccsdk.sli.plugins - restapi-call-node-provider - ${project.version} - - - org.onap.ccsdk.sli.plugins - restapi-call-node-installer - ${project.version} - - - org.onap.ccsdk.sli.plugins - restconf-client-provider - ${project.version} - - - org.onap.ccsdk.sli.plugins - restconf-client-installer - ${project.version} - - - org.onap.ccsdk.sli.plugins - template-node-provider - ${project.version} - - - org.onap.ccsdk.sli.plugins - template-node-installer - ${project.version} - - - + ccsdk-sli-plugins :: sli-plugins-artifacts + CCSDK plugins components Bill of Materials (BOM) + https://wiki.onap.org + + ONAP + + + + org.onap.ccsdk.parent + parent + 1.2.0 + + + + ${project.version} + + + + + + org.onap.ccsdk.sli.plugins + ccsdk-properties-node + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.plugins + ccsdk-restapi-call-node + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.plugins + ccsdk-restconf-client + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.plugins + ccsdk-template-node + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.plugins + fabric-discovery-plugin-provider + ${project.version} + + + org.onap.ccsdk.sli.plugins + fabric-discovery-plugin-installer + ${project.version} + + + org.onap.ccsdk.sli.plugins + properties-node-provider + ${project.version} + + + org.onap.ccsdk.sli.plugins + properties-node-installer + ${project.version} + + + org.onap.ccsdk.sli.plugins + restapi-call-node-provider + ${project.version} + + + org.onap.ccsdk.sli.plugins + restapi-call-node-installer + ${project.version} + + + org.onap.ccsdk.sli.plugins + restconf-client-provider + ${project.version} + + + org.onap.ccsdk.sli.plugins + restconf-client-installer + ${project.version} + + + org.onap.ccsdk.sli.plugins + template-node-provider + ${project.version} + + + org.onap.ccsdk.sli.plugins + template-node-installer + ${project.version} + + + diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index 56d724285..ac28d7878 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.0-SNAPSHOT + 1.2.0 @@ -16,6 +16,10 @@ ccsdk-sli-plugins :: features :: ${project.artifactId} + + ${project.version} + + ${project.groupId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index ac8f620ba..222d203d6 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -1,137 +1,136 @@ - - 4.0.0 + + 4.0.0 - - org.onap.ccsdk.parent - odlparent-lite - 1.2.0-SNAPSHOT - - + + org.onap.ccsdk.parent + odlparent-lite + 1.2.0 + + - org.onap.ccsdk.sli.plugins - sliplugins-features-installer - 0.4.0-SNAPSHOT - pom + org.onap.ccsdk.sli.plugins + sliplugins-features-installer + 0.4.0-SNAPSHOT + pom - ccsdk-sli-plugins :: features :: ${project.artifactId} + ccsdk-sli-plugins :: features :: ${project.artifactId} - - ccsdk-sli-plugins-all - ${application.name} - mvn:org.onap.ccsdk.sli.plugins/${features.boot}/${project.version}/xml/features - false - + + ccsdk-sli-plugins-all + ${application.name} + mvn:org.onap.ccsdk.sli.plugins/${features.boot}/${project.version}/xml/features + false + - + - - org.onap.ccsdk.sli.plugins - ${application.name} - ${project.version} - xml - features - - - * - * - - - + + org.onap.ccsdk.sli.plugins + ${application.name} + ${project.version} + xml + features + + + * + * + + + - + - - - - maven-assembly-plugin - - - maven-repo-zip - - single - - package - - true - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - true - - - - installer-zip - - single - - package - - true - ${application.name}-${project.version}-installer - - src/assembly/assemble_installer_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - false - ${project.build.directory}/assembly/system - false - true - true - true - false - false + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + true + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + true + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false org.onap.ccsdk.sli.plugins - provided - - - - - - maven-resources-plugin - 2.6 - - - copy-version - - copy-resources - - validate - - ${basedir}/target/stage - - - src/main/resources/scripts - - install-feature.sh - - true - - - - + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + - - + + - - + + diff --git a/features/pom.xml b/features/pom.xml index 18dbfbfc1..d2e0828e2 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 diff --git a/pom.xml b/pom.xml index 1eb8b8bbf..dbc4c0e36 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 org.onap.ccsdk.sli.plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index 84709fa4e..9e7988e39 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,8 +5,8 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.0-SNAPSHOT - + 1.2.0 + org.onap.ccsdk.sli.plugins @@ -18,10 +18,13 @@ + + ${project.version} + - - - + + + org.opendaylight.mdsal.model mdsal-model-artifacts ${odl.mdsal.model.version} @@ -35,9 +38,9 @@ pom import - - - + + + diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index 13d056f10..61365c4fe 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -1,29 +1,33 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - feature-repo-parent - 1.2.0-SNAPSHOT - - + + org.onap.ccsdk.parent + feature-repo-parent + 1.2.0 + + - org.onap.ccsdk.sli.plugins - features-properties-node - 0.4.0-SNAPSHOT - feature + org.onap.ccsdk.sli.plugins + features-properties-node + 0.4.0-SNAPSHOT + feature - ccsdk-sli-plugins :: properties-node :: ${project.artifactId} + ccsdk-sli-plugins :: properties-node :: ${project.artifactId} - - - ${project.groupId} - ccsdk-properties-node - ${project.version} - xml - features - + + ${project.version} + - + + + ${project.groupId} + ccsdk-properties-node + ${project.version} + xml + features + + + diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index c510a3ac3..339e9f7c0 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -1,22 +1,22 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.2.0-SNAPSHOT - - - org.onap.ccsdk.sli.plugins - properties-node-features - 0.4.0-SNAPSHOT - pom - - ccsdk-sli-plugins :: properties-node :: ${project.artifactId} - - - ccsdk-properties-node - features-properties-node - - + + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.2.0 + + + org.onap.ccsdk.sli.plugins + properties-node-features + 0.4.0-SNAPSHOT + pom + + ccsdk-sli-plugins :: properties-node :: ${project.artifactId} + + + ccsdk-properties-node + features-properties-node + + diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index c86901ee4..5c95c0233 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 org.onap.ccsdk.sli.plugins diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 0c167730f..ac1b28816 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -1,25 +1,25 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.2.0-SNAPSHOT - - - org.onap.ccsdk.sli.plugins - properties-node - 0.4.0-SNAPSHOT - pom - - ccsdk-sli-plugins :: properties-node - This is an implementation of DG Execute Node that reads property file and - puts the properties in the DG context - - - provider - features - installer - - + + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.2.0 + + + org.onap.ccsdk.sli.plugins + properties-node + 0.4.0-SNAPSHOT + pom + + ccsdk-sli-plugins :: properties-node + This is an implementation of DG Execute Node that reads property file and + puts the properties in the DG context + + + provider + features + installer + + diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index da1ff21ea..668e1168a 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -1,51 +1,52 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 1.2.0-SNAPSHOT - - - org.onap.ccsdk.sli.plugins - properties-node-provider - 0.4.0-SNAPSHOT - bundle - - ccsdk-sli-plugins :: properties-node :: ${project.artifactId} - http://maven.apache.org - - - UTF-8 - - - - - junit - junit - test - - - org.springframework - spring-test - test - - - org.onap.ccsdk.sli.core - sli-common - - - org.onap.ccsdk.sli.core - sli-provider - - - org.slf4j - slf4j-api - - - org.codehaus.jettison - jettison - - - + + + 4.0.0 + + + org.onap.ccsdk.parent + binding-parent + 1.2.0 + + + org.onap.ccsdk.sli.plugins + properties-node-provider + 0.4.0-SNAPSHOT + bundle + + ccsdk-sli-plugins :: properties-node :: ${project.artifactId} + http://maven.apache.org + + + UTF-8 + ${project.version} + + + + + junit + junit + test + + + org.springframework + spring-test + test + + + org.onap.ccsdk.sli.core + sli-common + + + org.onap.ccsdk.sli.core + sli-provider + + + org.slf4j + slf4j-api + + + org.codehaus.jettison + jettison + + + diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 80dcc0ac0..6a07d2d99 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -1,57 +1,59 @@ - - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.2.0-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - ccsdk-restapi-call-node - 0.4.0-SNAPSHOT - feature - - ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} - - - - - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - ${odl.mdsal.model.version} - pom - import - - - org.opendaylight.controller - mdsal-artifacts - ${odl.mdsal.version} - pom - import - - - - - - - - org.onap.ccsdk.sli.core - ccsdk-sli - ${ccsdk.sli.core.version} - xml - features - - - ${project.groupId} - restapi-call-node-provider - ${project.version} - - + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.2.0 + + + + org.onap.ccsdk.sli.plugins + ccsdk-restapi-call-node + 0.4.0-SNAPSHOT + feature + + ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} + + + + ${project.version} + + + + + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + ${odl.mdsal.model.version} + pom + import + + + org.opendaylight.controller + mdsal-artifacts + ${odl.mdsal.version} + pom + import + + + + + + + + org.onap.ccsdk.sli.core + ccsdk-sli + ${ccsdk.sli.core.version} + xml + features + + + ${project.groupId} + restapi-call-node-provider + ${project.version} + + diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index d6b4a2635..3ca5fa2f3 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -1,29 +1,33 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - feature-repo-parent - 1.2.0-SNAPSHOT - - + + org.onap.ccsdk.parent + feature-repo-parent + 1.2.0 + + - org.onap.ccsdk.sli.plugins - features-restapi-call-node - 0.4.0-SNAPSHOT - feature + org.onap.ccsdk.sli.plugins + features-restapi-call-node + 0.4.0-SNAPSHOT + feature - ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} + ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} - - - ${project.groupId} - ccsdk-restapi-call-node - ${project.version} - xml - features - + + ${project.version} + - + + + ${project.groupId} + ccsdk-restapi-call-node + ${project.version} + xml + features + + + diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index 36f9d28fe..b8351b34b 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 9bbcf2a08..399bcf3f2 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -1,48 +1,48 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - odlparent-lite - 1.2.0-SNAPSHOT - + + org.onap.ccsdk.parent + odlparent-lite + 1.2.0 + - org.onap.ccsdk.sli.plugins - restapi-call-node-installer - 0.4.0-SNAPSHOT - pom + org.onap.ccsdk.sli.plugins + restapi-call-node-installer + 0.4.0-SNAPSHOT + pom - ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} + ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} - - ccsdk-restapi-call-node - ${application.name} + + ccsdk-restapi-call-node + ${application.name} mvn:org.onap.ccsdk.sli.plugins/${features.boot}/${project.version}/xml/features - false - + false + - + - - org.onap.ccsdk.sli.plugins - ${application.name} - ${project.version} - xml - features - - - * - * - - - + + org.onap.ccsdk.sli.plugins + ${application.name} + ${project.version} + xml + features + + + * + * + + + - - org.onap.ccsdk.sli.plugins - restapi-call-node-provider - ${project.version} - + + org.onap.ccsdk.sli.plugins + restapi-call-node-provider + ${project.version} + org.springframework spring-beans @@ -51,98 +51,98 @@ org.springframework spring-context - + - - - - maven-assembly-plugin - 2.6 - - - maven-repo-zip - - single - - package - - true - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - true - - - - installer-zip - - single - - package - - true - ${application.name}-${project.version}-installer - - src/assembly/assemble_installer_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - false - ${project.build.directory}/assembly/system - false - true - true - true - false - false - org.onap.ccsdk.sli.core - provided - - - - - - maven-resources-plugin - 2.6 - - - copy-version - - copy-resources - - validate - - ${basedir}/target/stage - - - src/main/resources/scripts - - install-feature.sh - - true - - - - + + + + maven-assembly-plugin + 2.6 + + + maven-repo-zip + + single + + package + + true + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + true + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli.core + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + - - + + - - + + diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index cdfee6bf4..093497e90 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 5423292f1..74127832e 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -1,12 +1,11 @@ - + 4.0.0 org.onap.ccsdk.parent binding-parent - 1.2.0-SNAPSHOT + 1.2.0 org.onap.ccsdk.sli.plugins @@ -18,6 +17,7 @@ UTF-8 + ${project.version} diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index 82eba3bd1..97f36121e 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -1,61 +1,60 @@ - - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.2.0-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - ccsdk-restconf-client - 0.4.0-SNAPSHOT - feature - - - true - - - ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} - - - - - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - ${odl.mdsal.model.version} - pom - import - - - org.opendaylight.controller - mdsal-artifacts - ${odl.mdsal.version} - pom - import - - - - - - - - org.onap.ccsdk.sli.core - ccsdk-sli - ${ccsdk.sli.core.version} - xml - features - - - ${project.groupId} - restconf-client-provider - ${project.version} - - + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.2.0 + + + + org.onap.ccsdk.sli.plugins + ccsdk-restconf-client + 0.4.0-SNAPSHOT + feature + + + true + ${project.version} + + + ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} + + + + + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + ${odl.mdsal.model.version} + pom + import + + + org.opendaylight.controller + mdsal-artifacts + ${odl.mdsal.version} + pom + import + + + + + + + + org.onap.ccsdk.sli.core + ccsdk-sli + ${ccsdk.sli.core.version} + xml + features + + + ${project.groupId} + restconf-client-provider + ${project.version} + + diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml index 910e86574..32c7feb1b 100644 --- a/restconf-client/features/features-restconf-client/pom.xml +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -1,29 +1,33 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - feature-repo-parent - 1.2.0-SNAPSHOT - - + + org.onap.ccsdk.parent + feature-repo-parent + 1.2.0 + + - org.onap.ccsdk.sli.plugins - features-restconf-client - 0.4.0-SNAPSHOT - feature + org.onap.ccsdk.sli.plugins + features-restconf-client + 0.4.0-SNAPSHOT + feature - ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} + ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} - - - ${project.groupId} - ccsdk-restconf-client - ${project.version} - xml - features - + + ${project.version} + - + + + ${project.groupId} + ccsdk-restconf-client + ${project.version} + xml + features + + + diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml index df2abb123..e0595c1fc 100755 --- a/restconf-client/features/pom.xml +++ b/restconf-client/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index 23306c7cd..cbf003d23 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -1,12 +1,11 @@ - + 4.0.0 org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index 4a2609a9b..1097d721e 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 2618b5cca..78bbc1693 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -1,12 +1,11 @@ - + 4.0.0 org.onap.ccsdk.parent binding-parent - 1.2.0-SNAPSHOT + 1.2.0 org.onap.ccsdk.sli.plugins @@ -19,6 +18,7 @@ UTF-8 + ${project.version} diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index cb42fcf18..ead54c77f 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -1,14 +1,12 @@ - + 4.0.0 org.onap.ccsdk.parent single-feature-parent - 1.2.0-SNAPSHOT - + 1.2.0 + org.onap.ccsdk.sli.plugins @@ -20,6 +18,10 @@ + + ${project.version} + + diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml index 482c83f7b..430a305f5 100644 --- a/sshapi-call-node/features/features-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/features-sshapi-call-node/pom.xml @@ -1,13 +1,11 @@ - + 4.0.0 org.onap.ccsdk.parent feature-repo-parent - 1.2.0-SNAPSHOT + 1.2.0 @@ -18,6 +16,10 @@ ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} + + ${project.version} + + ${project.groupId} diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml index 25acf571d..aae34a5ce 100755 --- a/sshapi-call-node/features/pom.xml +++ b/sshapi-call-node/features/pom.xml @@ -1,13 +1,11 @@ - + 4.0.0 org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index 3adfb69f4..a726f6350 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index 88456c5ed..b6167c45b 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index 91ecfabca..b25b69e47 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.0-SNAPSHOT + 1.2.0 org.onap.ccsdk.sli.plugins @@ -18,6 +18,7 @@ UTF-8 + ${project.version} diff --git a/version.properties b/version.properties index c8f383798..8c1e34f3b 100644 --- a/version.properties +++ b/version.properties @@ -11,6 +11,6 @@ feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} -release_version=${base_version}-STAGING +release_version=${base_version} snapshot_version=${base_version}-SNAPSHOT -- cgit From 057bc260e7752bc11960cf9cab4005efec1739c7 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 4 Jan 2019 09:22:20 -0500 Subject: Changes for Fluorine Updates to sli/plugins to run in OpenDaylight Fluorine Change-Id: I093a663ff5459df5eacdb632ad3217c322cc9cfa Issue-ID: CCSDK-870 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 204 ++++++++--------- features/ccsdk-sli-plugins-all/pom.xml | 29 +-- features/features-sli-plugins/pom.xml | 8 +- features/installer/pom.xml | 242 ++++++++++---------- features/pom.xml | 4 +- pom.xml | 4 +- .../features/ccsdk-properties-node/pom.xml | 30 +-- .../features/features-properties-node/pom.xml | 46 ++-- properties-node/features/pom.xml | 4 +- properties-node/installer/pom.xml | 4 +- properties-node/pom.xml | 4 +- properties-node/provider/pom.xml | 17 +- .../features/ccsdk-restapi-call-node/pom.xml | 88 +++---- .../features/features-restapi-call-node/pom.xml | 46 ++-- restapi-call-node/features/pom.xml | 4 +- restapi-call-node/installer/pom.xml | 252 ++++++++++----------- restapi-call-node/pom.xml | 4 +- restapi-call-node/provider/pom.xml | 17 +- .../features/ccsdk-restconf-client/pom.xml | 95 ++++---- .../features/features-restconf-client/pom.xml | 46 ++-- restconf-client/features/pom.xml | 4 +- restconf-client/installer/pom.xml | 4 +- restconf-client/pom.xml | 4 +- restconf-client/provider/pom.xml | 27 ++- .../features/ccsdk-sshapi-call-node/pom.xml | 26 +-- .../features/features-sshapi-call-node/pom.xml | 8 +- sshapi-call-node/features/pom.xml | 4 +- sshapi-call-node/installer/pom.xml | 4 +- sshapi-call-node/pom.xml | 4 +- sshapi-call-node/provider/pom.xml | 17 +- template-node/features/ccsdk-template-node/pom.xml | 6 +- .../features/features-template-node/pom.xml | 12 +- template-node/features/pom.xml | 34 ++- template-node/installer/pom.xml | 4 +- template-node/pom.xml | 37 ++- template-node/provider/pom.xml | 16 +- version.properties | 2 +- 37 files changed, 637 insertions(+), 724 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 8679f7fb0..26dbaa59d 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -1,110 +1,106 @@ - 4.0.0 + 4.0.0 - org.onap.ccsdk.sli.plugins - sli-plugins-artifacts - 0.4.0-SNAPSHOT - pom + org.onap.ccsdk.sli.plugins + sli-plugins-artifacts + 0.4.1-SNAPSHOT + pom - ccsdk-sli-plugins :: sli-plugins-artifacts - CCSDK plugins components Bill of Materials (BOM) - https://wiki.onap.org - - ONAP - - - - org.onap.ccsdk.parent - parent - 1.2.0 - - - - ${project.version} - - - - - - org.onap.ccsdk.sli.plugins - ccsdk-properties-node - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.plugins - ccsdk-restapi-call-node - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.plugins - ccsdk-restconf-client - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.plugins - ccsdk-template-node - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.plugins - fabric-discovery-plugin-provider - ${project.version} - - - org.onap.ccsdk.sli.plugins - fabric-discovery-plugin-installer - ${project.version} - - - org.onap.ccsdk.sli.plugins - properties-node-provider - ${project.version} - - - org.onap.ccsdk.sli.plugins - properties-node-installer - ${project.version} - - - org.onap.ccsdk.sli.plugins - restapi-call-node-provider - ${project.version} - - - org.onap.ccsdk.sli.plugins - restapi-call-node-installer - ${project.version} - - - org.onap.ccsdk.sli.plugins - restconf-client-provider - ${project.version} - - - org.onap.ccsdk.sli.plugins - restconf-client-installer - ${project.version} - - - org.onap.ccsdk.sli.plugins - template-node-provider - ${project.version} - - - org.onap.ccsdk.sli.plugins - template-node-installer - ${project.version} - - - + ccsdk-sli-plugins :: sli-plugins-artifacts + CCSDK plugins components Bill of Materials (BOM) + https://wiki.onap.org + + ONAP + + + + org.onap.ccsdk.parent + parent + 1.2.1-SNAPSHOT + + + + + + org.onap.ccsdk.sli.plugins + ccsdk-properties-node + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.plugins + ccsdk-restapi-call-node + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.plugins + ccsdk-restconf-client + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.plugins + ccsdk-template-node + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.plugins + fabric-discovery-plugin-provider + ${project.version} + + + org.onap.ccsdk.sli.plugins + fabric-discovery-plugin-installer + ${project.version} + + + org.onap.ccsdk.sli.plugins + properties-node-provider + ${project.version} + + + org.onap.ccsdk.sli.plugins + properties-node-installer + ${project.version} + + + org.onap.ccsdk.sli.plugins + restapi-call-node-provider + ${project.version} + + + org.onap.ccsdk.sli.plugins + restapi-call-node-installer + ${project.version} + + + org.onap.ccsdk.sli.plugins + restconf-client-provider + ${project.version} + + + org.onap.ccsdk.sli.plugins + restconf-client-installer + ${project.version} + + + org.onap.ccsdk.sli.plugins + template-node-provider + ${project.version} + + + org.onap.ccsdk.sli.plugins + template-node-installer + ${project.version} + + + diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index 37692c0de..271cbb186 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -1,43 +1,22 @@ - + 4.0.0 org.onap.ccsdk.parent single-feature-parent - 1.2.0-SNAPSHOT - + 1.2.1-SNAPSHOT + org.onap.ccsdk.sli.plugins ccsdk-sli-plugins-all - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} - - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - ${odl.mdsal.model.version} - pom - import - - - org.opendaylight.controller - mdsal-artifacts - ${odl.mdsal.version} - pom - import - - - - ${project.groupId} diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index ac28d7878..eb84c5b93 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,21 +5,17 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.plugins features-sli-plugins - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} - - ${project.version} - - ${project.groupId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 222d203d6..ad751891f 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -1,136 +1,136 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - odlparent-lite - 1.2.0 - - + + org.onap.ccsdk.parent + odlparent-lite + 1.2.1-SNAPSHOT + + - org.onap.ccsdk.sli.plugins - sliplugins-features-installer - 0.4.0-SNAPSHOT - pom + org.onap.ccsdk.sli.plugins + sliplugins-features-installer + 0.4.1-SNAPSHOT + pom - ccsdk-sli-plugins :: features :: ${project.artifactId} + ccsdk-sli-plugins :: features :: ${project.artifactId} - - ccsdk-sli-plugins-all - ${application.name} - mvn:org.onap.ccsdk.sli.plugins/${features.boot}/${project.version}/xml/features - false - + + ccsdk-sli-plugins-all + ${application.name} + mvn:org.onap.ccsdk.sli.plugins/${features.boot}/${project.version}/xml/features + false + - + - - org.onap.ccsdk.sli.plugins - ${application.name} - ${project.version} - xml - features - - - * - * - - - + + org.onap.ccsdk.sli.plugins + ${application.name} + ${project.version} + xml + features + + + * + * + + + - + - - - - maven-assembly-plugin - - - maven-repo-zip - - single - - package - - true - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - true - - - - installer-zip - - single - - package - - true - ${application.name}-${project.version}-installer - - src/assembly/assemble_installer_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - false - ${project.build.directory}/assembly/system - false - true - true - true - false - false + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + true + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + true + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false org.onap.ccsdk.sli.plugins - provided - - - - - - maven-resources-plugin - 2.6 - - - copy-version - - copy-resources - - validate - - ${basedir}/target/stage - - - src/main/resources/scripts - - install-feature.sh - - true - - - - + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + - - + + - - + + diff --git a/features/pom.xml b/features/pom.xml index d2e0828e2..07d77718d 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.plugins sliplugins-feature-aggregator - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-plugins :: features diff --git a/pom.xml b/pom.xml index dbc4c0e36..201a59b39 100755 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index 9e7988e39..1d5feae6c 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,42 +5,18 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-properties-node - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} - - - - ${project.version} - - - - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - ${odl.mdsal.model.version} - pom - import - - - org.opendaylight.controller - mdsal-artifacts - ${odl.mdsal.version} - pom - import - - - - + diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index 61365c4fe..e00d2cfa4 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -1,33 +1,29 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - feature-repo-parent - 1.2.0 - - + + org.onap.ccsdk.parent + feature-repo-parent + 1.2.1-SNAPSHOT + + - org.onap.ccsdk.sli.plugins - features-properties-node - 0.4.0-SNAPSHOT - feature + org.onap.ccsdk.sli.plugins + features-properties-node + 0.4.1-SNAPSHOT + feature - ccsdk-sli-plugins :: properties-node :: ${project.artifactId} + ccsdk-sli-plugins :: properties-node :: ${project.artifactId} - - ${project.version} - + + + ${project.groupId} + ccsdk-properties-node + ${project.version} + xml + features + - - - ${project.groupId} - ccsdk-properties-node - ${project.version} - xml - features - - - + diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 339e9f7c0..27bea0291 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-features - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 5c95c0233..c431b521c 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-installer - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index ac1b28816..c8d9c9a3c 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-plugins :: properties-node diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 668e1168a..92cff9992 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-provider - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT bundle ccsdk-sli-plugins :: properties-node :: ${project.artifactId} @@ -18,8 +18,19 @@ UTF-8 - ${project.version} + + + + + org.onap.ccsdk.sli.core + sli-core-artifacts + ${ccsdk.sli.core.version} + pom + import + + + diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 6a07d2d99..da6b8d0d2 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -1,59 +1,35 @@ - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.2.0 - - - - org.onap.ccsdk.sli.plugins - ccsdk-restapi-call-node - 0.4.0-SNAPSHOT - feature - - ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} - - - - ${project.version} - - - - - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - ${odl.mdsal.model.version} - pom - import - - - org.opendaylight.controller - mdsal-artifacts - ${odl.mdsal.version} - pom - import - - - - - - - - org.onap.ccsdk.sli.core - ccsdk-sli - ${ccsdk.sli.core.version} - xml - features - - - ${project.groupId} - restapi-call-node-provider - ${project.version} - - + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.2.1-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + ccsdk-restapi-call-node + 0.4.1-SNAPSHOT + feature + + ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} + + + + + + org.onap.ccsdk.sli.core + ccsdk-sli + ${ccsdk.sli.core.version} + xml + features + + + ${project.groupId} + restapi-call-node-provider + ${project.version} + + diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index 3ca5fa2f3..64541a74b 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -1,33 +1,29 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - feature-repo-parent - 1.2.0 - - + + org.onap.ccsdk.parent + feature-repo-parent + 1.2.1-SNAPSHOT + + - org.onap.ccsdk.sli.plugins - features-restapi-call-node - 0.4.0-SNAPSHOT - feature + org.onap.ccsdk.sli.plugins + features-restapi-call-node + 0.4.1-SNAPSHOT + feature - ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} + ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} - - ${project.version} - + + + ${project.groupId} + ccsdk-restapi-call-node + ${project.version} + xml + features + - - - ${project.groupId} - ccsdk-restapi-call-node - ${project.version} - xml - features - - - + diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index b8351b34b..3ae7a2fc3 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-features - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 399bcf3f2..1675e4ed7 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -1,48 +1,48 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - odlparent-lite - 1.2.0 - + + org.onap.ccsdk.parent + odlparent-lite + 1.2.1-SNAPSHOT + - org.onap.ccsdk.sli.plugins - restapi-call-node-installer - 0.4.0-SNAPSHOT - pom + org.onap.ccsdk.sli.plugins + restapi-call-node-installer + 0.4.1-SNAPSHOT + pom - ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} + ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} - - ccsdk-restapi-call-node - ${application.name} + + ccsdk-restapi-call-node + ${application.name} mvn:org.onap.ccsdk.sli.plugins/${features.boot}/${project.version}/xml/features - false - + false + - + - - org.onap.ccsdk.sli.plugins - ${application.name} - ${project.version} - xml - features - - - * - * - - - + + org.onap.ccsdk.sli.plugins + ${application.name} + ${project.version} + xml + features + + + * + * + + + - - org.onap.ccsdk.sli.plugins - restapi-call-node-provider - ${project.version} - + + org.onap.ccsdk.sli.plugins + restapi-call-node-provider + ${project.version} + org.springframework spring-beans @@ -51,98 +51,98 @@ org.springframework spring-context - + - - - - maven-assembly-plugin - 2.6 - - - maven-repo-zip - - single - - package - - true - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - true - - - - installer-zip - - single - - package - - true - ${application.name}-${project.version}-installer - - src/assembly/assemble_installer_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - false - ${project.build.directory}/assembly/system - false - true - true - true - false - false - org.onap.ccsdk.sli.core - provided - - - - - - maven-resources-plugin - 2.6 - - - copy-version - - copy-resources - - validate - - ${basedir}/target/stage - - - src/main/resources/scripts - - install-feature.sh - - true - - - - + + + + maven-assembly-plugin + 2.6 + + + maven-repo-zip + + single + + package + + true + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + true + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli.core + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + - - + + - - + + diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 093497e90..de941aadc 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 74127832e..52178540c 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,21 +5,32 @@ org.onap.ccsdk.parent binding-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT bundle ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} UTF-8 - ${project.version} + + + + org.onap.ccsdk.sli.core + sli-core-artifacts + ${ccsdk.sli.core.version} + pom + import + + + + javax.ws.rs diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index 97f36121e..e439eac70 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -1,60 +1,41 @@ - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.2.0 - - - - org.onap.ccsdk.sli.plugins - ccsdk-restconf-client - 0.4.0-SNAPSHOT - feature - - - true - ${project.version} - - - ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} - - - - - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - ${odl.mdsal.model.version} - pom - import - - - org.opendaylight.controller - mdsal-artifacts - ${odl.mdsal.version} - pom - import - - - - - - - - org.onap.ccsdk.sli.core - ccsdk-sli - ${ccsdk.sli.core.version} - xml - features - - - ${project.groupId} - restconf-client-provider - ${project.version} - - + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.2.1-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + ccsdk-restconf-client + 0.4.1-SNAPSHOT + feature + + + true + + + ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} + + + + + + + + org.onap.ccsdk.sli.core + ccsdk-sli + ${ccsdk.sli.core.version} + xml + features + + + ${project.groupId} + restconf-client-provider + ${project.version} + + diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml index 32c7feb1b..e82e355d8 100644 --- a/restconf-client/features/features-restconf-client/pom.xml +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -1,33 +1,29 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - feature-repo-parent - 1.2.0 - - + + org.onap.ccsdk.parent + feature-repo-parent + 1.2.1-SNAPSHOT + + - org.onap.ccsdk.sli.plugins - features-restconf-client - 0.4.0-SNAPSHOT - feature + org.onap.ccsdk.sli.plugins + features-restconf-client + 0.4.1-SNAPSHOT + feature - ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} + ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} - - ${project.version} - + + + ${project.groupId} + ccsdk-restconf-client + ${project.version} + xml + features + - - - ${project.groupId} - ccsdk-restconf-client - ${project.version} - xml - features - - - + diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml index e0595c1fc..ae25b5d24 100755 --- a/restconf-client/features/pom.xml +++ b/restconf-client/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-features - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index cbf003d23..1bab5b3c1 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-installer - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index 1097d721e..57fc99f43 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 78bbc1693..e94671902 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-provider - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT bundle ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} @@ -18,8 +18,19 @@ UTF-8 - ${project.version} + + + + + org.onap.ccsdk.sli.core + sli-core-artifacts + ${ccsdk.sli.core.version} + pom + import + + + @@ -39,7 +50,7 @@ org.onap.ccsdk.sli.plugins properties-node-provider - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT org.opendaylight.yangtools @@ -63,18 +74,22 @@ org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT org.opendaylight.netconf restconf-nb-rfc8040 - ${odl.mdsal.version} org.opendaylight.yangtools yang-parser-impl 2.0.6.1 + + org.osgi + org.osgi.core + provided + diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index ead54c77f..3ac681f85 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -5,41 +5,19 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sshapi-call-node - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} - - ${project.version} - - - - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - ${odl.mdsal.model.version} - pom - import - - - org.opendaylight.controller - mdsal-artifacts - ${odl.mdsal.version} - pom - import - - - + + + + + installer_zip + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + diff --git a/grToolkit/installer/src/assembly/assemble_mvnrepo_zip.xml b/grToolkit/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100755 index 000000000..fe7a90ce5 --- /dev/null +++ b/grToolkit/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,45 @@ + + + + + + repo + + zip + + + + false + + + + target/assembly/ + . + + + + diff --git a/grToolkit/installer/src/main/resources/scripts/install-feature.sh b/grToolkit/installer/src/main/resources/scripts/install-feature.sh new file mode 100755 index 000000000..1d7be149e --- /dev/null +++ b/grToolkit/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +### +# ============LICENSE_START======================================================= +# openECOMP : SDN-C +# ================================================================================ +# Copyright (C) 2018 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========================================================= +### + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}-repo.zip + +if [ -f ${REPOZIP} ] +then + unzip -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} feature:install ${features.boot} diff --git a/grToolkit/model/.gitignore b/grToolkit/model/.gitignore new file mode 100755 index 000000000..eacf31a67 --- /dev/null +++ b/grToolkit/model/.gitignore @@ -0,0 +1 @@ +/target-ide/ diff --git a/grToolkit/model/pom.xml b/grToolkit/model/pom.xml new file mode 100755 index 000000000..348b34784 --- /dev/null +++ b/grToolkit/model/pom.xml @@ -0,0 +1,26 @@ + + + 4.0.0 + + org.onap.ccsdk.parent + binding-parent + 1.2.1-SNAPSHOT + + + ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} + org.onap.ccsdk.sli.plugins + gr-toolkit-model + 0.4.1-SNAPSHOT + bundle + + + + org.opendaylight.mdsal.model + ietf-inet-types-2013-07-15 + + + org.opendaylight.mdsal.model + ietf-yang-types-20130715 + + + diff --git a/grToolkit/model/scripts/python/yang2props.py b/grToolkit/model/scripts/python/yang2props.py new file mode 100755 index 000000000..85daccfbd --- /dev/null +++ b/grToolkit/model/scripts/python/yang2props.py @@ -0,0 +1,78 @@ +#!/usr/bin/python + +### +# ============LICENSE_START======================================================= +# openECOMP : SDN-C +# ================================================================================ +# Copyright (C) 2018 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========================================================= +### + +import re +import sys + + +# Convert word from foo-bar to FooBar +# words begining with a digit will be converted to _digit +def to_enum(s): + if s[0].isdigit(): + s = "_" + s + else: + s = s[0].upper() + s[1:] + return re.sub(r'(?!^)-([a-zA-Z])', lambda m: m.group(1).upper(), s) + +leaf = "" +val = "" +li = [] + +if len(sys.argv) < 3: + print 'yang2props.py ' + sys.exit(2) + +with open(sys.argv[1], "r") as ins: + for line in ins: + # if we see a leaf save the name for later + if "leaf " in line: + match = re.search(r'leaf (\S+)', line) + if match: + leaf = match.group(1) + + # if we see enum convert the value to enum format and see if it changed + # if the value is different write a property entry + if "enum " in line: + match = re.search(r'enum "(\S+)";', line) + if match: + val = match.group(1) + enum = to_enum(val) + + # see if converting to enum changed the string + if val != enum: + property = "yang."+leaf+"."+enum+"="+val + if property not in li: + li.append( property) + + +# Open output file +fo = open(sys.argv[2], "wb") +fo.write("# yang conversion properties \n") +fo.write("# used to convert Enum back to the original yang value \n") +fo.write("\n".join(li)) +fo.write("\n") + +# Close opend file +fo.close() + + diff --git a/grToolkit/model/src/main/yang/gr-toolkit.yang b/grToolkit/model/src/main/yang/gr-toolkit.yang new file mode 100755 index 000000000..951201c5e --- /dev/null +++ b/grToolkit/model/src/main/yang/gr-toolkit.yang @@ -0,0 +1,183 @@ +module gr-toolkit{ + namespace "org:onap:ccsdk:sli:plugins:gr-toolkit"; + prefix gr-toolkit; + + import ietf-inet-types { + prefix inet; + } + import ietf-yang-types { + prefix yang; + } + description + "This ODL feature is designed to gauge the health of all cluster members."; + revision "2018-09-26" { + description + "Release 19.02 draft"; + } + + grouping member { + leaf address { + type string; + mandatory true; + } + leaf role { + type string; + mandatory true; + } + leaf up { + type boolean; + mandatory true; + } + leaf unreachable { + type boolean; + mandatory true; + } + leaf voting { + type boolean; + mandatory true; + } + list leader { + leaf shard { + type string; + mandatory true; + } + } + list replicas { + leaf shard { + type string; + mandatory true; + } + } + list commit-status { + leaf shard { + type string; + mandatory true; + } + leaf delta { + type int32; + mandatory true; + } + } + } + + grouping site { + leaf id { + type string; + mandatory true; + } + leaf role { + type string; + mandatory true; + } + leaf health { + type string; + mandatory true; + } + } + + grouping node { + leaf node { + type string; + mandatory true; + } + leaf port { + type string; + mandatory true; + } + } + + rpc cluster-health { + description + "Parses akka.conf for seed nodes and queries Jolokia for the health + of each node."; + output { + leaf status { type string; } + leaf message { type string; } + leaf site1-health { type string; } + leaf site2-health { type string; } + list members { + uses member; + } + } + } + + rpc database-health { + description + "Uses DbLibService connection info to determine if the database is reachable."; + output { + leaf status { type string; } + leaf health { type string; } + } + } + + rpc admin-health { + description + "Pings the admin portal health check to determine if the admin portal is reachable."; + output { + leaf status { type string; } + leaf health { type string; } + } + } + + rpc site-health { + description + "Gathers health information on the ODL cluster, database, and admin portal + to determine if the entire site is in a healthy state."; + output { + leaf status { type string; } + list sites { + uses site; + } + } + } + + rpc site-identifier { + description + "Returns the unique site identifier."; + output { + leaf status { type string; } + leaf id { type string; mandatory true; } + } + } + + rpc halt-akka-traffic { + description + "Invokes a utility script to halt traffic to the akka port."; + input { + list node-info { + uses node; + } + } + output { + leaf status { type string; } + } + } + + rpc resume-akka-traffic { + description + "Invokes a utility script to resume traffic to the akka port."; + input { + list node-info { + uses node; + } + } + output { + leaf status { type string; } + } + } + + rpc failover { + description + "Performs a failover from primary site to standby site."; + input { + leaf backupData { + type string; + default "false"; + } + } + output { + leaf status { type string; } + leaf message { type string; } + } + } +} diff --git a/grToolkit/pom.xml b/grToolkit/pom.xml new file mode 100755 index 000000000..c36e2f161 --- /dev/null +++ b/grToolkit/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.2.1-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + gr-toolkit + 0.4.1-SNAPSHOT + pom + + ccsdk-sli-plugins :: gr-toolkit + ODL bundle used to judge health of SDN-C application. + + + model + features + installer + provider + + + + + + org.onap.ccsdk.sli.plugins + gr-toolkit-features + features + xml + ${project.version} + + + org.onap.ccsdk.sli.plugins + gr-toolkit-model + ${project.version} + + + org.onap.ccsdk.sli.plugins + gr-toolkit-provider + ${project.version} + + + + diff --git a/grToolkit/provider/.gitignore b/grToolkit/provider/.gitignore new file mode 100755 index 000000000..eacf31a67 --- /dev/null +++ b/grToolkit/provider/.gitignore @@ -0,0 +1 @@ +/target-ide/ diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml new file mode 100755 index 000000000..75b6d431b --- /dev/null +++ b/grToolkit/provider/pom.xml @@ -0,0 +1,102 @@ + + + 4.0.0 + + org.onap.ccsdk.parent + binding-parent + 1.2.1-SNAPSHOT + + + ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} + org.onap.ccsdk.sli.plugins + gr-toolkit-provider + 0.4.1-SNAPSHOT + bundle + + + + + org.apache.felix + maven-bundle-plugin + true + + + org.opendaylight.controller.config.yang.config.gr-toolkit_provider + * + + + + + + + + + org.onap.ccsdk.sli.plugins + gr-toolkit-model + ${project.version} + + + org.opendaylight.controller + sal-binding-api + + + org.onap.ccsdk.sli.core + dblib-provider + ${ccsdk.sli.core.version} + + + org.onap.ccsdk.sli.core + sli-common + ${ccsdk.sli.core.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${ccsdk.sli.core.version} + + + sal-test-model + org.opendaylight.controller + test + + + org.opendaylight.controller + sal-binding-broker-impl + test + + + org.opendaylight.controller + sal-binding-broker-impl + tests + test-jar + test + + + junit + junit + 4.11 + test + + + org.mockito + mockito-core + 1.10.19 + test + + + org.json + json + + + org.opendaylight.controller + sal-distributed-datastore + provided + + + com.typesafe.akka + akka-cluster_2.12 + ${akka.version} + provided + + + diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitProvider.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitProvider.java new file mode 100755 index 000000000..249640afa --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitProvider.java @@ -0,0 +1,937 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2018 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; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Properties; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.annotation.Nonnull; + +import com.google.common.util.concurrent.CheckedFuture; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; + +import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.onap.ccsdk.sli.plugins.data.ClusterActor; +import org.onap.ccsdk.sli.plugins.data.MemberBuilder; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.AdminHealthInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.AdminHealthOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.AdminHealthOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ClusterHealthInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ClusterHealthOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ClusterHealthOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.DatabaseHealthInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.DatabaseHealthOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.DatabaseHealthOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.GrToolkitService; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.HaltAkkaTrafficInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.HaltAkkaTrafficOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.HaltAkkaTrafficOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.Member; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ResumeAkkaTrafficInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ResumeAkkaTrafficOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ResumeAkkaTrafficOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.Site; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteHealthInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteHealthOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteHealthOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteIdentifierInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteIdentifierOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteIdentifierOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.site.health.output.SitesBuilder; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataTreeChangeListener { + private static final String PROPERTIES_FILE = System.getenv("SDNC_CONFIG_DIR") + "/gr-toolkit.properties"; + private static final String HEALTHY = "HEALTHY"; + private static final String FAULTY = "FAULTY"; + private static String AKKA_CONFIG; + private static String JOLOKIA_CLUSTER_PATH; + private static String SHARD_MANAGER_PATH; + private static String SHARD_PATH_TEMPLATE; + private static String CREDENTIALS; + private static String HTTP_PROTOCOL; + private static String SITE_IDENTIFIER = System.getenv("SITE_NAME"); + private final Logger log = LoggerFactory.getLogger(GrToolkitProvider.class); + private final String appName = "gr-toolkit"; + private final ExecutorService executor; + protected DataBroker dataBroker; + protected NotificationPublishService notificationService; + protected RpcProviderRegistry rpcRegistry; + protected BindingAwareBroker.RpcRegistration rpcRegistration; + protected DbLibService dbLib; + private String member; + private ClusterActor self; + private HashMap members; + private SiteConfiguration siteConfiguration; + private Properties properties; + private DistributedDataStoreInterface configDatastore; + public GrToolkitProvider(DataBroker dataBroker, + NotificationPublishService notificationProviderService, + RpcProviderRegistry rpcProviderRegistry, + DistributedDataStoreInterface configDatastore, + DbLibService dbLibService) { + this.log.info("Creating provider for " + appName); + this.executor = Executors.newFixedThreadPool(1); + this.dataBroker = dataBroker; + this.notificationService = notificationProviderService; + this.rpcRegistry = rpcProviderRegistry; + this.configDatastore = configDatastore; + this.dbLib = dbLibService; + initialize(); + } + + public void initialize() { + log.info("Initializing provider for " + appName); + // Create the top level containers + createContainers(); + try { + GrToolkitUtil.loadProperties(); + } catch (Exception e) { + log.error("Caught Exception while trying to load properties file.", e); + } + + setProperties(); + defineMembers(); + + rpcRegistration = rpcRegistry.addRpcImplementation(GrToolkitService.class, this); + log.info("Initialization complete for " + appName); + } + + private void setProperties() { + log.info("Loading properties from " + PROPERTIES_FILE); + properties = new Properties(); + File propertiesFile = new File(PROPERTIES_FILE); + if(!propertiesFile.exists()) { + log.warn("Properties file not found."); + return; + } + try(FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { + properties.load(fileInputStream); + if(!properties.containsKey("site.identifier")) { + properties.put("site.identifier", "Unknown Site"); + } + String port = "true".equals(properties.getProperty("controller.useSsl").trim()) ? properties.getProperty("controller.port.ssl").trim() : properties.getProperty("controller.port.http").trim(); + HTTP_PROTOCOL = "true".equals(properties.getProperty("controller.useSsl").trim()) ? "https://" : "http://"; + AKKA_CONFIG = properties.getProperty("akka.conf.location").trim(); + JOLOKIA_CLUSTER_PATH = ":" + port + properties.getProperty("mbean.cluster").trim(); + SHARD_MANAGER_PATH = ":" + port + properties.getProperty("mbean.shardManager").trim(); + SHARD_PATH_TEMPLATE = ":" + port + properties.getProperty("mbean.shard.config").trim(); + if(SITE_IDENTIFIER == null || SITE_IDENTIFIER.isEmpty()) { + SITE_IDENTIFIER = properties.getProperty("site.identifier").trim(); + } + CREDENTIALS = properties.getProperty("controller.credentials").trim(); + log.info("Loaded properties."); + } catch(IOException e) { + log.error("Error loading properties.", e); + } + } + + private void defineMembers() { + member = configDatastore.getActorContext().getCurrentMemberName().getName(); + log.info("Cluster member: " + member); + + log.info("Parsing akka.conf for cluster members..."); + try { + File akkaConfig = new File(AKKA_CONFIG); + FileReader fileReader = new FileReader(akkaConfig); + BufferedReader bufferedReader = new BufferedReader(fileReader); + String line; + while((line = bufferedReader.readLine()) != null) { + if(line.contains("seed-nodes =")) { + parseSeedNodes(line); + break; + } + } + bufferedReader.close(); + fileReader.close(); + } catch(IOException e) { + log.error("Couldn't load akka", e); + } + log.info("self:\n{}", self.toString()); + } + + private void createContainers() { + final WriteTransaction t = dataBroker.newReadWriteTransaction(); + try { + CheckedFuturecheckedFuture = t.submit(); + checkedFuture.get(); + log.info("Create Containers succeeded!"); + } catch (InterruptedException | ExecutionException e) { + log.error("Create Containers Failed: " + e); + log.error("context", e); + } + } + + protected void initializeChild() { + // Override if you have custom initialization intelligence + } + + @Override + public void close() throws Exception { + log.info("Closing provider for " + appName); + executor.shutdown(); + rpcRegistration.close(); + log.info("Successfully closed provider for " + appName); + } + + @Override + public void onDataTreeChanged(@Nonnull Collection changes) { + log.info("onDataTreeChanged() called. but there is no change here"); + } + + @Override + public ListenableFuture> clusterHealth(ClusterHealthInput input) { + log.info(appName + ":cluster-health invoked."); + getControllerHealth(); + return buildClusterHealthOutput("200"); + } + + @Override + public ListenableFuture> siteHealth(SiteHealthInput input) { + log.info(appName + ":site-health invoked."); + getControllerHealth(); + return buildSiteHealthOutput("200", getAdminHealth(), getDatabaseHealth()); + } + + @Override + public ListenableFuture> databaseHealth(DatabaseHealthInput input) { + log.info(appName + ":database-health invoked."); + DatabaseHealthOutputBuilder outputBuilder = new DatabaseHealthOutputBuilder(); + outputBuilder.setStatus("200"); + outputBuilder.setHealth(getDatabaseHealth()); + + return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); + } + + @Override + public ListenableFuture> adminHealth(AdminHealthInput input) { + log.info(appName + ":admin-health invoked."); + AdminHealthOutputBuilder outputBuilder = new AdminHealthOutputBuilder(); + outputBuilder.setStatus("200"); + outputBuilder.setHealth(getAdminHealth()); + + return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); + } + + @Override + public ListenableFuture> haltAkkaTraffic(HaltAkkaTrafficInput input) { + log.info(appName + ":halt-akka-traffic invoked."); + HaltAkkaTrafficOutputBuilder outputBuilder = new HaltAkkaTrafficOutputBuilder(); + outputBuilder.setStatus("200"); + modifyIpTables(IpTables.Add, input.getNodeInfo().toArray()); + + return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); + } + + @Override + public ListenableFuture> resumeAkkaTraffic(ResumeAkkaTrafficInput input) { + log.info(appName + ":resume-akka-traffic invoked."); + ResumeAkkaTrafficOutputBuilder outputBuilder = new ResumeAkkaTrafficOutputBuilder(); + outputBuilder.setStatus("200"); + modifyIpTables(IpTables.Delete, input.getNodeInfo().toArray()); + + return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); + } + + @Override + public ListenableFuture> siteIdentifier(SiteIdentifierInput input) { + log.info(appName + ":site-identifier invoked."); + SiteIdentifierOutputBuilder outputBuilder = new SiteIdentifierOutputBuilder(); + outputBuilder.setStatus("200"); + outputBuilder.setId(SITE_IDENTIFIER); + + return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); + } + + @Override + public ListenableFuture> failover(FailoverInput input) { + log.info(appName + ":failover invoked."); + FailoverOutputBuilder outputBuilder = new FailoverOutputBuilder(); + if(siteConfiguration != SiteConfiguration.Geo) { + log.info("Cannot failover non-Geo site."); + outputBuilder.setMessage("Failover aborted. This is not a Geo configuration."); + outputBuilder.setStatus("400"); + return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); + } + ArrayList activeSite = new ArrayList<>(); + ArrayList standbySite = new ArrayList<>(); + + log.info("Performing preliminary cluster health check..."); + // Necessary to populate all member info. Health is not used for judgement calls. + getControllerHealth(); + + log.info("Determining active site..."); + for(String key : members.keySet()) { + if(members.get(key).isVoting()) { + activeSite.add(members.get(key)); + log.debug("Active Site member: " + key); + } + else { + standbySite.add(members.get(key)); + log.debug("Standby Site member: " + key); + } + } + + String port = "true".equals(properties.getProperty("controller.useSsl")) ? properties.getProperty("controller.port.ssl") : properties.getProperty("controller.port.http"); + + if(Boolean.parseBoolean(input.getBackupData())) { + log.info("Backing up data..."); + for(ClusterActor actor : activeSite) { + try { + // Schedule backup + log.info("Scheduling backup for: " + actor.getNode()); + getRequestContent(HTTP_PROTOCOL + actor.getNode() + ":" + port + "/restconf/operations/data-export-import:schedule-export", HttpMethod.Post, ""); + try { + // Move data offsite + log.info("Backing up data for: " + actor.getNode()); + getRequestContent(HTTP_PROTOCOL + actor.getNode() + ":" + port + "/restconf/operations/daexim-offsite-backup:backup-data", HttpMethod.Post); + } catch(IOException e) { + log.error("Error backing up data.", e); + throw e; + } + } + catch(IOException e) { + log.error("Error exporting MD-SAL data.", e); + } + } + } + + log.info("Changing voting for all shards to standby site..."); + try { + JSONObject votingInput = new JSONObject(); + JSONObject inputBlock = new JSONObject(); + JSONArray votingStateArray = new JSONArray(); + JSONObject memberVotingState; + for(ClusterActor actor : activeSite) { + memberVotingState = new JSONObject(); + memberVotingState.put("member-name", actor.getMember()); + memberVotingState.put("voting", false); + votingStateArray.put(memberVotingState); + } + for(ClusterActor actor : standbySite) { + memberVotingState = new JSONObject(); + memberVotingState.put("member-name", actor.getMember()); + memberVotingState.put("voting", true); + votingStateArray.put(memberVotingState); + } + inputBlock.put("member-voting-state", votingStateArray); + votingInput.put("input", inputBlock); + log.debug(votingInput.toString(2)); + // Change voting all shards + getRequestContent(HTTP_PROTOCOL + self.getNode() + ":" + port + "/restconf/operations/cluster-admin:change-member-voting-states-for-all-shards", HttpMethod.Post, votingInput.toString()); + } catch(IOException e) { + log.error("Changing voting", e); + outputBuilder.setMessage("Failover aborted. Failed to change voting."); + outputBuilder.setStatus("500"); + return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); + } + + // Halt akka traffic + log.info("Halting Akka traffic..."); + for(ClusterActor actor : standbySite) { + try { + log.info("Halting Akka traffic for: " + actor.getNode()); + // Build JSON with activeSite actor.getNode() and actor.getAkkaPort(); + JSONObject akkaInput = new JSONObject(); + JSONObject inputBlock = new JSONObject(); + JSONArray votingStateArray = new JSONArray(); + JSONObject nodeInfo; + for(ClusterActor node : activeSite) { + nodeInfo = new JSONObject(); + nodeInfo.put("node", node.getNode()); + nodeInfo.put("port", node.getAkkaPort()); + votingStateArray.put(nodeInfo); + } + inputBlock.put("node-info", votingStateArray); + akkaInput.put("input", inputBlock); + getRequestContent(HTTP_PROTOCOL + actor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:halt-akka-traffic", HttpMethod.Post, akkaInput.toString()); + } catch(IOException e) { + log.error("Could not halt Akka traffic for: " + actor.getNode(), e); + } + } + + // Set unreachable + log.info("Setting site unreachable..."); + JSONObject jolokiaInput = new JSONObject(); + jolokiaInput.put("type", "EXEC"); + jolokiaInput.put("mbean", "akka:type=Cluster"); + jolokiaInput.put("operation", "down"); + JSONArray arguments = new JSONArray(); + for(ClusterActor actor : activeSite) { + // Build Jolokia input + //TODO: May need to change from akka port to actor.getAkkaPort() + arguments.put("akka.tcp://opendaylight-cluster-data@" + actor.getNode() + ":" + properties.getProperty("controller.port.akka")); + } + jolokiaInput.put("arguments", arguments); + log.debug(jolokiaInput.toString(2)); + try { + log.info("Setting nodes unreachable"); + getRequestContent(HTTP_PROTOCOL + standbySite.get(0).getNode() + ":" + port + "/jolokia", HttpMethod.Post, jolokiaInput.toString()); + } catch(IOException e) { + log.error("Error setting nodes unreachable", e); + } + + log.info(appName + ":failover complete."); + + outputBuilder.setMessage("Failover complete."); + outputBuilder.setStatus("200"); + return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); + } + + private ListenableFuture> buildClusterHealthOutput(String statusCode) { + ClusterHealthOutputBuilder outputBuilder = new ClusterHealthOutputBuilder(); + outputBuilder.setStatus(statusCode); + outputBuilder.setMembers((List) new ArrayList()); + int site1Health = 0; + int site2Health = 0; + + for(String key : members.keySet()) { + if(members.get(key).isUp() && !members.get(key).isUnreachable()) { + if(ClusterActor.SITE_1.equals(members.get(key).getSite())) + site1Health++; + else if(ClusterActor.SITE_2.equals(members.get(key).getSite())) + site2Health++; + } + outputBuilder.getMembers().add(new MemberBuilder(members.get(key)).build()); + } + if(siteConfiguration == SiteConfiguration.Solo) { + outputBuilder.setSite1Health(HEALTHY); + } + else { + if(site1Health > 1) { + outputBuilder.setSite1Health(HEALTHY); + } + else { + outputBuilder.setSite1Health(FAULTY); + } + } + if(siteConfiguration == SiteConfiguration.Geo) { + if(site2Health > 1) { + outputBuilder.setSite2Health(HEALTHY); + } + else { + outputBuilder.setSite2Health(FAULTY); + } + } + + RpcResult rpcResult = RpcResultBuilder.status(true).withResult(outputBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } + + private ListenableFuture> buildSiteHealthOutput(String statusCode, String adminHealth, String databaseHealth) { + SiteHealthOutputBuilder outputBuilder = new SiteHealthOutputBuilder(); + outputBuilder.setStatus(statusCode); + outputBuilder.setSites((List) new ArrayList()); + + if(siteConfiguration != SiteConfiguration.Geo) { + int healthyODLs = 0; + SitesBuilder builder = new SitesBuilder(); + for(String key : members.keySet()) { + if(members.get(key).isUp() && !members.get(key).isUnreachable()) { + healthyODLs++; + } + } + if(siteConfiguration != SiteConfiguration.Solo) { + builder.setHealth(HEALTHY); + builder.setRole("ACTIVE"); + builder.setId(SITE_IDENTIFIER); + } + else { + builder = getSitesBuilder(healthyODLs, true, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), SITE_IDENTIFIER); + } + outputBuilder.getSites().add(builder.build()); + } + else { + int site1HealthyODLs = 0; + int site2HealthyODLs = 0; + boolean site1Voting = false; + boolean site2Voting = false; + boolean performedCrossSiteHealthCheck = false; + boolean crossSiteAdminHealthy = false; + boolean crossSiteDbHealthy = false; + String crossSiteIdentifier = "UNKNOWN_SITE"; + String port = "true".equals(properties.getProperty("controller.useSsl")) ? properties.getProperty("controller.port.ssl") : properties.getProperty("controller.port.http"); + if(isSite1()) { + // Make calls over to site 2 healthchecks + for(String key : members.keySet()) { + if(members.get(key).isUp() && !members.get(key).isUnreachable()) { + if(ClusterActor.SITE_1.equals(members.get(key).getSite())) { + site1HealthyODLs++; + if(members.get(key).isVoting()) { + site1Voting = true; + } + } + else { + site2HealthyODLs++; + if(members.get(key).isVoting()) { + site2Voting = true; + } + if(!performedCrossSiteHealthCheck) { + try { + String content = getRequestContent(HTTP_PROTOCOL + members.get(key).getNode() + ":" + port + "/restconf/operations/gr-toolkit:site-identifier", HttpMethod.Post); + crossSiteIdentifier = new JSONObject(content).getJSONObject("output").getString("id"); + crossSiteDbHealthy = crossSiteHealthRequest(HTTP_PROTOCOL + members.get(key).getNode() + ":" + port + "/restconf/operations/gr-toolkit:database-health"); + crossSiteAdminHealthy = crossSiteHealthRequest(HTTP_PROTOCOL + members.get(key).getNode() + ":" + port + "/restconf/operations/gr-toolkit:admin-health"); + performedCrossSiteHealthCheck = true; + } catch(Exception e) { + log.error("Cannot get site identifier from " + members.get(key).getNode(), e); + } + } + } + } + } + SitesBuilder builder = getSitesBuilder(site1HealthyODLs, site1Voting, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), SITE_IDENTIFIER); + outputBuilder.getSites().add(builder.build()); + builder = getSitesBuilder(site2HealthyODLs, site2Voting, crossSiteAdminHealthy, crossSiteDbHealthy, crossSiteIdentifier); + outputBuilder.getSites().add(builder.build()); + } + else { + // Make calls over to site 1 healthchecks + for(String key : members.keySet()) { + if(members.get(key).isUp() && !members.get(key).isUnreachable()) { + if(ClusterActor.SITE_1.equals(members.get(key).getSite())) { + site1HealthyODLs++; + if(members.get(key).isVoting()) { + site1Voting = true; + } + if(!performedCrossSiteHealthCheck) { + try { + String content = getRequestContent(HTTP_PROTOCOL + members.get(key).getNode() + ":" + port + "/restconf/operations/gr-toolkit:site-identifier", HttpMethod.Post); + crossSiteIdentifier = new JSONObject(content).getJSONObject("output").getString("id"); + crossSiteDbHealthy = crossSiteHealthRequest(HTTP_PROTOCOL + members.get(key).getNode() + ":" + port + "/restconf/operations/gr-toolkit:database-health"); + crossSiteAdminHealthy = crossSiteHealthRequest(HTTP_PROTOCOL + members.get(key).getNode() + ":" + port + "/restconf/operations/gr-toolkit:admin-health"); + performedCrossSiteHealthCheck = true; + } catch(Exception e) { + log.error("Cannot get site identifier from " + members.get(key).getNode(), e); + } + } + } + else { + site2HealthyODLs++; + if(members.get(key).isVoting()) { + site2Voting = true; + } + } + } + } + // Build Output + SitesBuilder builder = getSitesBuilder(site1HealthyODLs, site1Voting, crossSiteAdminHealthy, crossSiteDbHealthy, crossSiteIdentifier); + outputBuilder.getSites().add(builder.build()); + builder = getSitesBuilder(site2HealthyODLs, site2Voting, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), SITE_IDENTIFIER); + outputBuilder.getSites().add(builder.build()); + } + } + + RpcResult rpcResult = RpcResultBuilder.status(true).withResult(outputBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } + + private SitesBuilder getSitesBuilder(int siteHealthyODLs, boolean siteVoting, boolean adminHealthy, boolean dbHealthy, String siteIdentifier) { + SitesBuilder builder = new SitesBuilder(); + if(siteHealthyODLs > 1) { + builder.setHealth(HEALTHY); + } + else { + log.warn(siteIdentifier + " Healthy ODLs: " + siteHealthyODLs); + builder.setHealth(FAULTY); + } + if(!adminHealthy) { + log.warn(siteIdentifier + " Admin Health: " + FAULTY); + builder.setHealth(FAULTY); + } + if(!dbHealthy) { + log.warn(siteIdentifier + " Database Health: " + FAULTY); + builder.setHealth(FAULTY); + } + if(siteVoting) { + builder.setRole("ACTIVE"); + } + else { + builder.setRole("STANDBY"); + } + builder.setId(siteIdentifier); + return builder; + } + + private boolean isSite1() { + int memberNumber = Integer.parseInt(member.split("-")[1]); + boolean isSite1 = memberNumber < 4; + log.info("isSite1(): " + isSite1); + return isSite1; + } + + private void parseSeedNodes(String line) { + members = new HashMap<>(); + line = line.substring(line.indexOf("[\""), line.indexOf("]")); + String[] splits = line.split(","); + + for(int ndx = 0; ndx < splits.length; ndx++) { + String nodeName = splits[ndx]; + int delimLocation = nodeName.indexOf("@"); + String port = nodeName.substring(splits[ndx].indexOf(":", delimLocation) + 1, splits[ndx].indexOf("\"", splits[ndx].indexOf(":"))); + splits[ndx] = nodeName.substring(delimLocation + 1, splits[ndx].indexOf(":", delimLocation)); + log.info("Adding node: " + splits[ndx] + ":" + port); + ClusterActor clusterActor = new ClusterActor(); + clusterActor.setNode(splits[ndx]); + clusterActor.setAkkaPort(port); + clusterActor.setMember("member-" + (ndx + 1)); + if(ndx < 3) { + clusterActor.setSite(ClusterActor.SITE_1); + } + else { + clusterActor.setSite(ClusterActor.SITE_2); + } + + if(member.equals(clusterActor.getMember())) { + self = clusterActor; + } + members.put(clusterActor.getNode(), clusterActor); + log.info(clusterActor.toString()); + } + + if(members.size() == 1) { + log.info("1 member found. This is a solo environment."); + siteConfiguration = SiteConfiguration.Solo; + } + else if(members.size() == 3) { + log.info("This is a single site."); + siteConfiguration = SiteConfiguration.Single; + } + else if(members.size() == 6) { + log.info("This is a georedundant site."); + siteConfiguration = SiteConfiguration.Geo; + } + } + + private void getMemberStatus(ClusterActor clusterActor) throws IOException { + log.info("Getting member status for " + clusterActor.getNode()); + String content = getRequestContent(HTTP_PROTOCOL + clusterActor.getNode() + JOLOKIA_CLUSTER_PATH, HttpMethod.Get); + try { + JSONObject responseJson = new JSONObject(content); + JSONObject responseValue = responseJson.getJSONObject("value"); + clusterActor.setUp("Up".equals(responseValue.getString("MemberStatus"))); + clusterActor.setUnreachable(false); + } catch(JSONException e) { + log.error("Error parsing response from " + clusterActor.getNode(), e); + clusterActor.setUp(false); + clusterActor.setUnreachable(true); + } + } + + private void getShardStatus(ClusterActor clusterActor) throws IOException { + log.info("Getting shard status for " + clusterActor.getNode()); + String content = getRequestContent(HTTP_PROTOCOL + clusterActor.getNode() + SHARD_MANAGER_PATH, HttpMethod.Get); + try { + JSONObject responseValue = new JSONObject(content).getJSONObject("value"); + JSONArray shardList = responseValue.getJSONArray("LocalShards"); + + String pattern = "-config$"; + Pattern r = Pattern.compile(pattern); + Matcher m; + for(int ndx = 0; ndx < shardList.length(); ndx++) { + String configShardName = shardList.getString(ndx); + m = r.matcher(configShardName); + String operationalShardName = m.replaceFirst("-operational"); + String shardConfigPath = String.format(SHARD_PATH_TEMPLATE, configShardName); + String shardOperationalPath = String.format(SHARD_PATH_TEMPLATE, operationalShardName).replace("Config", "Operational"); + extractShardInfo(clusterActor, configShardName, shardConfigPath); + extractShardInfo(clusterActor, operationalShardName, shardOperationalPath); + } + } catch(JSONException e) { + log.error("Error parsing response from " + clusterActor.getNode(), e); + } + } + + private void extractShardInfo(ClusterActor clusterActor, String shardName, String shardPath) throws IOException { + log.info("Extracting shard info for " + shardName); + log.debug("Pulling config info for " + shardName + " from: " + shardPath); + String content = getRequestContent(HTTP_PROTOCOL + clusterActor.getNode() + shardPath, HttpMethod.Get); + log.debug("Response: " + content); + + try { + JSONObject shardValue = new JSONObject(content).getJSONObject("value"); + clusterActor.setVoting(shardValue.getBoolean("Voting")); + if(shardValue.getString("PeerAddresses").length() > 0) { + clusterActor.getReplicaShards().add(shardName); + if(shardValue.getString("Leader").startsWith(clusterActor.getMember())) { + clusterActor.getShardLeader().add(shardName); + } + } + else { + clusterActor.getNonReplicaShards().add(shardName); + } + JSONArray followerInfo = shardValue.getJSONArray("FollowerInfo"); + for(int followerNdx = 0; followerNdx < followerInfo.length(); followerNdx++) { + int commitIndex = shardValue.getInt("CommitIndex"); + int matchIndex = followerInfo.getJSONObject(followerNdx).getInt("matchIndex"); + if(commitIndex != -1 && matchIndex != -1) { + int commitsBehind = commitIndex - matchIndex; + clusterActor.getCommits().put(followerInfo.getJSONObject(followerNdx).getString("id"), commitsBehind); + } + } + } catch(JSONException e) { + log.error("Error parsing response from " + clusterActor.getNode(), e); + } + } + + private void getControllerHealth() { + ClusterActor clusterActor; + for(String key : members.keySet()) { + try { + clusterActor = members.get(key); + // First flush out the old values + clusterActor.flush(); + log.info("Gathering info for " + clusterActor.getNode()); + getMemberStatus(clusterActor); + getShardStatus(clusterActor); + log.info("MemberInfo:\n" + clusterActor.toString()); + } catch(IOException e) { + log.error("Connection Error", e); + members.get(key).setUnreachable(true); + members.get(key).setUp(false); + log.info("MemberInfo:\n" + members.get(key).toString()); + } + } + } + + private void modifyIpTables(IpTables task, Object[] nodeInfo) { + log.info("Modifying IPTables rules..."); + switch(task) + { + case Add: + for(Object node : nodeInfo) { + org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.halt.akka.traffic.input.NodeInfo n = + (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.halt.akka.traffic.input.NodeInfo) node; + log.info("Isolating " + n.getNode()); + executeCommand(String.format("sudo /sbin/iptables -A INPUT -p tcp --destination-port %s -j DROP -s %s", properties.get("controller.port.akka"), n.getNode())); + executeCommand(String.format("sudo /sbin/iptables -A OUTPUT -p tcp --destination-port %s -j DROP -s %s", n.getPort(), n.getNode())); + } + break; + case Delete: + for(Object node : nodeInfo) { + org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.resume.akka.traffic.input.NodeInfo n = + (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.resume.akka.traffic.input.NodeInfo) node; + log.info("De-isolating " + n.getNode()); + executeCommand(String.format("sudo /sbin/iptables -D INPUT -p tcp --destination-port %s -j DROP -s %s", properties.get("controller.port.akka"), n.getNode())); + executeCommand(String.format("sudo /sbin/iptables -D OUTPUT -p tcp --destination-port %s -j DROP -s %s", n.getPort(), n.getNode())); + } + break; + } + executeCommand("sudo /sbin/iptables -L"); + } + + private void executeCommand(String command) { + log.info("Executing command: " + command); + String[] cmd = command.split(" "); + try { + Process p = Runtime.getRuntime().exec(cmd); + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(p.getInputStream())); + String inputLine; + StringBuffer content = new StringBuffer(); + while((inputLine = bufferedReader.readLine()) != null) { + content.append(inputLine); + } + bufferedReader.close(); + log.info(content.toString()); + } catch(IOException e) { + log.error("Error executing command", e); + } + } + + private boolean crossSiteHealthRequest(String path) throws IOException { + String content = getRequestContent(path, HttpMethod.Post); + try { + JSONObject responseJson = new JSONObject(content); + JSONObject responseValue = responseJson.getJSONObject("value"); + return HEALTHY.equals(responseValue.getString("health")); + } catch(JSONException e) { + log.error("Error parsing JSON", e); + throw new IOException(); + } + } + + private String getAdminHealth() { + String protocol = "true".equals(properties.getProperty("adm.useSsl")) ? "https://" : "http://"; + String port = "true".equals(properties.getProperty("adm.useSsl")) ? properties.getProperty("adm.port.ssl") : properties.getProperty("adm.port.http"); + String path = protocol + properties.getProperty("adm.fqdn") + ":" + port + properties.getProperty("adm.healthcheck"); + log.info("Requesting healthcheck from " + path); + try { + int response = getRequestStatus(path, HttpMethod.Get); + log.info("Response: " + response); + if(response == 200) + return HEALTHY; + return FAULTY; + } catch(IOException e) { + log.error("Problem getting ADM health.", e); + return FAULTY; + } + } + + private String getDatabaseHealth() { + log.info("Determining database health..."); + try { + log.info("DBLib isActive(): " + dbLib.isActive()); + log.info("DBLib isReadOnly(): " + dbLib.getConnection().isReadOnly()); + log.info("DBLib isClosed(): " + dbLib.getConnection().isClosed()); + if(!dbLib.isActive() || dbLib.getConnection().isClosed() || dbLib.getConnection().isReadOnly()) { + log.warn("Database is FAULTY"); + return FAULTY; + } + log.info("Database is HEALTHY"); + } catch(SQLException e) { + log.error("Database is FAULTY"); + log.error("Error", e); + return FAULTY; + } + + return HEALTHY; + } + + private String getRequestContent(String path, HttpMethod method) throws IOException { + return getRequestContent(path, method, null); + } + + private String getRequestContent(String path, HttpMethod method, String input) throws IOException { + HttpURLConnection connection = getConnection(path); + connection.setRequestMethod(method.getMethod()); + connection.setDoInput(true); + + if(input != null) { + sendPayload(input, connection); + } + + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String inputLine; + StringBuffer content = new StringBuffer(); + while((inputLine = bufferedReader.readLine()) != null) { + content.append(inputLine); + } + bufferedReader.close(); + connection.disconnect(); + return content.toString(); + } + + private int getRequestStatus(String path, HttpMethod method) throws IOException { + return getRequestStatus(path, method, null); + } + + private int getRequestStatus(String path, HttpMethod method, String input) throws IOException { + HttpURLConnection connection = getConnection(path); + connection.setRequestMethod(method.getMethod()); + connection.setDoInput(true); + + if(input != null) { + sendPayload(input, connection); + } + int response = connection.getResponseCode(); + log.info("Received " + response + " response code from " + path); + connection.disconnect(); + return response; + } + + private void sendPayload(String input, HttpURLConnection connection) throws IOException { + byte[] out = input.getBytes(StandardCharsets.UTF_8); + int length = out.length; + + connection.setFixedLengthStreamingMode(length); + connection.setRequestProperty("Content-Type", "application/json"); + connection.setDoOutput(true); + connection.connect(); + try(OutputStream os = connection.getOutputStream()) { + os.write(out); + } + } + + private HttpURLConnection getConnection(String host) throws IOException { + log.info("Getting connection to: " + host); + URL url = new URL(host); + String auth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(CREDENTIALS.getBytes()); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.addRequestProperty("Authorization", auth); + connection.setRequestProperty("Connection", "keep-alive"); + connection.setRequestProperty("Proxy-Connection", "keep-alive"); + return connection; + } + + private enum IpTables { + Add, + Delete + } + + private enum SiteConfiguration { + Solo, + Single, + Geo + } + + private enum HttpMethod { + Get("GET"), + Post("POST"); + + private String method; + HttpMethod(String method) { + this.method = method; + } + public String getMethod() { + return method; + } + } +} \ No newline at end of file diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitUtil.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitUtil.java new file mode 100755 index 000000000..7f91467a5 --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitUtil.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2018 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; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ClusterHealthOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteHealthOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.site.health.output.SitesBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.DatabaseHealthOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.AdminHealthOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.HaltAkkaTrafficOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ResumeAkkaTrafficOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteIdentifierOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverInputBuilder; + + +import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class GrToolkitUtil extends MdsalHelper { + private static final Logger LOG = LoggerFactory.getLogger(GrToolkitUtil.class); + public static String PROPERTIES_FILE = "/opt/opendaylight/current/controller/configuration/gr-toolkit.properties"; + + public static void loadProperties() { + File file = new File(PROPERTIES_FILE); + Properties properties = new Properties(); + InputStream input = null; + if(file.isFile() && file.canRead()) { + try { + input = new FileInputStream(file); + properties.load(input); + LOG.info("Loaded properties from " + PROPERTIES_FILE); + setProperties(properties); + } catch (Exception e) { + LOG.error("Failed to load properties " + PROPERTIES_FILE + "\n", e); + } finally { + if(input != null) { + try { + input.close(); + } catch (IOException e) { + LOG.error("Failed to close properties file " + PROPERTIES_FILE + "\n", e); + } + } + } + } + } + + static { + // Trick class loader into loading builders. Some of + // these will be needed later by Reflection classes, but need + // to explicitly "new" them here to get class loader to load them. + + ClusterHealthOutputBuilder b1 = new ClusterHealthOutputBuilder(); + SiteHealthOutputBuilder b2 = new SiteHealthOutputBuilder(); + SitesBuilder b3 = new SitesBuilder(); + DatabaseHealthOutputBuilder b4 = new DatabaseHealthOutputBuilder(); + AdminHealthOutputBuilder b5 = new AdminHealthOutputBuilder(); + HaltAkkaTrafficOutputBuilder b6 = new HaltAkkaTrafficOutputBuilder(); + ResumeAkkaTrafficOutputBuilder b7 = new ResumeAkkaTrafficOutputBuilder(); + SiteIdentifierOutputBuilder b8 = new SiteIdentifierOutputBuilder(); + FailoverOutputBuilder b9 = new FailoverOutputBuilder(); + FailoverInputBuilder b10 = new FailoverInputBuilder(); + } +} diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/ClusterActor.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/ClusterActor.java new file mode 100755 index 000000000..34a51192f --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/ClusterActor.java @@ -0,0 +1,212 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2018 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.data; + +import java.util.ArrayList; +import java.util.HashMap; + +public class ClusterActor { + private String node; + private String member; + private String site; + private String akkaPort; + private boolean voting; + private boolean up; + private boolean unreachable; + private ArrayList shardLeader; + private ArrayList replicaShards; + private ArrayList nonReplicaShards; + private HashMap commits; + + public static final String SITE_1 = "Site 1"; + public static final String SITE_2 = "Site 2"; + + public ClusterActor() { + node = ""; + member = ""; + site = ""; + voting = false; + up = false; + unreachable = false; + shardLeader = new ArrayList<>(); + replicaShards = new ArrayList<>(); + nonReplicaShards = new ArrayList<>(); + commits = new HashMap<>(); + } + + public String getNode() { + return node; + } + + public void setNode(String node) { + this.node = node; + } + + public String getMember() { + return member; + } + + public void setMember(String member) { + this.member = member; + } + + public String getSite() { + return site; + } + + public void setSite(String site) { + this.site = site; + } + + public String getAkkaPort() { + return akkaPort; + } + + public void setAkkaPort(String akkaPort) { + this.akkaPort = akkaPort; + } + + public boolean isVoting() { + return voting; + } + + public void setVoting(boolean voting) { + this.voting = voting; + } + + public boolean isUp() { + return up; + } + + public void setUp(boolean up) { + this.up = up; + } + + public boolean isUnreachable() { + return unreachable; + } + + public void setUnreachable(boolean unreachable) { + this.unreachable = unreachable; + } + + public ArrayList getShardLeader() { + return shardLeader; + } + + public void setShardLeader(ArrayList shardLeader) { + this.shardLeader = shardLeader; + } + + public ArrayList getReplicaShards() { + return replicaShards; + } + + public void setReplicaShards(ArrayList replicaShards) { + this.replicaShards = replicaShards; + } + + public ArrayList getNonReplicaShards() { + return nonReplicaShards; + } + + public void setNonReplicaShards(ArrayList nonReplicaShards) { + this.nonReplicaShards = nonReplicaShards; + } + + public HashMap getCommits() { + return commits; + } + + public void setCommits(HashMap commits) { + this.commits = commits; + } + + public void flush() { + shardLeader.clear(); + replicaShards.clear(); + nonReplicaShards.clear(); + commits.clear(); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("[ "); + builder.append(this.member); + builder.append(" ] "); + + builder.append(this.node); + builder.append(":"); + builder.append(this.akkaPort); + builder.append(" is"); + if(up) + builder.append(" Up"); + else + builder.append(" Down"); + if(unreachable) + builder.append(" [ UNREACHABLE ]"); + + if(voting) + builder.append(" (Voting)"); + + builder.append("\n"); + + for(String l : this.shardLeader) { + builder.append("\tLeader: "); + builder.append(l); + builder.append("\n"); + } + + for(String r : this.replicaShards) { + builder.append("\tReplicating: "); + builder.append(r); + builder.append("\n"); + } + + for(String n : this.nonReplicaShards) { + builder.append("\tNot replicating: "); + builder.append(n); + builder.append("\n"); + } + + for(String key : commits.keySet()) { + int value = commits.get(key); + if(value > 0) { + builder.append("\t"); + builder.append(value); + builder.append(" commits ahead of "); + builder.append(key); + builder.append("\n"); + } + else if(value < 0) { + builder.append("\t"); + builder.append(value); + builder.append(" commits behind "); + builder.append(key); + builder.append("\n"); + } + } + + return builder.toString(); + } +} diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/MemberBuilder.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/MemberBuilder.java new file mode 100755 index 000000000..1eb0e75ae --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/MemberBuilder.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2018 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.data; + +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.cluster.health.output.MembersBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.member.CommitStatusBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.member.CommitStatus; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.member.ReplicasBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.member.Replicas; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.member.LeaderBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.member.Leader; + + +import java.util.HashMap; +import java.util.ArrayList; +import java.util.List; + +public class MemberBuilder extends MembersBuilder { + public MemberBuilder(ClusterActor actor) { + super(); + this.setAddress(actor.getNode()); + this.setRole(actor.getMember()); + this.setVoting(actor.isVoting()); + this.setUp(actor.isUp()); + this.setUnreachable(actor.isUnreachable()); + populateReplicas(actor.getReplicaShards()); + populateCommits(actor.getCommits()); + populateLeader(actor.getShardLeader()); + //actor.getNonReplicaShards(); + } + + private void populateLeader(ArrayList shardLeader) { + LeaderBuilder builder; + this.setLeader((List) new ArrayList()); + for(String leader : shardLeader) { + builder = new LeaderBuilder(); + builder.setShard(leader); + this.getLeader().add(builder.build()); + } + } + + private void populateCommits(HashMap commits) { + CommitStatusBuilder builder; + this.setCommitStatus((List) new ArrayList()); + for(String key : commits.keySet()) { + if(commits.get(key) != 0) { + builder = new CommitStatusBuilder(); + builder.setShard(key); + builder.setDelta(commits.get(key)); + this.getCommitStatus().add(builder.build()); + } + } + } + + private void populateReplicas(ArrayList replicaShards) { + ReplicasBuilder builder; + this.setReplicas((List) new ArrayList()); + for(String shard : replicaShards) { + builder = new ReplicasBuilder(); + builder.setShard(shard); + this.getReplicas().add(builder.build()); + } + } +} diff --git a/grToolkit/provider/src/main/resources/gr-toolkit.properties b/grToolkit/provider/src/main/resources/gr-toolkit.properties new file mode 100755 index 000000000..2ddaa9a4e --- /dev/null +++ b/grToolkit/provider/src/main/resources/gr-toolkit.properties @@ -0,0 +1,15 @@ +akka.conf.location=/opt/opendaylight/current/controller/configuration/initial/akka.conf +adm.useSsl=true +adm.fqdn=sdnmlcadm-conexus-it.ecomp.cci.att.com +adm.healthcheck=/healthcheck +adm.port.http=8181 +adm.port.ssl=8443 +controller.credentials=admin:admin +controller.useSsl=true +controller.port.http=8181 +controller.port.ssl=8443 +controller.port.akka=2550 +mbean.cluster=/jolokia/read/akka:type=Cluster +mbean.shardManager=/jolokia/read/org.opendaylight.controller:Category=ShardManager,name=shard-manager-config,type=DistributedConfigDatastore +mbean.shard.config=/jolokia/read/org.opendaylight.controller:Category=Shards,name=%s,type=DistributedConfigDatastore +site.identifier=UniqueSiteNamehere diff --git a/grToolkit/provider/src/main/resources/org/opendaylight/blueprint/GrToolkit.xml b/grToolkit/provider/src/main/resources/org/opendaylight/blueprint/GrToolkit.xml new file mode 100755 index 000000000..606ce2771 --- /dev/null +++ b/grToolkit/provider/src/main/resources/org/opendaylight/blueprint/GrToolkit.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index 201a59b39..7528a9b78 100755 --- a/pom.xml +++ b/pom.xml @@ -26,6 +26,7 @@ sshapi-call-node restconf-client template-node + grToolkit features artifacts -- cgit From ce531cc96ecba4d48852ad36fe9d1ab461240596 Mon Sep 17 00:00:00 2001 From: "Haddox, Anthony" Date: Tue, 29 Jan 2019 08:50:09 -0800 Subject: Add Isolation Toggle Add extra input option that allows user to toggle the ODL isolation step in the failover process. Change-Id: I1fdfd4bf5cf2484af8ce67f9c91d0111134b762c Issue-ID: CCSDK-1012 Signed-off-by: Haddox, Anthony --- grToolkit/model/src/main/yang/gr-toolkit.yang | 12 +++- .../onap/ccsdk/sli/plugins/GrToolkitProvider.java | 82 +++++++++++----------- 2 files changed, 52 insertions(+), 42 deletions(-) diff --git a/grToolkit/model/src/main/yang/gr-toolkit.yang b/grToolkit/model/src/main/yang/gr-toolkit.yang index 951201c5e..8b22d666a 100755 --- a/grToolkit/model/src/main/yang/gr-toolkit.yang +++ b/grToolkit/model/src/main/yang/gr-toolkit.yang @@ -142,7 +142,7 @@ module gr-toolkit{ rpc halt-akka-traffic { description - "Invokes a utility script to halt traffic to the akka port."; + "Executes IP Tables commands to halt traffic to the akka port."; input { list node-info { uses node; @@ -155,7 +155,7 @@ module gr-toolkit{ rpc resume-akka-traffic { description - "Invokes a utility script to resume traffic to the akka port."; + "Executes IP Tables commands to resume traffic to the akka port."; input { list node-info { uses node; @@ -174,6 +174,14 @@ module gr-toolkit{ type string; default "false"; } + leaf isolate { + type string; + default "false"; + } + leaf downUnreachable { + type string; + default "false"; + } } output { leaf status { type string; } diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitProvider.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitProvider.java index 249640afa..f0a104de8 100755 --- a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitProvider.java +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitProvider.java @@ -384,49 +384,51 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); } - // Halt akka traffic - log.info("Halting Akka traffic..."); - for(ClusterActor actor : standbySite) { - try { - log.info("Halting Akka traffic for: " + actor.getNode()); - // Build JSON with activeSite actor.getNode() and actor.getAkkaPort(); - JSONObject akkaInput = new JSONObject(); - JSONObject inputBlock = new JSONObject(); - JSONArray votingStateArray = new JSONArray(); - JSONObject nodeInfo; - for(ClusterActor node : activeSite) { - nodeInfo = new JSONObject(); - nodeInfo.put("node", node.getNode()); - nodeInfo.put("port", node.getAkkaPort()); - votingStateArray.put(nodeInfo); + if(Boolean.parseBoolean(input.getIsolate())) { + log.info("Halting Akka traffic..."); + for(ClusterActor actor : standbySite) { + try { + log.info("Halting Akka traffic for: " + actor.getNode()); + // Build JSON with activeSite actor.getNode() and actor.getAkkaPort(); + JSONObject akkaInput = new JSONObject(); + JSONObject inputBlock = new JSONObject(); + JSONArray votingStateArray = new JSONArray(); + JSONObject nodeInfo; + for(ClusterActor node : activeSite) { + nodeInfo = new JSONObject(); + nodeInfo.put("node", node.getNode()); + nodeInfo.put("port", node.getAkkaPort()); + votingStateArray.put(nodeInfo); + } + inputBlock.put("node-info", votingStateArray); + akkaInput.put("input", inputBlock); + getRequestContent(HTTP_PROTOCOL + actor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:halt-akka-traffic", HttpMethod.Post, akkaInput.toString()); + } catch(IOException e) { + log.error("Could not halt Akka traffic for: " + actor.getNode(), e); } - inputBlock.put("node-info", votingStateArray); - akkaInput.put("input", inputBlock); - getRequestContent(HTTP_PROTOCOL + actor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:halt-akka-traffic", HttpMethod.Post, akkaInput.toString()); - } catch(IOException e) { - log.error("Could not halt Akka traffic for: " + actor.getNode(), e); } - } - // Set unreachable - log.info("Setting site unreachable..."); - JSONObject jolokiaInput = new JSONObject(); - jolokiaInput.put("type", "EXEC"); - jolokiaInput.put("mbean", "akka:type=Cluster"); - jolokiaInput.put("operation", "down"); - JSONArray arguments = new JSONArray(); - for(ClusterActor actor : activeSite) { - // Build Jolokia input - //TODO: May need to change from akka port to actor.getAkkaPort() - arguments.put("akka.tcp://opendaylight-cluster-data@" + actor.getNode() + ":" + properties.getProperty("controller.port.akka")); - } - jolokiaInput.put("arguments", arguments); - log.debug(jolokiaInput.toString(2)); - try { - log.info("Setting nodes unreachable"); - getRequestContent(HTTP_PROTOCOL + standbySite.get(0).getNode() + ":" + port + "/jolokia", HttpMethod.Post, jolokiaInput.toString()); - } catch(IOException e) { - log.error("Error setting nodes unreachable", e); + if(Boolean.parseBoolean(input.getDownUnreachable())) { + log.info("Setting site unreachable..."); + JSONObject jolokiaInput = new JSONObject(); + jolokiaInput.put("type", "EXEC"); + jolokiaInput.put("mbean", "akka:type=Cluster"); + jolokiaInput.put("operation", "down"); + JSONArray arguments = new JSONArray(); + for(ClusterActor actor : activeSite) { + // Build Jolokia input + //TODO: May need to change from akka port to actor.getAkkaPort() + arguments.put("akka.tcp://opendaylight-cluster-data@" + actor.getNode() + ":" + properties.getProperty("controller.port.akka")); + } + jolokiaInput.put("arguments", arguments); + log.debug(jolokiaInput.toString(2)); + try { + log.info("Setting nodes unreachable"); + getRequestContent(HTTP_PROTOCOL + standbySite.get(0).getNode() + ":" + port + "/jolokia", HttpMethod.Post, jolokiaInput.toString()); + } catch(IOException e) { + log.error("Error setting nodes unreachable", e); + } + } } log.info(appName + ":failover complete."); -- cgit From e421fb3c892f2d387f364a0a8e15f14132c9547f Mon Sep 17 00:00:00 2001 From: "Haddox, Anthony" Date: Mon, 4 Feb 2019 09:18:12 -0800 Subject: Rename ccsdk-gr-toolkit features.xml name Issue-ID: CCSDK-1019 Change-Id: I5443c223194d3d3df7a068b033475c4ccadec65e Signed-off-by: Haddox, Anthony --- grToolkit/features/ccsdk-gr-toolkit/src/main/feature/feature.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grToolkit/features/ccsdk-gr-toolkit/src/main/feature/feature.xml b/grToolkit/features/ccsdk-gr-toolkit/src/main/feature/feature.xml index 9f8278a02..4a21ca550 100755 --- a/grToolkit/features/ccsdk-gr-toolkit/src/main/feature/feature.xml +++ b/grToolkit/features/ccsdk-gr-toolkit/src/main/feature/feature.xml @@ -1,5 +1,5 @@ - + mvn:org.onap.ccsdk.sli.core/ccsdk-sli/LATEST/xml/features ccsdk-sli -- cgit From d53b22a833abf7a74257024bd0701b03774ebc42 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 1 Feb 2019 15:59:45 -0500 Subject: Fix restapi-call-node javax.ws.rs version Fix version of javax.ws.rs in feature.xml file for restapi-call-node to be 2.1. Change-Id: Ia2a4f065dff2fea8658d7d9e0f2915112a68a353 Issue-ID: CCSDK-489 Signed-off-by: Timoney, Dan (dt5972) Disable broken restapi-call-node Enabling restapi-call-node in Fluorine breaks the container due to a version conflict in jersey (restapi-call-node needs version 2.27, opendaylight aaa-shiro module requires 2.25.2) Change-Id: I2ed1810eeeb922e1df76ec580a5424832f5af721 Issue-ID: CCSDK-489 Signed-off-by: Timoney, Dan (dt5972) --- features/ccsdk-sli-plugins-all/pom.xml | 2 ++ restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index 271cbb186..2c4e4c615 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -25,6 +25,7 @@ xml features + ${project.groupId} ccsdk-template-node diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index da6b8d0d2..638cff391 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -18,7 +18,11 @@ - + + javax.ws.rs + javax.ws.rs-api + 2.1 + org.onap.ccsdk.sli.core ccsdk-sli -- cgit From 1120a398b0e9cb2e1da7e12e45f9a14d4ac61ba3 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Tue, 5 Feb 2019 19:29:22 +0000 Subject: template node patch Remove HideNullJson directive and update missing properties message Change-Id: I8eb1404d3844284fe28ed0d49226ad166e185656 Issue-ID: CCSDK-1040 Signed-off-by: Smokowski, Kevin (ks6305) --- .../ccsdk/sli/plugins/template/HideNullJson.java | 98 ---------------------- .../ccsdk/sli/plugins/template/TemplateNode.java | 3 +- .../sli/plugins/template/HideNullJsonTest.java | 46 ---------- .../provider/src/test/resources/HideNullJson.vtl | 22 ----- 4 files changed, 1 insertion(+), 168 deletions(-) delete mode 100755 template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/HideNullJson.java delete mode 100755 template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/HideNullJsonTest.java delete mode 100755 template-node/provider/src/test/resources/HideNullJson.vtl diff --git a/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/HideNullJson.java b/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/HideNullJson.java deleted file mode 100755 index d39d7e405..000000000 --- a/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/HideNullJson.java +++ /dev/null @@ -1,98 +0,0 @@ - -package org.onap.ccsdk.sli.plugins.template; - -import java.io.IOException; -import java.io.Writer; - -import org.apache.velocity.context.InternalContextAdapter; -import org.apache.velocity.exception.MethodInvocationException; -import org.apache.velocity.exception.ParseErrorException; -import org.apache.velocity.exception.ResourceNotFoundException; -import org.apache.velocity.runtime.directive.Directive; -import org.apache.velocity.runtime.parser.node.Node; - -// This directive can be used when handling optional json attributes in a template -// If an attribute value is null the entire name-value pair will not be rendered -// If an attribute value is not null the name-value pair will be rendered -// Additional optional parameters decide which values are quoted and if a comma and or newline should be appended -public class HideNullJson extends Directive { - - public String getName() { - return "hideNullJson"; - } - - public int getType() { - return BLOCK; - } - - // The first parameter is the json key - // The second parameter is the json value - // This directive handles placing the colon between the json key and json value - // The third parameter is a boolean, when true the json key is surrounded in double quotes by this directive - // The third parameter is true by default and is optional - // The fourth parameter is a boolean when true the json value is surrounded in double quotes by this directive - // The fourth parameter is true by default and is optional - // The fifth parameter is a boolean when true a comma is appended to the end - // The fifth parameter is true by default and is optional - // The sixth parameter is a boolean when true a newline is appended to the end - // The sixth parameter is true by default and is optional - public boolean render(InternalContextAdapter context, Writer writer, Node node) - throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { - String tagValue = null; - Object tagValueObject = node.jjtGetChild(1).value(context); - if (tagValueObject == null) { - return true; - } - tagValue = String.valueOf(tagValueObject); - - String tagName = String.valueOf(node.jjtGetChild(0).value(context)); - - Boolean quoteTagName = getBooleanParameter(true,node,2,context); - Boolean quoteTagValue = getBooleanParameter(true,node,3,context); - Boolean appendComma = getBooleanParameter(true,node,4,context); - Boolean appendNewLine = getBooleanParameter(true,node,5,context); - - StringBuilder sb = new StringBuilder(); - - if (quoteTagName) { - appendQuotedString(tagName,sb); - }else { - sb.append(tagName); - } - - sb.append(":"); - - if (quoteTagValue) { - appendQuotedString(tagValue,sb); - }else { - sb.append(tagValue); - } - - if(appendComma) { - sb.append(","); - } - - if(appendNewLine) { - sb.append("\n"); - } - writer.write(sb.toString()); - return true; - } - - private Boolean getBooleanParameter(Boolean defaultBool, Node node, int parameterPostion, InternalContextAdapter context) { - if (node.jjtGetNumChildren() > parameterPostion && node.jjtGetChild(parameterPostion) != null) { - Object val = node.jjtGetChild(parameterPostion).value(context); - if (val != null) { - return (Boolean) val; - } - } - return defaultBool; - } - - private void appendQuotedString(String str, StringBuilder sb) { - sb.append("\""); - sb.append(str); - sb.append("\""); - } - -} \ No newline at end of file diff --git a/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java b/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java index a78b81e9e..a36d1a510 100755 --- a/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java +++ b/template-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/template/TemplateNode.java @@ -53,7 +53,6 @@ public class TemplateNode implements SvcLogicJavaPlugin { ve = new VelocityEngine(); setProperties(); ve.init(); - ve.loadDirective("org.onap.ccsdk.sli.plugins.template.HideNullJson"); } protected void setProperties() { @@ -63,7 +62,7 @@ public class TemplateNode implements SvcLogicJavaPlugin { try (FileInputStream in = new FileInputStream(configDir + "/" + TEMPLATE_PROPERTIES_FILE_NAME)) { props.load(in); } catch (Exception e) { - logger.error("Caught exception loading properties!", e); + logger.warn("Properties not loaded for template node, using sensible defaults", e); } // give sensible defaults for required properties diff --git a/template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/HideNullJsonTest.java b/template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/HideNullJsonTest.java deleted file mode 100755 index 1fb1f676f..000000000 --- a/template-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/template/HideNullJsonTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.onap.ccsdk.sli.plugins.template; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; - -public class HideNullJsonTest { - - @Test - public void testSampleTemplate() throws Exception { - TemplateNode t = new MockTemplateNode(); - - Map params = new HashMap(); - params.put(TemplateNode.PREFIX_KEY, "output"); - params.put(TemplateNode.OUTPUT_PATH_KEY, "mycontainer"); - params.put(TemplateNode.TEMPLATE_PATH, "src/test/resources/HideNullJson.vtl"); - - //Setup sample data to feed into the directive - params.put("service-type", "\"VPN\""); //the value is quoted to test an override - params.put("svc-request-id", "REQ001"); - params.put("svc-action", "CREATE"); - params.put("service-instance-id", "SVC001"); - params.put("customerNameTag", "customer-name"); - params.put("customer-name", "TestCust"); - params.put("siidTag", "\"service-instance-id\""); //the value is quoted to test an override - - SvcLogicContext ctx = new SvcLogicContext(); - t.evaluateTemplate(params, ctx); - String result = ctx.getAttribute("output.mycontainer"); - assertTrue(result.contains("\"svc-request-id\":\"REQ001\",")); - assertTrue(result.contains("\"svc-action\":\"CREATE\"")); - assertFalse(result.contains("\"svc-action\":\"CREATE\",")); // there should be no trailing comma - assertTrue(result.contains("\"service-type\":\"VPN\",")); - assertTrue(result.contains("\"customer-name\":\"TestCust\",")); - assertTrue(result.contains("\"service-instance-id\":\"SVC001\"")); - assertFalse(result.contains("\"service-instance-id\":\"SVC001\",")); // there should be no trailing comma - //This should be hidden by the directive because the parameter was never populated - assertFalse(result.contains("customer-phone-number")); - } - -} \ No newline at end of file diff --git a/template-node/provider/src/test/resources/HideNullJson.vtl b/template-node/provider/src/test/resources/HideNullJson.vtl deleted file mode 100755 index 306679457..000000000 --- a/template-node/provider/src/test/resources/HideNullJson.vtl +++ /dev/null @@ -1,22 +0,0 @@ -## This is an example comment -## This velocity template is used to test the hideNullJson directive -{ - "input": { - "request-header": { -## by default the values parameters provided are surrounded in double quotes and separated by a colon - #hideNullJson("svc-request-id",$svc-request-id)#end -## override default settings so the comma isn't written - #hideNullJson("svc-action",$svc-action, true, true, false)#end - }, - "service-information": { -## if we look at the values in parameters we see service-type is already surrounded by quotes -## we override the default so the string isn't surrounded by excess quotes - #hideNullJson("service-type",$service-type,true,false,true)#end -## the first parameter doesn't need to be a literal - #hideNullJson($customerNameTag,$customer-name)#end -## if the first parameter already has already been quoted we can override the default - #hideNullJson($siidTag,$service-instance-id,false,true,false)#end - #hideNullJson("customer-phone-number",$customer-phone-number)#end - } - } -} \ No newline at end of file -- cgit From 02c666d1f6d40158a004a946a507c16e4ad5a70c Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 6 Feb 2019 20:26:17 +0000 Subject: template node packaging patch including ccsdk-sli features in ccsdk-template-node pom Change-Id: I5ac79f5e61c112da2a7fab164b2ee1a9479eabb5 Issue-ID: CCSDK-1043 Signed-off-by: Smokowski, Kevin (ks6305) --- template-node/features/ccsdk-template-node/pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index 442cc40ac..e43381f39 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -19,6 +19,13 @@ ccsdk-sli-plugins :: template-node :: ${project.artifactId} + + org.onap.ccsdk.sli.core + ccsdk-sli + ${ccsdk.sli.core.version} + xml + features + ${project.groupId} template-node-provider -- cgit From 77a8961d8a40afb557814802264aaab50291807f Mon Sep 17 00:00:00 2001 From: janani b Date: Thu, 7 Feb 2019 19:21:55 +0530 Subject: Resolution for jersey version conflict Moved the glassfish version of jersey to point to 2.25.1 as to that of odl Issue-ID: CCSDK-1034 Change-Id: Ia245f3f49f035b45ce9668d334b05a70254272d6 Signed-off-by: janani b --- features/ccsdk-sli-plugins-all/pom.xml | 4 ++-- restapi-call-node/provider/pom.xml | 17 +++++++++-------- restconf-client/provider/pom.xml | 18 +++++++++--------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index 2c4e4c615..7d9068e88 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -25,7 +25,7 @@ xml features - + ${project.groupId} ccsdk-template-node diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 52178540c..5b34153d8 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -49,15 +49,20 @@ org.slf4j slf4j-api + + org.glassfish.jersey.bundles.repackaged + jersey-guava + 2.22.2 + org.glassfish.jersey.security oauth1-signature - ${glassfish.version} + ${jersey.version} org.glassfish.jersey.security oauth1-client - ${glassfish.version} + ${jersey.version} org.codehaus.jettison @@ -66,14 +71,10 @@ org.glassfish.jersey.core jersey-client - ${glassfish.version} - - - org.glassfish.jersey.inject - jersey-hk2 - ${glassfish.version} + ${jersey.version} + junit diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index e94671902..0dae6960e 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -36,7 +36,7 @@ org.glassfish.jersey.media jersey-media-sse - ${glassfish.version} + ${jersey.version} javax.ws.rs @@ -103,22 +103,16 @@ ${mockito.version} test - - org.glassfish.jersey.inject - jersey-hk2 - ${glassfish.version} - test - org.glassfish.jersey.containers jersey-container-servlet - ${glassfish.version} + ${jersey.version} test org.glassfish.jersey.containers jersey-container-grizzly2-http - ${glassfish.version} + ${jersey.version} test @@ -133,5 +127,11 @@ 2.0.6.1 test + + org.glassfish.jersey.core + jersey-client + ${jersey.version} + test + -- cgit From 35f6854436afefc3083acd665689b00abd49a060 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Thu, 14 Feb 2019 20:10:03 +0000 Subject: RestApiCallNode header changes allow the http header Accept to be set independently from the http header Content-Type Change-Id: I66fd846cec065a12afe7111c644aa373b61cf424 Issue-ID: CCSDK-1077 Signed-off-by: Smokowski, Kevin (ks6305) --- .../ccsdk/sli/plugins/restapicall/Parameters.java | 1 + .../sli/plugins/restapicall/RestapiCallNode.java | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java index d3fec37ee..8f65cf261 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java @@ -50,4 +50,5 @@ public class Parameters { public String oAuthVersion; public AuthType authtype; public Boolean returnRequestPayload; + public String accept; } diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 83b12c767..4c04c9d3b 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -165,6 +165,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { false, null)); p.returnRequestPayload = valueOf(parseParam( paramMap, "returnRequestPayload", false, null)); + p.accept = parseParam(paramMap, "accept", + false, null); return p; } @@ -631,14 +633,16 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { r.code = 200; if (!p.skipSending) { - String tt = p.format == Format.XML ? "application/xml" : "application/json"; - String tt1 = tt + ";charset=UTF-8"; - if (p.contentType != null) { - tt = p.contentType; - tt1 = p.contentType; + String accept = p.accept; + if(accept == null) { + accept = p.format == Format.XML ? "application/xml" : "application/json"; + } + String contentType = p.contentType; + if(contentType == null) { + contentType = accept + ";charset=UTF-8"; } - Invocation.Builder invocationBuilder = webTarget.request(tt1).accept(tt); + Invocation.Builder invocationBuilder = webTarget.request(contentType).accept(accept); if (p.format == Format.NONE) { invocationBuilder.header("", ""); @@ -658,7 +662,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { Response response; try { - response = invocationBuilder.method(p.httpMethod.toString(), entity(request, tt1)); + response = invocationBuilder.method(p.httpMethod.toString(), entity(request, contentType)); } catch (ProcessingException | IllegalStateException e) { throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e); @@ -1012,4 +1016,4 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { public String responsePrefix; public boolean skipSending; } -} \ No newline at end of file +} -- cgit From e973a0552cc500d02cec4dcaa6205196ef2193ba Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Tue, 19 Feb 2019 16:05:46 +0000 Subject: dependency cleanup remove sli-provider from template node and restapicallnode Change-Id: I21ffceaf085016b112b3fbe9144870b8d136772f Issue-ID: CCSDK-1093 Signed-off-by: Smokowski, Kevin (ks6305) --- restapi-call-node/provider/pom.xml | 4 ---- template-node/provider/pom.xml | 4 ---- 2 files changed, 8 deletions(-) diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 5b34153d8..9f0f1cebf 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -41,10 +41,6 @@ org.onap.ccsdk.sli.core sli-common - - org.onap.ccsdk.sli.core - sli-provider - org.slf4j slf4j-api diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index 23eee4d61..7434abc0f 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -37,10 +37,6 @@ org.onap.ccsdk.sli.core sli-common - - org.onap.ccsdk.sli.core - sli-provider - org.slf4j slf4j-api -- cgit From cbfe76ee4ebe01b5b6f6f98e9ae907a63e8f1a3d Mon Sep 17 00:00:00 2001 From: "Haddox, Anthony" Date: Fri, 1 Mar 2019 12:38:21 -0800 Subject: [CCSDK-1115]GR-Toolkit Refactor Refactor of the provider module to resolve issues identified by SonarQube scans. Change-Id: Iff714123f34468359a7ec9f8d02a691027af15ed Issue-ID: CCSDK-1115 Signed-off-by: Haddox, Anthony --- .../onap/ccsdk/sli/plugins/GrToolkitProvider.java | 581 +++++++++++---------- .../org/onap/ccsdk/sli/plugins/GrToolkitUtil.java | 91 ---- .../onap/ccsdk/sli/plugins/data/ClusterActor.java | 31 +- .../onap/ccsdk/sli/plugins/data/MemberBuilder.java | 27 +- 4 files changed, 329 insertions(+), 401 deletions(-) delete mode 100755 grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitUtil.java diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitProvider.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitProvider.java index f0a104de8..dc8534be2 100755 --- a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitProvider.java +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitProvider.java @@ -35,16 +35,15 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.Map; import java.util.Properties; import java.util.List; -import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.annotation.Nonnull; -import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; @@ -60,8 +59,6 @@ import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterfa import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.AdminHealthInput; @@ -99,18 +96,19 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataTreeChangeListener { + private static final String APP_NAME = "gr-toolkit"; private static final String PROPERTIES_FILE = System.getenv("SDNC_CONFIG_DIR") + "/gr-toolkit.properties"; private static final String HEALTHY = "HEALTHY"; private static final String FAULTY = "FAULTY"; - private static String AKKA_CONFIG; - private static String JOLOKIA_CLUSTER_PATH; - private static String SHARD_MANAGER_PATH; - private static String SHARD_PATH_TEMPLATE; - private static String CREDENTIALS; - private static String HTTP_PROTOCOL; - private static String SITE_IDENTIFIER = System.getenv("SITE_NAME"); + private static final String VALUE = "value"; + private String akkaConfig; + private String jolokiaClusterPath; + private String shardManagerPath; + private String shardPathTemplate; + private String credentials; + private String httpProtocol; + private String siteIdentifier = System.getenv("SITE_NAME"); private final Logger log = LoggerFactory.getLogger(GrToolkitProvider.class); - private final String appName = "gr-toolkit"; private final ExecutorService executor; protected DataBroker dataBroker; protected NotificationPublishService notificationService; @@ -119,7 +117,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT protected DbLibService dbLib; private String member; private ClusterActor self; - private HashMap members; + private HashMap memberMap; private SiteConfiguration siteConfiguration; private Properties properties; private DistributedDataStoreInterface configDatastore; @@ -128,7 +126,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT RpcProviderRegistry rpcProviderRegistry, DistributedDataStoreInterface configDatastore, DbLibService dbLibService) { - this.log.info("Creating provider for " + appName); + this.log.info("Creating provider for {}", APP_NAME); this.executor = Executors.newFixedThreadPool(1); this.dataBroker = dataBroker; this.notificationService = notificationProviderService; @@ -138,25 +136,19 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT initialize(); } - public void initialize() { - log.info("Initializing provider for " + appName); + private void initialize() { + log.info("Initializing provider for {}", APP_NAME); // Create the top level containers createContainers(); - try { - GrToolkitUtil.loadProperties(); - } catch (Exception e) { - log.error("Caught Exception while trying to load properties file.", e); - } - setProperties(); defineMembers(); rpcRegistration = rpcRegistry.addRpcImplementation(GrToolkitService.class, this); - log.info("Initialization complete for " + appName); + log.info("Initialization complete for {}", APP_NAME); } private void setProperties() { - log.info("Loading properties from " + PROPERTIES_FILE); + log.info("Loading properties from {}", PROPERTIES_FILE); properties = new Properties(); File propertiesFile = new File(PROPERTIES_FILE); if(!propertiesFile.exists()) { @@ -165,19 +157,19 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT } try(FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { properties.load(fileInputStream); - if(!properties.containsKey("site.identifier")) { - properties.put("site.identifier", "Unknown Site"); + if(!properties.containsKey(PropertyKeys.SITE_IDENTIFIER)) { + properties.put(PropertyKeys.SITE_IDENTIFIER, "Unknown Site"); } - String port = "true".equals(properties.getProperty("controller.useSsl").trim()) ? properties.getProperty("controller.port.ssl").trim() : properties.getProperty("controller.port.http").trim(); - HTTP_PROTOCOL = "true".equals(properties.getProperty("controller.useSsl").trim()) ? "https://" : "http://"; - AKKA_CONFIG = properties.getProperty("akka.conf.location").trim(); - JOLOKIA_CLUSTER_PATH = ":" + port + properties.getProperty("mbean.cluster").trim(); - SHARD_MANAGER_PATH = ":" + port + properties.getProperty("mbean.shardManager").trim(); - SHARD_PATH_TEMPLATE = ":" + port + properties.getProperty("mbean.shard.config").trim(); - if(SITE_IDENTIFIER == null || SITE_IDENTIFIER.isEmpty()) { - SITE_IDENTIFIER = properties.getProperty("site.identifier").trim(); + String port = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL).trim()) ? properties.getProperty(PropertyKeys.CONTROLLER_PORT_SSL).trim() : properties.getProperty(PropertyKeys.CONTROLLER_PORT_HTTP).trim(); + httpProtocol = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL).trim()) ? "https://" : "http://"; + akkaConfig = properties.getProperty(PropertyKeys.AKKA_CONF_LOCATION).trim(); + jolokiaClusterPath = ":" + port + properties.getProperty(PropertyKeys.MBEAN_CLUSTER).trim(); + shardManagerPath = ":" + port + properties.getProperty(PropertyKeys.MBEAN_SHARD_MANAGER).trim(); + shardPathTemplate = ":" + port + properties.getProperty(PropertyKeys.MBEAN_SHARD_CONFIG).trim(); + if(siteIdentifier == null || siteIdentifier.isEmpty()) { + siteIdentifier = properties.getProperty(PropertyKeys.SITE_IDENTIFIER).trim(); } - CREDENTIALS = properties.getProperty("controller.credentials").trim(); + credentials = properties.getProperty(PropertyKeys.CONTROLLER_CREDENTIALS).trim(); log.info("Loaded properties."); } catch(IOException e) { log.error("Error loading properties.", e); @@ -186,38 +178,29 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT private void defineMembers() { member = configDatastore.getActorContext().getCurrentMemberName().getName(); - log.info("Cluster member: " + member); + log.info("Cluster member: {}", member); - log.info("Parsing akka.conf for cluster members..."); + log.info("Parsing akka.conf for cluster memberMap..."); try { - File akkaConfig = new File(AKKA_CONFIG); - FileReader fileReader = new FileReader(akkaConfig); - BufferedReader bufferedReader = new BufferedReader(fileReader); - String line; - while((line = bufferedReader.readLine()) != null) { - if(line.contains("seed-nodes =")) { - parseSeedNodes(line); - break; + File akkaConfigFile = new File(this.akkaConfig); + try(FileReader fileReader = new FileReader(akkaConfigFile); + BufferedReader bufferedReader = new BufferedReader(fileReader)) { + String line; + while((line = bufferedReader.readLine()) != null) { + if(line.contains("seed-nodes =")) { + parseSeedNodes(line); + break; + } } } - bufferedReader.close(); - fileReader.close(); } catch(IOException e) { log.error("Couldn't load akka", e); } - log.info("self:\n{}", self.toString()); + log.info("self:\n{}", self); } private void createContainers() { - final WriteTransaction t = dataBroker.newReadWriteTransaction(); - try { - CheckedFuturecheckedFuture = t.submit(); - checkedFuture.get(); - log.info("Create Containers succeeded!"); - } catch (InterruptedException | ExecutionException e) { - log.error("Create Containers Failed: " + e); - log.error("context", e); - } + // Replace with MD-SAL write for FailoverStatus } protected void initializeChild() { @@ -226,10 +209,10 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT @Override public void close() throws Exception { - log.info("Closing provider for " + appName); + log.info("Closing provider for {}", APP_NAME); executor.shutdown(); rpcRegistration.close(); - log.info("Successfully closed provider for " + appName); + log.info("Successfully closed provider for {}", APP_NAME); } @Override @@ -239,21 +222,21 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT @Override public ListenableFuture> clusterHealth(ClusterHealthInput input) { - log.info(appName + ":cluster-health invoked."); + log.info("{}:cluster-health invoked.", APP_NAME); getControllerHealth(); return buildClusterHealthOutput("200"); } @Override public ListenableFuture> siteHealth(SiteHealthInput input) { - log.info(appName + ":site-health invoked."); + log.info("{}:site-health invoked.", APP_NAME); getControllerHealth(); return buildSiteHealthOutput("200", getAdminHealth(), getDatabaseHealth()); } @Override public ListenableFuture> databaseHealth(DatabaseHealthInput input) { - log.info(appName + ":database-health invoked."); + log.info("{}:database-health invoked.", APP_NAME); DatabaseHealthOutputBuilder outputBuilder = new DatabaseHealthOutputBuilder(); outputBuilder.setStatus("200"); outputBuilder.setHealth(getDatabaseHealth()); @@ -263,7 +246,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT @Override public ListenableFuture> adminHealth(AdminHealthInput input) { - log.info(appName + ":admin-health invoked."); + log.info("{}:admin-health invoked.", APP_NAME); AdminHealthOutputBuilder outputBuilder = new AdminHealthOutputBuilder(); outputBuilder.setStatus("200"); outputBuilder.setHealth(getAdminHealth()); @@ -273,41 +256,41 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT @Override public ListenableFuture> haltAkkaTraffic(HaltAkkaTrafficInput input) { - log.info(appName + ":halt-akka-traffic invoked."); + log.info("{}:halt-akka-traffic invoked.", APP_NAME); HaltAkkaTrafficOutputBuilder outputBuilder = new HaltAkkaTrafficOutputBuilder(); outputBuilder.setStatus("200"); - modifyIpTables(IpTables.Add, input.getNodeInfo().toArray()); + modifyIpTables(IpTables.ADD, input.getNodeInfo().toArray()); return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); } @Override public ListenableFuture> resumeAkkaTraffic(ResumeAkkaTrafficInput input) { - log.info(appName + ":resume-akka-traffic invoked."); + log.info("{}:resume-akka-traffic invoked.", APP_NAME); ResumeAkkaTrafficOutputBuilder outputBuilder = new ResumeAkkaTrafficOutputBuilder(); outputBuilder.setStatus("200"); - modifyIpTables(IpTables.Delete, input.getNodeInfo().toArray()); + modifyIpTables(IpTables.DELETE, input.getNodeInfo().toArray()); return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); } @Override public ListenableFuture> siteIdentifier(SiteIdentifierInput input) { - log.info(appName + ":site-identifier invoked."); + log.info("{}:site-identifier invoked.", APP_NAME); SiteIdentifierOutputBuilder outputBuilder = new SiteIdentifierOutputBuilder(); outputBuilder.setStatus("200"); - outputBuilder.setId(SITE_IDENTIFIER); + outputBuilder.setId(siteIdentifier); return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); } @Override public ListenableFuture> failover(FailoverInput input) { - log.info(appName + ":failover invoked."); + log.info("{}:failover invoked.", APP_NAME); FailoverOutputBuilder outputBuilder = new FailoverOutputBuilder(); - if(siteConfiguration != SiteConfiguration.Geo) { - log.info("Cannot failover non-Geo site."); - outputBuilder.setMessage("Failover aborted. This is not a Geo configuration."); + if(siteConfiguration != SiteConfiguration.GEO) { + log.info("Cannot failover non-GEO site."); + outputBuilder.setMessage("Failover aborted. This is not a GEO configuration."); outputBuilder.setStatus("400"); return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); } @@ -319,41 +302,91 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT getControllerHealth(); log.info("Determining active site..."); - for(String key : members.keySet()) { - if(members.get(key).isVoting()) { - activeSite.add(members.get(key)); - log.debug("Active Site member: " + key); + for(Map.Entry entry : memberMap.entrySet()) { + String key = entry.getKey(); + ClusterActor clusterActor = entry.getValue(); + if(clusterActor.isVoting()) { + activeSite.add(clusterActor); + log.debug("Active Site member: {}", key); } else { - standbySite.add(members.get(key)); - log.debug("Standby Site member: " + key); + standbySite.add(clusterActor); + log.debug("Standby Site member: {}", key); } } - String port = "true".equals(properties.getProperty("controller.useSsl")) ? properties.getProperty("controller.port.ssl") : properties.getProperty("controller.port.http"); + String port = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL)) ? properties.getProperty(PropertyKeys.CONTROLLER_PORT_SSL) : properties.getProperty(PropertyKeys.CONTROLLER_PORT_HTTP); if(Boolean.parseBoolean(input.getBackupData())) { - log.info("Backing up data..."); - for(ClusterActor actor : activeSite) { - try { - // Schedule backup - log.info("Scheduling backup for: " + actor.getNode()); - getRequestContent(HTTP_PROTOCOL + actor.getNode() + ":" + port + "/restconf/operations/data-export-import:schedule-export", HttpMethod.Post, ""); - try { - // Move data offsite - log.info("Backing up data for: " + actor.getNode()); - getRequestContent(HTTP_PROTOCOL + actor.getNode() + ":" + port + "/restconf/operations/daexim-offsite-backup:backup-data", HttpMethod.Post); - } catch(IOException e) { - log.error("Error backing up data.", e); - throw e; - } - } - catch(IOException e) { - log.error("Error exporting MD-SAL data.", e); + backupMdSal(activeSite, port); + } + + if(!changeClusterVoting(outputBuilder, activeSite, standbySite, port)) + return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); + + if(Boolean.parseBoolean(input.getIsolate())) { + isolateSiteFromCluster(activeSite, standbySite, port); + + if(Boolean.parseBoolean(input.getDownUnreachable())) { + downUnreachableNodes(activeSite, standbySite, port); + } + } + + log.info("{}:failover complete.", APP_NAME); + + outputBuilder.setMessage("Failover complete."); + outputBuilder.setStatus("200"); + return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); + } + + private void isolateSiteFromCluster(ArrayList activeSite, ArrayList standbySite, String port) { + log.info("Halting Akka traffic..."); + for(ClusterActor actor : standbySite) { + try { + log.info("Halting Akka traffic for: {}", actor.getNode()); + // Build JSON with activeSite actor Node and actor AkkaPort + JSONObject akkaInput = new JSONObject(); + JSONObject inputBlock = new JSONObject(); + JSONArray votingStateArray = new JSONArray(); + JSONObject nodeInfo; + for(ClusterActor node : activeSite) { + nodeInfo = new JSONObject(); + nodeInfo.put("node", node.getNode()); + nodeInfo.put("port", node.getAkkaPort()); + votingStateArray.put(nodeInfo); } + inputBlock.put("node-info", votingStateArray); + akkaInput.put("input", inputBlock); + getRequestContent(httpProtocol + actor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:halt-akka-traffic", HttpMethod.POST, akkaInput.toString()); + } catch(IOException e) { + log.error("Could not halt Akka traffic for: " + actor.getNode(), e); } } + } + private void downUnreachableNodes(ArrayList activeSite, ArrayList standbySite, String port) { + log.info("Setting site unreachable..."); + JSONObject jolokiaInput = new JSONObject(); + jolokiaInput.put("type", "EXEC"); + jolokiaInput.put("mbean", "akka:type=Cluster"); + jolokiaInput.put("operation", "down"); + JSONArray arguments = new JSONArray(); + for(ClusterActor actor : activeSite) { + // Build Jolokia input + // May need to change from akka port to actor.getAkkaPort() + arguments.put("akka.tcp://opendaylight-cluster-data@" + actor.getNode() + ":" + properties.getProperty(PropertyKeys.CONTROLLER_PORT_AKKA)); + } + jolokiaInput.put("arguments", arguments); + log.debug("{}", jolokiaInput); + try { + log.info("Setting nodes unreachable"); + getRequestContent(httpProtocol + standbySite.get(0).getNode() + ":" + port + "/jolokia", HttpMethod.POST, jolokiaInput.toString()); + } catch(IOException e) { + log.error("Error setting nodes unreachable", e); + } + } + + private boolean changeClusterVoting(FailoverOutputBuilder outputBuilder, ArrayList activeSite, ArrayList standbySite, String port) { log.info("Changing voting for all shards to standby site..."); try { JSONObject votingInput = new JSONObject(); @@ -374,68 +407,35 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT } inputBlock.put("member-voting-state", votingStateArray); votingInput.put("input", inputBlock); - log.debug(votingInput.toString(2)); + log.debug("{}", votingInput); // Change voting all shards - getRequestContent(HTTP_PROTOCOL + self.getNode() + ":" + port + "/restconf/operations/cluster-admin:change-member-voting-states-for-all-shards", HttpMethod.Post, votingInput.toString()); + getRequestContent(httpProtocol + self.getNode() + ":" + port + "/restconf/operations/cluster-admin:change-member-voting-states-for-all-shards", HttpMethod.POST, votingInput.toString()); } catch(IOException e) { log.error("Changing voting", e); outputBuilder.setMessage("Failover aborted. Failed to change voting."); outputBuilder.setStatus("500"); - return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); + return false; } + return true; + } - if(Boolean.parseBoolean(input.getIsolate())) { - log.info("Halting Akka traffic..."); - for(ClusterActor actor : standbySite) { - try { - log.info("Halting Akka traffic for: " + actor.getNode()); - // Build JSON with activeSite actor.getNode() and actor.getAkkaPort(); - JSONObject akkaInput = new JSONObject(); - JSONObject inputBlock = new JSONObject(); - JSONArray votingStateArray = new JSONArray(); - JSONObject nodeInfo; - for(ClusterActor node : activeSite) { - nodeInfo = new JSONObject(); - nodeInfo.put("node", node.getNode()); - nodeInfo.put("port", node.getAkkaPort()); - votingStateArray.put(nodeInfo); - } - inputBlock.put("node-info", votingStateArray); - akkaInput.put("input", inputBlock); - getRequestContent(HTTP_PROTOCOL + actor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:halt-akka-traffic", HttpMethod.Post, akkaInput.toString()); - } catch(IOException e) { - log.error("Could not halt Akka traffic for: " + actor.getNode(), e); - } - } - - if(Boolean.parseBoolean(input.getDownUnreachable())) { - log.info("Setting site unreachable..."); - JSONObject jolokiaInput = new JSONObject(); - jolokiaInput.put("type", "EXEC"); - jolokiaInput.put("mbean", "akka:type=Cluster"); - jolokiaInput.put("operation", "down"); - JSONArray arguments = new JSONArray(); - for(ClusterActor actor : activeSite) { - // Build Jolokia input - //TODO: May need to change from akka port to actor.getAkkaPort() - arguments.put("akka.tcp://opendaylight-cluster-data@" + actor.getNode() + ":" + properties.getProperty("controller.port.akka")); - } - jolokiaInput.put("arguments", arguments); - log.debug(jolokiaInput.toString(2)); - try { - log.info("Setting nodes unreachable"); - getRequestContent(HTTP_PROTOCOL + standbySite.get(0).getNode() + ":" + port + "/jolokia", HttpMethod.Post, jolokiaInput.toString()); - } catch(IOException e) { - log.error("Error setting nodes unreachable", e); - } + private void backupMdSal(ArrayList activeSite, String port) { + log.info("Backing up data..."); + try { + log.info("Scheduling backup for: {}", activeSite.get(0).getNode()); + getRequestContent(httpProtocol + activeSite.get(0).getNode() + ":" + port + "/restconf/operations/data-export-import:schedule-export", HttpMethod.POST, "{ \"input\": { \"run-at\": \"30\" } }"); + } catch(IOException e) { + log.error("Error backing up MD-SAL", e); + } + for(ClusterActor actor : activeSite) { + try { + // Move data offsite + log.info("Backing up data for: {}", actor.getNode()); + getRequestContent(httpProtocol + actor.getNode() + ":" + port + "/restconf/operations/daexim-offsite-backup:backup-data", HttpMethod.POST); + } catch(IOException e) { + log.error("Error backing up data.", e); } } - - log.info(appName + ":failover complete."); - - outputBuilder.setMessage("Failover complete."); - outputBuilder.setStatus("200"); - return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); } private ListenableFuture> buildClusterHealthOutput(String statusCode) { @@ -445,33 +445,31 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT int site1Health = 0; int site2Health = 0; - for(String key : members.keySet()) { - if(members.get(key).isUp() && !members.get(key).isUnreachable()) { - if(ClusterActor.SITE_1.equals(members.get(key).getSite())) + for(Map.Entry entry : memberMap.entrySet()) { + ClusterActor clusterActor = entry.getValue(); + if(clusterActor.isUp() && !clusterActor.isUnreachable()) { + if(ClusterActor.SITE_1.equals(clusterActor.getSite())) site1Health++; - else if(ClusterActor.SITE_2.equals(members.get(key).getSite())) + else if(ClusterActor.SITE_2.equals(clusterActor.getSite())) site2Health++; } - outputBuilder.getMembers().add(new MemberBuilder(members.get(key)).build()); + outputBuilder.getMembers().add(new MemberBuilder(clusterActor).build()); } - if(siteConfiguration == SiteConfiguration.Solo) { + if(siteConfiguration == SiteConfiguration.SOLO) { + outputBuilder.setSite1Health(HEALTHY); + } + else if(site1Health > 1) { outputBuilder.setSite1Health(HEALTHY); } else { - if(site1Health > 1) { - outputBuilder.setSite1Health(HEALTHY); - } - else { - outputBuilder.setSite1Health(FAULTY); - } + outputBuilder.setSite1Health(FAULTY); } - if(siteConfiguration == SiteConfiguration.Geo) { - if(site2Health > 1) { - outputBuilder.setSite2Health(HEALTHY); - } - else { - outputBuilder.setSite2Health(FAULTY); - } + + if(siteConfiguration == SiteConfiguration.GEO && site2Health > 1) { + outputBuilder.setSite2Health(HEALTHY); + } + else if(siteConfiguration == SiteConfiguration.GEO) { + outputBuilder.setSite2Health(FAULTY); } RpcResult rpcResult = RpcResultBuilder.status(true).withResult(outputBuilder.build()).build(); @@ -483,21 +481,22 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT outputBuilder.setStatus(statusCode); outputBuilder.setSites((List) new ArrayList()); - if(siteConfiguration != SiteConfiguration.Geo) { + if(siteConfiguration != SiteConfiguration.GEO) { int healthyODLs = 0; SitesBuilder builder = new SitesBuilder(); - for(String key : members.keySet()) { - if(members.get(key).isUp() && !members.get(key).isUnreachable()) { + for(Map.Entry entry : memberMap.entrySet()) { + ClusterActor clusterActor = entry.getValue(); + if(clusterActor.isUp() && !clusterActor.isUnreachable()) { healthyODLs++; } } - if(siteConfiguration != SiteConfiguration.Solo) { + if(siteConfiguration != SiteConfiguration.SOLO) { builder.setHealth(HEALTHY); builder.setRole("ACTIVE"); - builder.setId(SITE_IDENTIFIER); + builder.setId(siteIdentifier); } else { - builder = getSitesBuilder(healthyODLs, true, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), SITE_IDENTIFIER); + builder = getSitesBuilder(healthyODLs, true, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), siteIdentifier); } outputBuilder.getSites().add(builder.build()); } @@ -510,65 +509,69 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT boolean crossSiteAdminHealthy = false; boolean crossSiteDbHealthy = false; String crossSiteIdentifier = "UNKNOWN_SITE"; - String port = "true".equals(properties.getProperty("controller.useSsl")) ? properties.getProperty("controller.port.ssl") : properties.getProperty("controller.port.http"); + String port = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL)) ? properties.getProperty(PropertyKeys.CONTROLLER_PORT_SSL) : properties.getProperty(PropertyKeys.CONTROLLER_PORT_HTTP); if(isSite1()) { // Make calls over to site 2 healthchecks - for(String key : members.keySet()) { - if(members.get(key).isUp() && !members.get(key).isUnreachable()) { - if(ClusterActor.SITE_1.equals(members.get(key).getSite())) { + for(Map.Entry entry : memberMap.entrySet()) { + ClusterActor clusterActor = entry.getValue(); + if(clusterActor.isUp() && !clusterActor.isUnreachable()) { + if(ClusterActor.SITE_1.equals(clusterActor.getSite())) { site1HealthyODLs++; - if(members.get(key).isVoting()) { + if(clusterActor.isVoting()) { site1Voting = true; } } else { site2HealthyODLs++; - if(members.get(key).isVoting()) { + if(clusterActor.isVoting()) { site2Voting = true; } if(!performedCrossSiteHealthCheck) { try { - String content = getRequestContent(HTTP_PROTOCOL + members.get(key).getNode() + ":" + port + "/restconf/operations/gr-toolkit:site-identifier", HttpMethod.Post); + String content = getRequestContent(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:site-identifier", HttpMethod.POST); crossSiteIdentifier = new JSONObject(content).getJSONObject("output").getString("id"); - crossSiteDbHealthy = crossSiteHealthRequest(HTTP_PROTOCOL + members.get(key).getNode() + ":" + port + "/restconf/operations/gr-toolkit:database-health"); - crossSiteAdminHealthy = crossSiteHealthRequest(HTTP_PROTOCOL + members.get(key).getNode() + ":" + port + "/restconf/operations/gr-toolkit:admin-health"); + crossSiteDbHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:database-health"); + crossSiteAdminHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:admin-health"); performedCrossSiteHealthCheck = true; } catch(Exception e) { - log.error("Cannot get site identifier from " + members.get(key).getNode(), e); + log.info("Cannot get site identifier from {}", clusterActor.getNode()); + log.error("Site Health Error", e); } } } } } - SitesBuilder builder = getSitesBuilder(site1HealthyODLs, site1Voting, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), SITE_IDENTIFIER); + SitesBuilder builder = getSitesBuilder(site1HealthyODLs, site1Voting, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), siteIdentifier); outputBuilder.getSites().add(builder.build()); builder = getSitesBuilder(site2HealthyODLs, site2Voting, crossSiteAdminHealthy, crossSiteDbHealthy, crossSiteIdentifier); outputBuilder.getSites().add(builder.build()); } else { // Make calls over to site 1 healthchecks - for(String key : members.keySet()) { - if(members.get(key).isUp() && !members.get(key).isUnreachable()) { - if(ClusterActor.SITE_1.equals(members.get(key).getSite())) { + for(Map.Entry entry : memberMap.entrySet()) { + ClusterActor clusterActor = entry.getValue(); + if(clusterActor.isUp() && !clusterActor.isUnreachable()) { + if(ClusterActor.SITE_1.equals(clusterActor.getSite())) { site1HealthyODLs++; - if(members.get(key).isVoting()) { + if(clusterActor.isVoting()) { site1Voting = true; } if(!performedCrossSiteHealthCheck) { try { - String content = getRequestContent(HTTP_PROTOCOL + members.get(key).getNode() + ":" + port + "/restconf/operations/gr-toolkit:site-identifier", HttpMethod.Post); + String content = getRequestContent(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:site-identifier", HttpMethod.POST); crossSiteIdentifier = new JSONObject(content).getJSONObject("output").getString("id"); - crossSiteDbHealthy = crossSiteHealthRequest(HTTP_PROTOCOL + members.get(key).getNode() + ":" + port + "/restconf/operations/gr-toolkit:database-health"); - crossSiteAdminHealthy = crossSiteHealthRequest(HTTP_PROTOCOL + members.get(key).getNode() + ":" + port + "/restconf/operations/gr-toolkit:admin-health"); + crossSiteDbHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:database-health"); + crossSiteAdminHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:admin-health"); performedCrossSiteHealthCheck = true; } catch(Exception e) { - log.error("Cannot get site identifier from " + members.get(key).getNode(), e); + log.info("Cannot get site identifier from {}", clusterActor.getNode()); + log.error("Site Health Error", e); } } } else { site2HealthyODLs++; - if(members.get(key).isVoting()) { + if(clusterActor.isVoting()) { site2Voting = true; } } @@ -577,7 +580,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT // Build Output SitesBuilder builder = getSitesBuilder(site1HealthyODLs, site1Voting, crossSiteAdminHealthy, crossSiteDbHealthy, crossSiteIdentifier); outputBuilder.getSites().add(builder.build()); - builder = getSitesBuilder(site2HealthyODLs, site2Voting, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), SITE_IDENTIFIER); + builder = getSitesBuilder(site2HealthyODLs, site2Voting, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), siteIdentifier); outputBuilder.getSites().add(builder.build()); } } @@ -592,15 +595,15 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT builder.setHealth(HEALTHY); } else { - log.warn(siteIdentifier + " Healthy ODLs: " + siteHealthyODLs); + log.warn("{} Healthy ODLs: {}", siteIdentifier, siteHealthyODLs); builder.setHealth(FAULTY); } if(!adminHealthy) { - log.warn(siteIdentifier + " Admin Health: " + FAULTY); + log.warn("{} Admin Health: {}", siteIdentifier, FAULTY); builder.setHealth(FAULTY); } if(!dbHealthy) { - log.warn(siteIdentifier + " Database Health: " + FAULTY); + log.warn("{} Database Health: {}", siteIdentifier, FAULTY); builder.setHealth(FAULTY); } if(siteVoting) { @@ -616,21 +619,21 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT private boolean isSite1() { int memberNumber = Integer.parseInt(member.split("-")[1]); boolean isSite1 = memberNumber < 4; - log.info("isSite1(): " + isSite1); + log.info("isSite1(): {}", isSite1); return isSite1; } private void parseSeedNodes(String line) { - members = new HashMap<>(); - line = line.substring(line.indexOf("[\""), line.indexOf("]")); + memberMap = new HashMap<>(); + line = line.substring(line.indexOf("[\""), line.indexOf(']')); String[] splits = line.split(","); for(int ndx = 0; ndx < splits.length; ndx++) { String nodeName = splits[ndx]; - int delimLocation = nodeName.indexOf("@"); - String port = nodeName.substring(splits[ndx].indexOf(":", delimLocation) + 1, splits[ndx].indexOf("\"", splits[ndx].indexOf(":"))); - splits[ndx] = nodeName.substring(delimLocation + 1, splits[ndx].indexOf(":", delimLocation)); - log.info("Adding node: " + splits[ndx] + ":" + port); + int delimLocation = nodeName.indexOf('@'); + String port = nodeName.substring(splits[ndx].indexOf(':', delimLocation) + 1, splits[ndx].indexOf('"', splits[ndx].indexOf(':'))); + splits[ndx] = nodeName.substring(delimLocation + 1, splits[ndx].indexOf(':', delimLocation)); + log.info("Adding node: {}:{}", splits[ndx], port); ClusterActor clusterActor = new ClusterActor(); clusterActor.setNode(splits[ndx]); clusterActor.setAkkaPort(port); @@ -645,44 +648,44 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT if(member.equals(clusterActor.getMember())) { self = clusterActor; } - members.put(clusterActor.getNode(), clusterActor); - log.info(clusterActor.toString()); + memberMap.put(clusterActor.getNode(), clusterActor); + log.info("{}", clusterActor); } - if(members.size() == 1) { + if(memberMap.size() == 1) { log.info("1 member found. This is a solo environment."); - siteConfiguration = SiteConfiguration.Solo; + siteConfiguration = SiteConfiguration.SOLO; } - else if(members.size() == 3) { + else if(memberMap.size() == 3) { log.info("This is a single site."); - siteConfiguration = SiteConfiguration.Single; + siteConfiguration = SiteConfiguration.SINGLE; } - else if(members.size() == 6) { + else if(memberMap.size() == 6) { log.info("This is a georedundant site."); - siteConfiguration = SiteConfiguration.Geo; + siteConfiguration = SiteConfiguration.GEO; } } private void getMemberStatus(ClusterActor clusterActor) throws IOException { - log.info("Getting member status for " + clusterActor.getNode()); - String content = getRequestContent(HTTP_PROTOCOL + clusterActor.getNode() + JOLOKIA_CLUSTER_PATH, HttpMethod.Get); + log.info("Getting member status for {}", clusterActor.getNode()); + String content = getRequestContent(httpProtocol + clusterActor.getNode() + jolokiaClusterPath, HttpMethod.GET); try { JSONObject responseJson = new JSONObject(content); - JSONObject responseValue = responseJson.getJSONObject("value"); + JSONObject responseValue = responseJson.getJSONObject(VALUE); clusterActor.setUp("Up".equals(responseValue.getString("MemberStatus"))); clusterActor.setUnreachable(false); } catch(JSONException e) { - log.error("Error parsing response from " + clusterActor.getNode(), e); + log.error("Error parsing response from {}", clusterActor.getNode(), e); clusterActor.setUp(false); clusterActor.setUnreachable(true); } } private void getShardStatus(ClusterActor clusterActor) throws IOException { - log.info("Getting shard status for " + clusterActor.getNode()); - String content = getRequestContent(HTTP_PROTOCOL + clusterActor.getNode() + SHARD_MANAGER_PATH, HttpMethod.Get); + log.info("Getting shard status for {}", clusterActor.getNode()); + String content = getRequestContent(httpProtocol + clusterActor.getNode() + shardManagerPath, HttpMethod.GET); try { - JSONObject responseValue = new JSONObject(content).getJSONObject("value"); + JSONObject responseValue = new JSONObject(content).getJSONObject(VALUE); JSONArray shardList = responseValue.getJSONArray("LocalShards"); String pattern = "-config$"; @@ -692,8 +695,8 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT String configShardName = shardList.getString(ndx); m = r.matcher(configShardName); String operationalShardName = m.replaceFirst("-operational"); - String shardConfigPath = String.format(SHARD_PATH_TEMPLATE, configShardName); - String shardOperationalPath = String.format(SHARD_PATH_TEMPLATE, operationalShardName).replace("Config", "Operational"); + String shardConfigPath = String.format(shardPathTemplate, configShardName); + String shardOperationalPath = String.format(shardPathTemplate, operationalShardName).replace("Config", "Operational"); extractShardInfo(clusterActor, configShardName, shardConfigPath); extractShardInfo(clusterActor, operationalShardName, shardOperationalPath); } @@ -703,13 +706,13 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT } private void extractShardInfo(ClusterActor clusterActor, String shardName, String shardPath) throws IOException { - log.info("Extracting shard info for " + shardName); - log.debug("Pulling config info for " + shardName + " from: " + shardPath); - String content = getRequestContent(HTTP_PROTOCOL + clusterActor.getNode() + shardPath, HttpMethod.Get); - log.debug("Response: " + content); + log.info("Extracting shard info for {}", shardName); + log.debug("Pulling config info for {} from: {}", shardName, shardPath); + String content = getRequestContent(httpProtocol + clusterActor.getNode() + shardPath, HttpMethod.GET); + log.debug("Response: {}", content); try { - JSONObject shardValue = new JSONObject(content).getJSONObject("value"); + JSONObject shardValue = new JSONObject(content).getJSONObject(VALUE); clusterActor.setVoting(shardValue.getBoolean("Voting")); if(shardValue.getString("PeerAddresses").length() > 0) { clusterActor.getReplicaShards().add(shardName); @@ -735,74 +738,72 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT } private void getControllerHealth() { - ClusterActor clusterActor; - for(String key : members.keySet()) { + for(Map.Entry entry : memberMap.entrySet()) { + ClusterActor clusterActor = entry.getValue(); + String key = entry.getKey(); try { - clusterActor = members.get(key); // First flush out the old values clusterActor.flush(); - log.info("Gathering info for " + clusterActor.getNode()); + log.info("Gathering info for {}", clusterActor.getNode()); getMemberStatus(clusterActor); getShardStatus(clusterActor); - log.info("MemberInfo:\n" + clusterActor.toString()); + log.info("MemberInfo:\n{}", clusterActor); } catch(IOException e) { log.error("Connection Error", e); - members.get(key).setUnreachable(true); - members.get(key).setUp(false); - log.info("MemberInfo:\n" + members.get(key).toString()); + memberMap.get(key).setUnreachable(true); + memberMap.get(key).setUp(false); + log.info("MemberInfo:\n{}", memberMap.get(key)); } } } private void modifyIpTables(IpTables task, Object[] nodeInfo) { log.info("Modifying IPTables rules..."); - switch(task) - { - case Add: - for(Object node : nodeInfo) { - org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.halt.akka.traffic.input.NodeInfo n = - (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.halt.akka.traffic.input.NodeInfo) node; - log.info("Isolating " + n.getNode()); - executeCommand(String.format("sudo /sbin/iptables -A INPUT -p tcp --destination-port %s -j DROP -s %s", properties.get("controller.port.akka"), n.getNode())); - executeCommand(String.format("sudo /sbin/iptables -A OUTPUT -p tcp --destination-port %s -j DROP -s %s", n.getPort(), n.getNode())); - } - break; - case Delete: - for(Object node : nodeInfo) { - org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.resume.akka.traffic.input.NodeInfo n = - (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.resume.akka.traffic.input.NodeInfo) node; - log.info("De-isolating " + n.getNode()); - executeCommand(String.format("sudo /sbin/iptables -D INPUT -p tcp --destination-port %s -j DROP -s %s", properties.get("controller.port.akka"), n.getNode())); - executeCommand(String.format("sudo /sbin/iptables -D OUTPUT -p tcp --destination-port %s -j DROP -s %s", n.getPort(), n.getNode())); - } - break; + if(task == IpTables.ADD) { + for(Object node : nodeInfo) { + org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.halt.akka.traffic.input.NodeInfo n = + (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.halt.akka.traffic.input.NodeInfo) node; + log.info("Isolating {}", n.getNode()); + executeCommand(String.format("sudo /sbin/iptables -A INPUT -p tcp --destination-port %s -j DROP -s %s", properties.get(PropertyKeys.CONTROLLER_PORT_AKKA), n.getNode())); + executeCommand(String.format("sudo /sbin/iptables -A OUTPUT -p tcp --destination-port %s -j DROP -s %s", n.getPort(), n.getNode())); + } + + } else if(task == IpTables.DELETE) { + for(Object node : nodeInfo) { + org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.resume.akka.traffic.input.NodeInfo n = + (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.resume.akka.traffic.input.NodeInfo) node; + log.info("De-isolating {}", n.getNode()); + executeCommand(String.format("sudo /sbin/iptables -D INPUT -p tcp --destination-port %s -j DROP -s %s", properties.get(PropertyKeys.CONTROLLER_PORT_AKKA), n.getNode())); + executeCommand(String.format("sudo /sbin/iptables -D OUTPUT -p tcp --destination-port %s -j DROP -s %s", n.getPort(), n.getNode())); + } + } executeCommand("sudo /sbin/iptables -L"); } private void executeCommand(String command) { - log.info("Executing command: " + command); + log.info("Executing command: {}", command); String[] cmd = command.split(" "); try { Process p = Runtime.getRuntime().exec(cmd); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(p.getInputStream())); String inputLine; - StringBuffer content = new StringBuffer(); + StringBuilder content = new StringBuilder(); while((inputLine = bufferedReader.readLine()) != null) { content.append(inputLine); } bufferedReader.close(); - log.info(content.toString()); + log.info("{}", content); } catch(IOException e) { log.error("Error executing command", e); } } private boolean crossSiteHealthRequest(String path) throws IOException { - String content = getRequestContent(path, HttpMethod.Post); + String content = getRequestContent(path, HttpMethod.POST); try { JSONObject responseJson = new JSONObject(content); - JSONObject responseValue = responseJson.getJSONObject("value"); + JSONObject responseValue = responseJson.getJSONObject(VALUE); return HEALTHY.equals(responseValue.getString("health")); } catch(JSONException e) { log.error("Error parsing JSON", e); @@ -811,13 +812,13 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT } private String getAdminHealth() { - String protocol = "true".equals(properties.getProperty("adm.useSsl")) ? "https://" : "http://"; - String port = "true".equals(properties.getProperty("adm.useSsl")) ? properties.getProperty("adm.port.ssl") : properties.getProperty("adm.port.http"); - String path = protocol + properties.getProperty("adm.fqdn") + ":" + port + properties.getProperty("adm.healthcheck"); - log.info("Requesting healthcheck from " + path); + String protocol = "true".equals(properties.getProperty(PropertyKeys.ADM_USE_SSL)) ? "https://" : "http://"; + String port = "true".equals(properties.getProperty(PropertyKeys.ADM_USE_SSL)) ? properties.getProperty(PropertyKeys.ADM_PORT_SSL) : properties.getProperty(PropertyKeys.ADM_PORT_HTTP); + String path = protocol + properties.getProperty(PropertyKeys.ADM_FQDN) + ":" + port + properties.getProperty(PropertyKeys.ADM_HEALTHCHECK); + log.info("Requesting healthcheck from {}", path); try { - int response = getRequestStatus(path, HttpMethod.Get); - log.info("Response: " + response); + int response = getRequestStatus(path, HttpMethod.GET); + log.info("Response: {}", response); if(response == 200) return HEALTHY; return FAULTY; @@ -830,9 +831,9 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT private String getDatabaseHealth() { log.info("Determining database health..."); try { - log.info("DBLib isActive(): " + dbLib.isActive()); - log.info("DBLib isReadOnly(): " + dbLib.getConnection().isReadOnly()); - log.info("DBLib isClosed(): " + dbLib.getConnection().isClosed()); + log.info("DBLib isActive(): {}", dbLib.isActive()); + log.info("DBLib isReadOnly(): {}", dbLib.getConnection().isReadOnly()); + log.info("DBLib isClosed(): {}", dbLib.getConnection().isClosed()); if(!dbLib.isActive() || dbLib.getConnection().isClosed() || dbLib.getConnection().isReadOnly()) { log.warn("Database is FAULTY"); return FAULTY; @@ -862,7 +863,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream())); String inputLine; - StringBuffer content = new StringBuffer(); + StringBuilder content = new StringBuilder(); while((inputLine = bufferedReader.readLine()) != null) { content.append(inputLine); } @@ -884,7 +885,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT sendPayload(input, connection); } int response = connection.getResponseCode(); - log.info("Received " + response + " response code from " + path); + log.info("Received {} response code from {}", response, path); connection.disconnect(); return response; } @@ -903,9 +904,9 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT } private HttpURLConnection getConnection(String host) throws IOException { - log.info("Getting connection to: " + host); + log.info("Getting connection to: {}", host); URL url = new URL(host); - String auth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(CREDENTIALS.getBytes()); + String auth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(credentials.getBytes()); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.addRequestProperty("Authorization", auth); connection.setRequestProperty("Connection", "keep-alive"); @@ -914,19 +915,19 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT } private enum IpTables { - Add, - Delete + ADD, + DELETE } private enum SiteConfiguration { - Solo, - Single, - Geo + SOLO, + SINGLE, + GEO } private enum HttpMethod { - Get("GET"), - Post("POST"); + GET("GET"), + POST("POST"); private String method; HttpMethod(String method) { @@ -936,4 +937,22 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT return method; } } + + private class PropertyKeys { + static final String SITE_IDENTIFIER = "site.identifier"; + static final String CONTROLLER_USE_SSL = "controller.useSsl"; + static final String CONTROLLER_PORT_SSL = "controller.port.ssl"; + static final String CONTROLLER_PORT_HTTP = "controller.port.http"; + static final String CONTROLLER_PORT_AKKA = "controller.port.akka"; + static final String CONTROLLER_CREDENTIALS = "controller.credentials"; + static final String AKKA_CONF_LOCATION = "akka.conf.location"; + static final String MBEAN_CLUSTER = "mbean.cluster"; + static final String MBEAN_SHARD_MANAGER = "mbean.shardManager"; + static final String MBEAN_SHARD_CONFIG = "mbean.shard.config"; + static final String ADM_USE_SSL = "adm.useSsl"; + static final String ADM_PORT_SSL = "adm.port.ssl"; + static final String ADM_PORT_HTTP = "adm.port.http"; + static final String ADM_FQDN = "adm.fqdn"; + static final String ADM_HEALTHCHECK= "adm.healthcheck"; + } } \ No newline at end of file diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitUtil.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitUtil.java deleted file mode 100755 index 7f91467a5..000000000 --- a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitUtil.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2018 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; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ClusterHealthOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteHealthOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.site.health.output.SitesBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.DatabaseHealthOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.AdminHealthOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.HaltAkkaTrafficOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ResumeAkkaTrafficOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteIdentifierOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverInputBuilder; - - -import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class GrToolkitUtil extends MdsalHelper { - private static final Logger LOG = LoggerFactory.getLogger(GrToolkitUtil.class); - public static String PROPERTIES_FILE = "/opt/opendaylight/current/controller/configuration/gr-toolkit.properties"; - - public static void loadProperties() { - File file = new File(PROPERTIES_FILE); - Properties properties = new Properties(); - InputStream input = null; - if(file.isFile() && file.canRead()) { - try { - input = new FileInputStream(file); - properties.load(input); - LOG.info("Loaded properties from " + PROPERTIES_FILE); - setProperties(properties); - } catch (Exception e) { - LOG.error("Failed to load properties " + PROPERTIES_FILE + "\n", e); - } finally { - if(input != null) { - try { - input.close(); - } catch (IOException e) { - LOG.error("Failed to close properties file " + PROPERTIES_FILE + "\n", e); - } - } - } - } - } - - static { - // Trick class loader into loading builders. Some of - // these will be needed later by Reflection classes, but need - // to explicitly "new" them here to get class loader to load them. - - ClusterHealthOutputBuilder b1 = new ClusterHealthOutputBuilder(); - SiteHealthOutputBuilder b2 = new SiteHealthOutputBuilder(); - SitesBuilder b3 = new SitesBuilder(); - DatabaseHealthOutputBuilder b4 = new DatabaseHealthOutputBuilder(); - AdminHealthOutputBuilder b5 = new AdminHealthOutputBuilder(); - HaltAkkaTrafficOutputBuilder b6 = new HaltAkkaTrafficOutputBuilder(); - ResumeAkkaTrafficOutputBuilder b7 = new ResumeAkkaTrafficOutputBuilder(); - SiteIdentifierOutputBuilder b8 = new SiteIdentifierOutputBuilder(); - FailoverOutputBuilder b9 = new FailoverOutputBuilder(); - FailoverInputBuilder b10 = new FailoverInputBuilder(); - } -} diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/ClusterActor.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/ClusterActor.java index 34a51192f..1c8faac08 100755 --- a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/ClusterActor.java +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/ClusterActor.java @@ -23,6 +23,8 @@ package org.onap.ccsdk.sli.plugins.data; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; +import java.util.Map; public class ClusterActor { private String node; @@ -109,36 +111,36 @@ public class ClusterActor { this.unreachable = unreachable; } - public ArrayList getShardLeader() { + public List getShardLeader() { return shardLeader; } - public void setShardLeader(ArrayList shardLeader) { - this.shardLeader = shardLeader; + public void setShardLeader(List shardLeader) { + this.shardLeader = (ArrayList) shardLeader; } - public ArrayList getReplicaShards() { + public List getReplicaShards() { return replicaShards; } - public void setReplicaShards(ArrayList replicaShards) { - this.replicaShards = replicaShards; + public void setReplicaShards(List replicaShards) { + this.replicaShards = (ArrayList) replicaShards; } - public ArrayList getNonReplicaShards() { + public List getNonReplicaShards() { return nonReplicaShards; } - public void setNonReplicaShards(ArrayList nonReplicaShards) { - this.nonReplicaShards = nonReplicaShards; + public void setNonReplicaShards(List nonReplicaShards) { + this.nonReplicaShards = (ArrayList) nonReplicaShards; } - public HashMap getCommits() { + public Map getCommits() { return commits; } - public void setCommits(HashMap commits) { - this.commits = commits; + public void setCommits(Map commits) { + this.commits = (HashMap) commits; } public void flush() { @@ -189,8 +191,9 @@ public class ClusterActor { builder.append("\n"); } - for(String key : commits.keySet()) { - int value = commits.get(key); + for(Map.Entry entry : commits.entrySet()) { + String key = entry.getKey(); + int value = entry.getValue(); if(value > 0) { builder.append("\t"); builder.append(value); diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/MemberBuilder.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/MemberBuilder.java index 1eb0e75ae..96dfa64a8 100755 --- a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/MemberBuilder.java +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/MemberBuilder.java @@ -23,16 +23,12 @@ package org.onap.ccsdk.sli.plugins.data; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.cluster.health.output.MembersBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.member.CommitStatusBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.member.CommitStatus; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.member.ReplicasBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.member.Replicas; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.member.LeaderBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.member.Leader; - -import java.util.HashMap; import java.util.ArrayList; import java.util.List; +import java.util.Map; public class MemberBuilder extends MembersBuilder { public MemberBuilder(ClusterActor actor) { @@ -45,12 +41,11 @@ public class MemberBuilder extends MembersBuilder { populateReplicas(actor.getReplicaShards()); populateCommits(actor.getCommits()); populateLeader(actor.getShardLeader()); - //actor.getNonReplicaShards(); } - private void populateLeader(ArrayList shardLeader) { + private void populateLeader(List shardLeader) { LeaderBuilder builder; - this.setLeader((List) new ArrayList()); + this.setLeader(new ArrayList<>()); for(String leader : shardLeader) { builder = new LeaderBuilder(); builder.setShard(leader); @@ -58,22 +53,24 @@ public class MemberBuilder extends MembersBuilder { } } - private void populateCommits(HashMap commits) { + private void populateCommits(Map commits) { CommitStatusBuilder builder; - this.setCommitStatus((List) new ArrayList()); - for(String key : commits.keySet()) { - if(commits.get(key) != 0) { + this.setCommitStatus(new ArrayList<>()); + for(Map.Entry entry : commits.entrySet()) { + String key = entry.getKey(); + Integer value = entry.getValue(); + if(value != 0) { builder = new CommitStatusBuilder(); builder.setShard(key); - builder.setDelta(commits.get(key)); + builder.setDelta(value); this.getCommitStatus().add(builder.build()); } } } - private void populateReplicas(ArrayList replicaShards) { + private void populateReplicas(List replicaShards) { ReplicasBuilder builder; - this.setReplicas((List) new ArrayList()); + this.setReplicas(new ArrayList<>()); for(String shard : replicaShards) { builder = new ReplicasBuilder(); builder.setShard(shard); -- cgit From 0320e9c271f8534ce867bd4c36ab1883e55cf6e6 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 14 Mar 2019 12:01:11 -0400 Subject: Prepare for release 0.4.1 Prepare to create release version 0.4.1 by using released version of parent pom Change-Id: I72b174efd82ab09b64e2c4c52225304f8174e07a Issue-ID: CCSDK-1156 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 2 +- features/ccsdk-sli-plugins-all/pom.xml | 2 +- features/features-sli-plugins/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- grToolkit/features/ccsdk-gr-toolkit/pom.xml | 7 +++---- grToolkit/features/features-gr-toolkit/pom.xml | 2 +- grToolkit/features/pom.xml | 2 +- grToolkit/installer/pom.xml | 2 +- grToolkit/model/pom.xml | 2 +- grToolkit/pom.xml | 2 +- grToolkit/provider/pom.xml | 2 +- pom.xml | 2 +- properties-node/features/ccsdk-properties-node/pom.xml | 2 +- properties-node/features/features-properties-node/pom.xml | 2 +- properties-node/features/pom.xml | 2 +- properties-node/installer/pom.xml | 2 +- properties-node/pom.xml | 2 +- properties-node/provider/pom.xml | 2 +- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/features-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/pom.xml | 2 +- restapi-call-node/installer/pom.xml | 2 +- restapi-call-node/pom.xml | 2 +- restapi-call-node/provider/pom.xml | 2 +- restconf-client/features/ccsdk-restconf-client/pom.xml | 2 +- restconf-client/features/features-restconf-client/pom.xml | 2 +- restconf-client/features/pom.xml | 2 +- restconf-client/installer/pom.xml | 2 +- restconf-client/pom.xml | 2 +- restconf-client/provider/pom.xml | 2 +- sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml | 2 +- sshapi-call-node/features/features-sshapi-call-node/pom.xml | 2 +- sshapi-call-node/features/pom.xml | 2 +- sshapi-call-node/installer/pom.xml | 2 +- sshapi-call-node/pom.xml | 2 +- sshapi-call-node/provider/pom.xml | 2 +- template-node/features/ccsdk-template-node/pom.xml | 6 ++---- template-node/features/features-template-node/pom.xml | 2 +- template-node/features/pom.xml | 2 +- template-node/installer/pom.xml | 6 ++---- template-node/pom.xml | 2 +- template-node/provider/pom.xml | 2 +- 43 files changed, 47 insertions(+), 52 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 26dbaa59d..354e995a0 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index 7d9068e88..b75833c38 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index eb84c5b93..a8e1ec967 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/features/installer/pom.xml b/features/installer/pom.xml index ad751891f..6459adc78 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/features/pom.xml b/features/pom.xml index 07d77718d..163ec876d 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/grToolkit/features/ccsdk-gr-toolkit/pom.xml b/grToolkit/features/ccsdk-gr-toolkit/pom.xml index f4865a5b3..3b655ce17 100755 --- a/grToolkit/features/ccsdk-gr-toolkit/pom.xml +++ b/grToolkit/features/ccsdk-gr-toolkit/pom.xml @@ -1,13 +1,12 @@ - + 4.0.0 org.onap.ccsdk.parent single-feature-parent - 1.2.1-SNAPSHOT - + 1.2.1 + org.onap.ccsdk.sli.plugins diff --git a/grToolkit/features/features-gr-toolkit/pom.xml b/grToolkit/features/features-gr-toolkit/pom.xml index d74cbb63c..2c966a999 100755 --- a/grToolkit/features/features-gr-toolkit/pom.xml +++ b/grToolkit/features/features-gr-toolkit/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/grToolkit/features/pom.xml b/grToolkit/features/pom.xml index 3f6ab6186..cf3886ce0 100755 --- a/grToolkit/features/pom.xml +++ b/grToolkit/features/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/grToolkit/installer/pom.xml b/grToolkit/installer/pom.xml index b15c877f7..9e44e8500 100755 --- a/grToolkit/installer/pom.xml +++ b/grToolkit/installer/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/grToolkit/model/pom.xml b/grToolkit/model/pom.xml index 348b34784..ade2c6fa2 100755 --- a/grToolkit/model/pom.xml +++ b/grToolkit/model/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1-SNAPSHOT + 1.2.1 ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/pom.xml b/grToolkit/pom.xml index c36e2f161..af3ada398 100755 --- a/grToolkit/pom.xml +++ b/grToolkit/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index 75b6d431b..6f23f9afa 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1-SNAPSHOT + 1.2.1 ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index 7528a9b78..d21e9eee2 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index 1d5feae6c..66b6bb8fc 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index e00d2cfa4..fc01a7491 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 27bea0291..75b7b23fb 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index c431b521c..c06ee8beb 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/properties-node/pom.xml b/properties-node/pom.xml index c8d9c9a3c..ec1b9980d 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 92cff9992..3b72050db 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 638cff391..cae47c65f 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index 64541a74b..f63a296c5 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index 3ae7a2fc3..6a2908d1c 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 1675e4ed7..10ce3c2c8 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index de941aadc..42b9ea98a 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 9f0f1cebf..fa69f5d0e 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index e439eac70..1255149b8 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml index e82e355d8..41c10f0ce 100644 --- a/restconf-client/features/features-restconf-client/pom.xml +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml index ae25b5d24..3e07de3e1 100755 --- a/restconf-client/features/pom.xml +++ b/restconf-client/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index 1bab5b3c1..b3f61302d 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index 57fc99f43..c5b753048 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 0dae6960e..ccc9ab869 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index 3ac681f85..7ec23e9cf 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml index 69273c34e..f0752ffeb 100644 --- a/sshapi-call-node/features/features-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/features-sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml index fae9df428..e9931fe77 100755 --- a/sshapi-call-node/features/pom.xml +++ b/sshapi-call-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index 7e703a7aa..169c4d481 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index cc3187bc4..4c866fdf9 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index 6dff42fb6..cad9b796f 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index e43381f39..4ce8a7d9b 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -1,13 +1,11 @@ - + 4.0.0 org.onap.ccsdk.parent single-feature-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml index 0e22b6137..6b2f28993 100644 --- a/template-node/features/features-template-node/pom.xml +++ b/template-node/features/features-template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml index a7a2d67d7..a43a8f142 100644 --- a/template-node/features/pom.xml +++ b/template-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index d8cdd69b3..f00714780 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -1,13 +1,11 @@ - + 4.0.0 org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/template-node/pom.xml b/template-node/pom.xml index 3bfe36279..d7277910a 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index 7434abc0f..38921305d 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1-SNAPSHOT + 1.2.1 org.onap.ccsdk.sli.plugins -- cgit From 271a15d2c98e4bd95963ca4733b469833bbc7905 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 15 Mar 2019 16:19:33 -0400 Subject: Remove -SNAPSHOT from test Jenkins staging plugin strips the string '-SNAPSHOT' from all xml files. Updated test case not to use a snapshot version in test data. Change-Id: I225b9a731bea2f21233327e4063ad841f0893f82 Issue-ID: CCSDK-1156 Signed-off-by: Timoney, Dan (dt5972) --- .../jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java | 8 ++++---- properties-node/provider/src/test/resources/test.xml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java b/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java index aa3f89d12..f1e0ab627 100644 --- a/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java +++ b/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java @@ -293,7 +293,7 @@ public class TestPropertiesNode { assertEquals(ctx.getAttribute("test-xml.project.dependencies.dependency.scope"),"provided"); assertEquals(ctx.getAttribute("test-xml.project.build.pluginManagement.plugins.plugin.configuration" + ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." + - "pluginExecutionFilter.versionRange"),"[1.2.0.100-SNAPSHOT,)"); + "pluginExecutionFilter.versionRange"),"[1.2.0.100,)"); assertEquals(ctx.getAttribute("test-xml.project.build.plugins.plugin.configuration." + "instructions.Import-Package"),"*"); } @@ -314,7 +314,7 @@ public class TestPropertiesNode { assertEquals(ctx.getAttribute("project.dependencies.dependency.scope"),"provided"); assertEquals(ctx.getAttribute("project.build.pluginManagement.plugins.plugin.configuration" + ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." + - "pluginExecutionFilter.versionRange"),"[1.2.0.100-SNAPSHOT,)"); + "pluginExecutionFilter.versionRange"),"[1.2.0.100,)"); assertEquals(ctx.getAttribute("project.build.plugins.plugin.configuration." + "instructions.Import-Package"),"*"); } @@ -334,7 +334,7 @@ public class TestPropertiesNode { assertEquals(ctx.getAttribute("project.dependencies.dependency.scope"),"provided"); assertEquals(ctx.getAttribute("project.build.pluginManagement.plugins.plugin.configuration" + ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." + - "pluginExecutionFilter.versionRange"),"[1.2.0.100-SNAPSHOT,)"); + "pluginExecutionFilter.versionRange"),"[1.2.0.100,)"); assertEquals(ctx.getAttribute("project.build.plugins.plugin.configuration." + "instructions.Import-Package"),"*"); } @@ -355,7 +355,7 @@ public class TestPropertiesNode { assertEquals(ctx.getAttribute("project.dependencies.dependency.scope"),"provided"); assertEquals(ctx.getAttribute("project.build.pluginManagement.plugins.plugin.configuration" + ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." + - "pluginExecutionFilter.versionRange"),"[1.2.0.100-SNAPSHOT,)"); + "pluginExecutionFilter.versionRange"),"[1.2.0.100,)"); assertEquals(ctx.getAttribute("project.build.plugins.plugin.configuration." + "instructions.Import-Package"),"*"); assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1"); diff --git a/properties-node/provider/src/test/resources/test.xml b/properties-node/provider/src/test/resources/test.xml index 1974f688e..19e3b7139 100644 --- a/properties-node/provider/src/test/resources/test.xml +++ b/properties-node/provider/src/test/resources/test.xml @@ -162,7 +162,7 @@ providermodule-plugin - [1.2.0.100-SNAPSHOT,) + [1.2.0.100,) process -- cgit From c43923c37deb4b74f1a011d08688f2f9fc3fe5e1 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Mon, 18 Mar 2019 13:25:25 -0400 Subject: Remove staging plugin from top level pom.xml Remove staging plugin from pom.xml. It should be part of a build profile in the odlparent pom. Change-Id: I04a621fbad9f6d671fdcdedf6ada18d377a2ce28 Issue-ID: CCSDK-1156 Signed-off-by: Timoney, Dan (dt5972) --- pom.xml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/pom.xml b/pom.xml index d21e9eee2..2cd2337e7 100755 --- a/pom.xml +++ b/pom.xml @@ -62,17 +62,6 @@ false - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - https://${onap.nexus.host} - ${onap.nexus.staging.profile-id} - ${onap.nexus.staging.server-id} - - -- cgit From 38147a9470892ef00182b58f48fd661032ce8a11 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 19 Mar 2019 18:08:37 -0400 Subject: Compile against Fluorine SR2 Updated to compile against Fluorine SR2 Change-Id: I83208310f6386ac8c37433ac8af50de7c611fd06 Issue-ID: CCSDK-1156 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 2 +- features/ccsdk-sli-plugins-all/pom.xml | 2 +- features/features-sli-plugins/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- grToolkit/features/ccsdk-gr-toolkit/pom.xml | 2 +- grToolkit/features/features-gr-toolkit/pom.xml | 2 +- grToolkit/features/pom.xml | 2 +- grToolkit/installer/pom.xml | 2 +- grToolkit/model/pom.xml | 2 +- grToolkit/pom.xml | 2 +- grToolkit/provider/pom.xml | 2 +- pom.xml | 2 +- properties-node/features/ccsdk-properties-node/pom.xml | 2 +- properties-node/features/features-properties-node/pom.xml | 2 +- properties-node/features/pom.xml | 2 +- properties-node/installer/pom.xml | 2 +- properties-node/pom.xml | 2 +- properties-node/provider/pom.xml | 2 +- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/features-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/pom.xml | 2 +- restapi-call-node/installer/pom.xml | 2 +- restapi-call-node/pom.xml | 2 +- restapi-call-node/provider/pom.xml | 2 +- restconf-client/features/ccsdk-restconf-client/pom.xml | 2 +- restconf-client/features/features-restconf-client/pom.xml | 2 +- restconf-client/features/pom.xml | 2 +- restconf-client/installer/pom.xml | 2 +- restconf-client/pom.xml | 2 +- restconf-client/provider/pom.xml | 2 +- sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml | 2 +- sshapi-call-node/features/features-sshapi-call-node/pom.xml | 2 +- sshapi-call-node/features/pom.xml | 2 +- sshapi-call-node/installer/pom.xml | 2 +- sshapi-call-node/pom.xml | 2 +- sshapi-call-node/provider/pom.xml | 2 +- template-node/features/ccsdk-template-node/pom.xml | 2 +- template-node/features/features-template-node/pom.xml | 2 +- template-node/features/pom.xml | 2 +- template-node/installer/pom.xml | 2 +- template-node/pom.xml | 2 +- template-node/provider/pom.xml | 2 +- version.properties | 2 +- 44 files changed, 44 insertions(+), 44 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 354e995a0..79ad7574d 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index b75833c38..c7a43a483 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index a8e1ec967..3d6364689 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 6459adc78..a83003c7c 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/features/pom.xml b/features/pom.xml index 163ec876d..4e8783475 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/grToolkit/features/ccsdk-gr-toolkit/pom.xml b/grToolkit/features/ccsdk-gr-toolkit/pom.xml index 3b655ce17..9c3a54a37 100755 --- a/grToolkit/features/ccsdk-gr-toolkit/pom.xml +++ b/grToolkit/features/ccsdk-gr-toolkit/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/grToolkit/features/features-gr-toolkit/pom.xml b/grToolkit/features/features-gr-toolkit/pom.xml index 2c966a999..abde024b4 100755 --- a/grToolkit/features/features-gr-toolkit/pom.xml +++ b/grToolkit/features/features-gr-toolkit/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/grToolkit/features/pom.xml b/grToolkit/features/pom.xml index cf3886ce0..cd8f272cf 100755 --- a/grToolkit/features/pom.xml +++ b/grToolkit/features/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/grToolkit/installer/pom.xml b/grToolkit/installer/pom.xml index 9e44e8500..71b097999 100755 --- a/grToolkit/installer/pom.xml +++ b/grToolkit/installer/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/grToolkit/model/pom.xml b/grToolkit/model/pom.xml index ade2c6fa2..1012e762b 100755 --- a/grToolkit/model/pom.xml +++ b/grToolkit/model/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1 + 1.2.2-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/pom.xml b/grToolkit/pom.xml index af3ada398..cf754dac5 100755 --- a/grToolkit/pom.xml +++ b/grToolkit/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index 6f23f9afa..cc4354b33 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1 + 1.2.2-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index 2cd2337e7..cdc24e08d 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index 66b6bb8fc..d30ee0ad3 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index fc01a7491..faea526e8 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 75b7b23fb..a1f58ab1f 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index c06ee8beb..dae92c36c 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/properties-node/pom.xml b/properties-node/pom.xml index ec1b9980d..b3ecbc6e1 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 3b72050db..e05a2b185 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index cae47c65f..1200f92ce 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index f63a296c5..04645ee77 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index 6a2908d1c..d5967d591 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 10ce3c2c8..187ed18d2 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 42b9ea98a..e2167ec4a 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index fa69f5d0e..aa183c58b 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index 1255149b8..52c766d7a 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml index 41c10f0ce..8757bec22 100644 --- a/restconf-client/features/features-restconf-client/pom.xml +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml index 3e07de3e1..2471ece18 100755 --- a/restconf-client/features/pom.xml +++ b/restconf-client/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index b3f61302d..32901f88b 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index c5b753048..cb63a81a9 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index ccc9ab869..1e6bfcc8e 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index 7ec23e9cf..b6534393f 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml index f0752ffeb..f0a3e8041 100644 --- a/sshapi-call-node/features/features-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/features-sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml index e9931fe77..c04ad6095 100755 --- a/sshapi-call-node/features/pom.xml +++ b/sshapi-call-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index 169c4d481..6b54e409a 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index 4c866fdf9..48adb81ba 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index cad9b796f..c3b7c281a 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index 4ce8a7d9b..b6cf31f2d 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml index 6b2f28993..0e1f5ec39 100644 --- a/template-node/features/features-template-node/pom.xml +++ b/template-node/features/features-template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml index a43a8f142..1e0fdb12e 100644 --- a/template-node/features/pom.xml +++ b/template-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index f00714780..26c745acc 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/template-node/pom.xml b/template-node/pom.xml index d7277910a..719e97576 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index 38921305d..fc714240f 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/version.properties b/version.properties index 6086d3c9f..80a47aef7 100644 --- a/version.properties +++ b/version.properties @@ -7,7 +7,7 @@ release_name=0 sprint_number=4 -feature_revision=1 +feature_revision=2 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit From d9080716861ba46ea86fc7aebd4d4c42eea97016 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 22 Mar 2019 09:37:52 -0400 Subject: Roll version to 0.4.2-SNAPSHOT Roll version of ccsdk/sli/plugins to next snapshot version Change-Id: I142e7b2ec5e72e318007c329640f1818255c60f4 Issue-ID: CCSDK-1156 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 2 +- features/ccsdk-sli-plugins-all/pom.xml | 2 +- features/features-sli-plugins/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- grToolkit/features/ccsdk-gr-toolkit/pom.xml | 2 +- grToolkit/features/features-gr-toolkit/pom.xml | 2 +- grToolkit/features/pom.xml | 2 +- grToolkit/installer/pom.xml | 2 +- grToolkit/model/pom.xml | 2 +- grToolkit/pom.xml | 2 +- grToolkit/provider/pom.xml | 2 +- pom.xml | 2 +- properties-node/features/ccsdk-properties-node/pom.xml | 2 +- properties-node/features/features-properties-node/pom.xml | 2 +- properties-node/features/pom.xml | 2 +- properties-node/installer/pom.xml | 2 +- properties-node/pom.xml | 2 +- properties-node/provider/pom.xml | 2 +- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/features-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/pom.xml | 2 +- restapi-call-node/installer/pom.xml | 2 +- restapi-call-node/pom.xml | 2 +- restapi-call-node/provider/pom.xml | 2 +- restconf-client/features/ccsdk-restconf-client/pom.xml | 2 +- restconf-client/features/features-restconf-client/pom.xml | 2 +- restconf-client/features/pom.xml | 2 +- restconf-client/installer/pom.xml | 2 +- restconf-client/pom.xml | 2 +- restconf-client/provider/pom.xml | 6 +++--- sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml | 2 +- sshapi-call-node/features/features-sshapi-call-node/pom.xml | 2 +- sshapi-call-node/features/pom.xml | 2 +- sshapi-call-node/installer/pom.xml | 2 +- sshapi-call-node/pom.xml | 2 +- sshapi-call-node/provider/pom.xml | 2 +- template-node/features/ccsdk-template-node/pom.xml | 2 +- template-node/features/features-template-node/pom.xml | 2 +- template-node/features/pom.xml | 2 +- template-node/installer/pom.xml | 2 +- template-node/pom.xml | 2 +- template-node/provider/pom.xml | 2 +- 43 files changed, 45 insertions(+), 45 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 79ad7574d..911a1d6ab 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.plugins sli-plugins-artifacts - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-plugins :: sli-plugins-artifacts diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index c7a43a483..0cd756eda 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins ccsdk-sli-plugins-all - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index 3d6364689..aff865f0a 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins features-sli-plugins - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index a83003c7c..ed909fc22 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins sliplugins-features-installer - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 4e8783475..efd6cbe68 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins sliplugins-feature-aggregator - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-plugins :: features diff --git a/grToolkit/features/ccsdk-gr-toolkit/pom.xml b/grToolkit/features/ccsdk-gr-toolkit/pom.xml index 9c3a54a37..264ad7cf6 100755 --- a/grToolkit/features/ccsdk-gr-toolkit/pom.xml +++ b/grToolkit/features/ccsdk-gr-toolkit/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins ccsdk-gr-toolkit - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/features/features-gr-toolkit/pom.xml b/grToolkit/features/features-gr-toolkit/pom.xml index abde024b4..db2887436 100755 --- a/grToolkit/features/features-gr-toolkit/pom.xml +++ b/grToolkit/features/features-gr-toolkit/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins features-gr-toolkit - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/features/pom.xml b/grToolkit/features/pom.xml index cd8f272cf..c092a4b80 100755 --- a/grToolkit/features/pom.xml +++ b/grToolkit/features/pom.xml @@ -11,7 +11,7 @@ ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} gr-toolkit-features org.onap.ccsdk.sli.plugins - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom diff --git a/grToolkit/installer/pom.xml b/grToolkit/installer/pom.xml index 71b097999..5d1743389 100755 --- a/grToolkit/installer/pom.xml +++ b/grToolkit/installer/pom.xml @@ -11,7 +11,7 @@ ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-installer - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-gr-toolkit diff --git a/grToolkit/model/pom.xml b/grToolkit/model/pom.xml index 1012e762b..c917c4567 100755 --- a/grToolkit/model/pom.xml +++ b/grToolkit/model/pom.xml @@ -10,7 +10,7 @@ ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-model - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT bundle diff --git a/grToolkit/pom.xml b/grToolkit/pom.xml index cf754dac5..d2d79c706 100755 --- a/grToolkit/pom.xml +++ b/grToolkit/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins gr-toolkit - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-plugins :: gr-toolkit diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index cc4354b33..951d2da60 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -10,7 +10,7 @@ ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-provider - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT bundle diff --git a/pom.xml b/pom.xml index cdc24e08d..9e564d5e8 100755 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index d30ee0ad3..6412ca3ae 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins ccsdk-properties-node - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index faea526e8..1f2da265c 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins features-properties-node - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index a1f58ab1f..23bfd53e2 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins properties-node-features - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index dae92c36c..d37160912 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins properties-node-installer - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index b3ecbc6e1..7ff022582 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins properties-node - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-plugins :: properties-node diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index e05a2b185..532d5f7b9 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins properties-node-provider - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT bundle ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 1200f92ce..a28cbbe4c 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins ccsdk-restapi-call-node - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index 04645ee77..23b8f84b5 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins features-restapi-call-node - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index d5967d591..8ca913bb8 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins restapi-call-node-features - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 187ed18d2..cbc4a6ec1 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins restapi-call-node-installer - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index e2167ec4a..7cdee7c50 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins restapi-call-node - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index aa183c58b..1d724c646 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT bundle ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index 52c766d7a..56fa2ebaf 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins ccsdk-restconf-client - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml index 8757bec22..56846fb45 100644 --- a/restconf-client/features/features-restconf-client/pom.xml +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins features-restconf-client - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml index 2471ece18..5a882ebcd 100755 --- a/restconf-client/features/pom.xml +++ b/restconf-client/features/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins restconf-client-features - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index 32901f88b..4a454b14a 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins restconf-client-installer - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index cb63a81a9..7f2e9c825 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins restconf-client - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 1e6bfcc8e..0d5ee180a 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins restconf-client-provider - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT bundle ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} @@ -50,7 +50,7 @@ org.onap.ccsdk.sli.plugins properties-node-provider - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT org.opendaylight.yangtools @@ -74,7 +74,7 @@ org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT org.opendaylight.netconf diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index b6534393f..ee153ad4e 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins ccsdk-sshapi-call-node - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml index f0a3e8041..421cbbaa7 100644 --- a/sshapi-call-node/features/features-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/features-sshapi-call-node/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins features-sshapi-call-node - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml index c04ad6095..cd045fde3 100755 --- a/sshapi-call-node/features/pom.xml +++ b/sshapi-call-node/features/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins sshapi-call-node-features - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index 6b54e409a..39c01db1b 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins sshapi-call-node-installer - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index 48adb81ba..6583e69bf 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins sshapi-call-node - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index c3b7c281a..bdf471b25 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins sshapi-call-node-provider - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT bundle ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index b6cf31f2d..c5152dbc4 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins ccsdk-template-node - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml index 0e1f5ec39..dd9c8992f 100644 --- a/template-node/features/features-template-node/pom.xml +++ b/template-node/features/features-template-node/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.plugins features-template-node - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml index 1e0fdb12e..b498051f6 100644 --- a/template-node/features/pom.xml +++ b/template-node/features/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins template-node-features - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index 26c745acc..44425d1e8 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins template-node-installer - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/template-node/pom.xml b/template-node/pom.xml index 719e97576..c0843b787 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins template-node - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index fc714240f..d52587922 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.plugins template-node-provider - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT bundle ccsdk-sli-plugins :: template-node :: ${project.artifactId} -- cgit From 2d465026f1ef738b1f4e0274c8608317c57bbdf5 Mon Sep 17 00:00:00 2001 From: janani b Date: Thu, 21 Mar 2019 22:56:13 +0530 Subject: Plugin points to 2.0.1 javax version RestapiCallNode and RestconfClient in plugins will point to the odl default javax version. Also RestconfClient is added to plugins-all features. Issue-ID: CCSDK-1045 Change-Id: I6f7173ec765bc21201f17a3bfd6801c18de610a9 Signed-off-by: janani b --- features/ccsdk-sli-plugins-all/pom.xml | 9 +++++++++ restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 1 - restapi-call-node/provider/pom.xml | 1 - restconf-client/provider/pom.xml | 1 - 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index b75833c38..3d5129b37 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -34,6 +34,14 @@ features + + ${project.groupId} + ccsdk-restconf-client + ${project.version} + xml + features + + ${project.groupId} ccsdk-template-node @@ -41,6 +49,7 @@ xml features + ${project.groupId} ccsdk-sshapi-call-node diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index cae47c65f..c9c08d669 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -21,7 +21,6 @@ javax.ws.rs javax.ws.rs-api - 2.1 org.onap.ccsdk.sli.core diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index fa69f5d0e..b927b4fc5 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -35,7 +35,6 @@ javax.ws.rs javax.ws.rs-api - 2.1 org.onap.ccsdk.sli.core diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index ccc9ab869..7cb2993c1 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -41,7 +41,6 @@ javax.ws.rs javax.ws.rs-api - 2.1 org.onap.ccsdk.sli.core -- cgit From f360b7b2bc9ed8d321dade9cadafe2ebda4f46ab Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Tue, 2 Apr 2019 13:38:06 +0000 Subject: RestApiCallNode HTTP method patch not working RestApiCallNode patch not working after upgrading from sun jersey to glassfish, apply workaround Change-Id: I3a36b9c0c8b241b46059edec08fb80087e67fd93 Issue-ID: CCSDK-1191 Signed-off-by: Smokowski, Kevin (ks6305) --- .../java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 4c04c9d3b..521c66cb3 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -58,6 +58,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import org.apache.commons.lang3.StringUtils; import org.glassfish.jersey.client.ClientProperties; +import org.glassfish.jersey.client.HttpUrlConnectorProvider; import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; import org.glassfish.jersey.client.oauth1.ConsumerCredentials; import org.glassfish.jersey.client.oauth1.OAuth1ClientSupport; @@ -622,6 +623,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { .build(); } client.property(ClientProperties.CONNECT_TIMEOUT, 5000); + // Needed to support additional HTTP methods such as PATCH + client.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true); WebTarget webTarget = addAuthType(client, p).target(p.restapiUrl); -- cgit From 614bd0b6897b1ece3ee7deb581089c301bb3f2e8 Mon Sep 17 00:00:00 2001 From: janani b Date: Fri, 5 Apr 2019 18:23:44 +0530 Subject: Replacing ":" by "_" for parameters Supporting "_" to be present for module name seperator while giving parameters in DG node. Issue-ID: CCSDK-1045 Change-Id: I008fa8503f1314e593f96393121a02f429bac636 Signed-off-by: janani b --- .../restconfapicall/RestconfApiCallNode.java | 25 +- .../plugins/restconfapicall/RestconfApiUtils.java | 22 +- .../DefaultPropertiesNodeListener.java | 11 +- .../MdsalPropertiesNodeSerializer.java | 41 +- .../pnserializer/MdsalPropertiesNodeUtils.java | 243 ++++++- .../pnserializer/SchemaPathHolder.java | 77 +++ .../dfserializer/DataFormatSerializerTest.java | 98 +-- .../dfserializer/DataFormatUtilsTest.java | 22 +- .../dfserializer/IdentifierValidationTest.java | 762 +++++++++++++++++++++ .../IdentifierValidationUtilsTest.java | 469 +++++++++++++ .../pnserializer/PropertiesSerializerTest.java | 224 +++--- .../resources/yang/test_augment_1_for_module.yang | 108 +++ .../resources/yang/test_name_of_the_module.yang | 231 +++++++ 13 files changed, 2107 insertions(+), 226 deletions(-) create mode 100644 restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/SchemaPathHolder.java create mode 100644 restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationTest.java create mode 100644 restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationUtilsTest.java create mode 100644 restconf-client/provider/src/test/resources/yang/test_augment_1_for_module.yang create mode 100644 restconf-client/provider/src/test/resources/yang/test_name_of_the_module.yang diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java index a76b27d0b..3007b5a1b 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java @@ -25,6 +25,18 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.stream.JsonWriter; + +import javax.ws.rs.core.UriBuilder; +import java.io.StringWriter; +import java.io.Writer; +import java.net.SocketException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.DocumentHelper; @@ -54,17 +66,6 @@ import org.osgi.framework.ServiceReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.ws.rs.core.UriBuilder; -import java.io.StringWriter; -import java.io.Writer; -import java.net.SocketException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - import static com.google.common.base.Strings.repeat; import static java.lang.String.format; import static java.lang.String.valueOf; @@ -91,8 +92,8 @@ import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.RES_PR import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.RETRY_COUNT; import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.RETRY_FAIL; import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.UPDATED_URL; -import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.getUpdatedXmlReq; import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.getSchemaCtxFromDir; +import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.getUpdatedXmlReq; import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.getYangParameters; import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.parseUrl; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfListenerFactory.instance; diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java index c5c7a919b..505089c44 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java @@ -22,15 +22,6 @@ package org.onap.ccsdk.sli.plugins.restconfapicall; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.plugins.restapicall.HttpMethod; -import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.YangParameters; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException; -import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource; -import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; -import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor; - import java.io.File; import java.io.IOException; import java.net.URI; @@ -43,6 +34,15 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.restapicall.HttpMethod; +import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.YangParameters; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException; +import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource; +import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; +import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor; + import static org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode.getParameters; import static org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode.parseParam; import static org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode.DEFAULT_MODE; @@ -156,6 +156,7 @@ public final class RestconfApiUtils { */ private static String getParsedPath(String path) { String firstHalf; + String secondHalf; if (path.contains(COLON)) { String[] p = path.split(COLON); if (p[0].contains(SLASH)) { @@ -164,7 +165,8 @@ public final class RestconfApiUtils { } else { firstHalf = p[0]; } - return firstHalf + COLON + p[1]; + secondHalf = path.substring(p[0].length() + 1); + return firstHalf + COLON + secondHalf; } return path; } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java index 491dcb099..2fa00bfb7 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeListener.java @@ -20,12 +20,14 @@ package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; - import java.util.Collection; import java.util.HashMap; import java.util.Map; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.COLON; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.UNDERSCORE; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_LEAF_NODE; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.SINGLE_INSTANCE_LEAF_NODE; @@ -56,9 +58,10 @@ public class DefaultPropertiesNodeListener implements PropertiesNodeListener { || node.nodeType() == MULTI_INSTANCE_LEAF_NODE) { String val = ((LeafNode) node).value(); if (((LeafNode) node).valueNs() != null) { - val = ((LeafNode) node).valueNs().moduleName() + ":" + val; + val = ((LeafNode) node).valueNs().moduleName() + COLON + val; } - params.put(node.uri(), val); + String uri = node.uri().replaceAll(COLON, UNDERSCORE); + params.put(uri, val); } } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java index 13a5c5a01..759fe802e 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java @@ -20,20 +20,25 @@ package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer; +import java.util.HashMap; +import java.util.Map; + import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaNode; import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil; -import java.util.Map; - +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.DOT_REGEX; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.SLASH; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getChildSchemaNode; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getIndex; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getListName; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getNamespace; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getNodeType; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getParsedValue; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getProcessedPath; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getRevision; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getValueNamespace; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.resolveName; @@ -70,6 +75,8 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer entry : paramMap.entrySet()) { String[] names = entry.getKey().split("\\."); for (int i = 0; i < names.length; i++) { @@ -86,6 +93,30 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer convertToValidParam(Map paramMap) { + Map fixedParams = new HashMap<>(); + for(Map.Entry entry : paramMap.entrySet()) { + String key = entry.getKey().replaceAll(DOT_REGEX, SLASH); + try { + SchemaPathHolder fixedUrl = getProcessedPath(key, schemaCtx()); + String fixedUri = fixedUrl.getUri().replaceAll( + SLASH, DOT_REGEX); + fixedParams.put(fixedUri, entry.getValue()); + } catch (IllegalArgumentException | RestconfDocumentedException + | NullPointerException e) { + fixedParams.put(entry.getKey(), entry.getValue()); + } + } + return fixedParams; + } + @Override public Map decode(PropertiesNode propertiesNode) throws SvcLogicException { @@ -104,8 +135,10 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer id = toInstanceIdentifier( + uri1, context, null); + return new SchemaPathHolder(id, uri1); + } catch (IllegalArgumentException | RestconfDocumentedException + | NullPointerException e) { + return processNodesAndAppendPath(uri, context); + } + } + + /** + * Processes the nodes in the given uri and finds instance identifier + * context till it reaches the last node in uri. If its not able to find + * schema for the path, it appends the suffix part and puts it back in + * the param list. + * + * @param uri uri with underscore + * @param context schema context + * @return schema and path holder + */ + private static SchemaPathHolder processNodesAndAppendPath(String uri, + SchemaContext context) { + + String actPath = ""; + SchemaPathHolder id = new SchemaPathHolder(null, ""); + String[] uriParts = uri.split(SLASH); + String sec = ""; + if (uri.contains(UNDERSCORE)) { + sec = uri.substring(uriParts[0].length()+1); + } + for (int i = 0; i id; + for (int i = 0; i< values.length-1; i++) { + val = values[i]; + val = firstHalf + val + COLON + secondHalf; + try { + id = toInstanceIdentifier(prefix + val, context, null); + return new SchemaPathHolder(id, val); + } catch (IllegalArgumentException | RestconfDocumentedException | + NullPointerException e) { + log.info(format(INFO_MSG, val)); + } + firstHalf.append(values[i]).append(UNDERSCORE); + secondHalf = secondHalf.replaceFirst( + values[i + 1] + UNDERSCORE,""); + } + val = val.replace(COLON,UNDERSCORE); + try { + id = toInstanceIdentifier(prefix + val, context, null); + return new SchemaPathHolder(id, val); + } catch (IllegalArgumentException | RestconfDocumentedException | + NullPointerException e1) { + throw new IllegalArgumentException(EXC_MSG, e1); + } + } + + /** + * Returns the namespace of the given node name. If the node name is + * separated by colon, the it splits with colon and forms the namespace. + * If the node name is formed with underscore, then it splits the node + * name consecutively to figure out the proper module name. + * + * @param childName node name + * @param ctx schema context + * @param parent parent properties node + * @param curSchema current schema + * @return namespace of the given node + */ + static Namespace getNamespace(String childName, SchemaContext ctx, + PropertiesNode parent, SchemaNode curSchema) { + + Namespace parentNs = parent.namespace(); + Namespace ns = new Namespace(parentNs.moduleName(), + parentNs.moduleNs(), parentNs.revision()); + int lastIndexOfColon = childName.lastIndexOf(COLON); if (lastIndexOfColon != -1) { String moduleName = childName.substring(0, lastIndexOfColon); - Iterator it = ctx.findModules(moduleName).iterator(); - if (!it.hasNext()) { - // module is not present in context - return null; + childName = childName.substring(lastIndexOfColon+1); + Namespace ns1 = getNs(moduleName, ctx); + if (ns1 != null) { + ns = ns1; } + } + + SchemaNode child = getChildSchemaNode(curSchema, childName, ns); + + if (child == null && childName.contains(UNDERSCORE)) { + String[] children = childName.split(UNDERSCORE); + String second = childName.substring(children[0].length() + 1); + StringBuilder first = new StringBuilder(); + + for (int i =0; i< children.length; i++) { + String moduleName = first + children[i]; + Namespace newNs = getNs(moduleName, ctx); + if (newNs != null) { + return newNs; + } + first.append(children[i]).append(UNDERSCORE); + if (i + 1 < children.length) { + second = second.replaceFirst( + children[i + 1] + UNDERSCORE, ""); + } + } + return ns; + } + return ns; + } + + /** + * Returns the namespace by finding the given module in the schema context. + * + * @param modName module name + * @param ctx schema context + * @return namespace of the given node name + */ + private static Namespace getNs(String modName, SchemaContext ctx) { + Iterator it = ctx.findModules(modName).iterator(); + if (it.hasNext()) { Module m = it.next(); - return new Namespace(moduleName, m.getQNameModule().getNamespace(), + return new Namespace(modName, m.getQNameModule().getNamespace(), getRevision(m.getRevision())); } - Namespace parentNs = parent.namespace(); - return new Namespace(parentNs.moduleName(), parentNs.moduleNs(), - parentNs.revision()); + return null; } /** @@ -239,7 +434,7 @@ public final class MdsalPropertiesNodeUtils { * @return child schema node */ public static SchemaNode getChildSchemaNode(SchemaNode curSchema, - String name, + String name, Namespace namespace) { if (namespace == null) { return null; diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/SchemaPathHolder.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/SchemaPathHolder.java new file mode 100644 index 000000000..4ef1bc664 --- /dev/null +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/SchemaPathHolder.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2019 Huawei Technologies Co., Ltd. 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.yangserializers.pnserializer; + +import org.opendaylight.restconf.common.context.InstanceIdentifierContext; + +/** + * Representation of a holder for a proper path and its corresponding schema. + */ +public class SchemaPathHolder { + + /** + * Schema context for the path. + */ + private InstanceIdentifierContext insId; + + /** + * Formatted path. + */ + private String uri; + + /** + * Constructs schema path holder with path and its schema. + * + * @param insId instance identifier context + * @param uri path + */ + public SchemaPathHolder(InstanceIdentifierContext insId, String uri) { + this.insId = insId; + this.uri = uri; + } + + /** + * Returns the instance identifier context of the path. + * + * @return schema of the path + */ + public InstanceIdentifierContext getInsId() { + return insId; + } + + /** + * Returns the formatted path. + * + * @return formatted path + */ + public String getUri() { + return uri; + } + + /** + * Sets the formatted path. + * + * @param uri formatted path + */ + public void setUri(String uri) { + this.uri = uri; + } +} diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java index 08fa33ee7..45e8eb3f1 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java @@ -20,6 +20,9 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; +import java.util.HashMap; +import java.util.Map; + import org.junit.Before; import org.junit.Test; import org.mockito.invocation.InvocationOnMock; @@ -31,9 +34,6 @@ import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode; import org.opendaylight.restconf.common.context.InstanceIdentifierContext; -import java.util.HashMap; -import java.util.Map; - import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.mockito.Matchers.any; @@ -136,7 +136,7 @@ public class DataFormatSerializerTest { */ @Test public void encodeToJsonId() throws SvcLogicException { - String pre = "identity-test:test."; + String pre = "identity-test_test."; SvcLogicContext ctx = createAttList(pre); ctx.setAttribute(pre + "l", "abc"); p.put("dirPath", "src/test/resources"); @@ -156,7 +156,7 @@ public class DataFormatSerializerTest { */ @Test public void encodeToJsonIdWithPut() throws SvcLogicException { - String pre = "identity-test:test."; + String pre = "identity-test_test."; SvcLogicContext ctx = createAttList(pre); ctx.setAttribute(pre + "l", "abc"); p.put("dirPath", "src/test/resources"); @@ -176,7 +176,7 @@ public class DataFormatSerializerTest { */ @Test public void encodeToJsonIdWithPatch() throws SvcLogicException { - String pre = "identity-test:test."; + String pre = "identity-test_test."; SvcLogicContext ctx = createAttList(pre); ctx.setAttribute(pre + "l", "abc"); p.put("dirPath", "src/test/resources"); @@ -196,7 +196,7 @@ public class DataFormatSerializerTest { */ @Test public void encodeToXmlId() throws SvcLogicException { - String pre = "identity-test:test."; + String pre = "identity-test_test."; SvcLogicContext ctx = createAttList(pre); p.put("dirPath", "src/test/resources"); p.put("format", "xml"); @@ -215,7 +215,7 @@ public class DataFormatSerializerTest { */ @Test public void encodeToXmlIdWithPut() throws SvcLogicException { - String pre = "identity-test:test."; + String pre = "identity-test_test."; SvcLogicContext ctx = createAttList(pre); p.put("dirPath", "src/test/resources"); p.put("format", "xml"); @@ -234,7 +234,7 @@ public class DataFormatSerializerTest { */ @Test public void encodeToXmlIdWithPatch() throws SvcLogicException { - String pre = "identity-test:test."; + String pre = "identity-test_test."; SvcLogicContext ctx = createAttList(pre); p.put("dirPath", "src/test/resources"); p.put("format", "xml"); @@ -255,7 +255,7 @@ public class DataFormatSerializerTest { public void decodeToJsonId() throws SvcLogicException { createMockForDecode(ENCODE_TO_JSON_ID); SvcLogicContext ctx = new SvcLogicContext(); - String pre = "identity-test:test."; + String pre = "identity-test_test."; p.put("dirPath", "src/test/resources"); p.put("format", "json"); p.put("httpMethod", "get"); @@ -276,7 +276,7 @@ public class DataFormatSerializerTest { public void decodeToXmlId() throws SvcLogicException { createMockForDecode(ENCODE_TO_XML_ID); SvcLogicContext ctx = new SvcLogicContext(); - String pre = "identity-test:test."; + String pre = "identity-test_test."; p.put("dirPath", "src/test/resources"); p.put("format", "xml"); p.put("httpMethod", "get"); @@ -294,7 +294,7 @@ public class DataFormatSerializerTest { */ @Test public void encodeToJsonYang() throws SvcLogicException { - String pre = "test-yang:cont1.cont2."; + String pre = "test-yang_cont1.cont2."; SvcLogicContext ctx = createAttListYang(pre); p.put("dirPath", "src/test/resources"); p.put("format", "json"); @@ -313,7 +313,7 @@ public class DataFormatSerializerTest { */ @Test public void encodeToJsonYangWithPut() throws SvcLogicException { - String pre = "test-yang:cont1.cont2."; + String pre = "test-yang_cont1.cont2."; SvcLogicContext ctx = createAttListYang(pre); p.put("dirPath", "src/test/resources"); p.put("format", "json"); @@ -332,7 +332,7 @@ public class DataFormatSerializerTest { */ @Test public void encodeToJsonYangWithPatch() throws SvcLogicException { - String pre = "test-yang:cont1.cont2."; + String pre = "test-yang_cont1.cont2."; SvcLogicContext ctx = createAttListYang(pre); p.put("dirPath", "src/test/resources"); p.put("format", "json"); @@ -351,7 +351,7 @@ public class DataFormatSerializerTest { */ @Test public void encodeToJsonWithAugAsRootChild() throws SvcLogicException { - String pre = "test-yang:cont1.cont2."; + String pre = "test-yang_cont1.cont2."; SvcLogicContext ctx = createAttListYang(pre); p.put("dirPath", "src/test/resources"); p.put("format", "json"); @@ -372,7 +372,7 @@ public class DataFormatSerializerTest { public void decodeToJsonYang() throws SvcLogicException { createMockForDecode(ENCODE_TO_JSON_YANG); SvcLogicContext ctx = new SvcLogicContext(); - String pre = "test-yang:cont1.cont2."; + String pre = "test-yang_cont1.cont2."; p.put("dirPath", "src/test/resources"); p.put("format", "json"); p.put("httpMethod", "get"); @@ -390,7 +390,7 @@ public class DataFormatSerializerTest { */ @Test public void encodeToXmlYang() throws SvcLogicException { - String pre = "test-yang:cont1.cont2."; + String pre = "test-yang_cont1.cont2."; SvcLogicContext ctx = createAttListYang(pre); p.put("dirPath", "src/test/resources"); p.put("format", "xml"); @@ -409,7 +409,7 @@ public class DataFormatSerializerTest { */ @Test public void encodeToXmlYangWithPut() throws SvcLogicException { - String pre = "test-yang:cont1.cont2."; + String pre = "test-yang_cont1.cont2."; SvcLogicContext ctx = createAttListYang(pre); p.put("dirPath", "src/test/resources"); p.put("format", "xml"); @@ -428,7 +428,7 @@ public class DataFormatSerializerTest { */ @Test public void encodeToXmlYangWithPatch() throws SvcLogicException { - String pre = "test-yang:cont1.cont2."; + String pre = "test-yang_cont1.cont2."; SvcLogicContext ctx = createAttListYang(pre); p.put("dirPath", "src/test/resources"); p.put("format", "xml"); @@ -447,7 +447,7 @@ public class DataFormatSerializerTest { */ @Test public void encodeToXmlWithAugAsRootChild() throws SvcLogicException { - String pre = "test-yang:cont1.cont2."; + String pre = "test-yang_cont1.cont2."; SvcLogicContext ctx = createAttListYang(pre); p.put("dirPath", "src/test/resources"); p.put("format", "xml"); @@ -468,7 +468,7 @@ public class DataFormatSerializerTest { public void decodeToXmlYang() throws SvcLogicException { createMockForDecode(ENCODE_TO_XML_YANG); SvcLogicContext ctx = new SvcLogicContext(); - String pre = "test-yang:cont1.cont2."; + String pre = "test-yang_cont1.cont2."; p.put("dirPath", "src/test/resources"); p.put("format", "xml"); p.put("httpMethod", "get"); @@ -487,8 +487,8 @@ public class DataFormatSerializerTest { @Test public void codecToJsonRpc() throws SvcLogicException { createMockForDecode(DECODE_FROM_JSON_RPC); - String inPre = "test-yang:create-sfc.input."; - String outPre = "test-yang:create-sfc.output."; + String inPre = "test-yang_create-sfc.input."; + String outPre = "test-yang_create-sfc.output."; SvcLogicContext ctx = createAttListRpc(inPre); p.put("dirPath", "src/test/resources"); p.put("format", "json"); @@ -509,8 +509,8 @@ public class DataFormatSerializerTest { @Test public void codecToXmlRpc() throws SvcLogicException { createMockForDecode(DECODE_FROM_XML_RPC); - String inPre = "test-yang:create-sfc.input."; - String outPre = "test-yang:create-sfc.output."; + String inPre = "test-yang_create-sfc.input."; + String outPre = "test-yang_create-sfc.output."; SvcLogicContext ctx = createAttListRpc(inPre); p.put("dirPath", "src/test/resources"); p.put("format", "xml"); @@ -650,21 +650,21 @@ public class DataFormatSerializerTest { ctx.setAttribute(pre + "leaf12", "abc"); ctx.setAttribute(pre + "ll5[0]", "abc"); ctx.setAttribute(pre + "ll5[1]", "abc"); - ctx.setAttribute(pre + "cont4.test-augment:cont5.leaf13", "true"); - ctx.setAttribute(pre + "cont4.test-augment:list7[0].leaf14", "test"); - ctx.setAttribute(pre + "cont4.test-augment:list7[1].leaf14", "create"); - ctx.setAttribute(pre + "cont4.test-augment:leaf15", "abc"); - ctx.setAttribute(pre + "cont4.test-augment:ll6[0]", "unbounded"); - ctx.setAttribute(pre + "cont4.test-augment:ll6[1]", "8"); - ctx.setAttribute(pre + "cont4.test-augment:cont13.cont12.leaf26", + ctx.setAttribute(pre + "cont4.test-augment_cont5.leaf13", "true"); + ctx.setAttribute(pre + "cont4.test-augment_list7[0].leaf14", "test"); + ctx.setAttribute(pre + "cont4.test-augment_list7[1].leaf14", "create"); + ctx.setAttribute(pre + "cont4.test-augment_leaf15", "abc"); + ctx.setAttribute(pre + "cont4.test-augment_ll6[0]", "unbounded"); + ctx.setAttribute(pre + "cont4.test-augment_ll6[1]", "8"); + ctx.setAttribute(pre + "cont4.test-augment_cont13.cont12.leaf26", "abc"); - ctx.setAttribute(pre + "cont4.test-augment:cont13.list9[0].leaf27", + ctx.setAttribute(pre + "cont4.test-augment_cont13.list9[0].leaf27", "abc"); - ctx.setAttribute(pre + "cont4.test-augment:cont13.list9[1].leaf27", + ctx.setAttribute(pre + "cont4.test-augment_cont13.list9[1].leaf27", "abc"); - ctx.setAttribute(pre + "cont4.test-augment:cont13.leaf28", "abc"); - ctx.setAttribute(pre + "cont4.test-augment:cont13.ll9[0]", "abc"); - ctx.setAttribute(pre + "cont4.test-augment:cont13.ll9[1]", "abc"); + ctx.setAttribute(pre + "cont4.test-augment_cont13.leaf28", "abc"); + ctx.setAttribute(pre + "cont4.test-augment_cont13.ll9[0]", "abc"); + ctx.setAttribute(pre + "cont4.test-augment_cont13.ll9[1]", "abc"); return ctx; } @@ -785,29 +785,29 @@ public class DataFormatSerializerTest { assertThat(ctx.getAttribute(pre + "leaf12"), is("abc")); assertThat(ctx.getAttribute(pre + "ll5[0]"), is("abc")); assertThat(ctx.getAttribute(pre + "ll5[1]"), is("abc")); - assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont5.leaf13"), + assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont5.leaf13"), is("true")); - assertThat(ctx.getAttribute(pre + "cont4.test-augment:list7[0].leaf14"), + assertThat(ctx.getAttribute(pre + "cont4.test-augment_list7[0].leaf14"), is("test")); - assertThat(ctx.getAttribute(pre + "cont4.test-augment:list7[1].leaf14"), + assertThat(ctx.getAttribute(pre + "cont4.test-augment_list7[1].leaf14"), is("create")); - assertThat(ctx.getAttribute(pre + "cont4.test-augment:leaf15"), + assertThat(ctx.getAttribute(pre + "cont4.test-augment_leaf15"), is("abc")); - assertThat(ctx.getAttribute(pre + "cont4.test-augment:ll6[0]"), + assertThat(ctx.getAttribute(pre + "cont4.test-augment_ll6[0]"), is("unbounded")); - assertThat(ctx.getAttribute(pre + "cont4.test-augment:ll6[1]"), + assertThat(ctx.getAttribute(pre + "cont4.test-augment_ll6[1]"), is("8")); - assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13" + + assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13" + ".cont12.leaf26"), is("abc")); - assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.list9[0]" + + assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.list9[0]" + ".leaf27"), is("abc")); - assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.list9[1]" + + assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.list9[1]" + ".leaf27"), is("abc")); - assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.leaf28"), + assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.leaf28"), is("abc")); - assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.ll9[0]"), + assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.ll9[0]"), is("abc")); - assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.ll9[1]"), + assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.ll9[1]"), is("abc")); } diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java index 027604480..a7814e10e 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java @@ -121,7 +121,11 @@ public final class DataFormatUtilsTest { "\n"; static final String ENCODE_TO_JSON_YANG_COMMON = "\n " + - "\"test-augment:cont13\": {\n" + + "\"test-augment:ll6\": [\n" + + " \"unbounded\",\n" + + " \"8\"\n" + + " ],\n" + + " \"test-augment:cont13\": {\n" + " \"ll9\": [\n" + " \"abc\",\n" + " \"abc\"\n" + @@ -148,10 +152,6 @@ public final class DataFormatUtilsTest { " }\n" + " ],\n" + " \"test-augment:leaf15\": \"abc\",\n" + - " \"test-augment:ll6\": [\n" + - " \"unbounded\",\n" + - " \"8\"\n" + - " ],\n" + " \"test-augment:cont5\": {\n" + " \"leaf13\": \"true\"\n" + " }"; @@ -277,6 +277,10 @@ public final class DataFormatUtilsTest { "}"; static final String ENCODE_TO_XML_YANG_COMMON = "\n" + + "unbounded\n" + + "8\n" + "\n" + " abc\n" + @@ -302,10 +306,6 @@ public final class DataFormatUtilsTest { "\n" + "abc\n" + - "unbounded\n" + - "8\n" + "\n" + " true\n" + @@ -557,8 +557,8 @@ public final class DataFormatUtilsTest { * @param i number of space * @return space appended string */ - private static String addSpace(String req, int i) { - StringBuilder space = new StringBuilder(""); + public static String addSpace(String req, int i) { + StringBuilder space = new StringBuilder(); for (int sp = 0; sp < i; sp++) { space = space.append(" "); } diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationTest.java new file mode 100644 index 000000000..1109d426c --- /dev/null +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationTest.java @@ -0,0 +1,762 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2019 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.restapicall.HttpResponse; +import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; +import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode; +import org.opendaylight.restconf.common.context.InstanceIdentifierContext; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doCallRealMethod; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.DECODE_FROM_JSON_RPC_ID; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.DECODE_FROM_XML_RPC_ID; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_RPC_ID; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_WITH_AUG_PATH; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_YANG_AUG_POST_ID; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_YANG_ID; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_YANG_PUT_ID; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_RPC_ID; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_YANG_AUG_POST_ID; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_YANG_ID; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_YANG_PUT_ID; + +/** + * Unit test cases for identifier validation test. + */ +public class IdentifierValidationTest { + + private Map p; + + private RestconfApiCallNode restconf; + + private RestapiCallNode restApi; + + private DfCaptor dfCaptor; + + /** + * Sets up the pre-requisite for each test case. + * + * @throws SvcLogicException when test case fails + */ + @Before + public void setUp() throws SvcLogicException { + p = new HashMap<>(); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + restApi = new RestapiCallNode(); + restconf = mock(RestconfApiCallNode.class); + dfCaptor = new DfCaptor(); + createMethodMocks(); + } + + /** + * Creates method mocks using mockito for RestconfApiCallNode class. + * + * @throws SvcLogicException when test case fails + */ + private void createMethodMocks() throws SvcLogicException { + doReturn(restApi).when(restconf).getRestapiCallNode(); + doCallRealMethod().when(restconf).sendRequest( + any(Map.class), any(SvcLogicContext.class)); + doCallRealMethod().when(restconf).sendRequest( + any(Map.class), any(SvcLogicContext.class), any(Integer.class)); + doAnswer(dfCaptor).when(restconf).serializeRequest( + any(Map.class), any(YangParameters.class), any(String.class), + any(InstanceIdentifierContext.class)); + doAnswer(dfCaptor).when(restconf).updateReq( + any(String.class), any(YangParameters.class), + any(InstanceIdentifierContext.class)); + } + + /** + * Creates mock using mockito with input data for decoding. + * + * @param decodeData input data + * @throws SvcLogicException when test case fails + */ + private void createMockForDecode(String decodeData) + throws SvcLogicException { + doReturn(decodeData).when(restconf).getResponse( + any(SvcLogicContext.class), any(YangParameters.class), + any(String.class), any(HttpResponse.class)); + doCallRealMethod().when(restconf).serializeResponse( + any(YangParameters.class), any(String.class), any(String.class), + any(InstanceIdentifierContext.class)); + } + + /** + * Verifies encoding of parameters to JSON data format with containers, + * grouping and augment. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToJsonYang() throws SvcLogicException { + String pre = "test_name_of_the_module_name_of_the_cont1.name_" + + "of_the_cont2."; + SvcLogicContext ctx = createAttListYang(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("restapiUrl", "http://echo.getpostman.com/restconf/operati" + + "ons/test_name_of_the_module:name_of_the_cont1"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_ID)); + } + + /** + * Verifies encoding of parameters with augment in the URL. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToJsonYangWithAugUrl() throws SvcLogicException { + String pre = "test_name_of_the_module_name_of_the_cont1.name_" + + "of_the_cont2."; + SvcLogicContext ctx = createAttListYang(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("restapiUrl", "http://echo.getpostman.com/restconf/operati" + + "ons/test_name_of_the_module:name_of_the_cont1/name_of_t" + + "he_cont2/name_of_the_cont4/test_augment_1_for_module:na" + + "me_of_the_cont5"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_WITH_AUG_PATH)); + } + + /** + * Verifies encoding of parameters to JSON data format with containers, + * grouping and augment for put operation-type. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToJsonYangWithPut() throws SvcLogicException { + String pre = "test_name_of_the_module_name_of_the_cont1.name_of_the_cont2."; + SvcLogicContext ctx = createAttListYang(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "json"); + p.put("httpMethod", "put"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/test_name_of_the_module:name_of" + + "_the_cont1/name_of_the_cont2/name_of_the_cont4"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_PUT_ID)); + } + + /** + * Verifies encoding of parameters to JSON data format with containers, + * grouping and augment for patch operation-type. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToJsonYangWithPatch() throws SvcLogicException { + String pre = "test_name_of_the_module_name_of_the_cont1.name_o" + + "f_the_cont2."; + SvcLogicContext ctx = createAttListYang(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "json"); + p.put("httpMethod", "patch"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/test_name_of_the_module:name_of_" + + "the_cont1/name_of_the_cont2/name_of_the_cont4"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_PUT_ID)); + } + + /** + * Verifies encoding of parameters to JSON data format with augment as + * root child. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToJsonWithAugAsRootChild() throws SvcLogicException { + String pre = "test_name_of_the_module_name_of_the_cont1.name_of_" + + "the_cont2."; + SvcLogicContext ctx = createAttListYang(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/test_name_of_the_module:name_of_" + + "the_cont1/name_of_the_cont2/name_of_the_cont4"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_AUG_POST_ID)); + } + + /** + * Verifies decoding of parameters from JSON data format with containers, + * grouping and augment. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void decodeToJsonYang() throws SvcLogicException { + createMockForDecode(ENCODE_TO_JSON_YANG_ID); + SvcLogicContext ctx = new SvcLogicContext(); + String pre = "test_name_of_the_module_name_of_the_cont1.name_" + + "of_the_cont2."; + p.put("dirPath", "src/test/resources"); + p.put("format", "json"); + p.put("httpMethod", "get"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/test_name_of_the_module:name" + + "_of_the_cont1"); + restconf.sendRequest(p, ctx); + verifyAttListYang(ctx, pre); + } + + /** + * Verifies encoding of parameters to XML data format with containers, + * grouping and augment. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToXmlYang() throws SvcLogicException { + String pre = "test_name_of_the_module_name_of_the_cont1.name_of" + + "_the_cont2."; + SvcLogicContext ctx = createAttListYang(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "xml"); + p.put("httpMethod", "post"); + p.put("restapiUrl", "http://echo.getpostman.com/restconf/operations/" + + "test_name_of_the_module:name_of_the_cont1"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_ID)); + } + + /** + * Verifies encoding of parameters to XML data format with containers, + * grouping and augment for put operation-type + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToXmlYangWithPut() throws SvcLogicException { + String pre = "test_name_of_the_module_name_of_the_cont1.name_" + + "of_the_cont2."; + SvcLogicContext ctx = createAttListYang(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "xml"); + p.put("httpMethod", "put"); + p.put("restapiUrl", "http://echo.getpostman.com/restconf/operations/" + + "test_name_of_the_module:name_of_the_cont1/name_of_the_cont2" + + "/name_of_the_cont4"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_PUT_ID)); + } + + /** + * Verifies encoding of parameters to XML data format with containers, + * grouping and augment for patch operation-type + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToXmlYangWithPatch() throws SvcLogicException { + String pre = "test_name_of_the_module_name_of_the_cont1.name_of" + + "_the_cont2."; + SvcLogicContext ctx = createAttListYang(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "xml"); + p.put("httpMethod", "put"); + p.put("restapiUrl", "http://echo.getpostman.com/restconf/operation" + + "s/test_name_of_the_module:name_of_the_cont1/name_of_the_c" + + "ont2/name_of_the_cont4"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_PUT_ID)); + } + + /** + * Verifies encoding of parameters to XML data format with augment as + * root child. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToXmlWithAugAsRootChild() throws SvcLogicException { + String pre = "test_name_of_the_module_name_of_the_cont1.name_of_the" + + "_cont2."; + SvcLogicContext ctx = createAttListYang(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "xml"); + p.put("httpMethod", "post"); + p.put("restapiUrl", "http://echo.getpostman.com/restconf/operations/" + + "test_name_of_the_module:name_of_the_cont1/name_of_the_cont2" + + "/name_of_the_cont4"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_AUG_POST_ID)); + } + + /** + * Verifies decoding of parameters from XML data format with containers, + * grouping and augment. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void decodeToXmlYang() throws SvcLogicException { + createMockForDecode(ENCODE_TO_XML_YANG_ID); + SvcLogicContext ctx = new SvcLogicContext(); + String pre = "test_name_of_the_module_name_of_the_cont1.name_of_" + + "the_cont2."; + p.put("dirPath", "src/test/resources"); + p.put("format", "xml"); + p.put("httpMethod", "get"); + p.put("restapiUrl", "http://echo.getpostman.com/restconf/operation" + + "s/test_name_of_the_module:name_of_the_cont1"); + restconf.sendRequest(p, ctx); + verifyAttListYang(ctx, pre); + } + + /** + * Verifies encoding of and decoding from, JSON respectively for data + * format with containers, grouping and augment. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void codecToJsonRpc() throws SvcLogicException { + createMockForDecode(DECODE_FROM_JSON_RPC_ID); + String inPre = "test_name_of_the_module_name_of_the_create-sfc.input."; + String outPre = "test_name_of_the_module_name_of_the_create-sfc" + + ".output."; + SvcLogicContext ctx = createAttListRpc(inPre); + p.put("dirPath", "src/test/resources"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("restapiUrl", "http://echo.getpostman.com/restconf/operations" + + "/test_name_of_the_module:name_of_the_create-sfc"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_RPC_ID)); + verifyAttListRpc(ctx, outPre); + } + + /** + * Verifies encoding of and decoding from, XML respectively for data + * format with containers, grouping and augment. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void codecToXmlRpc() throws SvcLogicException { + createMockForDecode(DECODE_FROM_XML_RPC_ID); + String inPre = "test_name_of_the_module_name_of_the_create-sfc.input."; + String outPre = "test_name_of_the_module_name_of_the_create-sfc.output."; + SvcLogicContext ctx = createAttListRpc(inPre); + p.put("dirPath", "src/test/resources"); + p.put("format", "xml"); + p.put("httpMethod", "post"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/test_name_of_the_module" + + ":name_of_the_create-sfc"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_RPC_ID)); + verifyAttListRpc(ctx, outPre); + } + + /** + * Creates attribute list for encoding JSON or XML with container, + * grouping and augmented YANG file. + * + * @param pre prefix + * @return service logic context + */ + private SvcLogicContext createAttListYang(String pre) { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute(pre + "name_of_the_cont3.name_of_the_leaf" + + "10", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_leaf1" + + "", "true"); + ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_leaf2" + + "", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_leaf3" + + "", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" + + "ll1[0]", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" + + "ll1[1]", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" + + "ll2[0]", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" + + "ll2[1]", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" + + "cont4.name_of_the_leaf11", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" + + "list4[0].name_of_the_leaf8", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" + + "list4[1].name_of_the_leaf8", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" + + "list5[0].name_of_the_leaf9", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" + + "list5[1].name_of_the_leaf9", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" + + "leaf1", "true"); + ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" + + "leaf2", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" + + "leaf3", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" + + "ll1[0]", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" + + "ll1[1]", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" + + "ll2[0]", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" + + "ll2[1]", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" + + "cont4.name_of_the_leaf11", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" + + "list4[0].name_of_the_leaf8", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" + + "list4[1].name_of_the_leaf8", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" + + "list5[0].name_of_the_leaf9", "abc"); + ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" + + "list5[1].name_of_the_leaf9", "abc"); + ctx.setAttribute(pre + "name_of_the_list2[0].name_of_the_" + + "leaf4", "abc"); + ctx.setAttribute(pre + "name_of_the_list2[1].name_of_the_" + + "leaf4", "abc"); + ctx.setAttribute(pre + "name_of_the_leaf5", "abc"); + ctx.setAttribute(pre + "name_of_the_leaf6", "abc"); + ctx.setAttribute(pre + "name_of_the_ll3[0]", "abc"); + ctx.setAttribute(pre + "name_of_the_ll3[1]", "abc"); + ctx.setAttribute(pre + "name_of_the_ll4[0]", "abc"); + ctx.setAttribute(pre + "name_of_the_ll4[1]", "abc"); + ctx.setAttribute(pre + "name_of_the_cont4.name_of_the_leaf10", + "abc"); + ctx.setAttribute(pre + "name_of_the_list6[0].name_of_the_leaf11", + "abc"); + ctx.setAttribute(pre + "name_of_the_list6[1].name_of_the_leaf11", + "abc"); + ctx.setAttribute(pre + "name_of_the_leaf12", "abc"); + ctx.setAttribute(pre + "name_of_the_ll5[0]", "abc"); + ctx.setAttribute(pre + "name_of_the_ll5[1]", "abc"); + ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" + + "module_name_of_the_cont5.name_of_the_leaf13", + "true"); + ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" + + "module_name_of_the_list7[0].name_of_the" + + "_leaf14", "test"); + ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" + + "module_name_of_the_list7[1].name_of_the" + + "_leaf14", "create"); + ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" + + "module_name_of_the_leaf15", "abc"); + ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" + + "module_name_of_the_ll6[0]", + "unbounded"); + ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" + + "_module_name_of_the_ll6[1]", "8"); + ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" + + "_module_name_of_the_cont13.name_of_the_" + + "cont12.name_of_the_leaf26", + "abc"); + ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" + + "module_name_of_the_cont13.name_of_the_" + + "list9[0].name_of_the_leaf27", + "abc"); + ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" + + "_module_name_of_the_cont13.name_of_the_" + + "list9[1].name_of_the_leaf27", + "abc"); + ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" + + "_module_name_of_the_cont13.name_of_the_" + + "leaf28", "abc"); + ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" + + "_module_name_of_the_cont13.name_of_the_" + + "ll9[0]", "abc"); + ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" + + "_module_name_of_the_cont13.name_of_the_" + + "ll9[1]", "abc"); + return ctx; + } + + /** + * Creates attribute list for encoding JSON or XML with RPC YANG file. + * + * @param pre prefix + * @return service logic context + */ + private SvcLogicContext createAttListRpc(String pre) { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute(pre + "name_of_the_cont14.name_of_the_leaf28", + "abc"); + ctx.setAttribute(pre + "name_of_the_list10[0].name_of_the_leaf29", + "abc"); + ctx.setAttribute(pre + "name_of_the_list10[1].name_of_the_leaf29", + "abc"); + ctx.setAttribute(pre + "name_of_the_leaf30", "abc"); + ctx.setAttribute(pre + "name_of_the_ll10[0]", "abc"); + ctx.setAttribute(pre + "name_of_the_ll10[1]", "abc"); + ctx.setAttribute(pre + "name_of_the_cont15.name_of_the_leaf31", + "abc"); + ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_list9[0]" + + ".name_of_the_leaf27", "abc"); + ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_list9[1]" + + ".name_of_the_leaf27", "abc"); + ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_leaf28", + "abc"); + ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_ll9[0]", + "abc"); + ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_ll9[1]", + "abc"); + return ctx; + } + + /** + * Verifies the attribute list for decoding from JSON or XML with + * container, grouping and augmented file. + * + * @param ctx service logic context + * @param pre prefix + */ + private void verifyAttListYang(SvcLogicContext ctx, String pre) { + assertThat(ctx.getAttribute(pre + "name_of_the_cont3.name_of" + + "_the_leaf10"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" + + "_of_the_leaf1"), is("true")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" + + "_of_the_leaf2"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" + + "_of_the_leaf3"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" + + "_of_the_ll1[0]"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" + + "_of_the_ll1[1]"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" + + "_of_the_ll2[0]"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" + + "_of_the_ll2[1]"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" + + "_of_the_cont4.name_of_the_leaf11"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" + + "_the_list4[0].name_of_the_leaf8"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" + + "_the_list4[1].name_of_the_leaf8"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" + + "_the_list5[0].name_of_the_leaf9"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" + + "_the_list5[1].name_of_the_leaf9"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" + + "_the_leaf1"), is("true")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" + + "_the_leaf2"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" + + "_the_leaf3"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" + + "_the_ll1[0]"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" + + "_the_ll1[1]"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" + + "_the_ll2[0]"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" + + "_the_ll2[1]"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" + + "_the_cont4.name_of_the_leaf11"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" + + "_the_list4[0].name_of_the_leaf8"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" + + "_the_list4[1].name_of_the_leaf8"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" + + "_the_list5[0].name_of_the_leaf9"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" + + "_the_list5[1].name_of_the_leaf9"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list2[0].name_of" + + "_the_leaf4"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list2[1].name_of" + + "_the_leaf4"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_leaf5"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_leaf6"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_ll3[0]"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_ll3[1]"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_ll4[0]"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_ll4[1]"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont4.name_of" + + "_the_leaf10"), is( "abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list6[0].name_of" + + "_the_leaf11"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list6[1].name_of" + + "_the_leaf11"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_leaf12"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_ll5[0]"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_ll5[1]"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" + + "augment_1_for_module_name_of_" + + "the_cont5.name_of_the_leaf13"), + is("true")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" + + "augment_1_for_module_name_of_" + + "the_list7[0].name_of_the_leaf14"), + is("test")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" + + "augment_1_for_module_name_of_" + + "the_list7[1].name_of_the_leaf14"), + is("create")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" + + "augment_1_for_module_name_of_" + + "the_leaf15"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" + + "augment_1_for_module_name_of_" + + "the_ll6[0]"), + is("unbounded")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" + + "augment_1_for_module_name_of_" + + "the_ll6[1]"), + is("8")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" + + "augment_1_for_module_name_of_" + + "the_cont13" + + ".name_of_the_cont12.name_of_" + + "the_leaf26"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" + + "augment_1_for_module_name_of_" + + "the_cont13.name_of_the_list9[0]" + + ".name_of_the_leaf27"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" + + "augment_1_for_module_name_of_" + + "the_cont13.name_of_the_list9[1]" + + ".name_of_the_leaf27"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" + + "augment_1_for_module_name_of_" + + "the_cont13.name_of_the_leaf28"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" + + "augment_1_for_module_name_of_" + + "the_cont13.name_of_the_ll9[0]"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" + + "augment_1_for_module_name_of_" + + "the_cont13.name_of_the_ll9[1]"), + is("abc")); + } + + /** + * Verifies the attribute list for decoding from JSON or XML with + * RPC YANG file. + * + * @param ctx service logic context + * @param pre prefix + */ + private void verifyAttListRpc(SvcLogicContext ctx, String pre) { + assertThat(ctx.getAttribute(pre + "name_of_the_cont16.name_of_" + + "the_leaf32"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list11[0].name" + + "_of_the_leaf33"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_list11[1].name" + + "_of_the_leaf33"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_leaf34"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_ll11[0]"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_ll11[1]"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont17.name_of_" + + "the_leaf35"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" + + "the_cont12.name_of_the_leaf26"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" + + "the_list9[0].name_of_the_leaf27"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" + + "the_list9[1].name_of_the_leaf27"), + is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" + + "the_ll9[0]"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" + + "the_ll9[1]"), is("abc")); + assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" + + "the_leaf28"), is("abc")); + } + + /** + * Captures the data format messages by mocking it, which can be used in + * testing the value. + * + * @param capturing data format + */ + public class DfCaptor implements Answer { + + private String result; + + /** + * Returns the captured data format message. + * + * @return data format message. + */ + public String getResult() { + return result; + } + + @Override + public String answer(InvocationOnMock invocationOnMock) + throws Throwable { + result = (String) invocationOnMock.callRealMethod(); + return result; + } + } + +} diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationUtilsTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationUtilsTest.java new file mode 100644 index 000000000..a866f1c4a --- /dev/null +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationUtilsTest.java @@ -0,0 +1,469 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2019 Huawei Technologies Co., Ltd. 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.yangserializers.dfserializer; + +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.addSpace; + +/** + * Unit test case utilities for identifier validation and restconf api + * call node. + */ +public final class IdentifierValidationUtilsTest { + + static final String ENCODE_TO_JSON_YANG_COMMON_ID = "\n " + + "\"test_augment_1_for_module:name_of_the_ll6\": [\n" + + " \"unbounded\",\n" + + " \"8\"\n" + + " ],\n" + + " \"test_augment_1_for_module:name_of_the_cont13\": {\n" + + " \"name_of_the_cont12\": {\n" + + " \"name_of_the_leaf26\": \"abc\"\n" + + " },\n" + + " \"name_of_the_ll9\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"name_of_the_leaf28\": \"abc\",\n" + + " \"name_of_the_list9\": [\n" + + " {\n" + + " \"name_of_the_leaf27\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"name_of_the_leaf27\": \"abc\"\n" + + " }\n" + + " ]\n" + + " },\n" + + " \"test_augment_1_for_module:name_of_the_list7\": [\n" + + " {\n" + + " \"name_of_the_leaf14\": \"test\"\n" + + " },\n" + + " {\n" + + " \"name_of_the_leaf14\": \"create\"\n" + + " }\n" + + " ],\n" + + " \"test_augment_1_for_module:name_of_the_leaf15\": \"abc\",\n" + + " \"test_augment_1_for_module:name_of_the_cont5\": {\n" + + " \"name_of_the_leaf13\": \"true\"\n" + + " }"; + + static final String ENCODE_TO_JSON_YANG_AUG_POST_ID = "{\n" + + " \"test_name_of_the_module:name_of_the_leaf10\": \"abc\"," + + ENCODE_TO_JSON_YANG_COMMON_ID + "\n}"; + + static final String ENCODE_TO_JSON_YANG_ID = "{\n" + + " \"test_name_of_the_module:name_of_the_cont2\": {\n" + + " \"name_of_the_ll4\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"name_of_the_leaf5\": \"abc\",\n" + + " \"name_of_the_list6\": [\n" + + " {\n" + + " \"name_of_the_leaf11\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"name_of_the_leaf11\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"name_of_the_ll5\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"name_of_the_ll3\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"name_of_the_leaf6\": \"abc\",\n" + + " \"name_of_the_cont3\": {\n" + + " \"name_of_the_leaf10\": \"abc\"\n" + + " },\n" + + " \"name_of_the_list2\": [\n" + + " {\n" + + " \"name_of_the_leaf4\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"name_of_the_leaf4\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"name_of_the_list1\": [\n" + + " {\n" + + " \"name_of_the_ll2\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"name_of_the_list5\": [\n" + + " {\n" + + " \"name_of_the_leaf9\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"name_of_the_leaf9\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"name_of_the_list4\": [\n" + + " {\n" + + " \"name_of_the_leaf8\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"name_of_the_leaf8\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"name_of_the_leaf1\": \"true\",\n" + + " \"name_of_the_leaf3\": \"abc\",\n" + + " \"name_of_the_leaf2\": \"abc\",\n" + + " \"name_of_the_cont4\": {\n" + + " \"name_of_the_leaf11\": \"abc\"\n" + + " },\n" + + " \"name_of_the_ll1\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"name_of_the_ll2\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"name_of_the_list5\": [\n" + + " {\n" + + " \"name_of_the_leaf9\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"name_of_the_leaf9\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"name_of_the_list4\": [\n" + + " {\n" + + " \"name_of_the_leaf8\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"name_of_the_leaf8\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"name_of_the_leaf1\": \"true\",\n" + + " \"name_of_the_leaf3\": \"abc\",\n" + + " \"name_of_the_leaf2\": \"abc\",\n" + + " \"name_of_the_cont4\": {\n" + + " \"name_of_the_leaf11\": \"abc\"\n" + + " },\n" + + " \"name_of_the_ll1\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"name_of_the_cont4\": {\n" + + " \"name_of_the_leaf10\": \"abc\"," + + addSpace(ENCODE_TO_JSON_YANG_COMMON_ID,8) + "\n" + + " },\n" + + " \"name_of_the_leaf12\": \"abc\"\n" + + " }\n" + + "}"; + + static final String ENCODE_TO_JSON_WITH_AUG_PATH = "{\n" + + " \"test_augment_1_for_module:name_of_the_leaf13\": \"true\"\n" + + "}"; + + static final String ENCODE_TO_JSON_YANG_PUT_ID = "{\n" + + " \"test_name_of_the_module:name_of_the_cont4\": {" + addSpace( + ENCODE_TO_JSON_YANG_COMMON_ID, 4) + ",\n" + + " \"name_of_the_leaf10\": \"abc\"\n" + + " }\n" + + "}"; + + static final String ENCODE_TO_XML_YANG_COMMON_ID = "\n" + + "unbounded\n" + + "8\n" + + "\n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + "\n" + + "\n" + + " test\n" + + "\n" + + "\n" + + " create\n" + + "\n" + + "abc\n" + + "\n" + + " true\n" + + ""; + + static final String ENCODE_TO_XML_YANG_AUG_POST_ID = "\n" + + "abc" + + ENCODE_TO_XML_YANG_COMMON_ID + "\n"; + + static final String ENCODE_TO_XML_YANG_PUT_ID = "\n" + + "\n" + + " abc" + + addSpace(ENCODE_TO_XML_YANG_COMMON_ID, 4) + "\n\n"; + + static final String ENCODE_TO_XML_YANG_ID= "\n" + + "\n" + + " abc\n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " abc\n" + + " abc\n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " true\n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " true\n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " abc\n" + + " \n" + + " \n" + + " abc" + + addSpace(ENCODE_TO_XML_YANG_COMMON_ID, 8) + "\n" + + " \n" + + " abc\n" + + "\n"; + + static final String ENCODE_TO_JSON_RPC_ID = "{\n" + + " \"test_name_of_the_module:input\": {\n" + + " \"name_of_the_cont14\": {\n" + + " \"name_of_the_leaf28\": \"abc\"\n" + + " },\n" + + " \"name_of_the_cont13\": {\n" + + " \"name_of_the_ll9\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"name_of_the_leaf28\": \"abc\",\n" + + " \"name_of_the_list9\": [\n" + + " {\n" + + " \"name_of_the_leaf27\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"name_of_the_leaf27\": \"abc\"\n" + + " }\n" + + " ]\n" + + " },\n" + + " \"name_of_the_leaf30\": \"abc\",\n" + + " \"name_of_the_ll10\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"name_of_the_list10\": [\n" + + " {\n" + + " \"name_of_the_leaf29\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"name_of_the_leaf29\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"name_of_the_cont15\": {\n" + + " \"name_of_the_leaf31\": \"abc\"\n" + + " }\n" + + " }\n" + + "}"; + + static final String DECODE_FROM_JSON_RPC_ID = "{\n" + + " \"test_name_of_the_module:output\": {\n" + + " \"name_of_the_cont16\": {\n" + + " \"name_of_the_leaf32\": \"abc\"\n" + + " },\n" + + " \"name_of_the_list11\": [\n" + + " {\n" + + " \"name_of_the_leaf33\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"name_of_the_leaf33\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"name_of_the_leaf34\": \"abc\",\n" + + " \"name_of_the_ll11\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"name_of_the_cont17\": {\n" + + " \"name_of_the_leaf35\": \"abc\"\n" + + " },\n" + + " \"name_of_the_cont13\": {\n" + + " \"name_of_the_cont12\": {\n" + + " \"name_of_the_leaf26\": \"abc\"\n" + + " },\n" + + " \"name_of_the_list9\": [\n" + + " {\n" + + " \"name_of_the_leaf27\": \"abc\"\n" + + " },\n" + + " {\n" + + " \"name_of_the_leaf27\": \"abc\"\n" + + " }\n" + + " ],\n" + + " \"name_of_the_ll9\": [\n" + + " \"abc\",\n" + + " \"abc\"\n" + + " ],\n" + + " \"name_of_the_leaf28\": \"abc\"\n" + + " }\n" + + " }\n" + + "}"; + + static final String ENCODE_TO_XML_RPC_ID = "\n" + + "\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + "\n"; + + static final String DECODE_FROM_XML_RPC_ID = "\n" + + "\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " abc\n" + + " abc\n" + + " \n" + + ""; +} diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java index dc0da6f7c..c3a6b4ea8 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java @@ -19,15 +19,6 @@ */ package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer; -import org.junit.Before; -import org.junit.Test; - -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.opendaylight.restconf.common.context.InstanceIdentifierContext; -import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; - import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; @@ -37,6 +28,14 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.opendaylight.restconf.common.context.InstanceIdentifierContext; +import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertTrue; @@ -53,39 +52,39 @@ public final class PropertiesSerializerTest { public void testBasicConstructs() throws SvcLogicException { String uri = "test-yang:cont1/cont2"; Map params = new HashMap<>(); - params.put("test-yang:cont1.cont2.cont3.leaf10", "abc"); - params.put("test-yang:cont1.cont2.list1[0].leaf1", "abc"); - params.put("test-yang:cont1.cont2.list1[0].leaf2", "abc"); - params.put("test-yang:cont1.cont2.list1[0].leaf3", "abc"); - params.put("test-yang:cont1.cont2.list1[0].ll1[0]", "abc"); - params.put("test-yang:cont1.cont2.list1[0].ll1[1]", "abc"); - params.put("test-yang:cont1.cont2.list1[0].ll2[0]", "abc"); - params.put("test-yang:cont1.cont2.list1[0].ll2[1]", "abc"); - params.put("test-yang:cont1.cont2.list1[0].cont4.leaf11", "abc"); - params.put("test-yang:cont1.cont2.list1[0].list4[0].leaf8", "abc"); - params.put("test-yang:cont1.cont2.list1[0].list4[1].leaf8", "abc"); - params.put("test-yang:cont1.cont2.list1[0].list5[0].leaf9", "abc"); - params.put("test-yang:cont1.cont2.list1[0].list5[1].leaf9", "abc"); - params.put("test-yang:cont1.cont2.list1[1].leaf1", "abc"); - params.put("test-yang:cont1.cont2.list1[1].leaf2", "abc"); - params.put("test-yang:cont1.cont2.list1[1].leaf3", "abc"); - params.put("test-yang:cont1.cont2.list1[1].ll1[0]", "abc"); - params.put("test-yang:cont1.cont2.list1[1].ll1[1]", "abc"); - params.put("test-yang:cont1.cont2.list1[1].ll2[0]", "abc"); - params.put("test-yang:cont1.cont2.list1[1].ll2[1]", "abc"); - params.put("test-yang:cont1.cont2.list1[1].cont4.leaf11", "abc"); - params.put("test-yang:cont1.cont2.list1[1].list4[0].leaf8", "abc"); - params.put("test-yang:cont1.cont2.list1[1].list4[1].leaf8", "abc"); - params.put("test-yang:cont1.cont2.list1[1].list5[0].leaf9", "abc"); - params.put("test-yang:cont1.cont2.list1[1].list5[1].leaf9", "abc"); - params.put("test-yang:cont1.cont2.list2[0].leaf4", "abc"); - params.put("test-yang:cont1.cont2.list2[1].leaf4", "abc"); - params.put("test-yang:cont1.cont2.leaf5", "abc"); - params.put("test-yang:cont1.cont2.leaf6", "abc"); - params.put("test-yang:cont1.cont2.ll3[0]", "abc"); - params.put("test-yang:cont1.cont2.ll3[1]", "abc"); - params.put("test-yang:cont1.cont2.ll4[0]", "abc"); - params.put("test-yang:cont1.cont2.ll4[1]", "abc"); + params.put("test-yang_cont1.cont2.cont3.leaf10", "abc"); + params.put("test-yang_cont1.cont2.list1[0].leaf1", "abc"); + params.put("test-yang_cont1.cont2.list1[0].leaf2", "abc"); + params.put("test-yang_cont1.cont2.list1[0].leaf3", "abc"); + params.put("test-yang_cont1.cont2.list1[0].ll1[0]", "abc"); + params.put("test-yang_cont1.cont2.list1[0].ll1[1]", "abc"); + params.put("test-yang_cont1.cont2.list1[0].ll2[0]", "abc"); + params.put("test-yang_cont1.cont2.list1[0].ll2[1]", "abc"); + params.put("test-yang_cont1.cont2.list1[0].cont4.leaf11", "abc"); + params.put("test-yang_cont1.cont2.list1[0].list4[0].leaf8", "abc"); + params.put("test-yang_cont1.cont2.list1[0].list4[1].leaf8", "abc"); + params.put("test-yang_cont1.cont2.list1[0].list5[0].leaf9", "abc"); + params.put("test-yang_cont1.cont2.list1[0].list5[1].leaf9", "abc"); + params.put("test-yang_cont1.cont2.list1[1].leaf1", "abc"); + params.put("test-yang_cont1.cont2.list1[1].leaf2", "abc"); + params.put("test-yang_cont1.cont2.list1[1].leaf3", "abc"); + params.put("test-yang_cont1.cont2.list1[1].ll1[0]", "abc"); + params.put("test-yang_cont1.cont2.list1[1].ll1[1]", "abc"); + params.put("test-yang_cont1.cont2.list1[1].ll2[0]", "abc"); + params.put("test-yang_cont1.cont2.list1[1].ll2[1]", "abc"); + params.put("test-yang_cont1.cont2.list1[1].cont4.leaf11", "abc"); + params.put("test-yang_cont1.cont2.list1[1].list4[0].leaf8", "abc"); + params.put("test-yang_cont1.cont2.list1[1].list4[1].leaf8", "abc"); + params.put("test-yang_cont1.cont2.list1[1].list5[0].leaf9", "abc"); + params.put("test-yang_cont1.cont2.list1[1].list5[1].leaf9", "abc"); + params.put("test-yang_cont1.cont2.list2[0].leaf4", "abc"); + params.put("test-yang_cont1.cont2.list2[1].leaf4", "abc"); + params.put("test-yang_cont1.cont2.leaf5", "abc"); + params.put("test-yang_cont1.cont2.leaf6", "abc"); + params.put("test-yang_cont1.cont2.ll3[0]", "abc"); + params.put("test-yang_cont1.cont2.ll3[1]", "abc"); + params.put("test-yang_cont1.cont2.ll4[0]", "abc"); + params.put("test-yang_cont1.cont2.ll4[1]", "abc"); InstanceIdentifierContext iCtx = ParserIdentifier .toInstanceIdentifier(uri, context, null); @@ -283,18 +282,18 @@ public final class PropertiesSerializerTest { public void testAugment() throws SvcLogicException { String uri = "test-yang:cont1/cont2"; Map params = new HashMap<>(); - params.put("test-yang:cont1.cont2.cont4.leaf10", "abc"); - params.put("test-yang:cont1.cont2.cont4.test-augment:cont5.leaf13", "abc"); - params.put("test-yang:cont1.cont2.cont4.test-augment:list7[0].leaf14", "abc"); - params.put("test-yang:cont1.cont2.cont4.test-augment:list7[1].leaf14", "abc"); - params.put("test-yang:cont1.cont2.cont4.test-augment:leaf15", "abc"); - params.put("test-yang:cont1.cont2.cont4.test-augment:ll6[0]", "abc"); - params.put("test-yang:cont1.cont2.cont4.test-augment:ll6[1]", "abc"); - params.put("test-yang:cont1.cont2.list6[0].leaf11", "abc"); - params.put("test-yang:cont1.cont2.list6[1].leaf11", "abc"); - params.put("test-yang:cont1.cont2.leaf12", "abc"); - params.put("test-yang:cont1.cont2.ll5[0]", "abc"); - params.put("test-yang:cont1.cont2.ll5[1]", "abc"); + params.put("test-yang_cont1.cont2.cont4.leaf10", "abc"); + params.put("test-yang_cont1.cont2.cont4.test-augment_cont5.leaf13", "abc"); + params.put("test-yang_cont1.cont2.cont4.test-augment_list7[0].leaf14", "abc"); + params.put("test-yang_cont1.cont2.cont4.test-augment_list7[1].leaf14", "abc"); + params.put("test-yang_cont1.cont2.cont4.test-augment_leaf15", "abc"); + params.put("test-yang_cont1.cont2.cont4.test-augment_ll6[0]", "abc"); + params.put("test-yang_cont1.cont2.cont4.test-augment_ll6[1]", "abc"); + params.put("test-yang_cont1.cont2.list6[0].leaf11", "abc"); + params.put("test-yang_cont1.cont2.list6[1].leaf11", "abc"); + params.put("test-yang_cont1.cont2.leaf12", "abc"); + params.put("test-yang_cont1.cont2.ll5[0]", "abc"); + params.put("test-yang_cont1.cont2.ll5[1]", "abc"); InstanceIdentifierContext iCtx = ParserIdentifier .toInstanceIdentifier(uri, context, null); @@ -397,12 +396,12 @@ public final class PropertiesSerializerTest { public void testChoiceCase1() throws SvcLogicException { String uri = "test-yang:cont8"; Map params = new HashMap<>(); - params.put("test-yang:cont8.cont6.leaf16", "abc"); - params.put("test-yang:cont8.list8[0].leaf18", "abc"); - params.put("test-yang:cont8.list8[1].leaf18", "abc"); - params.put("test-yang:cont8.leaf19", "abc"); - params.put("test-yang:cont8.ll7[0]", "abc"); - params.put("test-yang:cont8.ll7[1]", "abc"); + params.put("test-yang_cont8.cont6.leaf16", "abc"); + params.put("test-yang_cont8.list8[0].leaf18", "abc"); + params.put("test-yang_cont8.list8[1].leaf18", "abc"); + params.put("test-yang_cont8.leaf19", "abc"); + params.put("test-yang_cont8.ll7[0]", "abc"); + params.put("test-yang_cont8.ll7[1]", "abc"); InstanceIdentifierContext iCtx = ParserIdentifier .toInstanceIdentifier(uri, context, null); @@ -459,9 +458,9 @@ public final class PropertiesSerializerTest { public void testChoiceCase2() throws SvcLogicException { String uri = "test-yang:cont9"; Map params = new HashMap<>(); - params.put("test-yang:cont9.leaf20", "abc"); - params.put("test-yang:cont9.ll8[0]", "abc"); - params.put("test-yang:cont9.cont11.leaf25", "abc"); + params.put("test-yang_cont9.leaf20", "abc"); + params.put("test-yang_cont9.ll8[0]", "abc"); + params.put("test-yang_cont9.cont11.leaf25", "abc"); InstanceIdentifierContext iCtx = ParserIdentifier .toInstanceIdentifier(uri, context, null); @@ -499,7 +498,7 @@ public final class PropertiesSerializerTest { public void testChoiceCase3() throws SvcLogicException { String uri = "test-yang:cont8/cont6"; Map params = new HashMap<>(); - params.put("test-yang:cont8.cont6.test-augment:leaf21", "abc"); + params.put("test-yang_cont8.cont6.test-augment_leaf21", "abc"); InstanceIdentifierContext iCtx = ParserIdentifier .toInstanceIdentifier(uri, context, null); @@ -538,10 +537,10 @@ public final class PropertiesSerializerTest { public void testGrouping() throws SvcLogicException { String uri = "test-yang:cont13"; Map params = new HashMap<>(); - params.put("test-yang:cont13.cont12.leaf26", "abc"); - params.put("test-yang:cont13.list9[0].leaf27", "abc"); - params.put("test-yang:cont13.leaf28", "abc"); - params.put("test-yang:cont13.ll9[0]", "abc"); + params.put("test-yang_cont13.cont12.leaf26", "abc"); + params.put("test-yang_cont13.list9[0].leaf27", "abc"); + params.put("test-yang_cont13.leaf28", "abc"); + params.put("test-yang_cont13.ll9[0]", "abc"); InstanceIdentifierContext iCtx = ParserIdentifier .toInstanceIdentifier(uri, context, null); @@ -587,11 +586,11 @@ public final class PropertiesSerializerTest { public void testGrouping2() throws SvcLogicException { String uri = "test-yang:cont9/cont11"; Map params = new HashMap<>(); - params.put("test-yang:cont9.cont11.leaf25", "abc"); - params.put("test-yang:cont9.cont11.cont13.cont12.leaf26", "abc"); - params.put("test-yang:cont9.cont11.cont13.list9[0].leaf27", "abc"); - params.put("test-yang:cont9.cont11.cont13.leaf28", "abc"); - params.put("test-yang:cont9.cont11.cont13.ll9[0]", "abc"); + params.put("test-yang_cont9.cont11.leaf25", "abc"); + params.put("test-yang_cont9.cont11.cont13.cont12.leaf26", "abc"); + params.put("test-yang_cont9.cont11.cont13.list9[0].leaf27", "abc"); + params.put("test-yang_cont9.cont11.cont13.leaf28", "abc"); + params.put("test-yang_cont9.cont11.cont13.ll9[0]", "abc"); InstanceIdentifierContext iCtx = ParserIdentifier .toInstanceIdentifier(uri, context, null); PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer( @@ -642,10 +641,10 @@ public final class PropertiesSerializerTest { public void testGrouping3() throws SvcLogicException { String uri = "test-augment:cont13"; Map params = new HashMap<>(); - params.put("test-augment:cont13.cont12.leaf26", "abc"); - params.put("test-augment:cont13.list9[0].leaf27", "abc"); - params.put("test-augment:cont13.leaf28", "abc"); - params.put("test-augment:cont13.ll9[0]", "abc"); + params.put("test-augment_cont13.cont12.leaf26", "abc"); + params.put("test-augment_cont13.list9[0].leaf27", "abc"); + params.put("test-augment_cont13.leaf28", "abc"); + params.put("test-augment_cont13.ll9[0]", "abc"); InstanceIdentifierContext iCtx = ParserIdentifier .toInstanceIdentifier(uri, context, null); PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer( @@ -693,10 +692,10 @@ public final class PropertiesSerializerTest { public void testGrouping4() throws SvcLogicException { String uri = "test-yang:cont1/cont2/cont4"; Map params = new HashMap<>(); - params.put("test-yang:cont1.cont2.cont4.test-augment:cont13.cont12.leaf26", "abc"); - params.put("test-yang:cont1.cont2.cont4.test-augment:cont13.list9[0].leaf27", "abc"); - params.put("test-yang:cont1.cont2.cont4.test-augment:cont13.leaf28", "abc"); - params.put("test-yang:cont1.cont2.cont4.test-augment:cont13.ll9[0]", "abc"); + params.put("test-yang_cont1.cont2.cont4.test-augment_cont13.cont12.leaf26", "abc"); + params.put("test-yang_cont1.cont2.cont4.test-augment_cont13.list9[0].leaf27", "abc"); + params.put("test-yang_cont1.cont2.cont4.test-augment_cont13.leaf28", "abc"); + params.put("test-yang_cont1.cont2.cont4.test-augment_cont13.ll9[0]", "abc"); InstanceIdentifierContext iCtx = ParserIdentifier .toInstanceIdentifier(uri, context, null); @@ -755,16 +754,16 @@ public final class PropertiesSerializerTest { public void testRpcInput() throws SvcLogicException { String uri = "test-yang:create-sfc"; Map params = new HashMap<>(); - params.put("test-yang:create-sfc.input.cont14.leaf28", "abc"); - params.put("test-yang:create-sfc.input.list10[0].leaf29", "abc"); - params.put("test-yang:create-sfc.input.leaf30", "abc"); - params.put("test-yang:create-sfc.input.ll10[0]", "abc"); - params.put("test-yang:create-sfc.input.cont15.leaf31", "abc"); - params.put("test-yang:create-sfc.input.cont13.cont12.leaf26", "abc"); - params.put("test-yang:create-sfc.input.cont13.list9[0].leaf27", "abc"); - params.put("test-yang:create-sfc.input.cont13.leaf28", "abc"); - params.put("test-yang:create-sfc.input.cont13.ll9[0]", "abc"); - params.put("test-yang:create-sfc.input.test-augment:leaf36", "abc"); + params.put("test-yang_create-sfc.input.cont14.leaf28", "abc"); + params.put("test-yang_create-sfc.input.list10[0].leaf29", "abc"); + params.put("test-yang_create-sfc.input.leaf30", "abc"); + params.put("test-yang_create-sfc.input.ll10[0]", "abc"); + params.put("test-yang_create-sfc.input.cont15.leaf31", "abc"); + params.put("test-yang_create-sfc.input.cont13.cont12.leaf26", "abc"); + params.put("test-yang_create-sfc.input.cont13.list9[0].leaf27", "abc"); + params.put("test-yang_create-sfc.input.cont13.leaf28", "abc"); + params.put("test-yang_create-sfc.input.cont13.ll9[0]", "abc"); + params.put("test-yang_create-sfc.input.test-augment_leaf36", "abc"); InstanceIdentifierContext iCtx = ParserIdentifier .toInstanceIdentifier(uri, context, null); @@ -869,16 +868,16 @@ public final class PropertiesSerializerTest { public void testRpcOutput() throws SvcLogicException { String uri = "test-yang:create-sfc"; Map params = new HashMap<>(); - params.put("test-yang:create-sfc.output.cont16.leaf32", "abc"); - params.put("test-yang:create-sfc.output.list11[0].leaf33", "abc"); - params.put("test-yang:create-sfc.output.leaf34", "abc"); - params.put("test-yang:create-sfc.output.ll11[0]", "abc"); - params.put("test-yang:create-sfc.output.cont17.leaf35", "abc"); - params.put("test-yang:create-sfc.output.cont13.cont12.leaf26", "abc"); - params.put("test-yang:create-sfc.output.cont13.list9[0].leaf27", "abc"); - params.put("test-yang:create-sfc.output.cont13.leaf28", "abc"); - params.put("test-yang:create-sfc.output.cont13.ll9[0]", "abc"); - params.put("test-yang:create-sfc.output.test-augment:leaf37", "abc"); + params.put("test-yang_create-sfc.output.cont16.leaf32", "abc"); + params.put("test-yang_create-sfc.output.list11[0].leaf33", "abc"); + params.put("test-yang_create-sfc.output.leaf34", "abc"); + params.put("test-yang_create-sfc.output.ll11[0]", "abc"); + params.put("test-yang_create-sfc.output.cont17.leaf35", "abc"); + params.put("test-yang_create-sfc.output.cont13.cont12.leaf26", "abc"); + params.put("test-yang_create-sfc.output.cont13.list9[0].leaf27", "abc"); + params.put("test-yang_create-sfc.output.cont13.leaf28", "abc"); + params.put("test-yang_create-sfc.output.cont13.ll9[0]", "abc"); + params.put("test-yang_create-sfc.output.test-augment_leaf37", "abc"); InstanceIdentifierContext iCtx = ParserIdentifier .toInstanceIdentifier(uri, context, null); @@ -983,10 +982,10 @@ public final class PropertiesSerializerTest { public void testContainerSameName() throws SvcLogicException { String uri = "test-yang:cont18"; Map params = new HashMap<>(); - params.put("test-yang:cont18.cont18.list12[0].list12[0].leaf36", "abc"); - params.put("test-yang:cont18.cont18.list12[0].leaf36", "hi"); - params.put("test-yang:cont18.cont18.list12[1].list12[0].leaf36", "xyz"); - params.put("test-yang:cont18.cont18.list12[1].list12[1].leaf36", "hey!"); + params.put("test-yang_cont18.cont18.list12[0].list12[0].leaf36", "abc"); + params.put("test-yang_cont18.cont18.list12[0].leaf36", "hi"); + params.put("test-yang_cont18.cont18.list12[1].list12[0].leaf36", "xyz"); + params.put("test-yang_cont18.cont18.list12[1].list12[1].leaf36", "hey!"); InstanceIdentifierContext iCtx = ParserIdentifier .toInstanceIdentifier(uri, context, null); @@ -1055,9 +1054,9 @@ public final class PropertiesSerializerTest { public void testPropertiesWithoutSchema() throws SvcLogicException { String uri = "test-yang:cont18"; Map params = new HashMap<>(); - params.put("test-yang:cont18.leaf40", "abc"); + params.put("test-yang_cont18.leaf40", "abc"); params.put("leaf41", "hi"); - params.put("test-yang:cont18.leaf41", "abc"); + params.put("test-yang_cont18.leaf41", "abc"); InstanceIdentifierContext iCtx = ParserIdentifier .toInstanceIdentifier(uri, context, null); @@ -1075,11 +1074,12 @@ public final class PropertiesSerializerTest { public void testIdentityRef() throws SvcLogicException { String uri = "identity-test:test"; Map params = new HashMap<>(); - params.put("identity-test:test.con1.interface", "identity-types:physical"); - params.put("identity-test:test.con1.interfaces.int-list[0].iden", "identity-test:Giga"); - params.put("identity-test:test.con1.interfaces.int-list[0].available.ll[0]", "identity-types:Loopback"); - params.put("identity-test:test.con1.interfaces.int-list[0].available.leaf1", "identity-types-second:Ethernet"); - params.put("identity-test:test.con1.interfaces.int-list[0].available.leaf2", "identity-types-second:iden2"); + params.put("identity-test_test.con1.interface", "identity-types" + + ":physical"); + params.put("identity-test_test.con1.interfaces.int-list[0].iden", "identity-test:Giga"); + params.put("identity-test_test.con1.interfaces.int-list[0].available.ll[0]", "identity-types:Loopback"); + params.put("identity-test_test.con1.interfaces.int-list[0].available.leaf1", "identity-types-second:Ethernet"); + params.put("identity-test_test.con1.interfaces.int-list[0].available.leaf2", "identity-types-second:iden2"); InstanceIdentifierContext iCtx = ParserIdentifier .toInstanceIdentifier(uri, context, null); diff --git a/restconf-client/provider/src/test/resources/yang/test_augment_1_for_module.yang b/restconf-client/provider/src/test/resources/yang/test_augment_1_for_module.yang new file mode 100644 index 000000000..d2eeea7d1 --- /dev/null +++ b/restconf-client/provider/src/test/resources/yang/test_augment_1_for_module.yang @@ -0,0 +1,108 @@ +module test_augment_1_for_module { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:test:augment:name"; + prefix "augment-name"; + + import test_name_of_the_module { + prefix aug; + } + + revision "2015-01-05" { + description "Initial revision of hello model"; + } + + augment "/aug:name_of_the_cont1/aug:name_of_the_cont2/aug:name_of_the_cont4" { + container name_of_the_cont5 { + leaf name_of_the_leaf13 { + type empty; + } + } + list name_of_the_list7 { + leaf name_of_the_leaf14 { + type instance-identifier; + } + } + leaf name_of_the_leaf15 { + type string; + } + leaf-list name_of_the_ll6 { + type union { + type int32; + type enumeration { + enum "unbounded"; + } + } + } + uses "aug:name_of_the_g1"; + } + + uses "aug:name_of_the_g1"; + + augment "/aug:name_of_the_cont1/aug:name_of_the_cont2/aug:name_of_the_cont3" { + choice name_of_the_ch2 { + case name_of_the_c3 { + leaf name_of_the_leaf21 { + type string; + } + } + case name_of_the_c4 { + leaf name_of_the_leaf22 { + type enumeration { + enum zero; + enum one; + enum seven { + value 7; + } + } + } + } + } + } + + augment "/aug:name_of_the_ch1" { + case name_of_the_c5 { + container name_of_the_cont10 { + leaf name_of_the_leaf23 { + type string; + } + } + } + } + + augment "/aug:name_of_the_ch1/aug:name_of_the_c1" { + container name_of_the_cont7 { + leaf name_of_the_leaf24 { + type string; + } + } + } + + augment "/aug:name_of_the_cont13/aug:name_of_the_cont12" { + leaf name_of_the_leaf29 { + type string; + } + } + + augment "/aug:name_of_the_create-sfc/aug:input" { + leaf name_of_the_leaf36 { + type bits { + bit angle { + position 0; + } + bit degree { + position 1; + } + bit movement { + position 2; + } + } + } + } + + augment "/aug:name_of_the_create-sfc/aug:output" { + leaf leaf37 { + type boolean; + } + } + +} \ No newline at end of file diff --git a/restconf-client/provider/src/test/resources/yang/test_name_of_the_module.yang b/restconf-client/provider/src/test/resources/yang/test_name_of_the_module.yang new file mode 100644 index 000000000..973475ee7 --- /dev/null +++ b/restconf-client/provider/src/test/resources/yang/test_name_of_the_module.yang @@ -0,0 +1,231 @@ +module test_name_of_the_module { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:test:name"; + prefix "name"; + + revision "2015-01-05" { + description "Initial revision of hello model"; + } + + container name_of_the_cont1 { + container name_of_the_cont2 { + container name_of_the_cont3 { + leaf name_of_the_leaf10 { + type string; + } + } + list name_of_the_list1 { + key "name_of_the_leaf1 name_of_the_leaf2"; + leaf name_of_the_leaf1 { + type empty; + } + leaf name_of_the_leaf2 { + type string; + } + leaf name_of_the_leaf3 { + type string; + } + leaf-list name_of_the_ll1 { + type string; + } + leaf-list name_of_the_ll2 { + type string; + } + container name_of_the_cont4 { + leaf name_of_the_leaf11 { + type string; + } + } + list name_of_the_list4 { + leaf name_of_the_leaf8 { + type string; + } + } + list name_of_the_list5 { + leaf name_of_the_leaf9 { + type string; + } + } + } + list name_of_the_list2 { + leaf name_of_the_leaf4 { + type string; + } + } + leaf name_of_the_leaf5 { + type string; + } + leaf name_of_the_leaf6 { + type string; + } + leaf-list name_of_the_ll3 { + type string; + } + leaf-list name_of_the_ll4 { + type string; + } + } + } + + augment "/name_of_the_cont1/name_of_the_cont2" { + container name_of_the_cont4 { + leaf name_of_the_leaf10 { + type string; + } + } + list name_of_the_list6 { + leaf name_of_the_leaf11 { + type string; + } + } + leaf name_of_the_leaf12 { + type string; + } + leaf-list name_of_the_ll5 { + type string; + } + } + + choice name_of_the_ch1 { + case name_of_the_c1 { + container name_of_the_cont8 { + container name_of_the_cont6 { + leaf name_of_the_leaf16 { + type string; + } + } + list name_of_the_list8 { + leaf name_of_the_leaf18 { + type string; + } + } + leaf name_of_the_leaf19 { + type string; + } + leaf-list name_of_the_ll7 { + type string; + } + } + } + case name_of_the_c2 { + container name_of_the_cont9 { + leaf name_of_the_leaf20 { + type string; + } + leaf-list name_of_the_ll8 { + type string; + } + container name_of_the_cont11 { + choice name_of_the_ch3 { + case name_of_the_c1 { + leaf name_of_the_leaf25 { + type string; + } + uses name_of_the_g1; + } + } + } + } + } + } + + grouping name_of_the_g1 { + container name_of_the_cont13 { + container name_of_the_cont12 { + leaf name_of_the_leaf26 { + type string; + } + } + list name_of_the_list9 { + leaf name_of_the_leaf27 { + type string; + } + } + leaf name_of_the_leaf28 { + type string; + } + leaf-list name_of_the_ll9 { + type string; + } + } + } + + uses name_of_the_g1; + + rpc name_of_the_create-sfc { + input { + container name_of_the_cont14 { + leaf name_of_the_leaf28 { + type string; + } + } + list name_of_the_list10 { + leaf name_of_the_leaf29 { + type string; + } + } + leaf name_of_the_leaf30 { + type string; + } + leaf-list name_of_the_ll10 { + type string; + } + choice name_of_the_ch3 { + case name_of_the_c1 { + container name_of_the_cont15 { + leaf name_of_the_leaf31 { + type string; + } + } + } + } + uses name_of_the_g1; + } + output { + container name_of_the_cont16 { + leaf name_of_the_leaf32 { + type string; + } + } + list name_of_the_list11 { + leaf name_of_the_leaf33 { + type string; + } + } + leaf name_of_the_leaf34 { + type string; + } + leaf-list name_of_the_ll11 { + type string; + } + choice name_of_the_ch4 { + case name_of_the_c1 { + container name_of_the_cont17 { + leaf name_of_the_leaf35 { + type string; + } + } + } + } + uses name_of_the_g1; + } + } + + container name_of_the_cont18 { + container name_of_the_cont18 { + list name_of_the_list12 { + list name_of_the_list12 { + leaf name_of_the_leaf36 { + type string; + } + } + leaf name_of_the_leaf36 { + type string; + } + } + } + leaf name_of_the_leaf40 { + type string; + } + } +} \ No newline at end of file -- cgit From 2f860ff302a9583a49a08524a5fcdd7435ee2359 Mon Sep 17 00:00:00 2001 From: Vidyashree Rama Date: Fri, 12 Apr 2019 15:21:56 +0530 Subject: Invalid package name for restapicallnode test Invalid package name for restapicallnode test Issue-ID: CCSDK-1218 Change-Id: Ie0275fa333183dc017c1cf0cc65a4cad87b226f0 Signed-off-by: Vidyashree Rama --- .../sli/plugins/restapicall/TestJsonParser.java | 73 +++ .../plugins/restapicall/TestRestapiCallNode.java | 630 +++++++++++++++++++++ .../sli/plugins/restapicall/TestXmlJsonUtil.java | 262 +++++++++ .../sli/plugins/restapicall/TestXmlParser.java | 121 ++++ .../sli/plugins/sshapicall/TestJsonParser.java | 73 --- .../plugins/sshapicall/TestRestapiCallNode.java | 630 --------------------- .../sli/plugins/sshapicall/TestXmlJsonUtil.java | 262 --------- .../sli/plugins/sshapicall/TestXmlParser.java | 121 ---- .../sli/plugins/restapicall/TestJsonParser.java | 85 +++ .../plugins/restapicall/TestSshApiCallNode.java | 330 +++++++++++ .../sli/plugins/restapicall/TestXmlJsonUtil.java | 264 +++++++++ .../sli/plugins/restapicall/TestXmlParser.java | 123 ++++ .../sli/plugins/sshapicall/TestJsonParser.java | 85 --- .../sli/plugins/sshapicall/TestSshApiCallNode.java | 335 ----------- .../sli/plugins/sshapicall/TestXmlJsonUtil.java | 264 --------- .../sli/plugins/sshapicall/TestXmlParser.java | 123 ---- 16 files changed, 1888 insertions(+), 1893 deletions(-) create mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java create mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java create mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java create mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java delete mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java delete mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestRestapiCallNode.java delete mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java delete mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java create mode 100644 sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java create mode 100644 sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestSshApiCallNode.java create mode 100644 sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java create mode 100644 sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java delete mode 100644 sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java delete mode 100644 sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java delete mode 100644 sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java delete mode 100644 sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java new file mode 100644 index 000000000..5526be81f --- /dev/null +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java @@ -0,0 +1,73 @@ +/*- + * ============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 jtest.org.onap.ccsdk.sli.plugins.restapicall; + +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.restapicall.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 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 mm) { + List 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/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java new file mode 100644 index 000000000..fd982d76e --- /dev/null +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -0,0 +1,630 @@ +/*- + * ============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 jtest.org.onap.ccsdk.sli.plugins.restapicall; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestRestapiCallNode { + + private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class); + + + @Test + public void testDelete() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "pwd1"); + p.put("httpMethod", "delete"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testJsonSdwanVpnTopologyTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + ctx.setAttribute("prop.topology", "topoType"); + + ctx.setAttribute("prop.roles_length", "1"); + ctx.setAttribute("prop.roles[0]", "role1"); + + ctx.setAttribute("prop.siteAttachement_length", "2"); + + ctx.setAttribute("prop.siteAttachement[0].siteId", "site1"); + ctx.setAttribute("prop.siteAttachement[0].roles_length", "0"); + ctx.setAttribute("prop.siteAttachement[0].roles[0]", "role1"); + ctx.setAttribute("prop.siteAttachement[0].roles[1]", "role3"); + + ctx.setAttribute("prop.siteAttachement[1].siteId", "site2"); + ctx.setAttribute("prop.siteAttachement[1].roles_length", "1"); + ctx.setAttribute("prop.siteAttachement[1].roles[0]", "role2"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/sdwan-vpn-topology.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testJsonSdwanSiteTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + ctx.setAttribute("prop.name", "site1"); + + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/sdwan-site.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "3"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].clci", "clci"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].clci", "clci"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testInvalidRepeatTimes() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "a"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testInvalidTemplatePath() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resourcess/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testWithoutSkipSending() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "false"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + + @Test(expected = SvcLogicException.class) + public void testWithInvalidURI() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo. getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "false"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testVpnJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testSiteJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + ctx.setAttribute("prop.l3vpn.site1_name", "10000000-0000-0000-0000-000000000002"); + ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003"); + ctx.setAttribute("prop.l3vpn.entry1-id", "1"); + ctx.setAttribute("prop.l3vpn.sna1_name", "10000000-0000-0000-0000-000000000004"); + ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e"); + ctx.setAttribute("prop.l3vpn.ac1_id", "a8098c1a-f86e-11da-bd1a-00112444be1b"); + ctx.setAttribute("prop.l3vpn.ac1-peer-ip", "192.168.1.1"); + ctx.setAttribute("prop.l3vpn.ac1-ip", "192.168.1.2"); + ctx.setAttribute("prop.l3vpn.sna1_svlan", "100"); + ctx.setAttribute("prop.l3vpn.ac1_protocol", "static"); + ctx.setAttribute("prop.l3vpn.sna1-route.ip-prefix", "192.168.1.1/24"); + ctx.setAttribute("prop.l3vpn.sna1-route.next-hop", "192.168.1.4"); + + ctx.setAttribute("prop.l3vpn.site2_name", "10000000-0000-0000-0000-000000000005"); + ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006"); + ctx.setAttribute("prop.l3vpn.entry2-id", "1"); + ctx.setAttribute("prop.l3vpn.sna2_name", "10000000-0000-0000-0000-000000000007"); + ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a"); + ctx.setAttribute("prop.l3vpn.ac2_id", "a8098c1a-f86e-11da-bd1a-00112444be1c"); + ctx.setAttribute("prop.l3vpn.ac2-peer-ip", "192.168.1.6"); + ctx.setAttribute("prop.l3vpn.ac2-ip", "192.168.1.5"); + ctx.setAttribute("prop.l3vpn.sna2_svlan", "200"); + ctx.setAttribute("prop.l3vpn.ac2_protocol", "bgp"); + ctx.setAttribute("prop.l3vpn.peer2-ip", "192.168.1.7"); + ctx.setAttribute("prop.l3vpn.ac2_protocol_bgp_as", "200"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/l3smsitetemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/sites"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testVrfJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.vrf1-id", "10000000-0000-0000-0000-000000000007"); + ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003"); + ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e"); + ctx.setAttribute("prop.l3vpn.vrf2-id", "10000000-0000-0000-0000-000000000009"); + ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006"); + ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/l3smvrftemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vrf-attributes"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteVpnJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + Map p = new HashMap(); + //p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services" + + "/vpnservice=10000000-0000-0000-0000-000000000001"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "delete"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testL2DciTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.dci-connects.id", "Id1"); + ctx.setAttribute("prop.dci-connects.name", "Name1"); + ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1"); + ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2"); + ctx.setAttribute("prop.dci-connects.vni", "1"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/l2-dci-connects-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testL3DciTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.dci-connects.id", "Id1"); + ctx.setAttribute("prop.dci-connects.name", "Name1"); + ctx.setAttribute("prop.dci-connects.local_networks_length", "2"); + ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1"); + ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2"); + ctx.setAttribute("prop.dci-connects.vni", "1"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/l3-dci-connects-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + + } + + @Test + public void testControllerTokenTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.user", "admin"); + ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.password", "admin123"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/actokentemplate.json"); + p.put("restapiUrl", "https://ipwan:18002/controller/v2/tokens"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + + @Test + public void testDeleteNoneAsContentType() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "pwd1"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testPostNoneAsContentType() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "none"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteOAuthType() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("oAuthSignatureMethod", "plainTEXT"); + p.put("oAuthVersion", "1.0"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteAuthTypeBasic() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "basic"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteAuthTypeDigest() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "digest"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteAuthTypeOAuth() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "oauth"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("oAuthSignatureMethod", "plainTEXT"); + p.put("oAuthVersion", "1.0"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteAuthTypeNoneOAuth() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("oAuthSignatureMethod", "plainTEXT"); + p.put("oAuthVersion", "1.0"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + @Test + public void testDeleteAuthTypeNoneBasic() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testInvalidDeleteAuthTypeOAuth() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "oauth"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testInvalidDeleteAuthTypeBasic() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "basic"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testInvalidDeleteAuthTypeDigest() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "digest"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } +} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java new file mode 100644 index 000000000..11eeba7f0 --- /dev/null +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java @@ -0,0 +1,262 @@ +/*- + * ============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 jtest.org.onap.ccsdk.sli.plugins.restapicall; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.ccsdk.sli.plugins.restapicall.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 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 = "" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " blah\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " blah blah\n" + + "\n"; + + String xmloutexpected = "" + + "\n" + + " \n" + + " blah\n" + + " \n" + + " blah blah\n" + + "\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(null, xmlin); + log.info(xmlout); + + Assert.assertEquals(xmloutexpected, xmlout); + } +} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java new file mode 100644 index 000000000..c6bf4a8b9 --- /dev/null +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java @@ -0,0 +1,121 @@ +/*- + * ============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 jtest.org.onap.ccsdk.sli.plugins.restapicall; + +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.restapicall.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 listNameList = new HashSet(); + 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 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 listNameList = new HashSet(); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); + + Map 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 listNameList = new HashSet(); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); + + Map mm = XmlParser.convertToProperties(b.toString(), listNameList); + logProperties(mm); + in.close(); + } + + private void logProperties(Map mm) { + List 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/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java deleted file mode 100644 index 0216b6675..000000000 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============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 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.restapicall.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 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 mm) { - List 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/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestRestapiCallNode.java deleted file mode 100644 index 4008c56c7..000000000 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestRestapiCallNode.java +++ /dev/null @@ -1,630 +0,0 @@ -/*- - * ============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 jtest.org.onap.ccsdk.sli.plugins.sshapicall; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestRestapiCallNode { - - private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class); - - - @Test - public void testDelete() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "pwd1"); - p.put("httpMethod", "delete"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testJsonSdwanVpnTopologyTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - ctx.setAttribute("prop.topology", "topoType"); - - ctx.setAttribute("prop.roles_length", "1"); - ctx.setAttribute("prop.roles[0]", "role1"); - - ctx.setAttribute("prop.siteAttachement_length", "2"); - - ctx.setAttribute("prop.siteAttachement[0].siteId", "site1"); - ctx.setAttribute("prop.siteAttachement[0].roles_length", "0"); - ctx.setAttribute("prop.siteAttachement[0].roles[0]", "role1"); - ctx.setAttribute("prop.siteAttachement[0].roles[1]", "role3"); - - ctx.setAttribute("prop.siteAttachement[1].siteId", "site2"); - ctx.setAttribute("prop.siteAttachement[1].roles_length", "1"); - ctx.setAttribute("prop.siteAttachement[1].roles[0]", "role2"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/sdwan-vpn-topology.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testJsonSdwanSiteTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - ctx.setAttribute("prop.name", "site1"); - - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/sdwan-site.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testJsonTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.sdn-circuit-req-row_length", "3"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].clci", "clci"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].clci", "clci"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/test-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testInvalidRepeatTimes() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.sdn-circuit-req-row_length", "a"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/test-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testInvalidTemplatePath() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resourcess/test-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testWithoutSkipSending() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/test-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "false"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - - @Test(expected = SvcLogicException.class) - public void testWithInvalidURI() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/test-template.json"); - p.put("restapiUrl", "http://echo. getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "false"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testVpnJsonTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); - ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); - p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "restapi-result"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testSiteJsonTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); - ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); - - ctx.setAttribute("prop.l3vpn.site1_name", "10000000-0000-0000-0000-000000000002"); - ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003"); - ctx.setAttribute("prop.l3vpn.entry1-id", "1"); - ctx.setAttribute("prop.l3vpn.sna1_name", "10000000-0000-0000-0000-000000000004"); - ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e"); - ctx.setAttribute("prop.l3vpn.ac1_id", "a8098c1a-f86e-11da-bd1a-00112444be1b"); - ctx.setAttribute("prop.l3vpn.ac1-peer-ip", "192.168.1.1"); - ctx.setAttribute("prop.l3vpn.ac1-ip", "192.168.1.2"); - ctx.setAttribute("prop.l3vpn.sna1_svlan", "100"); - ctx.setAttribute("prop.l3vpn.ac1_protocol", "static"); - ctx.setAttribute("prop.l3vpn.sna1-route.ip-prefix", "192.168.1.1/24"); - ctx.setAttribute("prop.l3vpn.sna1-route.next-hop", "192.168.1.4"); - - ctx.setAttribute("prop.l3vpn.site2_name", "10000000-0000-0000-0000-000000000005"); - ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006"); - ctx.setAttribute("prop.l3vpn.entry2-id", "1"); - ctx.setAttribute("prop.l3vpn.sna2_name", "10000000-0000-0000-0000-000000000007"); - ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a"); - ctx.setAttribute("prop.l3vpn.ac2_id", "a8098c1a-f86e-11da-bd1a-00112444be1c"); - ctx.setAttribute("prop.l3vpn.ac2-peer-ip", "192.168.1.6"); - ctx.setAttribute("prop.l3vpn.ac2-ip", "192.168.1.5"); - ctx.setAttribute("prop.l3vpn.sna2_svlan", "200"); - ctx.setAttribute("prop.l3vpn.ac2_protocol", "bgp"); - ctx.setAttribute("prop.l3vpn.peer2-ip", "192.168.1.7"); - ctx.setAttribute("prop.l3vpn.ac2_protocol_bgp_as", "200"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/l3smsitetemplate.json"); - p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/sites"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "restapi-result"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testVrfJsonTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.l3vpn.vrf1-id", "10000000-0000-0000-0000-000000000007"); - ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003"); - ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e"); - ctx.setAttribute("prop.l3vpn.vrf2-id", "10000000-0000-0000-0000-000000000009"); - ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006"); - ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/l3smvrftemplate.json"); - p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vrf-attributes"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "restapi-result"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteVpnJsonTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); - ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); - - Map p = new HashMap(); - //p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); - p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services" - + "/vpnservice=10000000-0000-0000-0000-000000000001"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("format", "json"); - p.put("httpMethod", "delete"); - p.put("responsePrefix", "restapi-result"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testL2DciTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.dci-connects.id", "Id1"); - ctx.setAttribute("prop.dci-connects.name", "Name1"); - ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1"); - ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2"); - ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1"); - ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2"); - ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1"); - ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2"); - ctx.setAttribute("prop.dci-connects.vni", "1"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/l2-dci-connects-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testL3DciTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.dci-connects.id", "Id1"); - ctx.setAttribute("prop.dci-connects.name", "Name1"); - ctx.setAttribute("prop.dci-connects.local_networks_length", "2"); - ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1"); - ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2"); - ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1"); - ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2"); - ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1"); - ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2"); - ctx.setAttribute("prop.dci-connects.vni", "1"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/l3-dci-connects-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - - } - - @Test - public void testControllerTokenTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.user", "admin"); - ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.password", "admin123"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/actokentemplate.json"); - p.put("restapiUrl", "https://ipwan:18002/controller/v2/tokens"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "restapi-result"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - - @Test - public void testDeleteNoneAsContentType() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "pwd1"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testPostNoneAsContentType() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); - ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); - - Map p = new HashMap(); - p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); - p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("format", "none"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "restapi-result"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteOAuthType() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("oAuthSignatureMethod", "plainTEXT"); - p.put("oAuthVersion", "1.0"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteAuthTypeBasic() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "basic"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteAuthTypeDigest() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "digest"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteAuthTypeOAuth() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "oauth"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("oAuthSignatureMethod", "plainTEXT"); - p.put("oAuthVersion", "1.0"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteAuthTypeNoneOAuth() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("oAuthSignatureMethod", "plainTEXT"); - p.put("oAuthVersion", "1.0"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - @Test - public void testDeleteAuthTypeNoneBasic() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testInvalidDeleteAuthTypeOAuth() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "oauth"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testInvalidDeleteAuthTypeBasic() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "basic"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testInvalidDeleteAuthTypeDigest() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "digest"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } -} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java deleted file mode 100644 index 31fa2f9f9..000000000 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java +++ /dev/null @@ -1,262 +0,0 @@ -/*- - * ============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 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.restapicall.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 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 = "" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " blah\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " blah blah\n" + - "\n"; - - String xmloutexpected = "" + - "\n" + - " \n" + - " blah\n" + - " \n" + - " blah blah\n" + - "\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(null, xmlin); - log.info(xmlout); - - Assert.assertEquals(xmloutexpected, xmlout); - } -} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java deleted file mode 100644 index 8ff0b0a3f..000000000 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java +++ /dev/null @@ -1,121 +0,0 @@ -/*- - * ============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 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.restapicall.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 listNameList = new HashSet(); - 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 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 listNameList = new HashSet(); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); - - Map 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 listNameList = new HashSet(); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); - - Map mm = XmlParser.convertToProperties(b.toString(), listNameList); - logProperties(mm); - in.close(); - } - - private void logProperties(Map mm) { - List 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/restapicall/TestJsonParser.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java new file mode 100644 index 000000000..78f20e327 --- /dev/null +++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.restapicall; + +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.codehaus.jettison.json.JSONException; +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 mm = null; + try { + mm = JsonParser.convertToProperties(b.toString()); + } catch (JSONException e){ + throw new SvcLogicException(e.getMessage()); + } + + logProperties(mm); + + in.close(); + } + + @Test(expected = NullPointerException.class) + public void testNullString() throws SvcLogicException { + Map mm = null; + try { + mm = JsonParser.convertToProperties(null); + } catch (JSONException e){ + throw new SvcLogicException(e.getMessage()); + } + } + + private void logProperties(Map mm) { + List 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/restapicall/TestSshApiCallNode.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestSshApiCallNode.java new file mode 100644 index 000000000..c0bcdb82a --- /dev/null +++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestSshApiCallNode.java @@ -0,0 +1,330 @@ +package jtest.org.onap.ccsdk.sli.plugins.restapicall; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +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 org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.assertEquals; + +public class TestSshApiCallNode { + + private static final Logger log = LoggerFactory.getLogger(TestSshApiCallNode.class); + + private SshApiCallNode adapter; + private String TestId; + private boolean testMode = true; + private Map params; + private SvcLogicContext svcContext; + + + @Before + public void setup() throws IllegalArgumentException { + testMode = true; + svcContext = new SvcLogicContext(); + adapter = new SshApiCallNode(); + + params = new HashMap<>(); + params.put("AgentUrl", "https://192.168.1.1"); + params.put("User", "test"); + params.put("Password", "test"); + } + + @After + public void tearDown() { + testMode = false; + adapter = null; + params = null; + svcContext = null; + } + + @Test(expected = SvcLogicException.class) + public void testExecCommand_noUrlFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("HostName", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Test", "fail"); + adapter.execCommand(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandPty_noUrlFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("HostName", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Test", "fail"); + adapter.execCommandWithPty(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noUrlFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("HostName", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Test", "fail"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommand_noPortFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Test", "fail"); + adapter.execCommand(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandPty_noPortFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Test", "fail"); + adapter.execCommandWithPty(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noPortFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Test", "fail"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommand_noCmdFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + adapter.execCommand(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandPty_noCmdFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + adapter.execCommandWithPty(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noCmdFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noSSHBasicFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("AuthType", "basic"); + params.put("Cmd", "test"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noSSHKeyFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("AuthType", "key"); + params.put("Cmd", "test"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noSSHNoneFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("AuthType", "none"); + params.put("Cmd", "test"); + params.put("ResponseType", "xml"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_noSSHFailed() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("ResponseType", "json"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = IllegalArgumentException.class) + public void testExecCommandResponse_noSSHInvalidParam() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("ResponseType", "txt"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = IllegalArgumentException.class) + public void testExecCommandResponse_noSSHInvalidAuthParam() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("AuthType", "spring"); + params.put("ResponseType", "json"); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test + public void testExecCommandResponse_validJSON() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("AuthType", "basic"); + params.put("ResponseType", "json"); + params.put("TestOut", "{\"equipment-data\":\"boo\"}"); + params.put("TestFail", "false"); + adapter = new SshApiCallNode(true); + adapter.execWithStatusCheck(params, svcContext); + assertEquals("boo", svcContext.getAttribute("equipment-data")); + } + + @Test + public void testExecCommandResponse_validXML() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("AuthType", "basic"); + params.put("ResponseType", "xml"); + params.put("TestOut", "4.0.0"); + params.put("TestFail", "false"); + adapter = new SshApiCallNode(true); + adapter.execWithStatusCheck(params, svcContext); + assertEquals("4.0.0", svcContext.getAttribute("modelVersion")); + } + + @Test + public void testExecCommandResponse_validJSONPrefix() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("AuthType", "basic"); + params.put("ResponseType", "json"); + params.put("TestOut", "{\"equipment-data\":\"boo\"}"); + params.put("ResponsePrefix", "test"); + params.put("TestFail", "false"); + adapter = new SshApiCallNode(true); + adapter.execWithStatusCheck(params, svcContext); + assertEquals("boo", svcContext.getAttribute("test.equipment-data")); + } + + @Test + public void testExecCommandResponse_validXMLPrefix() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("AuthType", "basic"); + params.put("ResponseType", "xml"); + params.put("TestOut", "4.0.0"); + params.put("ResponsePrefix", "test"); + params.put("TestFail", "false"); + adapter = new SshApiCallNode(true); + adapter.execWithStatusCheck(params, svcContext); + assertEquals("4.0.0", svcContext.getAttribute("test.modelVersion")); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_validXMLFail() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("Url", "test"); + params.put("Port", "10"); + params.put("User", "test"); + params.put("Password", "test"); + params.put("Cmd", "test"); + params.put("AuthType", "basic"); + params.put("ResponseType", "xml"); + params.put("TestOut", "4.0.0"); + params.put("TestFail", "true"); + params.put("ResponsePrefix", "test"); + adapter = new SshApiCallNode(true); + adapter.execWithStatusCheck(params, svcContext); + } + + @Test(expected = SvcLogicException.class) + public void testExecCommandResponse_validXMLPrefixKey() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + params = new HashMap<>(); + params.put("Url", "test"); + params.put("Port", "10"); + params.put("SshKey", "test"); + params.put("Cmd", "test"); + params.put("ResponseType", "xml"); + params.put("TestOut", "4.0.0"); + params.put("ResponsePrefix", "test"); + adapter.execWithStatusCheck(params, svcContext); + assertEquals("4.0.0", svcContext.getAttribute("test.modelVersion")); + } +} diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java new file mode 100644 index 000000000..33e0f24dd --- /dev/null +++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java @@ -0,0 +1,264 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.restapicall; + +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 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 = "" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " blah\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " blah blah\n" + + "\n"; + + String xmloutexpected = "" + + "\n" + + " \n" + + " blah\n" + + " \n" + + " blah blah\n" + + "\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/restapicall/TestXmlParser.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java new file mode 100644 index 000000000..ba0ae41de --- /dev/null +++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java @@ -0,0 +1,123 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.restapicall; + +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 listNameList = new HashSet(); + 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 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 listNameList = new HashSet(); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); + + Map 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 listNameList = new HashSet(); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); + + Map mm = XmlParser.convertToProperties(b.toString(), listNameList); + logProperties(mm); + in.close(); + } + + private void logProperties(Map mm) { + List 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/TestJsonParser.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java deleted file mode 100644 index 4a5b765a8..000000000 --- a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestJsonParser.java +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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.codehaus.jettison.json.JSONException; -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 mm = null; - try { - mm = JsonParser.convertToProperties(b.toString()); - } catch (JSONException e){ - throw new SvcLogicException(e.getMessage()); - } - - logProperties(mm); - - in.close(); - } - - @Test(expected = NullPointerException.class) - public void testNullString() throws SvcLogicException { - Map mm = null; - try { - mm = JsonParser.convertToProperties(null); - } catch (JSONException e){ - throw new SvcLogicException(e.getMessage()); - } - } - - private void logProperties(Map mm) { - List 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/TestSshApiCallNode.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java deleted file mode 100644 index 544057a6e..000000000 --- a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java +++ /dev/null @@ -1,335 +0,0 @@ -package jtest.org.onap.ccsdk.sli.plugins.sshapicall; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -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 org.onap.ccsdk.sli.plugins.sshapicall.model.XmlParser; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import static org.junit.Assert.assertEquals; - -public class TestSshApiCallNode { - - private static final Logger log = LoggerFactory.getLogger(TestSshApiCallNode.class); - - private SshApiCallNode adapter; - private String TestId; - private boolean testMode = true; - private Map params; - private SvcLogicContext svcContext; - - - @Before - public void setup() throws IllegalArgumentException { - testMode = true; - svcContext = new SvcLogicContext(); - adapter = new SshApiCallNode(); - - params = new HashMap<>(); - params.put("AgentUrl", "https://192.168.1.1"); - params.put("User", "test"); - params.put("Password", "test"); - } - - @After - public void tearDown() { - testMode = false; - adapter = null; - params = null; - svcContext = null; - } - - @Test(expected = SvcLogicException.class) - public void testExecCommand_noUrlFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("HostName", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Test", "fail"); - adapter.execCommand(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandPty_noUrlFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("HostName", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Test", "fail"); - adapter.execCommandWithPty(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandResponse_noUrlFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("HostName", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Test", "fail"); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommand_noPortFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Test", "fail"); - adapter.execCommand(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandPty_noPortFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Test", "fail"); - adapter.execCommandWithPty(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandResponse_noPortFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Test", "fail"); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommand_noCmdFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - adapter.execCommand(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandPty_noCmdFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - adapter.execCommandWithPty(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandResponse_noCmdFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandResponse_noSSHBasicFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("AuthType", "basic"); - params.put("Cmd", "test"); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandResponse_noSSHKeyFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("AuthType", "key"); - params.put("Cmd", "test"); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandResponse_noSSHNoneFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("AuthType", "none"); - params.put("Cmd", "test"); - params.put("ResponseType", "xml"); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandResponse_noSSHFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Cmd", "test"); - params.put("ResponseType", "json"); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test(expected = IllegalArgumentException.class) - public void testExecCommandResponse_noSSHInvalidParam() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Cmd", "test"); - params.put("ResponseType", "txt"); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test(expected = IllegalArgumentException.class) - public void testExecCommandResponse_noSSHInvalidAuthParam() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Cmd", "test"); - params.put("AuthType", "spring"); - params.put("ResponseType", "json"); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test - public void testExecCommandResponse_validJSON() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Cmd", "test"); - params.put("AuthType", "basic"); - params.put("ResponseType", "json"); - params.put("TestOut", "{\"equipment-data\":\"boo\"}"); - params.put("TestFail", "false"); - adapter = new SshApiCallNode(true); - adapter.execWithStatusCheck(params, svcContext); - assertEquals("boo", svcContext.getAttribute("equipment-data")); - } - - @Test - public void testExecCommandResponse_validXML() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Cmd", "test"); - params.put("AuthType", "basic"); - params.put("ResponseType", "xml"); - params.put("TestOut", "4.0.0"); - params.put("TestFail", "false"); - adapter = new SshApiCallNode(true); - adapter.execWithStatusCheck(params, svcContext); - assertEquals("4.0.0", svcContext.getAttribute("modelVersion")); - } - - @Test - public void testExecCommandResponse_validJSONPrefix() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Cmd", "test"); - params.put("AuthType", "basic"); - params.put("ResponseType", "json"); - params.put("TestOut", "{\"equipment-data\":\"boo\"}"); - params.put("ResponsePrefix", "test"); - params.put("TestFail", "false"); - adapter = new SshApiCallNode(true); - adapter.execWithStatusCheck(params, svcContext); - assertEquals("boo", svcContext.getAttribute("test.equipment-data")); - } - - @Test - public void testExecCommandResponse_validXMLPrefix() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Cmd", "test"); - params.put("AuthType", "basic"); - params.put("ResponseType", "xml"); - params.put("TestOut", "4.0.0"); - params.put("ResponsePrefix", "test"); - params.put("TestFail", "false"); - adapter = new SshApiCallNode(true); - adapter.execWithStatusCheck(params, svcContext); - assertEquals("4.0.0", svcContext.getAttribute("test.modelVersion")); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandResponse_validXMLFail() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Cmd", "test"); - params.put("AuthType", "basic"); - params.put("ResponseType", "xml"); - params.put("TestOut", "4.0.0"); - params.put("TestFail", "true"); - params.put("ResponsePrefix", "test"); - adapter = new SshApiCallNode(true); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandResponse_validXMLPrefixKey() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - params = new HashMap<>(); - params.put("Url", "test"); - params.put("Port", "10"); - params.put("SshKey", "test"); - params.put("Cmd", "test"); - params.put("ResponseType", "xml"); - params.put("TestOut", "4.0.0"); - params.put("ResponsePrefix", "test"); - adapter.execWithStatusCheck(params, svcContext); - assertEquals("4.0.0", svcContext.getAttribute("test.modelVersion")); - } -} 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 deleted file mode 100644 index 218ad6a8d..000000000 --- a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java +++ /dev/null @@ -1,264 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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 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 = "" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " blah\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " blah blah\n" + - "\n"; - - String xmloutexpected = "" + - "\n" + - " \n" + - " blah\n" + - " \n" + - " blah blah\n" + - "\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 deleted file mode 100644 index 3f8d37163..000000000 --- a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlParser.java +++ /dev/null @@ -1,123 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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 listNameList = new HashSet(); - 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 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 listNameList = new HashSet(); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); - - Map 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 listNameList = new HashSet(); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); - - Map mm = XmlParser.convertToProperties(b.toString(), listNameList); - logProperties(mm); - in.close(); - } - - private void logProperties(Map mm) { - List 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)); - } -} -- cgit From e4c9cfddd142785d527f29ff5c2b5883cc255033 Mon Sep 17 00:00:00 2001 From: Gaurav Agrawal Date: Fri, 12 Apr 2019 10:08:20 +0530 Subject: Add support for multi part form data Add support for multipart form data in CCSDK Change-Id: Iacc35efe28b9d91afcfc1e87e0faf41fc74d5c8a Issue-ID: CCSDK-239 Signed-off-by: Gaurav Agrawal --- restapi-call-node/provider/pom.xml | 6 +- .../ccsdk/sli/plugins/restapicall/Parameters.java | 2 + .../sli/plugins/restapicall/RestapiCallNode.java | 86 ++++++++++++++++++---- .../plugins/restapicall/TestRestapiCallNode.java | 27 +++++++ 4 files changed, 105 insertions(+), 16 deletions(-) diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index c5556011a..2455866a4 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -68,7 +68,11 @@ jersey-client ${jersey.version} - + + org.glassfish.jersey.media + jersey-media-multipart + ${jersey.version} + diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java index 8f65cf261..aeb07c4d6 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java @@ -51,4 +51,6 @@ public class Parameters { public AuthType authtype; public Boolean returnRequestPayload; public String accept; + public boolean multipartFormData; + public String multipartFile; } diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 521c66cb3..a7235fcb5 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -26,6 +26,7 @@ import static java.lang.Boolean.valueOf; import static javax.ws.rs.client.Entity.entity; import static org.onap.ccsdk.sli.plugins.restapicall.AuthType.fromString; +import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.net.SocketException; @@ -51,17 +52,17 @@ import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Entity; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.EntityTag; -import javax.ws.rs.core.Feature; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; +import javax.ws.rs.core.*; + import org.apache.commons.lang3.StringUtils; import org.glassfish.jersey.client.ClientProperties; import org.glassfish.jersey.client.HttpUrlConnectorProvider; import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; import org.glassfish.jersey.client.oauth1.ConsumerCredentials; import org.glassfish.jersey.client.oauth1.OAuth1ClientSupport; +import org.glassfish.jersey.media.multipart.MultiPart; +import org.glassfish.jersey.media.multipart.MultiPartFeature; +import org.glassfish.jersey.media.multipart.file.FileDataBodyPart; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; @@ -168,6 +169,10 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { paramMap, "returnRequestPayload", false, null)); p.accept = parseParam(paramMap, "accept", false, null); + p.multipartFormData = valueOf(parseParam(paramMap, "multipartFormData", + false, "false")); + p.multipartFile = parseParam(paramMap, "multipartFile", + false, null); return p; } @@ -635,15 +640,17 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { HttpResponse r = new HttpResponse(); r.code = 200; - if (!p.skipSending) { - String accept = p.accept; - if(accept == null) { - accept = p.format == Format.XML ? "application/xml" : "application/json"; - } - String contentType = p.contentType; - if(contentType == null) { - contentType = accept + ";charset=UTF-8"; - } + String accept = p.accept; + if(accept == null) { + accept = p.format == Format.XML ? "application/xml" : "application/json"; + } + + String contentType = p.contentType; + if(contentType == null) { + contentType = accept + ";charset=UTF-8"; + } + + if (!p.skipSending && !p.multipartFormData) { Invocation.Builder invocationBuilder = webTarget.request(contentType).accept(accept); @@ -680,6 +687,55 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { if (response.hasEntity() && r.code != 204) { r.body = response.readEntity(String.class); } + } else if (!p.skipSending && p.multipartFormData) { + + WebTarget wt = client.register(MultiPartFeature.class).target(p.restapiUrl); + + MultiPart multiPart = new MultiPart(); + multiPart.setMediaType(MediaType.MULTIPART_FORM_DATA_TYPE); + + FileDataBodyPart fileDataBodyPart = new FileDataBodyPart("file", + new File(p.multipartFile), + MediaType.APPLICATION_OCTET_STREAM_TYPE); + multiPart.bodyPart(fileDataBodyPart); + + + Invocation.Builder invocationBuilder = wt.request(contentType).accept(accept); + + if (p.format == Format.NONE) { + invocationBuilder.header("", ""); + } + + if (p.customHttpHeaders != null && p.customHttpHeaders.length() > 0) { + String[] keyValuePairs = p.customHttpHeaders.split(","); + for (String singlePair : keyValuePairs) { + int equalPosition = singlePair.indexOf('='); + invocationBuilder.header(singlePair.substring(0, equalPosition), + singlePair.substring(equalPosition + 1, singlePair.length())); + } + } + + invocationBuilder.header("X-ECOMP-RequestID", org.slf4j.MDC.get("X-ECOMP-RequestID")); + + Response response; + + try { + response = invocationBuilder.method(p.httpMethod.toString(), entity(multiPart, multiPart.getMediaType())); + } catch (ProcessingException | IllegalStateException e) { + throw new SvcLogicException(requestPostingException + + e.getLocalizedMessage(), e); + } + + r.code = response.getStatus(); + r.headers = response.getStringHeaders(); + EntityTag etag = response.getEntityTag(); + if (etag != null) { + r.message = etag.getValue(); + } + if (response.hasEntity() && r.code != 204) { + r.body = response.readEntity(String.class); + } + } long t2 = System.currentTimeMillis(); @@ -858,7 +914,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { log.info("Got response code 301. Sending same request to URL: {}", newUrl); - webTarget = client.target(newUrl); + webTarget = client.target(newUrl); invocationBuilder = webTarget.request(tt).accept(tt); try { diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index fd982d76e..5b047e4e7 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -224,6 +224,33 @@ public class TestRestapiCallNode { rcn.sendRequest(p, ctx); } + @Test(expected = SvcLogicException.class) + public void testFormData() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "false"); + p.put("multipartFormData", "true"); + p.put("multipartFile", "src/test/resources/test-template.json"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } @Test(expected = SvcLogicException.class) public void testWithInvalidURI() throws SvcLogicException { -- cgit From a5fa2ea36c115aba01eb3328fd95a12dd654ed00 Mon Sep 17 00:00:00 2001 From: Vidyashree Rama Date: Fri, 12 Apr 2019 14:21:37 +0530 Subject: Add test case for multi part form data Add test case for multipart form data in restapicallnode Issue-ID: CCSDK-239 Change-Id: Icad15bce57455ed2c1cbf4779cf8b0820fa24dc9 Signed-off-by: Vidyashree Rama --- restapi-call-node/provider/pom.xml | 12 ++++++ .../plugins/restapicall/MultipartServerMock.java | 44 ++++++++++++++++++++++ .../plugins/restapicall/TestRestapiCallNode.java | 27 +++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MultipartServerMock.java diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 2455866a4..1f698eade 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -80,5 +80,17 @@ junit test + + org.glassfish.jersey.containers + jersey-container-servlet + ${jersey.version} + test + + + org.glassfish.jersey.containers + jersey-container-grizzly2-http + ${jersey.version} + test + diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MultipartServerMock.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MultipartServerMock.java new file mode 100644 index 000000000..9646272b4 --- /dev/null +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MultipartServerMock.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2019 Huawei Technologies Co., Ltd. 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.restapicall; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; +import org.glassfish.jersey.media.multipart.FormDataParam; + +import javax.ws.rs.Consumes; + +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.io.InputStream; + +@Path("file-upload") +public class MultipartServerMock { + + @POST + @Path("upload") + @Consumes(MediaType.MULTIPART_FORM_DATA) + public Response uploadFile( + @FormDataParam("file") InputStream inputStream, + @FormDataParam("file") FormDataContentDisposition fileDetail) { + return Response.status(200).entity(fileDetail.getFileName()).build(); + } +} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index 5b047e4e7..7a24ca1a9 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -21,15 +21,22 @@ package jtest.org.onap.ccsdk.sli.plugins.restapicall; +import java.net.URI; import java.util.HashMap; import java.util.Map; +import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; +import org.glassfish.jersey.media.multipart.MultiPartFeature; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.glassfish.jersey.server.ResourceConfig; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; public class TestRestapiCallNode { @@ -654,4 +661,24 @@ public class TestRestapiCallNode { RestapiCallNode rcn = new RestapiCallNode(); rcn.sendRequest(p, ctx); } + + @Test + public void testMultipartFormData() throws SvcLogicException { + final ResourceConfig resourceConfig = new ResourceConfig( + MultipartServerMock.class, MultiPartFeature.class); + GrizzlyHttpServerFactory.createHttpServer( + URI.create("http://localhost:8080/"),resourceConfig); + + Map p = new HashMap<>(); + p.put("multipartFormData", "true"); + p.put("format", "none"); + p.put("multipartFile", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://localhost:8080/file-upload/upload"); + + SvcLogicContext ctx = new SvcLogicContext(); + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + assertThat(ctx.getAttribute("response-code"), is("200")); + assertThat(ctx.getAttribute("httpResponse"), is( "test-template.json")); + } } -- cgit From f98a2022690815ac159161f942950aac3b7ed9a6 Mon Sep 17 00:00:00 2001 From: Gaurav Agrawal Date: Tue, 16 Apr 2019 12:00:40 +0530 Subject: Restapicallnode with cookie based auth Validate the cookie based auth feature of RestApiCallNode Fix multipart form data test to stop server after completion to avoid impacting other testcases Change-Id: I221b668978abf630f35cbb213687a25cc0de8b79 Issue-ID: CCSDK-239 Signed-off-by: Gaurav Agrawal --- restapi-call-node/provider/pom.xml | 1 + .../plugins/restapicall/MockCookieAuthServer.java | 40 ++++++++++++++++++++++ .../plugins/restapicall/TestRestapiCallNode.java | 25 +++++++++++++- 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 1f698eade..32089455f 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -93,4 +93,5 @@ test + diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java new file mode 100644 index 000000000..b4a30d3ab --- /dev/null +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2019 Huawei Technologies Co., Ltd. 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.restapicall; + +import javax.ws.rs.Consumes; +import javax.ws.rs.Produces; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.NewCookie; +import javax.ws.rs.core.Response; + +@Path("get-cookie") +public class MockCookieAuthServer { + @GET + @Path("cookie") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public Response getCookie() { + return Response.status(200).entity("success").cookie(new NewCookie("cookieResponse", "cookieValueInReturn")).build(); + } +} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index 7a24ca1a9..52da46157 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -25,6 +25,7 @@ import java.net.URI; import java.util.HashMap; import java.util.Map; +import org.glassfish.grizzly.http.server.HttpServer; import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; import org.glassfish.jersey.media.multipart.MultiPartFeature; import org.junit.Test; @@ -666,7 +667,7 @@ public class TestRestapiCallNode { public void testMultipartFormData() throws SvcLogicException { final ResourceConfig resourceConfig = new ResourceConfig( MultipartServerMock.class, MultiPartFeature.class); - GrizzlyHttpServerFactory.createHttpServer( + HttpServer server = GrizzlyHttpServerFactory.createHttpServer( URI.create("http://localhost:8080/"),resourceConfig); Map p = new HashMap<>(); @@ -680,5 +681,27 @@ public class TestRestapiCallNode { rcn.sendRequest(p, ctx); assertThat(ctx.getAttribute("response-code"), is("200")); assertThat(ctx.getAttribute("httpResponse"), is( "test-template.json")); + server.shutdownNow(); + } + + @Test + public void testCookieResponse() throws SvcLogicException { + final ResourceConfig resourceConfig = new ResourceConfig( + MockCookieAuthServer.class); + HttpServer server = GrizzlyHttpServerFactory.createHttpServer( + URI.create("http://localhost:8080/"),resourceConfig); + + Map p = new HashMap<>(); + p.put("format", "none"); + p.put("httpMethod", "get"); + p.put("restapiUrl", "http://localhost:8080/get-cookie/cookie"); + p.put("dumpHeaders", "true"); + + SvcLogicContext ctx = new SvcLogicContext(); + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + assertThat(ctx.getAttribute("response-code"), is("200")); + assertThat(ctx.getAttribute("header.Set-Cookie"), is("cookieResponse=cookieValueInReturn;Version=1")); + server.shutdownNow(); } } -- cgit From 0570deb66e8815ad78a486516ebe5273b3238e78 Mon Sep 17 00:00:00 2001 From: Vidyashree Rama Date: Wed, 17 Apr 2019 09:10:56 +0530 Subject: Code refactoring in restconf client yang serialisers. 1. logging the exception when handling underscore in yang serialisers 2. Refactor code to not nest more than 3 if/for statements 3. Throw SvcLogicException instead of generic 4. Reduce switch case number of lines from 8 to at most 5 Issue-ID: CCSDK-1236 Change-Id: Ic02ba424c2d1748d071e38d25ae159f5d8bd6451 Signed-off-by: Vidyashree Rama --- .../MdsalPropertiesNodeSerializer.java | 51 ++++++++++++++++------ .../pnserializer/MdsalPropertiesNodeUtils.java | 31 ++++++++----- 2 files changed, 58 insertions(+), 24 deletions(-) diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java index 759fe802e..0eca40d06 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java @@ -29,6 +29,8 @@ import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaNode; import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.DOT_REGEX; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.SLASH; @@ -52,6 +54,8 @@ import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.S */ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer { + private static final Logger log = LoggerFactory.getLogger( + MdsalPropertiesNodeSerializer.class); private SchemaNode curSchema; private PropertiesNode node; @@ -111,6 +115,8 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer childsFromAugmentation = parent - .augmentations().get(augSchema); - if (!childsFromAugmentation.isEmpty()) { - for (PropertiesNode pNode : childsFromAugmentation) { - if (pNode.name().equals(name)) { - return pNode; - } + if (augSchema == null) { + return null; + } + + Collection childsFromAugmentation = parent + .augmentations().get(augSchema); + if (!childsFromAugmentation.isEmpty()) { + for (PropertiesNode pNode : childsFromAugmentation) { + if (pNode.name().equals(name)) { + return pNode; } } } + return null; } @@ -218,10 +221,12 @@ public final class MdsalPropertiesNodeUtils { * @param appInfo application info * @param type node type * @return new properties node + * @throws SvcLogicException exception while creating properties node */ public static PropertiesNode createNode(String name, Namespace namespace, String uri, PropertiesNode parent, - Object appInfo, NodeType type) { + Object appInfo, NodeType type) + throws SvcLogicException { switch (type) { case SINGLE_INSTANCE_NODE: return new SingleInstanceNode(name, namespace, uri, parent, appInfo, type); @@ -230,7 +235,7 @@ public final class MdsalPropertiesNodeUtils { case MULTI_INSTANCE_LEAF_HOLDER_NODE: return new LeafListHolderNode(name, namespace, uri, parent, appInfo, type); default: - throw new RuntimeException("Invalid node type"); + throw new SvcLogicException("Invalid node type " + type); } } @@ -265,6 +270,9 @@ public final class MdsalPropertiesNodeUtils { return new SchemaPathHolder(id, uri1); } catch (IllegalArgumentException | RestconfDocumentedException | NullPointerException e) { + log.info("Exception while converting uri to instance identifier" + + " context. Process each node in uri to get instance identifier" + + " context " + e); return processNodesAndAppendPath(uri, context); } } @@ -294,6 +302,7 @@ public final class MdsalPropertiesNodeUtils { try { id = processIdentifier(uriParts[i], context, actPath); } catch (IllegalArgumentException e) { + log.info(format(EXC_MSG, e)); id.setUri(actPath+ uriParts[i] + sec); return id; } @@ -340,7 +349,7 @@ public final class MdsalPropertiesNodeUtils { return new SchemaPathHolder(id, val); } catch (IllegalArgumentException | RestconfDocumentedException | NullPointerException e) { - log.info(format(INFO_MSG, val)); + log.info(format(INFO_MSG, val, e)); } firstHalf.append(values[i]).append(UNDERSCORE); secondHalf = secondHalf.replaceFirst( -- cgit From 3a50557405e66759277ab71d85963d0943cd08d2 Mon Sep 17 00:00:00 2001 From: "Haddox, Anthony" Date: Wed, 17 Apr 2019 09:07:36 -0700 Subject: [CCSDK-1241] Increase GRToolkit Unit Test Coverage Add unit tests for GRToolkit. Slight changes to make code testable. Change-Id: Ib435da58b62e7b8edda4876f0f3a262cbc41a8ca Issue-ID: CCSDK-1241 Signed-off-by: Haddox, Anthony --- grToolkit/provider/pom.xml | 6 + .../onap/ccsdk/sli/plugins/GrToolkitProvider.java | 958 -------------------- .../onap/ccsdk/sli/plugins/data/ClusterActor.java | 215 ----- .../onap/ccsdk/sli/plugins/data/MemberBuilder.java | 80 -- .../sli/plugins/grtoolkit/GrToolkitProvider.java | 965 +++++++++++++++++++++ .../sli/plugins/grtoolkit/data/ClusterActor.java | 215 +++++ .../sli/plugins/grtoolkit/data/MemberBuilder.java | 80 ++ .../src/main/resources/gr-toolkit.properties | 21 +- .../org/opendaylight/blueprint/GrToolkit.xml | 2 +- .../plugins/grtoolkit/GrToolkitProviderTest.java | 344 ++++++++ .../plugins/grtoolkit/data/MemberBuilderTest.java | 41 + grToolkit/provider/src/test/resources/akka.conf | 49 ++ grToolkit/provider/src/test/resources/akka6.conf | 49 ++ .../src/test/resources/gr-toolkit.properties | 34 + 14 files changed, 1804 insertions(+), 1255 deletions(-) delete mode 100755 grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitProvider.java delete mode 100755 grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/ClusterActor.java delete mode 100755 grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/MemberBuilder.java create mode 100755 grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java create mode 100755 grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/ClusterActor.java create mode 100755 grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/MemberBuilder.java create mode 100644 grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProviderTest.java create mode 100644 grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/MemberBuilderTest.java create mode 100644 grToolkit/provider/src/test/resources/akka.conf create mode 100644 grToolkit/provider/src/test/resources/akka6.conf create mode 100755 grToolkit/provider/src/test/resources/gr-toolkit.properties diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index 951d2da60..51a850b8d 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -98,5 +98,11 @@ ${akka.version} provided + + com.github.stefanbirkner + system-rules + 1.19.0 + test + diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitProvider.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitProvider.java deleted file mode 100755 index dc8534be2..000000000 --- a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/GrToolkitProvider.java +++ /dev/null @@ -1,958 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2018 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; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import javax.annotation.Nonnull; - -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; - -import org.onap.ccsdk.sli.core.dblib.DbLibService; -import org.onap.ccsdk.sli.plugins.data.ClusterActor; -import org.onap.ccsdk.sli.plugins.data.MemberBuilder; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.AdminHealthInput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.AdminHealthOutput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.AdminHealthOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ClusterHealthInput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ClusterHealthOutput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ClusterHealthOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.DatabaseHealthInput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.DatabaseHealthOutput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.DatabaseHealthOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverInput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverOutput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.GrToolkitService; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.HaltAkkaTrafficInput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.HaltAkkaTrafficOutput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.HaltAkkaTrafficOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.Member; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ResumeAkkaTrafficInput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ResumeAkkaTrafficOutput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ResumeAkkaTrafficOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.Site; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteHealthInput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteHealthOutput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteHealthOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteIdentifierInput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteIdentifierOutput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteIdentifierOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.site.health.output.SitesBuilder; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataTreeChangeListener { - private static final String APP_NAME = "gr-toolkit"; - private static final String PROPERTIES_FILE = System.getenv("SDNC_CONFIG_DIR") + "/gr-toolkit.properties"; - private static final String HEALTHY = "HEALTHY"; - private static final String FAULTY = "FAULTY"; - private static final String VALUE = "value"; - private String akkaConfig; - private String jolokiaClusterPath; - private String shardManagerPath; - private String shardPathTemplate; - private String credentials; - private String httpProtocol; - private String siteIdentifier = System.getenv("SITE_NAME"); - private final Logger log = LoggerFactory.getLogger(GrToolkitProvider.class); - private final ExecutorService executor; - protected DataBroker dataBroker; - protected NotificationPublishService notificationService; - protected RpcProviderRegistry rpcRegistry; - protected BindingAwareBroker.RpcRegistration rpcRegistration; - protected DbLibService dbLib; - private String member; - private ClusterActor self; - private HashMap memberMap; - private SiteConfiguration siteConfiguration; - private Properties properties; - private DistributedDataStoreInterface configDatastore; - public GrToolkitProvider(DataBroker dataBroker, - NotificationPublishService notificationProviderService, - RpcProviderRegistry rpcProviderRegistry, - DistributedDataStoreInterface configDatastore, - DbLibService dbLibService) { - this.log.info("Creating provider for {}", APP_NAME); - this.executor = Executors.newFixedThreadPool(1); - this.dataBroker = dataBroker; - this.notificationService = notificationProviderService; - this.rpcRegistry = rpcProviderRegistry; - this.configDatastore = configDatastore; - this.dbLib = dbLibService; - initialize(); - } - - private void initialize() { - log.info("Initializing provider for {}", APP_NAME); - // Create the top level containers - createContainers(); - setProperties(); - defineMembers(); - - rpcRegistration = rpcRegistry.addRpcImplementation(GrToolkitService.class, this); - log.info("Initialization complete for {}", APP_NAME); - } - - private void setProperties() { - log.info("Loading properties from {}", PROPERTIES_FILE); - properties = new Properties(); - File propertiesFile = new File(PROPERTIES_FILE); - if(!propertiesFile.exists()) { - log.warn("Properties file not found."); - return; - } - try(FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { - properties.load(fileInputStream); - if(!properties.containsKey(PropertyKeys.SITE_IDENTIFIER)) { - properties.put(PropertyKeys.SITE_IDENTIFIER, "Unknown Site"); - } - String port = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL).trim()) ? properties.getProperty(PropertyKeys.CONTROLLER_PORT_SSL).trim() : properties.getProperty(PropertyKeys.CONTROLLER_PORT_HTTP).trim(); - httpProtocol = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL).trim()) ? "https://" : "http://"; - akkaConfig = properties.getProperty(PropertyKeys.AKKA_CONF_LOCATION).trim(); - jolokiaClusterPath = ":" + port + properties.getProperty(PropertyKeys.MBEAN_CLUSTER).trim(); - shardManagerPath = ":" + port + properties.getProperty(PropertyKeys.MBEAN_SHARD_MANAGER).trim(); - shardPathTemplate = ":" + port + properties.getProperty(PropertyKeys.MBEAN_SHARD_CONFIG).trim(); - if(siteIdentifier == null || siteIdentifier.isEmpty()) { - siteIdentifier = properties.getProperty(PropertyKeys.SITE_IDENTIFIER).trim(); - } - credentials = properties.getProperty(PropertyKeys.CONTROLLER_CREDENTIALS).trim(); - log.info("Loaded properties."); - } catch(IOException e) { - log.error("Error loading properties.", e); - } - } - - private void defineMembers() { - member = configDatastore.getActorContext().getCurrentMemberName().getName(); - log.info("Cluster member: {}", member); - - log.info("Parsing akka.conf for cluster memberMap..."); - try { - File akkaConfigFile = new File(this.akkaConfig); - try(FileReader fileReader = new FileReader(akkaConfigFile); - BufferedReader bufferedReader = new BufferedReader(fileReader)) { - String line; - while((line = bufferedReader.readLine()) != null) { - if(line.contains("seed-nodes =")) { - parseSeedNodes(line); - break; - } - } - } - } catch(IOException e) { - log.error("Couldn't load akka", e); - } - log.info("self:\n{}", self); - } - - private void createContainers() { - // Replace with MD-SAL write for FailoverStatus - } - - protected void initializeChild() { - // Override if you have custom initialization intelligence - } - - @Override - public void close() throws Exception { - log.info("Closing provider for {}", APP_NAME); - executor.shutdown(); - rpcRegistration.close(); - log.info("Successfully closed provider for {}", APP_NAME); - } - - @Override - public void onDataTreeChanged(@Nonnull Collection changes) { - log.info("onDataTreeChanged() called. but there is no change here"); - } - - @Override - public ListenableFuture> clusterHealth(ClusterHealthInput input) { - log.info("{}:cluster-health invoked.", APP_NAME); - getControllerHealth(); - return buildClusterHealthOutput("200"); - } - - @Override - public ListenableFuture> siteHealth(SiteHealthInput input) { - log.info("{}:site-health invoked.", APP_NAME); - getControllerHealth(); - return buildSiteHealthOutput("200", getAdminHealth(), getDatabaseHealth()); - } - - @Override - public ListenableFuture> databaseHealth(DatabaseHealthInput input) { - log.info("{}:database-health invoked.", APP_NAME); - DatabaseHealthOutputBuilder outputBuilder = new DatabaseHealthOutputBuilder(); - outputBuilder.setStatus("200"); - outputBuilder.setHealth(getDatabaseHealth()); - - return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); - } - - @Override - public ListenableFuture> adminHealth(AdminHealthInput input) { - log.info("{}:admin-health invoked.", APP_NAME); - AdminHealthOutputBuilder outputBuilder = new AdminHealthOutputBuilder(); - outputBuilder.setStatus("200"); - outputBuilder.setHealth(getAdminHealth()); - - return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); - } - - @Override - public ListenableFuture> haltAkkaTraffic(HaltAkkaTrafficInput input) { - log.info("{}:halt-akka-traffic invoked.", APP_NAME); - HaltAkkaTrafficOutputBuilder outputBuilder = new HaltAkkaTrafficOutputBuilder(); - outputBuilder.setStatus("200"); - modifyIpTables(IpTables.ADD, input.getNodeInfo().toArray()); - - return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); - } - - @Override - public ListenableFuture> resumeAkkaTraffic(ResumeAkkaTrafficInput input) { - log.info("{}:resume-akka-traffic invoked.", APP_NAME); - ResumeAkkaTrafficOutputBuilder outputBuilder = new ResumeAkkaTrafficOutputBuilder(); - outputBuilder.setStatus("200"); - modifyIpTables(IpTables.DELETE, input.getNodeInfo().toArray()); - - return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); - } - - @Override - public ListenableFuture> siteIdentifier(SiteIdentifierInput input) { - log.info("{}:site-identifier invoked.", APP_NAME); - SiteIdentifierOutputBuilder outputBuilder = new SiteIdentifierOutputBuilder(); - outputBuilder.setStatus("200"); - outputBuilder.setId(siteIdentifier); - - return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); - } - - @Override - public ListenableFuture> failover(FailoverInput input) { - log.info("{}:failover invoked.", APP_NAME); - FailoverOutputBuilder outputBuilder = new FailoverOutputBuilder(); - if(siteConfiguration != SiteConfiguration.GEO) { - log.info("Cannot failover non-GEO site."); - outputBuilder.setMessage("Failover aborted. This is not a GEO configuration."); - outputBuilder.setStatus("400"); - return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); - } - ArrayList activeSite = new ArrayList<>(); - ArrayList standbySite = new ArrayList<>(); - - log.info("Performing preliminary cluster health check..."); - // Necessary to populate all member info. Health is not used for judgement calls. - getControllerHealth(); - - log.info("Determining active site..."); - for(Map.Entry entry : memberMap.entrySet()) { - String key = entry.getKey(); - ClusterActor clusterActor = entry.getValue(); - if(clusterActor.isVoting()) { - activeSite.add(clusterActor); - log.debug("Active Site member: {}", key); - } - else { - standbySite.add(clusterActor); - log.debug("Standby Site member: {}", key); - } - } - - String port = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL)) ? properties.getProperty(PropertyKeys.CONTROLLER_PORT_SSL) : properties.getProperty(PropertyKeys.CONTROLLER_PORT_HTTP); - - if(Boolean.parseBoolean(input.getBackupData())) { - backupMdSal(activeSite, port); - } - - if(!changeClusterVoting(outputBuilder, activeSite, standbySite, port)) - return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); - - if(Boolean.parseBoolean(input.getIsolate())) { - isolateSiteFromCluster(activeSite, standbySite, port); - - if(Boolean.parseBoolean(input.getDownUnreachable())) { - downUnreachableNodes(activeSite, standbySite, port); - } - } - - log.info("{}:failover complete.", APP_NAME); - - outputBuilder.setMessage("Failover complete."); - outputBuilder.setStatus("200"); - return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); - } - - private void isolateSiteFromCluster(ArrayList activeSite, ArrayList standbySite, String port) { - log.info("Halting Akka traffic..."); - for(ClusterActor actor : standbySite) { - try { - log.info("Halting Akka traffic for: {}", actor.getNode()); - // Build JSON with activeSite actor Node and actor AkkaPort - JSONObject akkaInput = new JSONObject(); - JSONObject inputBlock = new JSONObject(); - JSONArray votingStateArray = new JSONArray(); - JSONObject nodeInfo; - for(ClusterActor node : activeSite) { - nodeInfo = new JSONObject(); - nodeInfo.put("node", node.getNode()); - nodeInfo.put("port", node.getAkkaPort()); - votingStateArray.put(nodeInfo); - } - inputBlock.put("node-info", votingStateArray); - akkaInput.put("input", inputBlock); - getRequestContent(httpProtocol + actor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:halt-akka-traffic", HttpMethod.POST, akkaInput.toString()); - } catch(IOException e) { - log.error("Could not halt Akka traffic for: " + actor.getNode(), e); - } - } - } - - private void downUnreachableNodes(ArrayList activeSite, ArrayList standbySite, String port) { - log.info("Setting site unreachable..."); - JSONObject jolokiaInput = new JSONObject(); - jolokiaInput.put("type", "EXEC"); - jolokiaInput.put("mbean", "akka:type=Cluster"); - jolokiaInput.put("operation", "down"); - JSONArray arguments = new JSONArray(); - for(ClusterActor actor : activeSite) { - // Build Jolokia input - // May need to change from akka port to actor.getAkkaPort() - arguments.put("akka.tcp://opendaylight-cluster-data@" + actor.getNode() + ":" + properties.getProperty(PropertyKeys.CONTROLLER_PORT_AKKA)); - } - jolokiaInput.put("arguments", arguments); - log.debug("{}", jolokiaInput); - try { - log.info("Setting nodes unreachable"); - getRequestContent(httpProtocol + standbySite.get(0).getNode() + ":" + port + "/jolokia", HttpMethod.POST, jolokiaInput.toString()); - } catch(IOException e) { - log.error("Error setting nodes unreachable", e); - } - } - - private boolean changeClusterVoting(FailoverOutputBuilder outputBuilder, ArrayList activeSite, ArrayList standbySite, String port) { - log.info("Changing voting for all shards to standby site..."); - try { - JSONObject votingInput = new JSONObject(); - JSONObject inputBlock = new JSONObject(); - JSONArray votingStateArray = new JSONArray(); - JSONObject memberVotingState; - for(ClusterActor actor : activeSite) { - memberVotingState = new JSONObject(); - memberVotingState.put("member-name", actor.getMember()); - memberVotingState.put("voting", false); - votingStateArray.put(memberVotingState); - } - for(ClusterActor actor : standbySite) { - memberVotingState = new JSONObject(); - memberVotingState.put("member-name", actor.getMember()); - memberVotingState.put("voting", true); - votingStateArray.put(memberVotingState); - } - inputBlock.put("member-voting-state", votingStateArray); - votingInput.put("input", inputBlock); - log.debug("{}", votingInput); - // Change voting all shards - getRequestContent(httpProtocol + self.getNode() + ":" + port + "/restconf/operations/cluster-admin:change-member-voting-states-for-all-shards", HttpMethod.POST, votingInput.toString()); - } catch(IOException e) { - log.error("Changing voting", e); - outputBuilder.setMessage("Failover aborted. Failed to change voting."); - outputBuilder.setStatus("500"); - return false; - } - return true; - } - - private void backupMdSal(ArrayList activeSite, String port) { - log.info("Backing up data..."); - try { - log.info("Scheduling backup for: {}", activeSite.get(0).getNode()); - getRequestContent(httpProtocol + activeSite.get(0).getNode() + ":" + port + "/restconf/operations/data-export-import:schedule-export", HttpMethod.POST, "{ \"input\": { \"run-at\": \"30\" } }"); - } catch(IOException e) { - log.error("Error backing up MD-SAL", e); - } - for(ClusterActor actor : activeSite) { - try { - // Move data offsite - log.info("Backing up data for: {}", actor.getNode()); - getRequestContent(httpProtocol + actor.getNode() + ":" + port + "/restconf/operations/daexim-offsite-backup:backup-data", HttpMethod.POST); - } catch(IOException e) { - log.error("Error backing up data.", e); - } - } - } - - private ListenableFuture> buildClusterHealthOutput(String statusCode) { - ClusterHealthOutputBuilder outputBuilder = new ClusterHealthOutputBuilder(); - outputBuilder.setStatus(statusCode); - outputBuilder.setMembers((List) new ArrayList()); - int site1Health = 0; - int site2Health = 0; - - for(Map.Entry entry : memberMap.entrySet()) { - ClusterActor clusterActor = entry.getValue(); - if(clusterActor.isUp() && !clusterActor.isUnreachable()) { - if(ClusterActor.SITE_1.equals(clusterActor.getSite())) - site1Health++; - else if(ClusterActor.SITE_2.equals(clusterActor.getSite())) - site2Health++; - } - outputBuilder.getMembers().add(new MemberBuilder(clusterActor).build()); - } - if(siteConfiguration == SiteConfiguration.SOLO) { - outputBuilder.setSite1Health(HEALTHY); - } - else if(site1Health > 1) { - outputBuilder.setSite1Health(HEALTHY); - } - else { - outputBuilder.setSite1Health(FAULTY); - } - - if(siteConfiguration == SiteConfiguration.GEO && site2Health > 1) { - outputBuilder.setSite2Health(HEALTHY); - } - else if(siteConfiguration == SiteConfiguration.GEO) { - outputBuilder.setSite2Health(FAULTY); - } - - RpcResult rpcResult = RpcResultBuilder.status(true).withResult(outputBuilder.build()).build(); - return Futures.immediateFuture(rpcResult); - } - - private ListenableFuture> buildSiteHealthOutput(String statusCode, String adminHealth, String databaseHealth) { - SiteHealthOutputBuilder outputBuilder = new SiteHealthOutputBuilder(); - outputBuilder.setStatus(statusCode); - outputBuilder.setSites((List) new ArrayList()); - - if(siteConfiguration != SiteConfiguration.GEO) { - int healthyODLs = 0; - SitesBuilder builder = new SitesBuilder(); - for(Map.Entry entry : memberMap.entrySet()) { - ClusterActor clusterActor = entry.getValue(); - if(clusterActor.isUp() && !clusterActor.isUnreachable()) { - healthyODLs++; - } - } - if(siteConfiguration != SiteConfiguration.SOLO) { - builder.setHealth(HEALTHY); - builder.setRole("ACTIVE"); - builder.setId(siteIdentifier); - } - else { - builder = getSitesBuilder(healthyODLs, true, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), siteIdentifier); - } - outputBuilder.getSites().add(builder.build()); - } - else { - int site1HealthyODLs = 0; - int site2HealthyODLs = 0; - boolean site1Voting = false; - boolean site2Voting = false; - boolean performedCrossSiteHealthCheck = false; - boolean crossSiteAdminHealthy = false; - boolean crossSiteDbHealthy = false; - String crossSiteIdentifier = "UNKNOWN_SITE"; - String port = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL)) ? properties.getProperty(PropertyKeys.CONTROLLER_PORT_SSL) : properties.getProperty(PropertyKeys.CONTROLLER_PORT_HTTP); - if(isSite1()) { - // Make calls over to site 2 healthchecks - for(Map.Entry entry : memberMap.entrySet()) { - ClusterActor clusterActor = entry.getValue(); - if(clusterActor.isUp() && !clusterActor.isUnreachable()) { - if(ClusterActor.SITE_1.equals(clusterActor.getSite())) { - site1HealthyODLs++; - if(clusterActor.isVoting()) { - site1Voting = true; - } - } - else { - site2HealthyODLs++; - if(clusterActor.isVoting()) { - site2Voting = true; - } - if(!performedCrossSiteHealthCheck) { - try { - String content = getRequestContent(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:site-identifier", HttpMethod.POST); - crossSiteIdentifier = new JSONObject(content).getJSONObject("output").getString("id"); - crossSiteDbHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:database-health"); - crossSiteAdminHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:admin-health"); - performedCrossSiteHealthCheck = true; - } catch(Exception e) { - log.info("Cannot get site identifier from {}", clusterActor.getNode()); - log.error("Site Health Error", e); - } - } - } - } - } - SitesBuilder builder = getSitesBuilder(site1HealthyODLs, site1Voting, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), siteIdentifier); - outputBuilder.getSites().add(builder.build()); - builder = getSitesBuilder(site2HealthyODLs, site2Voting, crossSiteAdminHealthy, crossSiteDbHealthy, crossSiteIdentifier); - outputBuilder.getSites().add(builder.build()); - } - else { - // Make calls over to site 1 healthchecks - for(Map.Entry entry : memberMap.entrySet()) { - ClusterActor clusterActor = entry.getValue(); - if(clusterActor.isUp() && !clusterActor.isUnreachable()) { - if(ClusterActor.SITE_1.equals(clusterActor.getSite())) { - site1HealthyODLs++; - if(clusterActor.isVoting()) { - site1Voting = true; - } - if(!performedCrossSiteHealthCheck) { - try { - String content = getRequestContent(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:site-identifier", HttpMethod.POST); - crossSiteIdentifier = new JSONObject(content).getJSONObject("output").getString("id"); - crossSiteDbHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:database-health"); - crossSiteAdminHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:admin-health"); - performedCrossSiteHealthCheck = true; - } catch(Exception e) { - log.info("Cannot get site identifier from {}", clusterActor.getNode()); - log.error("Site Health Error", e); - } - } - } - else { - site2HealthyODLs++; - if(clusterActor.isVoting()) { - site2Voting = true; - } - } - } - } - // Build Output - SitesBuilder builder = getSitesBuilder(site1HealthyODLs, site1Voting, crossSiteAdminHealthy, crossSiteDbHealthy, crossSiteIdentifier); - outputBuilder.getSites().add(builder.build()); - builder = getSitesBuilder(site2HealthyODLs, site2Voting, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), siteIdentifier); - outputBuilder.getSites().add(builder.build()); - } - } - - RpcResult rpcResult = RpcResultBuilder.status(true).withResult(outputBuilder.build()).build(); - return Futures.immediateFuture(rpcResult); - } - - private SitesBuilder getSitesBuilder(int siteHealthyODLs, boolean siteVoting, boolean adminHealthy, boolean dbHealthy, String siteIdentifier) { - SitesBuilder builder = new SitesBuilder(); - if(siteHealthyODLs > 1) { - builder.setHealth(HEALTHY); - } - else { - log.warn("{} Healthy ODLs: {}", siteIdentifier, siteHealthyODLs); - builder.setHealth(FAULTY); - } - if(!adminHealthy) { - log.warn("{} Admin Health: {}", siteIdentifier, FAULTY); - builder.setHealth(FAULTY); - } - if(!dbHealthy) { - log.warn("{} Database Health: {}", siteIdentifier, FAULTY); - builder.setHealth(FAULTY); - } - if(siteVoting) { - builder.setRole("ACTIVE"); - } - else { - builder.setRole("STANDBY"); - } - builder.setId(siteIdentifier); - return builder; - } - - private boolean isSite1() { - int memberNumber = Integer.parseInt(member.split("-")[1]); - boolean isSite1 = memberNumber < 4; - log.info("isSite1(): {}", isSite1); - return isSite1; - } - - private void parseSeedNodes(String line) { - memberMap = new HashMap<>(); - line = line.substring(line.indexOf("[\""), line.indexOf(']')); - String[] splits = line.split(","); - - for(int ndx = 0; ndx < splits.length; ndx++) { - String nodeName = splits[ndx]; - int delimLocation = nodeName.indexOf('@'); - String port = nodeName.substring(splits[ndx].indexOf(':', delimLocation) + 1, splits[ndx].indexOf('"', splits[ndx].indexOf(':'))); - splits[ndx] = nodeName.substring(delimLocation + 1, splits[ndx].indexOf(':', delimLocation)); - log.info("Adding node: {}:{}", splits[ndx], port); - ClusterActor clusterActor = new ClusterActor(); - clusterActor.setNode(splits[ndx]); - clusterActor.setAkkaPort(port); - clusterActor.setMember("member-" + (ndx + 1)); - if(ndx < 3) { - clusterActor.setSite(ClusterActor.SITE_1); - } - else { - clusterActor.setSite(ClusterActor.SITE_2); - } - - if(member.equals(clusterActor.getMember())) { - self = clusterActor; - } - memberMap.put(clusterActor.getNode(), clusterActor); - log.info("{}", clusterActor); - } - - if(memberMap.size() == 1) { - log.info("1 member found. This is a solo environment."); - siteConfiguration = SiteConfiguration.SOLO; - } - else if(memberMap.size() == 3) { - log.info("This is a single site."); - siteConfiguration = SiteConfiguration.SINGLE; - } - else if(memberMap.size() == 6) { - log.info("This is a georedundant site."); - siteConfiguration = SiteConfiguration.GEO; - } - } - - private void getMemberStatus(ClusterActor clusterActor) throws IOException { - log.info("Getting member status for {}", clusterActor.getNode()); - String content = getRequestContent(httpProtocol + clusterActor.getNode() + jolokiaClusterPath, HttpMethod.GET); - try { - JSONObject responseJson = new JSONObject(content); - JSONObject responseValue = responseJson.getJSONObject(VALUE); - clusterActor.setUp("Up".equals(responseValue.getString("MemberStatus"))); - clusterActor.setUnreachable(false); - } catch(JSONException e) { - log.error("Error parsing response from {}", clusterActor.getNode(), e); - clusterActor.setUp(false); - clusterActor.setUnreachable(true); - } - } - - private void getShardStatus(ClusterActor clusterActor) throws IOException { - log.info("Getting shard status for {}", clusterActor.getNode()); - String content = getRequestContent(httpProtocol + clusterActor.getNode() + shardManagerPath, HttpMethod.GET); - try { - JSONObject responseValue = new JSONObject(content).getJSONObject(VALUE); - JSONArray shardList = responseValue.getJSONArray("LocalShards"); - - String pattern = "-config$"; - Pattern r = Pattern.compile(pattern); - Matcher m; - for(int ndx = 0; ndx < shardList.length(); ndx++) { - String configShardName = shardList.getString(ndx); - m = r.matcher(configShardName); - String operationalShardName = m.replaceFirst("-operational"); - String shardConfigPath = String.format(shardPathTemplate, configShardName); - String shardOperationalPath = String.format(shardPathTemplate, operationalShardName).replace("Config", "Operational"); - extractShardInfo(clusterActor, configShardName, shardConfigPath); - extractShardInfo(clusterActor, operationalShardName, shardOperationalPath); - } - } catch(JSONException e) { - log.error("Error parsing response from " + clusterActor.getNode(), e); - } - } - - private void extractShardInfo(ClusterActor clusterActor, String shardName, String shardPath) throws IOException { - log.info("Extracting shard info for {}", shardName); - log.debug("Pulling config info for {} from: {}", shardName, shardPath); - String content = getRequestContent(httpProtocol + clusterActor.getNode() + shardPath, HttpMethod.GET); - log.debug("Response: {}", content); - - try { - JSONObject shardValue = new JSONObject(content).getJSONObject(VALUE); - clusterActor.setVoting(shardValue.getBoolean("Voting")); - if(shardValue.getString("PeerAddresses").length() > 0) { - clusterActor.getReplicaShards().add(shardName); - if(shardValue.getString("Leader").startsWith(clusterActor.getMember())) { - clusterActor.getShardLeader().add(shardName); - } - } - else { - clusterActor.getNonReplicaShards().add(shardName); - } - JSONArray followerInfo = shardValue.getJSONArray("FollowerInfo"); - for(int followerNdx = 0; followerNdx < followerInfo.length(); followerNdx++) { - int commitIndex = shardValue.getInt("CommitIndex"); - int matchIndex = followerInfo.getJSONObject(followerNdx).getInt("matchIndex"); - if(commitIndex != -1 && matchIndex != -1) { - int commitsBehind = commitIndex - matchIndex; - clusterActor.getCommits().put(followerInfo.getJSONObject(followerNdx).getString("id"), commitsBehind); - } - } - } catch(JSONException e) { - log.error("Error parsing response from " + clusterActor.getNode(), e); - } - } - - private void getControllerHealth() { - for(Map.Entry entry : memberMap.entrySet()) { - ClusterActor clusterActor = entry.getValue(); - String key = entry.getKey(); - try { - // First flush out the old values - clusterActor.flush(); - log.info("Gathering info for {}", clusterActor.getNode()); - getMemberStatus(clusterActor); - getShardStatus(clusterActor); - log.info("MemberInfo:\n{}", clusterActor); - } catch(IOException e) { - log.error("Connection Error", e); - memberMap.get(key).setUnreachable(true); - memberMap.get(key).setUp(false); - log.info("MemberInfo:\n{}", memberMap.get(key)); - } - } - } - - private void modifyIpTables(IpTables task, Object[] nodeInfo) { - log.info("Modifying IPTables rules..."); - if(task == IpTables.ADD) { - for(Object node : nodeInfo) { - org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.halt.akka.traffic.input.NodeInfo n = - (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.halt.akka.traffic.input.NodeInfo) node; - log.info("Isolating {}", n.getNode()); - executeCommand(String.format("sudo /sbin/iptables -A INPUT -p tcp --destination-port %s -j DROP -s %s", properties.get(PropertyKeys.CONTROLLER_PORT_AKKA), n.getNode())); - executeCommand(String.format("sudo /sbin/iptables -A OUTPUT -p tcp --destination-port %s -j DROP -s %s", n.getPort(), n.getNode())); - } - - } else if(task == IpTables.DELETE) { - for(Object node : nodeInfo) { - org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.resume.akka.traffic.input.NodeInfo n = - (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.resume.akka.traffic.input.NodeInfo) node; - log.info("De-isolating {}", n.getNode()); - executeCommand(String.format("sudo /sbin/iptables -D INPUT -p tcp --destination-port %s -j DROP -s %s", properties.get(PropertyKeys.CONTROLLER_PORT_AKKA), n.getNode())); - executeCommand(String.format("sudo /sbin/iptables -D OUTPUT -p tcp --destination-port %s -j DROP -s %s", n.getPort(), n.getNode())); - } - - } - executeCommand("sudo /sbin/iptables -L"); - } - - private void executeCommand(String command) { - log.info("Executing command: {}", command); - String[] cmd = command.split(" "); - try { - Process p = Runtime.getRuntime().exec(cmd); - BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(p.getInputStream())); - String inputLine; - StringBuilder content = new StringBuilder(); - while((inputLine = bufferedReader.readLine()) != null) { - content.append(inputLine); - } - bufferedReader.close(); - log.info("{}", content); - } catch(IOException e) { - log.error("Error executing command", e); - } - } - - private boolean crossSiteHealthRequest(String path) throws IOException { - String content = getRequestContent(path, HttpMethod.POST); - try { - JSONObject responseJson = new JSONObject(content); - JSONObject responseValue = responseJson.getJSONObject(VALUE); - return HEALTHY.equals(responseValue.getString("health")); - } catch(JSONException e) { - log.error("Error parsing JSON", e); - throw new IOException(); - } - } - - private String getAdminHealth() { - String protocol = "true".equals(properties.getProperty(PropertyKeys.ADM_USE_SSL)) ? "https://" : "http://"; - String port = "true".equals(properties.getProperty(PropertyKeys.ADM_USE_SSL)) ? properties.getProperty(PropertyKeys.ADM_PORT_SSL) : properties.getProperty(PropertyKeys.ADM_PORT_HTTP); - String path = protocol + properties.getProperty(PropertyKeys.ADM_FQDN) + ":" + port + properties.getProperty(PropertyKeys.ADM_HEALTHCHECK); - log.info("Requesting healthcheck from {}", path); - try { - int response = getRequestStatus(path, HttpMethod.GET); - log.info("Response: {}", response); - if(response == 200) - return HEALTHY; - return FAULTY; - } catch(IOException e) { - log.error("Problem getting ADM health.", e); - return FAULTY; - } - } - - private String getDatabaseHealth() { - log.info("Determining database health..."); - try { - log.info("DBLib isActive(): {}", dbLib.isActive()); - log.info("DBLib isReadOnly(): {}", dbLib.getConnection().isReadOnly()); - log.info("DBLib isClosed(): {}", dbLib.getConnection().isClosed()); - if(!dbLib.isActive() || dbLib.getConnection().isClosed() || dbLib.getConnection().isReadOnly()) { - log.warn("Database is FAULTY"); - return FAULTY; - } - log.info("Database is HEALTHY"); - } catch(SQLException e) { - log.error("Database is FAULTY"); - log.error("Error", e); - return FAULTY; - } - - return HEALTHY; - } - - private String getRequestContent(String path, HttpMethod method) throws IOException { - return getRequestContent(path, method, null); - } - - private String getRequestContent(String path, HttpMethod method, String input) throws IOException { - HttpURLConnection connection = getConnection(path); - connection.setRequestMethod(method.getMethod()); - connection.setDoInput(true); - - if(input != null) { - sendPayload(input, connection); - } - - BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream())); - String inputLine; - StringBuilder content = new StringBuilder(); - while((inputLine = bufferedReader.readLine()) != null) { - content.append(inputLine); - } - bufferedReader.close(); - connection.disconnect(); - return content.toString(); - } - - private int getRequestStatus(String path, HttpMethod method) throws IOException { - return getRequestStatus(path, method, null); - } - - private int getRequestStatus(String path, HttpMethod method, String input) throws IOException { - HttpURLConnection connection = getConnection(path); - connection.setRequestMethod(method.getMethod()); - connection.setDoInput(true); - - if(input != null) { - sendPayload(input, connection); - } - int response = connection.getResponseCode(); - log.info("Received {} response code from {}", response, path); - connection.disconnect(); - return response; - } - - private void sendPayload(String input, HttpURLConnection connection) throws IOException { - byte[] out = input.getBytes(StandardCharsets.UTF_8); - int length = out.length; - - connection.setFixedLengthStreamingMode(length); - connection.setRequestProperty("Content-Type", "application/json"); - connection.setDoOutput(true); - connection.connect(); - try(OutputStream os = connection.getOutputStream()) { - os.write(out); - } - } - - private HttpURLConnection getConnection(String host) throws IOException { - log.info("Getting connection to: {}", host); - URL url = new URL(host); - String auth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(credentials.getBytes()); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.addRequestProperty("Authorization", auth); - connection.setRequestProperty("Connection", "keep-alive"); - connection.setRequestProperty("Proxy-Connection", "keep-alive"); - return connection; - } - - private enum IpTables { - ADD, - DELETE - } - - private enum SiteConfiguration { - SOLO, - SINGLE, - GEO - } - - private enum HttpMethod { - GET("GET"), - POST("POST"); - - private String method; - HttpMethod(String method) { - this.method = method; - } - public String getMethod() { - return method; - } - } - - private class PropertyKeys { - static final String SITE_IDENTIFIER = "site.identifier"; - static final String CONTROLLER_USE_SSL = "controller.useSsl"; - static final String CONTROLLER_PORT_SSL = "controller.port.ssl"; - static final String CONTROLLER_PORT_HTTP = "controller.port.http"; - static final String CONTROLLER_PORT_AKKA = "controller.port.akka"; - static final String CONTROLLER_CREDENTIALS = "controller.credentials"; - static final String AKKA_CONF_LOCATION = "akka.conf.location"; - static final String MBEAN_CLUSTER = "mbean.cluster"; - static final String MBEAN_SHARD_MANAGER = "mbean.shardManager"; - static final String MBEAN_SHARD_CONFIG = "mbean.shard.config"; - static final String ADM_USE_SSL = "adm.useSsl"; - static final String ADM_PORT_SSL = "adm.port.ssl"; - static final String ADM_PORT_HTTP = "adm.port.http"; - static final String ADM_FQDN = "adm.fqdn"; - static final String ADM_HEALTHCHECK= "adm.healthcheck"; - } -} \ No newline at end of file diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/ClusterActor.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/ClusterActor.java deleted file mode 100755 index 1c8faac08..000000000 --- a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/ClusterActor.java +++ /dev/null @@ -1,215 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2018 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.data; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class ClusterActor { - private String node; - private String member; - private String site; - private String akkaPort; - private boolean voting; - private boolean up; - private boolean unreachable; - private ArrayList shardLeader; - private ArrayList replicaShards; - private ArrayList nonReplicaShards; - private HashMap commits; - - public static final String SITE_1 = "Site 1"; - public static final String SITE_2 = "Site 2"; - - public ClusterActor() { - node = ""; - member = ""; - site = ""; - voting = false; - up = false; - unreachable = false; - shardLeader = new ArrayList<>(); - replicaShards = new ArrayList<>(); - nonReplicaShards = new ArrayList<>(); - commits = new HashMap<>(); - } - - public String getNode() { - return node; - } - - public void setNode(String node) { - this.node = node; - } - - public String getMember() { - return member; - } - - public void setMember(String member) { - this.member = member; - } - - public String getSite() { - return site; - } - - public void setSite(String site) { - this.site = site; - } - - public String getAkkaPort() { - return akkaPort; - } - - public void setAkkaPort(String akkaPort) { - this.akkaPort = akkaPort; - } - - public boolean isVoting() { - return voting; - } - - public void setVoting(boolean voting) { - this.voting = voting; - } - - public boolean isUp() { - return up; - } - - public void setUp(boolean up) { - this.up = up; - } - - public boolean isUnreachable() { - return unreachable; - } - - public void setUnreachable(boolean unreachable) { - this.unreachable = unreachable; - } - - public List getShardLeader() { - return shardLeader; - } - - public void setShardLeader(List shardLeader) { - this.shardLeader = (ArrayList) shardLeader; - } - - public List getReplicaShards() { - return replicaShards; - } - - public void setReplicaShards(List replicaShards) { - this.replicaShards = (ArrayList) replicaShards; - } - - public List getNonReplicaShards() { - return nonReplicaShards; - } - - public void setNonReplicaShards(List nonReplicaShards) { - this.nonReplicaShards = (ArrayList) nonReplicaShards; - } - - public Map getCommits() { - return commits; - } - - public void setCommits(Map commits) { - this.commits = (HashMap) commits; - } - - public void flush() { - shardLeader.clear(); - replicaShards.clear(); - nonReplicaShards.clear(); - commits.clear(); - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("[ "); - builder.append(this.member); - builder.append(" ] "); - - builder.append(this.node); - builder.append(":"); - builder.append(this.akkaPort); - builder.append(" is"); - if(up) - builder.append(" Up"); - else - builder.append(" Down"); - if(unreachable) - builder.append(" [ UNREACHABLE ]"); - - if(voting) - builder.append(" (Voting)"); - - builder.append("\n"); - - for(String l : this.shardLeader) { - builder.append("\tLeader: "); - builder.append(l); - builder.append("\n"); - } - - for(String r : this.replicaShards) { - builder.append("\tReplicating: "); - builder.append(r); - builder.append("\n"); - } - - for(String n : this.nonReplicaShards) { - builder.append("\tNot replicating: "); - builder.append(n); - builder.append("\n"); - } - - for(Map.Entry entry : commits.entrySet()) { - String key = entry.getKey(); - int value = entry.getValue(); - if(value > 0) { - builder.append("\t"); - builder.append(value); - builder.append(" commits ahead of "); - builder.append(key); - builder.append("\n"); - } - else if(value < 0) { - builder.append("\t"); - builder.append(value); - builder.append(" commits behind "); - builder.append(key); - builder.append("\n"); - } - } - - return builder.toString(); - } -} diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/MemberBuilder.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/MemberBuilder.java deleted file mode 100755 index 96dfa64a8..000000000 --- a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/data/MemberBuilder.java +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2018 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.data; - -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.cluster.health.output.MembersBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.member.CommitStatusBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.member.ReplicasBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.member.LeaderBuilder; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class MemberBuilder extends MembersBuilder { - public MemberBuilder(ClusterActor actor) { - super(); - this.setAddress(actor.getNode()); - this.setRole(actor.getMember()); - this.setVoting(actor.isVoting()); - this.setUp(actor.isUp()); - this.setUnreachable(actor.isUnreachable()); - populateReplicas(actor.getReplicaShards()); - populateCommits(actor.getCommits()); - populateLeader(actor.getShardLeader()); - } - - private void populateLeader(List shardLeader) { - LeaderBuilder builder; - this.setLeader(new ArrayList<>()); - for(String leader : shardLeader) { - builder = new LeaderBuilder(); - builder.setShard(leader); - this.getLeader().add(builder.build()); - } - } - - private void populateCommits(Map commits) { - CommitStatusBuilder builder; - this.setCommitStatus(new ArrayList<>()); - for(Map.Entry entry : commits.entrySet()) { - String key = entry.getKey(); - Integer value = entry.getValue(); - if(value != 0) { - builder = new CommitStatusBuilder(); - builder.setShard(key); - builder.setDelta(value); - this.getCommitStatus().add(builder.build()); - } - } - } - - private void populateReplicas(List replicaShards) { - ReplicasBuilder builder; - this.setReplicas(new ArrayList<>()); - for(String shard : replicaShards) { - builder = new ReplicasBuilder(); - builder.setShard(shard); - this.getReplicas().add(builder.build()); - } - } -} diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java new file mode 100755 index 000000000..4e121e345 --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java @@ -0,0 +1,965 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2018 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.grtoolkit; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.annotation.Nonnull; + +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; + +import org.onap.ccsdk.sli.core.dblib.DBLibConnection; +import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterActor; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.MemberBuilder; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.AdminHealthInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.AdminHealthOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.AdminHealthOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ClusterHealthInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ClusterHealthOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ClusterHealthOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.DatabaseHealthInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.DatabaseHealthOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.DatabaseHealthOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.GrToolkitService; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.HaltAkkaTrafficInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.HaltAkkaTrafficOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.HaltAkkaTrafficOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.Member; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ResumeAkkaTrafficInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ResumeAkkaTrafficOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ResumeAkkaTrafficOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.Site; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteHealthInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteHealthOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteHealthOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteIdentifierInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteIdentifierOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteIdentifierOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.site.health.output.SitesBuilder; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataTreeChangeListener { + private static final String APP_NAME = "gr-toolkit"; + private static final String PROPERTIES_FILE = System.getenv("SDNC_CONFIG_DIR") + "/gr-toolkit.properties"; + private static final String HEALTHY = "HEALTHY"; + private static final String FAULTY = "FAULTY"; + private static final String VALUE = "value"; + private String akkaConfig; + private String jolokiaClusterPath; + private String shardManagerPath; + private String shardPathTemplate; + private String credentials; + private String httpProtocol; + private String siteIdentifier = System.getenv("SITE_NAME"); + private final Logger log = LoggerFactory.getLogger(GrToolkitProvider.class); + private final ExecutorService executor; + protected DataBroker dataBroker; + protected NotificationPublishService notificationService; + protected RpcProviderRegistry rpcRegistry; + protected BindingAwareBroker.RpcRegistration rpcRegistration; + protected DbLibService dbLib; + private String member; + private ClusterActor self; + private HashMap memberMap; + private SiteConfiguration siteConfiguration; + private Properties properties; + private DistributedDataStoreInterface configDatastore; + public GrToolkitProvider(DataBroker dataBroker, + NotificationPublishService notificationProviderService, + RpcProviderRegistry rpcProviderRegistry, + DistributedDataStoreInterface configDatastore, + DbLibService dbLibService) { + this.log.info("Creating provider for {}", APP_NAME); + this.executor = Executors.newFixedThreadPool(1); + this.dataBroker = dataBroker; + this.notificationService = notificationProviderService; + this.rpcRegistry = rpcProviderRegistry; + this.configDatastore = configDatastore; + this.dbLib = dbLibService; + initialize(); + } + + private void initialize() { + log.info("Initializing provider for {}", APP_NAME); + // Create the top level containers + createContainers(); + setProperties(); + defineMembers(); + + rpcRegistration = rpcRegistry.addRpcImplementation(GrToolkitService.class, this); + log.info("Initialization complete for {}", APP_NAME); + } + + private void setProperties() { + log.info("Loading properties from {}", PROPERTIES_FILE); + properties = new Properties(); + File propertiesFile = new File(PROPERTIES_FILE); + if(!propertiesFile.exists()) { + log.warn("Properties file not found."); + return; + } + try(FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { + properties.load(fileInputStream); + if(!properties.containsKey(PropertyKeys.SITE_IDENTIFIER)) { + properties.put(PropertyKeys.SITE_IDENTIFIER, "Unknown Site"); + } + String port = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL).trim()) ? properties.getProperty(PropertyKeys.CONTROLLER_PORT_SSL).trim() : properties.getProperty(PropertyKeys.CONTROLLER_PORT_HTTP).trim(); + httpProtocol = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL).trim()) ? "https://" : "http://"; + akkaConfig = properties.getProperty(PropertyKeys.AKKA_CONF_LOCATION).trim(); + jolokiaClusterPath = ":" + port + properties.getProperty(PropertyKeys.MBEAN_CLUSTER).trim(); + shardManagerPath = ":" + port + properties.getProperty(PropertyKeys.MBEAN_SHARD_MANAGER).trim(); + shardPathTemplate = ":" + port + properties.getProperty(PropertyKeys.MBEAN_SHARD_CONFIG).trim(); + if(siteIdentifier == null || siteIdentifier.isEmpty()) { + siteIdentifier = properties.getProperty(PropertyKeys.SITE_IDENTIFIER).trim(); + } + credentials = properties.getProperty(PropertyKeys.CONTROLLER_CREDENTIALS).trim(); + log.info("Loaded properties."); + } catch(IOException e) { + log.error("Error loading properties.", e); + } + } + + private void defineMembers() { + member = configDatastore.getActorContext().getCurrentMemberName().getName(); + log.info("Cluster member: {}", member); + + log.info("Parsing akka.conf for cluster memberMap..."); + try { + File akkaConfigFile = new File(this.akkaConfig); + try(FileReader fileReader = new FileReader(akkaConfigFile); + BufferedReader bufferedReader = new BufferedReader(fileReader)) { + String line; + while((line = bufferedReader.readLine()) != null) { + if(line.contains("seed-nodes =")) { + parseSeedNodes(line); + break; + } + } + } + } catch(IOException e) { + log.error("Couldn't load akka", e); + } catch(NullPointerException e) { + log.error("akkaConfig is null. Check properties file and restart {} bundle.", APP_NAME); + } + log.info("self:\n{}", self); + } + + private void createContainers() { + // Replace with MD-SAL write for FailoverStatus + } + + protected void initializeChild() { + // Override if you have custom initialization intelligence + } + + @Override + public void close() throws Exception { + log.info("Closing provider for {}", APP_NAME); + executor.shutdown(); + rpcRegistration.close(); + log.info("Successfully closed provider for {}", APP_NAME); + } + + @Override + public void onDataTreeChanged(@Nonnull Collection changes) { + log.info("onDataTreeChanged() called. but there is no change here"); + } + + @Override + public ListenableFuture> clusterHealth(ClusterHealthInput input) { + log.info("{}:cluster-health invoked.", APP_NAME); + getControllerHealth(); + return buildClusterHealthOutput("200"); + } + + @Override + public ListenableFuture> siteHealth(SiteHealthInput input) { + log.info("{}:site-health invoked.", APP_NAME); + getControllerHealth(); + return buildSiteHealthOutput("200", getAdminHealth(), getDatabaseHealth()); + } + + @Override + public ListenableFuture> databaseHealth(DatabaseHealthInput input) { + log.info("{}:database-health invoked.", APP_NAME); + DatabaseHealthOutputBuilder outputBuilder = new DatabaseHealthOutputBuilder(); + outputBuilder.setStatus("200"); + outputBuilder.setHealth(getDatabaseHealth()); + + return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); + } + + @Override + public ListenableFuture> adminHealth(AdminHealthInput input) { + log.info("{}:admin-health invoked.", APP_NAME); + AdminHealthOutputBuilder outputBuilder = new AdminHealthOutputBuilder(); + outputBuilder.setStatus("200"); + outputBuilder.setHealth(getAdminHealth()); + + return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); + } + + @Override + public ListenableFuture> haltAkkaTraffic(HaltAkkaTrafficInput input) { + log.info("{}:halt-akka-traffic invoked.", APP_NAME); + HaltAkkaTrafficOutputBuilder outputBuilder = new HaltAkkaTrafficOutputBuilder(); + outputBuilder.setStatus("200"); + modifyIpTables(IpTables.ADD, input.getNodeInfo().toArray()); + + return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); + } + + @Override + public ListenableFuture> resumeAkkaTraffic(ResumeAkkaTrafficInput input) { + log.info("{}:resume-akka-traffic invoked.", APP_NAME); + ResumeAkkaTrafficOutputBuilder outputBuilder = new ResumeAkkaTrafficOutputBuilder(); + outputBuilder.setStatus("200"); + modifyIpTables(IpTables.DELETE, input.getNodeInfo().toArray()); + + return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); + } + + @Override + public ListenableFuture> siteIdentifier(SiteIdentifierInput input) { + log.info("{}:site-identifier invoked.", APP_NAME); + SiteIdentifierOutputBuilder outputBuilder = new SiteIdentifierOutputBuilder(); + outputBuilder.setStatus("200"); + outputBuilder.setId(siteIdentifier); + + return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); + } + + @Override + public ListenableFuture> failover(FailoverInput input) { + log.info("{}:failover invoked.", APP_NAME); + FailoverOutputBuilder outputBuilder = new FailoverOutputBuilder(); + if(siteConfiguration != SiteConfiguration.GEO) { + log.info("Cannot failover non-GEO site."); + outputBuilder.setMessage("Failover aborted. This is not a GEO configuration."); + outputBuilder.setStatus("400"); + return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); + } + ArrayList activeSite = new ArrayList<>(); + ArrayList standbySite = new ArrayList<>(); + + log.info("Performing preliminary cluster health check..."); + // Necessary to populate all member info. Health is not used for judgement calls. + getControllerHealth(); + + log.info("Determining active site..."); + for(Map.Entry entry : memberMap.entrySet()) { + String key = entry.getKey(); + ClusterActor clusterActor = entry.getValue(); + if(clusterActor.isVoting()) { + activeSite.add(clusterActor); + log.debug("Active Site member: {}", key); + } + else { + standbySite.add(clusterActor); + log.debug("Standby Site member: {}", key); + } + } + + String port = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL)) ? properties.getProperty(PropertyKeys.CONTROLLER_PORT_SSL) : properties.getProperty(PropertyKeys.CONTROLLER_PORT_HTTP); + + if(Boolean.parseBoolean(input.getBackupData())) { + backupMdSal(activeSite, port); + } + + if(!changeClusterVoting(outputBuilder, activeSite, standbySite, port)) + return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); + + if(Boolean.parseBoolean(input.getIsolate())) { + isolateSiteFromCluster(activeSite, standbySite, port); + + if(Boolean.parseBoolean(input.getDownUnreachable())) { + downUnreachableNodes(activeSite, standbySite, port); + } + } + + log.info("{}:failover complete.", APP_NAME); + + outputBuilder.setMessage("Failover complete."); + outputBuilder.setStatus("200"); + return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); + } + + private void isolateSiteFromCluster(ArrayList activeSite, ArrayList standbySite, String port) { + log.info("Halting Akka traffic..."); + for(ClusterActor actor : standbySite) { + try { + log.info("Halting Akka traffic for: {}", actor.getNode()); + // Build JSON with activeSite actor Node and actor AkkaPort + JSONObject akkaInput = new JSONObject(); + JSONObject inputBlock = new JSONObject(); + JSONArray votingStateArray = new JSONArray(); + JSONObject nodeInfo; + for(ClusterActor node : activeSite) { + nodeInfo = new JSONObject(); + nodeInfo.put("node", node.getNode()); + nodeInfo.put("port", node.getAkkaPort()); + votingStateArray.put(nodeInfo); + } + inputBlock.put("node-info", votingStateArray); + akkaInput.put("input", inputBlock); + getRequestContent(httpProtocol + actor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:halt-akka-traffic", HttpMethod.POST, akkaInput.toString()); + } catch(IOException e) { + log.error("Could not halt Akka traffic for: " + actor.getNode(), e); + } + } + } + + private void downUnreachableNodes(ArrayList activeSite, ArrayList standbySite, String port) { + log.info("Setting site unreachable..."); + JSONObject jolokiaInput = new JSONObject(); + jolokiaInput.put("type", "EXEC"); + jolokiaInput.put("mbean", "akka:type=Cluster"); + jolokiaInput.put("operation", "down"); + JSONArray arguments = new JSONArray(); + for(ClusterActor actor : activeSite) { + // Build Jolokia input + // May need to change from akka port to actor.getAkkaPort() + arguments.put("akka.tcp://opendaylight-cluster-data@" + actor.getNode() + ":" + properties.getProperty(PropertyKeys.CONTROLLER_PORT_AKKA)); + } + jolokiaInput.put("arguments", arguments); + log.debug("{}", jolokiaInput); + try { + log.info("Setting nodes unreachable"); + getRequestContent(httpProtocol + standbySite.get(0).getNode() + ":" + port + "/jolokia", HttpMethod.POST, jolokiaInput.toString()); + } catch(IOException e) { + log.error("Error setting nodes unreachable", e); + } + } + + private boolean changeClusterVoting(FailoverOutputBuilder outputBuilder, ArrayList activeSite, ArrayList standbySite, String port) { + log.info("Changing voting for all shards to standby site..."); + try { + JSONObject votingInput = new JSONObject(); + JSONObject inputBlock = new JSONObject(); + JSONArray votingStateArray = new JSONArray(); + JSONObject memberVotingState; + for(ClusterActor actor : activeSite) { + memberVotingState = new JSONObject(); + memberVotingState.put("member-name", actor.getMember()); + memberVotingState.put("voting", false); + votingStateArray.put(memberVotingState); + } + for(ClusterActor actor : standbySite) { + memberVotingState = new JSONObject(); + memberVotingState.put("member-name", actor.getMember()); + memberVotingState.put("voting", true); + votingStateArray.put(memberVotingState); + } + inputBlock.put("member-voting-state", votingStateArray); + votingInput.put("input", inputBlock); + log.debug("{}", votingInput); + // Change voting all shards + getRequestContent(httpProtocol + self.getNode() + ":" + port + "/restconf/operations/cluster-admin:change-member-voting-states-for-all-shards", HttpMethod.POST, votingInput.toString()); + } catch(IOException e) { + log.error("Changing voting", e); + outputBuilder.setMessage("Failover aborted. Failed to change voting."); + outputBuilder.setStatus("500"); + return false; + } + return true; + } + + private void backupMdSal(ArrayList activeSite, String port) { + log.info("Backing up data..."); + try { + log.info("Scheduling backup for: {}", activeSite.get(0).getNode()); + getRequestContent(httpProtocol + activeSite.get(0).getNode() + ":" + port + "/restconf/operations/data-export-import:schedule-export", HttpMethod.POST, "{ \"input\": { \"run-at\": \"30\" } }"); + } catch(IOException e) { + log.error("Error backing up MD-SAL", e); + } + for(ClusterActor actor : activeSite) { + try { + // Move data offsite + log.info("Backing up data for: {}", actor.getNode()); + getRequestContent(httpProtocol + actor.getNode() + ":" + port + "/restconf/operations/daexim-offsite-backup:backup-data", HttpMethod.POST); + } catch(IOException e) { + log.error("Error backing up data.", e); + } + } + } + + private ListenableFuture> buildClusterHealthOutput(String statusCode) { + ClusterHealthOutputBuilder outputBuilder = new ClusterHealthOutputBuilder(); + outputBuilder.setStatus(statusCode); + outputBuilder.setMembers((List) new ArrayList()); + int site1Health = 0; + int site2Health = 0; + + for(Map.Entry entry : memberMap.entrySet()) { + ClusterActor clusterActor = entry.getValue(); + if(clusterActor.isUp() && !clusterActor.isUnreachable()) { + if(ClusterActor.SITE_1.equals(clusterActor.getSite())) + site1Health++; + else if(ClusterActor.SITE_2.equals(clusterActor.getSite())) + site2Health++; + } + outputBuilder.getMembers().add(new MemberBuilder(clusterActor).build()); + } + if(siteConfiguration == SiteConfiguration.SOLO) { + outputBuilder.setSite1Health(HEALTHY); + } + else if(site1Health > 1) { + outputBuilder.setSite1Health(HEALTHY); + } + else { + outputBuilder.setSite1Health(FAULTY); + } + + if(siteConfiguration == SiteConfiguration.GEO && site2Health > 1) { + outputBuilder.setSite2Health(HEALTHY); + } + else if(siteConfiguration == SiteConfiguration.GEO) { + outputBuilder.setSite2Health(FAULTY); + } + + RpcResult rpcResult = RpcResultBuilder.status(true).withResult(outputBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } + + private ListenableFuture> buildSiteHealthOutput(String statusCode, String adminHealth, String databaseHealth) { + SiteHealthOutputBuilder outputBuilder = new SiteHealthOutputBuilder(); + outputBuilder.setStatus(statusCode); + outputBuilder.setSites((List) new ArrayList()); + + if(siteConfiguration != SiteConfiguration.GEO) { + int healthyODLs = 0; + SitesBuilder builder = new SitesBuilder(); + for(Map.Entry entry : memberMap.entrySet()) { + ClusterActor clusterActor = entry.getValue(); + if(clusterActor.isUp() && !clusterActor.isUnreachable()) { + healthyODLs++; + } + } + if(siteConfiguration != SiteConfiguration.SOLO) { + builder.setHealth(HEALTHY); + builder.setRole("ACTIVE"); + builder.setId(siteIdentifier); + } + else { + builder = getSitesBuilder(healthyODLs, true, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), siteIdentifier); + } + outputBuilder.getSites().add(builder.build()); + } + else { + int site1HealthyODLs = 0; + int site2HealthyODLs = 0; + boolean site1Voting = false; + boolean site2Voting = false; + boolean performedCrossSiteHealthCheck = false; + boolean crossSiteAdminHealthy = false; + boolean crossSiteDbHealthy = false; + String crossSiteIdentifier = "UNKNOWN_SITE"; + String port = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL)) ? properties.getProperty(PropertyKeys.CONTROLLER_PORT_SSL) : properties.getProperty(PropertyKeys.CONTROLLER_PORT_HTTP); + if(isSite1()) { + // Make calls over to site 2 healthchecks + for(Map.Entry entry : memberMap.entrySet()) { + ClusterActor clusterActor = entry.getValue(); + if(clusterActor.isUp() && !clusterActor.isUnreachable()) { + if(ClusterActor.SITE_1.equals(clusterActor.getSite())) { + site1HealthyODLs++; + if(clusterActor.isVoting()) { + site1Voting = true; + } + } + else { + site2HealthyODLs++; + if(clusterActor.isVoting()) { + site2Voting = true; + } + if(!performedCrossSiteHealthCheck) { + try { + String content = getRequestContent(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:site-identifier", HttpMethod.POST); + crossSiteIdentifier = new JSONObject(content).getJSONObject("output").getString("id"); + crossSiteDbHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:database-health"); + crossSiteAdminHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:admin-health"); + performedCrossSiteHealthCheck = true; + } catch(Exception e) { + log.info("Cannot get site identifier from {}", clusterActor.getNode()); + log.error("Site Health Error", e); + } + } + } + } + } + SitesBuilder builder = getSitesBuilder(site1HealthyODLs, site1Voting, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), siteIdentifier); + outputBuilder.getSites().add(builder.build()); + builder = getSitesBuilder(site2HealthyODLs, site2Voting, crossSiteAdminHealthy, crossSiteDbHealthy, crossSiteIdentifier); + outputBuilder.getSites().add(builder.build()); + } + else { + // Make calls over to site 1 healthchecks + for(Map.Entry entry : memberMap.entrySet()) { + ClusterActor clusterActor = entry.getValue(); + if(clusterActor.isUp() && !clusterActor.isUnreachable()) { + if(ClusterActor.SITE_1.equals(clusterActor.getSite())) { + site1HealthyODLs++; + if(clusterActor.isVoting()) { + site1Voting = true; + } + if(!performedCrossSiteHealthCheck) { + try { + String content = getRequestContent(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:site-identifier", HttpMethod.POST); + crossSiteIdentifier = new JSONObject(content).getJSONObject("output").getString("id"); + crossSiteDbHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:database-health"); + crossSiteAdminHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:admin-health"); + performedCrossSiteHealthCheck = true; + } catch(Exception e) { + log.info("Cannot get site identifier from {}", clusterActor.getNode()); + log.error("Site Health Error", e); + } + } + } + else { + site2HealthyODLs++; + if(clusterActor.isVoting()) { + site2Voting = true; + } + } + } + } + // Build Output + SitesBuilder builder = getSitesBuilder(site1HealthyODLs, site1Voting, crossSiteAdminHealthy, crossSiteDbHealthy, crossSiteIdentifier); + outputBuilder.getSites().add(builder.build()); + builder = getSitesBuilder(site2HealthyODLs, site2Voting, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), siteIdentifier); + outputBuilder.getSites().add(builder.build()); + } + } + + RpcResult rpcResult = RpcResultBuilder.status(true).withResult(outputBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } + + private SitesBuilder getSitesBuilder(int siteHealthyODLs, boolean siteVoting, boolean adminHealthy, boolean dbHealthy, String siteIdentifier) { + SitesBuilder builder = new SitesBuilder(); + if(siteHealthyODLs > 1) { + builder.setHealth(HEALTHY); + } + else { + log.warn("{} Healthy ODLs: {}", siteIdentifier, siteHealthyODLs); + builder.setHealth(FAULTY); + } + if(!adminHealthy) { + log.warn("{} Admin Health: {}", siteIdentifier, FAULTY); + builder.setHealth(FAULTY); + } + if(!dbHealthy) { + log.warn("{} Database Health: {}", siteIdentifier, FAULTY); + builder.setHealth(FAULTY); + } + if(siteVoting) { + builder.setRole("ACTIVE"); + } + else { + builder.setRole("STANDBY"); + } + builder.setId(siteIdentifier); + return builder; + } + + private boolean isSite1() { + int memberNumber = Integer.parseInt(member.split("-")[1]); + boolean isSite1 = memberNumber < 4; + log.info("isSite1(): {}", isSite1); + return isSite1; + } + + private void parseSeedNodes(String line) { + memberMap = new HashMap<>(); + line = line.substring(line.indexOf("[\""), line.indexOf(']')); + String[] splits = line.split(","); + + for(int ndx = 0; ndx < splits.length; ndx++) { + String nodeName = splits[ndx]; + int delimLocation = nodeName.indexOf('@'); + String port = nodeName.substring(splits[ndx].indexOf(':', delimLocation) + 1, splits[ndx].indexOf('"', splits[ndx].indexOf(':'))); + splits[ndx] = nodeName.substring(delimLocation + 1, splits[ndx].indexOf(':', delimLocation)); + log.info("Adding node: {}:{}", splits[ndx], port); + ClusterActor clusterActor = new ClusterActor(); + clusterActor.setNode(splits[ndx]); + clusterActor.setAkkaPort(port); + clusterActor.setMember("member-" + (ndx + 1)); + if(ndx < 3) { + clusterActor.setSite(ClusterActor.SITE_1); + } + else { + clusterActor.setSite(ClusterActor.SITE_2); + } + + if(member.equals(clusterActor.getMember())) { + self = clusterActor; + } + memberMap.put(clusterActor.getNode(), clusterActor); + log.info("{}", clusterActor); + } + + if(memberMap.size() == 1) { + log.info("1 member found. This is a solo environment."); + siteConfiguration = SiteConfiguration.SOLO; + } + else if(memberMap.size() == 3) { + log.info("This is a single site."); + siteConfiguration = SiteConfiguration.SINGLE; + } + else if(memberMap.size() == 6) { + log.info("This is a georedundant site."); + siteConfiguration = SiteConfiguration.GEO; + } + } + + private void getMemberStatus(ClusterActor clusterActor) throws IOException { + log.info("Getting member status for {}", clusterActor.getNode()); + String content = getRequestContent(httpProtocol + clusterActor.getNode() + jolokiaClusterPath, HttpMethod.GET); + try { + JSONObject responseJson = new JSONObject(content); + JSONObject responseValue = responseJson.getJSONObject(VALUE); + clusterActor.setUp("Up".equals(responseValue.getString("MemberStatus"))); + clusterActor.setUnreachable(false); + } catch(JSONException e) { + log.error("Error parsing response from {}", clusterActor.getNode(), e); + clusterActor.setUp(false); + clusterActor.setUnreachable(true); + } + } + + private void getShardStatus(ClusterActor clusterActor) throws IOException { + log.info("Getting shard status for {}", clusterActor.getNode()); + String content = getRequestContent(httpProtocol + clusterActor.getNode() + shardManagerPath, HttpMethod.GET); + try { + JSONObject responseValue = new JSONObject(content).getJSONObject(VALUE); + JSONArray shardList = responseValue.getJSONArray("LocalShards"); + + String pattern = "-config$"; + Pattern r = Pattern.compile(pattern); + Matcher m; + for(int ndx = 0; ndx < shardList.length(); ndx++) { + String configShardName = shardList.getString(ndx); + m = r.matcher(configShardName); + String operationalShardName = m.replaceFirst("-operational"); + String shardConfigPath = String.format(shardPathTemplate, configShardName); + String shardOperationalPath = String.format(shardPathTemplate, operationalShardName).replace("Config", "Operational"); + extractShardInfo(clusterActor, configShardName, shardConfigPath); + extractShardInfo(clusterActor, operationalShardName, shardOperationalPath); + } + } catch(JSONException e) { + log.error("Error parsing response from " + clusterActor.getNode(), e); + } + } + + private void extractShardInfo(ClusterActor clusterActor, String shardName, String shardPath) throws IOException { + log.info("Extracting shard info for {}", shardName); + log.debug("Pulling config info for {} from: {}", shardName, shardPath); + String content = getRequestContent(httpProtocol + clusterActor.getNode() + shardPath, HttpMethod.GET); + log.debug("Response: {}", content); + + try { + JSONObject shardValue = new JSONObject(content).getJSONObject(VALUE); + clusterActor.setVoting(shardValue.getBoolean("Voting")); + if(shardValue.getString("PeerAddresses").length() > 0) { + clusterActor.getReplicaShards().add(shardName); + if(shardValue.getString("Leader").startsWith(clusterActor.getMember())) { + clusterActor.getShardLeader().add(shardName); + } + } + else { + clusterActor.getNonReplicaShards().add(shardName); + } + JSONArray followerInfo = shardValue.getJSONArray("FollowerInfo"); + for(int followerNdx = 0; followerNdx < followerInfo.length(); followerNdx++) { + int commitIndex = shardValue.getInt("CommitIndex"); + int matchIndex = followerInfo.getJSONObject(followerNdx).getInt("matchIndex"); + if(commitIndex != -1 && matchIndex != -1) { + int commitsBehind = commitIndex - matchIndex; + clusterActor.getCommits().put(followerInfo.getJSONObject(followerNdx).getString("id"), commitsBehind); + } + } + } catch(JSONException e) { + log.error("Error parsing response from " + clusterActor.getNode(), e); + } + } + + private void getControllerHealth() { + for(Map.Entry entry : memberMap.entrySet()) { + ClusterActor clusterActor = entry.getValue(); + String key = entry.getKey(); + try { + // First flush out the old values + clusterActor.flush(); + log.info("Gathering info for {}", clusterActor.getNode()); + getMemberStatus(clusterActor); + getShardStatus(clusterActor); + log.info("MemberInfo:\n{}", clusterActor); + } catch(IOException e) { + log.error("Connection Error", e); + memberMap.get(key).setUnreachable(true); + memberMap.get(key).setUp(false); + log.info("MemberInfo:\n{}", memberMap.get(key)); + } + } + } + + private void modifyIpTables(IpTables task, Object[] nodeInfo) { + log.info("Modifying IPTables rules..."); + if(task == IpTables.ADD) { + for(Object node : nodeInfo) { + org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.halt.akka.traffic.input.NodeInfo n = + (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.halt.akka.traffic.input.NodeInfo) node; + log.info("Isolating {}", n.getNode()); + executeCommand(String.format("sudo /sbin/iptables -A INPUT -p tcp --destination-port %s -j DROP -s %s", properties.get(PropertyKeys.CONTROLLER_PORT_AKKA), n.getNode())); + executeCommand(String.format("sudo /sbin/iptables -A OUTPUT -p tcp --destination-port %s -j DROP -s %s", n.getPort(), n.getNode())); + } + + } else if(task == IpTables.DELETE) { + for(Object node : nodeInfo) { + org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.resume.akka.traffic.input.NodeInfo n = + (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.resume.akka.traffic.input.NodeInfo) node; + log.info("De-isolating {}", n.getNode()); + executeCommand(String.format("sudo /sbin/iptables -D INPUT -p tcp --destination-port %s -j DROP -s %s", properties.get(PropertyKeys.CONTROLLER_PORT_AKKA), n.getNode())); + executeCommand(String.format("sudo /sbin/iptables -D OUTPUT -p tcp --destination-port %s -j DROP -s %s", n.getPort(), n.getNode())); + } + + } + executeCommand("sudo /sbin/iptables -L"); + } + + private void executeCommand(String command) { + log.info("Executing command: {}", command); + String[] cmd = command.split(" "); + try { + Process p = Runtime.getRuntime().exec(cmd); + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(p.getInputStream())); + String inputLine; + StringBuilder content = new StringBuilder(); + while((inputLine = bufferedReader.readLine()) != null) { + content.append(inputLine); + } + bufferedReader.close(); + log.info("{}", content); + } catch(IOException e) { + log.error("Error executing command", e); + } + } + + private boolean crossSiteHealthRequest(String path) throws IOException { + String content = getRequestContent(path, HttpMethod.POST); + try { + JSONObject responseJson = new JSONObject(content); + JSONObject responseValue = responseJson.getJSONObject(VALUE); + return HEALTHY.equals(responseValue.getString("health")); + } catch(JSONException e) { + log.error("Error parsing JSON", e); + throw new IOException(); + } + } + + private String getAdminHealth() { + String protocol = "true".equals(properties.getProperty(PropertyKeys.ADM_USE_SSL)) ? "https://" : "http://"; + String port = "true".equals(properties.getProperty(PropertyKeys.ADM_USE_SSL)) ? properties.getProperty(PropertyKeys.ADM_PORT_SSL) : properties.getProperty(PropertyKeys.ADM_PORT_HTTP); + String path = protocol + properties.getProperty(PropertyKeys.ADM_FQDN) + ":" + port + properties.getProperty(PropertyKeys.ADM_HEALTHCHECK); + log.info("Requesting healthcheck from {}", path); + try { + int response = getRequestStatus(path, HttpMethod.GET); + log.info("Response: {}", response); + if(response == 200) + return HEALTHY; + return FAULTY; + } catch(IOException e) { + log.error("Problem getting ADM health.", e); + return FAULTY; + } + } + + private String getDatabaseHealth() { + log.info("Determining database health..."); + try { + Connection connection = dbLib.getConnection(); + log.info("DBLib isActive(): {}", dbLib.isActive()); + log.info("DBLib isReadOnly(): {}", connection.isReadOnly()); + log.info("DBLib isClosed(): {}", connection.isClosed()); + if(!dbLib.isActive() || connection.isClosed() || connection.isReadOnly()) { + log.warn("Database is FAULTY"); + connection.close(); + return FAULTY; + } + connection.close(); + log.info("Database is HEALTHY"); + } catch(SQLException e) { + log.error("Database is FAULTY"); + log.error("Error", e); + return FAULTY; + } + + return HEALTHY; + } + + private String getRequestContent(String path, HttpMethod method) throws IOException { + return getRequestContent(path, method, null); + } + + private String getRequestContent(String path, HttpMethod method, String input) throws IOException { + HttpURLConnection connection = getConnection(path); + connection.setRequestMethod(method.getMethod()); + connection.setDoInput(true); + + if(input != null) { + sendPayload(input, connection); + } + + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String inputLine; + StringBuilder content = new StringBuilder(); + while((inputLine = bufferedReader.readLine()) != null) { + content.append(inputLine); + } + bufferedReader.close(); + connection.disconnect(); + return content.toString(); + } + + private int getRequestStatus(String path, HttpMethod method) throws IOException { + return getRequestStatus(path, method, null); + } + + private int getRequestStatus(String path, HttpMethod method, String input) throws IOException { + HttpURLConnection connection = getConnection(path); + connection.setRequestMethod(method.getMethod()); + connection.setDoInput(true); + + if(input != null) { + sendPayload(input, connection); + } + int response = connection.getResponseCode(); + log.info("Received {} response code from {}", response, path); + connection.disconnect(); + return response; + } + + private void sendPayload(String input, HttpURLConnection connection) throws IOException { + byte[] out = input.getBytes(StandardCharsets.UTF_8); + int length = out.length; + + connection.setFixedLengthStreamingMode(length); + connection.setRequestProperty("Content-Type", "application/json"); + connection.setDoOutput(true); + connection.connect(); + try(OutputStream os = connection.getOutputStream()) { + os.write(out); + } + } + + private HttpURLConnection getConnection(String host) throws IOException { + log.info("Getting connection to: {}", host); + URL url = new URL(host); + String auth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(credentials.getBytes()); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.addRequestProperty("Authorization", auth); + connection.setRequestProperty("Connection", "keep-alive"); + connection.setRequestProperty("Proxy-Connection", "keep-alive"); + return connection; + } + + enum IpTables { + ADD, + DELETE + } + + enum SiteConfiguration { + SOLO, + SINGLE, + GEO + } + + enum HttpMethod { + GET("GET"), + POST("POST"); + + private String method; + HttpMethod(String method) { + this.method = method; + } + public String getMethod() { + return method; + } + } + + class PropertyKeys { + static final String SITE_IDENTIFIER = "site.identifier"; + static final String CONTROLLER_USE_SSL = "controller.useSsl"; + static final String CONTROLLER_PORT_SSL = "controller.port.ssl"; + static final String CONTROLLER_PORT_HTTP = "controller.port.http"; + static final String CONTROLLER_PORT_AKKA = "controller.port.akka"; + static final String CONTROLLER_CREDENTIALS = "controller.credentials"; + static final String AKKA_CONF_LOCATION = "akka.conf.location"; + static final String MBEAN_CLUSTER = "mbean.cluster"; + static final String MBEAN_SHARD_MANAGER = "mbean.shardManager"; + static final String MBEAN_SHARD_CONFIG = "mbean.shard.config"; + static final String ADM_USE_SSL = "adm.useSsl"; + static final String ADM_PORT_SSL = "adm.port.ssl"; + static final String ADM_PORT_HTTP = "adm.port.http"; + static final String ADM_FQDN = "adm.fqdn"; + static final String ADM_HEALTHCHECK= "adm.healthcheck"; + } +} \ No newline at end of file diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/ClusterActor.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/ClusterActor.java new file mode 100755 index 000000000..7cd503a95 --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/ClusterActor.java @@ -0,0 +1,215 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2018 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.grtoolkit.data; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ClusterActor { + private String node; + private String member; + private String site; + private String akkaPort; + private boolean voting; + private boolean up; + private boolean unreachable; + private ArrayList shardLeader; + private ArrayList replicaShards; + private ArrayList nonReplicaShards; + private HashMap commits; + + public static final String SITE_1 = "Site 1"; + public static final String SITE_2 = "Site 2"; + + public ClusterActor() { + node = ""; + member = ""; + site = ""; + voting = false; + up = false; + unreachable = false; + shardLeader = new ArrayList<>(); + replicaShards = new ArrayList<>(); + nonReplicaShards = new ArrayList<>(); + commits = new HashMap<>(); + } + + public String getNode() { + return node; + } + + public void setNode(String node) { + this.node = node; + } + + public String getMember() { + return member; + } + + public void setMember(String member) { + this.member = member; + } + + public String getSite() { + return site; + } + + public void setSite(String site) { + this.site = site; + } + + public String getAkkaPort() { + return akkaPort; + } + + public void setAkkaPort(String akkaPort) { + this.akkaPort = akkaPort; + } + + public boolean isVoting() { + return voting; + } + + public void setVoting(boolean voting) { + this.voting = voting; + } + + public boolean isUp() { + return up; + } + + public void setUp(boolean up) { + this.up = up; + } + + public boolean isUnreachable() { + return unreachable; + } + + public void setUnreachable(boolean unreachable) { + this.unreachable = unreachable; + } + + public List getShardLeader() { + return shardLeader; + } + + public void setShardLeader(List shardLeader) { + this.shardLeader = (ArrayList) shardLeader; + } + + public List getReplicaShards() { + return replicaShards; + } + + public void setReplicaShards(List replicaShards) { + this.replicaShards = (ArrayList) replicaShards; + } + + public List getNonReplicaShards() { + return nonReplicaShards; + } + + public void setNonReplicaShards(List nonReplicaShards) { + this.nonReplicaShards = (ArrayList) nonReplicaShards; + } + + public Map getCommits() { + return commits; + } + + public void setCommits(Map commits) { + this.commits = (HashMap) commits; + } + + public void flush() { + shardLeader.clear(); + replicaShards.clear(); + nonReplicaShards.clear(); + commits.clear(); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("[ "); + builder.append(this.member); + builder.append(" ] "); + + builder.append(this.node); + builder.append(":"); + builder.append(this.akkaPort); + builder.append(" is"); + if(up) + builder.append(" Up"); + else + builder.append(" Down"); + if(unreachable) + builder.append(" [ UNREACHABLE ]"); + + if(voting) + builder.append(" (Voting)"); + + builder.append("\n"); + + for(String l : this.shardLeader) { + builder.append("\tLeader: "); + builder.append(l); + builder.append("\n"); + } + + for(String r : this.replicaShards) { + builder.append("\tReplicating: "); + builder.append(r); + builder.append("\n"); + } + + for(String n : this.nonReplicaShards) { + builder.append("\tNot replicating: "); + builder.append(n); + builder.append("\n"); + } + + for(Map.Entry entry : commits.entrySet()) { + String key = entry.getKey(); + int value = entry.getValue(); + if(value > 0) { + builder.append("\t"); + builder.append(value); + builder.append(" commits ahead of "); + builder.append(key); + builder.append("\n"); + } + else if(value < 0) { + builder.append("\t"); + builder.append(value); + builder.append(" commits behind "); + builder.append(key); + builder.append("\n"); + } + } + + return builder.toString(); + } +} diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/MemberBuilder.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/MemberBuilder.java new file mode 100755 index 000000000..8bbf574d6 --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/MemberBuilder.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2018 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.grtoolkit.data; + +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.cluster.health.output.MembersBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.member.CommitStatusBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.member.ReplicasBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.member.LeaderBuilder; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class MemberBuilder extends MembersBuilder { + public MemberBuilder(ClusterActor actor) { + super(); + this.setAddress(actor.getNode()); + this.setRole(actor.getMember()); + this.setVoting(actor.isVoting()); + this.setUp(actor.isUp()); + this.setUnreachable(actor.isUnreachable()); + populateReplicas(actor.getReplicaShards()); + populateCommits(actor.getCommits()); + populateLeader(actor.getShardLeader()); + } + + private void populateLeader(List shardLeader) { + LeaderBuilder builder; + this.setLeader(new ArrayList<>()); + for(String leader : shardLeader) { + builder = new LeaderBuilder(); + builder.setShard(leader); + this.getLeader().add(builder.build()); + } + } + + private void populateCommits(Map commits) { + CommitStatusBuilder builder; + this.setCommitStatus(new ArrayList<>()); + for(Map.Entry entry : commits.entrySet()) { + String key = entry.getKey(); + Integer value = entry.getValue(); + if(value != 0) { + builder = new CommitStatusBuilder(); + builder.setShard(key); + builder.setDelta(value); + this.getCommitStatus().add(builder.build()); + } + } + } + + private void populateReplicas(List replicaShards) { + ReplicasBuilder builder; + this.setReplicas(new ArrayList<>()); + for(String shard : replicaShards) { + builder = new ReplicasBuilder(); + builder.setShard(shard); + this.getReplicas().add(builder.build()); + } + } +} diff --git a/grToolkit/provider/src/main/resources/gr-toolkit.properties b/grToolkit/provider/src/main/resources/gr-toolkit.properties index 2ddaa9a4e..c008eea98 100755 --- a/grToolkit/provider/src/main/resources/gr-toolkit.properties +++ b/grToolkit/provider/src/main/resources/gr-toolkit.properties @@ -1,6 +1,25 @@ +# ============LICENSE_START======================================================= +# openECOMP : SDN-C +# ================================================================================ +# Copyright (C) 2019 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========================================================= + akka.conf.location=/opt/opendaylight/current/controller/configuration/initial/akka.conf adm.useSsl=true -adm.fqdn=sdnmlcadm-conexus-it.ecomp.cci.att.com +adm.fqdn= adm.healthcheck=/healthcheck adm.port.http=8181 adm.port.ssl=8443 diff --git a/grToolkit/provider/src/main/resources/org/opendaylight/blueprint/GrToolkit.xml b/grToolkit/provider/src/main/resources/org/opendaylight/blueprint/GrToolkit.xml index 606ce2771..5a4492c56 100755 --- a/grToolkit/provider/src/main/resources/org/opendaylight/blueprint/GrToolkit.xml +++ b/grToolkit/provider/src/main/resources/org/opendaylight/blueprint/GrToolkit.xml @@ -21,7 +21,7 @@ - + diff --git a/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProviderTest.java b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProviderTest.java new file mode 100644 index 000000000..dabdf2065 --- /dev/null +++ b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProviderTest.java @@ -0,0 +1,344 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2018 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.grtoolkit; +import com.google.common.util.concurrent.ListenableFuture; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.contrib.java.lang.system.EnvironmentVariables; +import org.onap.ccsdk.sli.core.dblib.DBLibConnection; +import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterActor; +import org.opendaylight.controller.cluster.access.concepts.MemberName; +import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface; +import org.opendaylight.controller.cluster.datastore.utils.ActorContext; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.AdminHealthOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ClusterHealthOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.DatabaseHealthOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteHealthOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteIdentifierOutput; +import org.opendaylight.yangtools.yang.common.RpcResult; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ExecutionException; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; + +public class GrToolkitProviderTest { + GrToolkitProvider provider; + GrToolkitProvider providerSpy; + DataBroker dataBroker; + NotificationPublishService notificationProviderService; + RpcProviderRegistry rpcProviderRegistry; + DistributedDataStoreInterface configDatastore; + DbLibService dbLibService; + DBLibConnection connection; + + @Rule + public final EnvironmentVariables environmentVariables = new EnvironmentVariables(); + + @Before + public void setup() { + environmentVariables.set("SDNC_CONFIG_DIR","src/test/resources/"); + dataBroker = mock(DataBroker.class); + notificationProviderService = mock(NotificationPublishService.class); + rpcProviderRegistry = mock(RpcProviderRegistry.class); + configDatastore = mock(DistributedDataStoreInterface.class); + dbLibService = mock(DbLibService.class); + connection = mock(DBLibConnection.class); + + ActorContext actorContext = mock(ActorContext.class); + MemberName memberName = MemberName.forName("Test"); + + when(actorContext.getCurrentMemberName()).thenReturn(memberName); + when(configDatastore.getActorContext()).thenReturn(actorContext); + + try { + when(connection.isReadOnly()).thenReturn(false); + when(connection.isClosed()).thenReturn(false); + when(dbLibService.isActive()).thenReturn(true); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + + provider = new GrToolkitProvider(dataBroker, notificationProviderService, + rpcProviderRegistry, configDatastore, dbLibService); + providerSpy = spy(provider); + } + + @Test + public void closeTest() { + try { + provider.close(); + } + catch(Exception e) { + // Exception expected + } + } + + @Test + public void onDataTreeChangedTest() { + provider.onDataTreeChanged(new ArrayList()); + // onDataTreeChanged is an empty stub + } + + @Test + public void clusterHealthTest() { + ListenableFuture> result = provider.clusterHealth(null); + try { + assertEquals("200", result.get().getResult().getStatus()); + } catch(InterruptedException | ExecutionException e) { + fail(); + } + } + + @Test + public void siteHealthTest() { + ListenableFuture> result = provider.siteHealth(null); + try { + assertEquals("200", result.get().getResult().getStatus()); + } catch(InterruptedException | ExecutionException e) { + fail(); + } + } + + @Test + public void siteHealth6NodeTest() { + Map memberMap = new HashMap<>(); + ClusterActor actor; + for(int ndx = 0; ndx < 6; ndx++) { + actor = new ClusterActor(); + actor.setNode("member-" + (ndx + 1)); + actor.setUp(true); + actor.setUnreachable(false); + + memberMap.put(actor.getNode(), actor); + } + + try { + Field field = provider.getClass().getDeclaredField("siteConfiguration"); + field.setAccessible(true); + field.set(provider, GrToolkitProvider.SiteConfiguration.GEO); + + field = provider.getClass().getDeclaredField("memberMap"); + field.setAccessible(true); + field.set(provider, memberMap); + + + actor = new ClusterActor(); + actor.setNode("member-1"); + field = provider.getClass().getDeclaredField("self"); + field.setAccessible(true); + field.set(provider, actor); + + field = provider.getClass().getDeclaredField("member"); + field.setAccessible(true); + field.set(provider, actor.getNode()); + } + catch(IllegalAccessException | NoSuchFieldException e) { + fail(); + } + + ListenableFuture> result = provider.siteHealth(null); + try { + assertEquals("200", result.get().getResult().getStatus()); + } catch(InterruptedException | ExecutionException e) { + fail(); + } + } + + @Test + public void databaseHealthTest() { + ListenableFuture> result = provider.databaseHealth(null); + try { + assertEquals("200", result.get().getResult().getStatus()); + } catch(InterruptedException | ExecutionException e) { + fail(); + } + } + + @Test + public void databaseHealthWhenROTest() { + try { + when(connection.isReadOnly()).thenReturn(true); + } catch(SQLException e) { + fail(); + } + ListenableFuture> result = provider.databaseHealth(null); + try { + assertEquals("200", result.get().getResult().getStatus()); + } catch(InterruptedException | ExecutionException e) { + fail(); + } + } + + @Test + public void databaseHealthWhenExceptionTest() { + try { + when(connection.isReadOnly()).thenThrow(new SQLException()); + } catch(SQLException e) { + //expected + } + ListenableFuture> result = provider.databaseHealth(null); + try { + assertEquals("200", result.get().getResult().getStatus()); + } catch(InterruptedException | ExecutionException e) { + fail(); + } + } + + @Test + public void adminHealthTest() { + ListenableFuture> result = provider.adminHealth(null); + try { + assertEquals("200", result.get().getResult().getStatus()); + } catch(InterruptedException | ExecutionException e) { + fail(); + } + } + + @Test + public void siteIdentifierTest() { + ListenableFuture> result = provider.siteIdentifier(null); + try { + assertEquals("200", result.get().getResult().getStatus()); + } catch(InterruptedException | ExecutionException e) { + fail(); + } + } + + @Test + public void failoverTest() { + ListenableFuture> result = provider.failover(null); + try { + assertEquals("400", result.get().getResult().getStatus()); + } catch(InterruptedException | ExecutionException e) { + fail(); + } + } + + @Test + public void executeCommandTest() { + try { + Method method = provider.getClass().getDeclaredMethod("executeCommand", String.class); + method.setAccessible(true); + method.invoke(provider, "ls"); + } + catch(NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + fail(); + } + } + + @Test + public void isolateSiteFromClusterTest() { + try { + ClusterActor actor = new ClusterActor(); + actor.setNode("some-node"); + actor.setAkkaPort("2550"); + ArrayList activeList = new ArrayList<>(); + activeList.add(actor); + ArrayList standbyList = new ArrayList<>(); + standbyList.add(actor); + Method method = provider.getClass().getDeclaredMethod("isolateSiteFromCluster", ArrayList.class, ArrayList.class, String.class); + method.setAccessible(true); + method.invoke(provider, activeList, standbyList, "80"); + } + catch(NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + fail(); + } + } + + @Test + public void downUnreachableNodesTest() { + try { + ClusterActor actor = new ClusterActor(); + actor.setNode("some-node"); + actor.setAkkaPort("2550"); + ArrayList activeList = new ArrayList<>(); + activeList.add(actor); + ArrayList standbyList = new ArrayList<>(); + standbyList.add(actor); + Method method = provider.getClass().getDeclaredMethod("downUnreachableNodes", ArrayList.class, ArrayList.class, String.class); + method.setAccessible(true); + method.invoke(provider, activeList, standbyList, "80"); + } + catch(NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + fail(); + } + } + + @Test + public void changeClusterVotingTest() { + try { + ClusterActor actor = new ClusterActor(); + actor.setMember("some-member"); + actor.setNode("some-Node"); + ArrayList activeList = new ArrayList<>(); + activeList.add(actor); + ArrayList standbyList = new ArrayList<>(); + standbyList.add(actor); + Field field = provider.getClass().getDeclaredField("self"); + field.setAccessible(true); + field.set(provider, actor); + Method method = provider.getClass().getDeclaredMethod("changeClusterVoting", FailoverOutputBuilder.class, ArrayList.class, ArrayList.class, String.class); + method.setAccessible(true); + method.invoke(provider, new FailoverOutputBuilder(), activeList, standbyList, "80"); + } + catch(NoSuchMethodException | IllegalAccessException | InvocationTargetException | NoSuchFieldException e) { + fail(); + } + } + + @Test + public void backupMdSalTest() { + try { + ClusterActor actor = new ClusterActor(); + actor.setNode("some-Node"); + actor.setAkkaPort("2550"); + ArrayList activeList = new ArrayList<>(); + activeList.add(actor); + Method method = provider.getClass().getDeclaredMethod("backupMdSal", ArrayList.class, String.class); + method.setAccessible(true); + method.invoke(provider, activeList, "80"); + } + catch(NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + fail(); + } + } + +} diff --git a/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/MemberBuilderTest.java b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/MemberBuilderTest.java new file mode 100644 index 000000000..4b657cf0a --- /dev/null +++ b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/MemberBuilderTest.java @@ -0,0 +1,41 @@ +package org.onap.ccsdk.sli.plugins.grtoolkit.data; + +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.HashMap; + +import static org.junit.Assert.*; + +public class MemberBuilderTest { + MemberBuilder builder; + ClusterActor actor; + + @Before + public void setUp() { + actor = new ClusterActor(); + actor.setUp(true); + actor.setVoting(true); + } + + @Test + public void constructorTest() { + ArrayList actorList = new ArrayList<>(); + ArrayList shardList = new ArrayList<>(); + HashMap commitMap = new HashMap<>(); + actorList.add("Some-Actor"); + shardList.add("Some-shard"); + commitMap.put("Some-shard", 4); + commitMap.put("Some-other-shard", -4); + actor.setShardLeader(actorList); + actor.setReplicaShards(shardList); + actor.setNonReplicaShards(shardList); + actor.setCommits(commitMap); + assertNotNull(actor.toString()); + assertEquals("", actor.getSite()); + assertEquals(1, actor.getNonReplicaShards().size()); + builder = new MemberBuilder(actor); + assertNotNull(builder.build()); + } +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/resources/akka.conf b/grToolkit/provider/src/test/resources/akka.conf new file mode 100644 index 000000000..cbb73d548 --- /dev/null +++ b/grToolkit/provider/src/test/resources/akka.conf @@ -0,0 +1,49 @@ + +odl-cluster-data { + akka { + remote { + artery { + enabled = off + canonical.hostname = "127.0.0.1" + canonical.port = 2550 + } + netty.tcp { + hostname = "127.0.0.1" + port = 2550 + } + # when under load we might trip a false positive on the failure detector + # transport-failure-detector { + # heartbeat-interval = 4 s + # acceptable-heartbeat-pause = 16s + # } + } + + cluster { + # Remove ".tcp" when using artery. + seed-nodes = ["akka.tcp://opendaylight-cluster-data@127.0.0.1:2550"] + + roles = [ + "member-1" + ] + + } + + persistence { + # By default the snapshots/journal directories live in KARAF_HOME. You can choose to put it somewhere else by + # modifying the following two properties. The directory location specified may be a relative or absolute path. + # The relative path is always relative to KARAF_HOME. + + # snapshot-store.local.dir = "target/snapshots" + # journal.leveldb.dir = "target/journal" + + journal { + leveldb { + # Set native = off to use a Java-only implementation of leveldb. + # Note that the Java-only version is not currently considered by Akka to be production quality. + + # native = off + } + } + } + } +} diff --git a/grToolkit/provider/src/test/resources/akka6.conf b/grToolkit/provider/src/test/resources/akka6.conf new file mode 100644 index 000000000..358218d9c --- /dev/null +++ b/grToolkit/provider/src/test/resources/akka6.conf @@ -0,0 +1,49 @@ + +odl-cluster-data { + akka { + remote { + artery { + enabled = off + canonical.hostname = "127.0.0.1" + canonical.port = 2550 + } + netty.tcp { + hostname = "127.0.0.1" + port = 2550 + } + # when under load we might trip a false positive on the failure detector + # transport-failure-detector { + # heartbeat-interval = 4 s + # acceptable-heartbeat-pause = 16s + # } + } + + cluster { + # Remove ".tcp" when using artery. + seed-nodes = ["akka.tcp://opendaylight-cluster-data@127.0.0.1:2550", "akka.tcp://opendaylight-cluster-data@127.0.0.2:2550", "akka.tcp://opendaylight-cluster-data@127.0.0.3:2550", "akka.tcp://opendaylight-cluster-data@127.0.0.4:2550", "akka.tcp://opendaylight-cluster-data@127.0.0.5:2550", "akka.tcp://opendaylight-cluster-data@127.0.0.6:2550"] + + roles = [ + "member-1" + ] + + } + + persistence { + # By default the snapshots/journal directories live in KARAF_HOME. You can choose to put it somewhere else by + # modifying the following two properties. The directory location specified may be a relative or absolute path. + # The relative path is always relative to KARAF_HOME. + + # snapshot-store.local.dir = "target/snapshots" + # journal.leveldb.dir = "target/journal" + + journal { + leveldb { + # Set native = off to use a Java-only implementation of leveldb. + # Note that the Java-only version is not currently considered by Akka to be production quality. + + # native = off + } + } + } + } +} diff --git a/grToolkit/provider/src/test/resources/gr-toolkit.properties b/grToolkit/provider/src/test/resources/gr-toolkit.properties new file mode 100755 index 000000000..d9bc66dcd --- /dev/null +++ b/grToolkit/provider/src/test/resources/gr-toolkit.properties @@ -0,0 +1,34 @@ +# ============LICENSE_START======================================================= +# openECOMP : SDN-C +# ================================================================================ +# Copyright (C) 2019 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========================================================= + +akka.conf.location=src/test/resources/akka.conf +adm.useSsl=false +adm.fqdn=wiki.onap.org +adm.healthcheck= +adm.port.http=80 +adm.port.ssl=443 +controller.credentials=admin:admin +controller.useSsl=false +controller.port.http=8181 +controller.port.ssl=8443 +controller.port.akka=2550 +mbean.cluster=/jolokia/read/akka:type=Cluster +mbean.shardManager=/jolokia/read/org.opendaylight.controller:Category=ShardManager,name=shard-manager-config,type=DistributedConfigDatastore +mbean.shard.config=/jolokia/read/org.opendaylight.controller:Category=Shards,name=%s,type=DistributedConfigDatastore +site.identifier=TestODL -- cgit From 93c91c2fc80a31585c8f902c86bc4e1faf5b966d Mon Sep 17 00:00:00 2001 From: Vidyashree Rama Date: Tue, 23 Apr 2019 09:29:36 +0530 Subject: Test coverage imporvement and code refactoring of restconf discovery node. Test coverage imporvement and code refactoring of restconf discovery node. Issue-ID: CCSDK-1236 Change-Id: Ic44899d71b92be3d7b88be3abb0feb311e6ad8c0 Signed-off-by: Vidyashree Rama --- .../restconfdiscovery/RestconfDiscoveryNode.java | 48 +++++++++---------- .../TestRestconfDiscoveryNode.java | 56 ++++++++++++++++++---- 2 files changed, 72 insertions(+), 32 deletions(-) diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java index 5c7d695d9..cf69d7a3c 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java @@ -141,7 +141,7 @@ public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { WebTarget target = null; try { RestapiCallNode restapi = restconfApiCallNode.getRestapiCallNode(); - p = restapi.getParameters(paramMap, new Parameters()); + p = RestapiCallNode.getParameters(paramMap, new Parameters()); Client client = ignoreSslClient().register(SseFeature.class); target = restapi.addAuthType(client, p).target(url); } catch (SvcLogicException e) { @@ -166,37 +166,37 @@ public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { eventSource.close(); log.info("Closed connection to SSE source"); } - } - - private Client ignoreSslClient() { - SSLContext sslcontext = null; - try { - sslcontext = SSLContext.getInstance("TLS"); - sslcontext.init(null, new TrustManager[]{new X509TrustManager() { - @Override - public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { - } + private Client ignoreSslClient() { + SSLContext sslcontext = null; - @Override - public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { - } + try { + sslcontext = SSLContext.getInstance("TLS"); + sslcontext.init(null, new TrustManager[]{new X509TrustManager() { + @Override + public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { + } + + @Override + public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + } }, new java.security.SecureRandom()); + } catch (NoSuchAlgorithmException | KeyManagementException e) { + throw new IllegalStateException(e); + } - @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } - } }, new java.security.SecureRandom()); - } catch (NoSuchAlgorithmException | KeyManagementException e) { - throw new IllegalStateException(e); + return ClientBuilder.newBuilder().sslContext(sslcontext).hostnameVerifier((s1, s2) -> true).build(); } - - return ClientBuilder.newBuilder().sslContext(sslcontext).hostnameVerifier((s1, s2) -> true).build(); } protected String getTokenId(String customHttpHeaders) { if (customHttpHeaders.contains("=")) { - String s[] = customHttpHeaders.split("="); + String[] s = customHttpHeaders.split("="); return s[1]; } return customHttpHeaders; diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java index af354e9bf..aa89d67d7 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java @@ -20,6 +20,7 @@ package org.onap.ccsdk.sli.plugins.restconfdiscovery; +import org.glassfish.grizzly.http.server.HttpServer; import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; import org.glassfish.jersey.media.sse.SseFeature; import org.glassfish.jersey.server.ResourceConfig; @@ -29,29 +30,41 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode; +import java.io.IOException; import java.net.URI; import java.util.HashMap; import java.util.Map; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; public class TestRestconfDiscoveryNode { private static final URI CONTEXT = URI.create("http://localhost:8080/"); @Test - public void testEstablishPersistentConnection() throws SvcLogicException, - InterruptedException { + public void sendRequest() throws SvcLogicException, InterruptedException, IOException { final ResourceConfig resourceConfig = new ResourceConfig( SseServerMock.class, SseFeature.class); - GrizzlyHttpServerFactory.createHttpServer(CONTEXT, resourceConfig); + HttpServer server = GrizzlyHttpServerFactory.createHttpServer(CONTEXT, + resourceConfig); + server.start(); + RestconfApiCallNode restconf = mock(RestconfApiCallNode.class); + doNothing().when(restconf) + .sendRequest(any(Map.class), any(SvcLogicContext.class)); + RestapiCallNode restApi = new RestapiCallNode(); + doReturn(restApi).when(restconf).getRestapiCallNode(); + SvcLogicContext ctx = new SvcLogicContext(); ctx.setAttribute("prop.encoding-json", "encoding-json"); ctx.setAttribute("restapi-result.response-code", "200"); ctx.setAttribute("restapi-result.ietf-subscribed-notifications" + ":establish-subscription.output.identifier", - "100"); + "89"); Map p = new HashMap<>(); p.put("sseConnectURL", "http://localhost:8080/events"); @@ -64,11 +77,15 @@ public class TestRestconfDiscoveryNode { "bv5itd6m1cftldpjarnyle3sdcqq9hftc4lebz464b5ffxmlbvg9"); p.put("restapiUrl", "https://localhost:8080/restconf/operations/" + "ietf-subscribed-notifications:establish-subscription"); - RestconfDiscoveryNode rdn = new RestconfDiscoveryNode( - new RestconfApiCallNode(new RestapiCallNode())); - rdn.establishPersistentConnection(p, ctx, "networkId"); - Thread.sleep(2000); + p.put("module", "testmodule"); + p.put("rpc", "testrpc"); + p.put("version", "1.0"); + p.put("mode", "sync"); + RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(restconf); + rdn.establishSubscription(p, ctx); + Thread.sleep(1000); rdn.deleteSubscription(p, ctx); + server.shutdown(); } @Test(expected = SvcLogicException.class) @@ -132,4 +149,27 @@ public class TestRestconfDiscoveryNode { "emlqm4bbsmnar3vrtbyrzukbv5itd6m1cftldpjarnyle3sdcqq9h" + "ftc4lebz464b5ffxmlbvg9")); } + + @Test + public void testSubscriptionInfo() throws SvcLogicException { + SubscriptionInfo info = new SubscriptionInfo(); + info.subscriberId("network-id"); + info.subscriptionId("8"); + info.filterUrl("/ietf-interfaces:interfaces"); + info.yangFilePath("/opt/yang"); + SvcLogicGraphInfo svcLogicGraphInfo = new SvcLogicGraphInfo(); + svcLogicGraphInfo.mode("sync"); + svcLogicGraphInfo.module("testModule"); + svcLogicGraphInfo.rpc("testRpc"); + svcLogicGraphInfo.version("1.0"); + info.callBackDG(svcLogicGraphInfo); + assertThat(info.subscriberId(), is("network-id")); + assertThat(info.subscriptionId(), is("8")); + assertThat(info.filterUrl(), is("/ietf-interfaces:interfaces")); + assertThat(info.yangFilePath(), is("/opt/yang")); + assertThat(info.callBackDG().module(), is("testModule")); + assertThat(info.callBackDG().mode(), is("sync")); + assertThat(info.callBackDG().rpc(), is("testRpc")); + assertThat(info.callBackDG().version(), is("1.0")); + } } -- cgit From 5ddde36ddd17ef3cbcae6df12cd4862998d7f2ad Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 24 Apr 2019 13:55:43 -0400 Subject: Update to use released 1.2.2 parent Update to use released 1.2.2 version of parent poms. Change-Id: I303781ad2d8946a942212780884a96c1ac34d75c Issue-ID: CCSDK-1222 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 2 +- features/ccsdk-sli-plugins-all/pom.xml | 2 +- features/features-sli-plugins/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- grToolkit/features/ccsdk-gr-toolkit/pom.xml | 2 +- grToolkit/features/features-gr-toolkit/pom.xml | 2 +- grToolkit/features/pom.xml | 2 +- grToolkit/installer/pom.xml | 2 +- grToolkit/model/pom.xml | 2 +- grToolkit/pom.xml | 2 +- grToolkit/provider/pom.xml | 2 +- pom.xml | 2 +- properties-node/features/ccsdk-properties-node/pom.xml | 2 +- properties-node/features/features-properties-node/pom.xml | 2 +- properties-node/features/pom.xml | 2 +- properties-node/installer/pom.xml | 2 +- properties-node/pom.xml | 2 +- properties-node/provider/pom.xml | 2 +- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/features-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/pom.xml | 2 +- restapi-call-node/installer/pom.xml | 2 +- restapi-call-node/pom.xml | 2 +- restapi-call-node/provider/pom.xml | 2 +- restconf-client/features/ccsdk-restconf-client/pom.xml | 2 +- restconf-client/features/features-restconf-client/pom.xml | 2 +- restconf-client/features/pom.xml | 2 +- restconf-client/installer/pom.xml | 2 +- restconf-client/pom.xml | 2 +- restconf-client/provider/pom.xml | 2 +- sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml | 2 +- sshapi-call-node/features/features-sshapi-call-node/pom.xml | 2 +- sshapi-call-node/features/pom.xml | 2 +- sshapi-call-node/installer/pom.xml | 2 +- sshapi-call-node/pom.xml | 2 +- sshapi-call-node/provider/pom.xml | 2 +- template-node/features/ccsdk-template-node/pom.xml | 2 +- template-node/features/features-template-node/pom.xml | 2 +- template-node/features/pom.xml | 2 +- template-node/installer/pom.xml | 2 +- template-node/pom.xml | 2 +- template-node/provider/pom.xml | 2 +- 43 files changed, 43 insertions(+), 43 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 911a1d6ab..2daa2c5b2 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index c589ba3f0..0ca186002 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index aff865f0a..c30fb147a 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/features/installer/pom.xml b/features/installer/pom.xml index ed909fc22..9f0276044 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/features/pom.xml b/features/pom.xml index efd6cbe68..2aa82953c 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/grToolkit/features/ccsdk-gr-toolkit/pom.xml b/grToolkit/features/ccsdk-gr-toolkit/pom.xml index 264ad7cf6..0ca01cd3f 100755 --- a/grToolkit/features/ccsdk-gr-toolkit/pom.xml +++ b/grToolkit/features/ccsdk-gr-toolkit/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/grToolkit/features/features-gr-toolkit/pom.xml b/grToolkit/features/features-gr-toolkit/pom.xml index db2887436..2d9a6933a 100755 --- a/grToolkit/features/features-gr-toolkit/pom.xml +++ b/grToolkit/features/features-gr-toolkit/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/grToolkit/features/pom.xml b/grToolkit/features/pom.xml index c092a4b80..caadecac8 100755 --- a/grToolkit/features/pom.xml +++ b/grToolkit/features/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/grToolkit/installer/pom.xml b/grToolkit/installer/pom.xml index 5d1743389..4f5780683 100755 --- a/grToolkit/installer/pom.xml +++ b/grToolkit/installer/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/grToolkit/model/pom.xml b/grToolkit/model/pom.xml index c917c4567..67b94d1ce 100755 --- a/grToolkit/model/pom.xml +++ b/grToolkit/model/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.2-SNAPSHOT + 1.2.2 ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/pom.xml b/grToolkit/pom.xml index d2d79c706..c0be3d858 100755 --- a/grToolkit/pom.xml +++ b/grToolkit/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index 51a850b8d..f2dad8b86 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.2-SNAPSHOT + 1.2.2 ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index 9e564d5e8..af41ee390 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index 6412ca3ae..a8e642ea0 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index 1f2da265c..56945da4b 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 23bfd53e2..06d45f638 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index d37160912..c8354be31 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 7ff022582..52a9539f8 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 532d5f7b9..c819973c9 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 0bf2a023d..c0703ce16 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index 23b8f84b5..943ebbcac 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index 8ca913bb8..ab665203f 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index cbc4a6ec1..c6c722765 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 7cdee7c50..3498bdc4c 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 32089455f..d22e3edcc 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index 56fa2ebaf..3a143282d 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml index 56846fb45..a99be46ba 100644 --- a/restconf-client/features/features-restconf-client/pom.xml +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml index 5a882ebcd..ee2f035c6 100755 --- a/restconf-client/features/pom.xml +++ b/restconf-client/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index 4a454b14a..321b5b524 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index 7f2e9c825..067166f8b 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index e6da0cd13..24db30ad4 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index ee153ad4e..18cfe9abc 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml index 421cbbaa7..34cecd0e0 100644 --- a/sshapi-call-node/features/features-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/features-sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml index cd045fde3..ec1125d6b 100755 --- a/sshapi-call-node/features/pom.xml +++ b/sshapi-call-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index 39c01db1b..844e52fe1 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index 6583e69bf..bd5dd54ba 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index bdf471b25..13d5b0aaa 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index c5152dbc4..9a876be5d 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml index dd9c8992f..a6d9681de 100644 --- a/template-node/features/features-template-node/pom.xml +++ b/template-node/features/features-template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml index b498051f6..71ab77898 100644 --- a/template-node/features/pom.xml +++ b/template-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index 44425d1e8..98ade668b 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/template-node/pom.xml b/template-node/pom.xml index c0843b787..2fd3cfdef 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index d52587922..4a44b6d5a 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.2-SNAPSHOT + 1.2.2 org.onap.ccsdk.sli.plugins -- cgit From 824ac8dcefe0a08cbcd293952573e327866aca25 Mon Sep 17 00:00:00 2001 From: "Haddox, Anthony" Date: Tue, 30 Apr 2019 08:50:45 -0700 Subject: [CCSDK-1298] Add served-by field Add served-by field to RPC responses and output getRequestContent response. Issue-ID: CCSDK-1298 Change-Id: Ic8c327dd1acc44aeab2c999851b22fdba5eed232 Signed-off-by: Haddox, Anthony --- grToolkit/model/src/main/yang/gr-toolkit.yang | 8 ++++++++ .../sli/plugins/grtoolkit/GrToolkitProvider.java | 19 +++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/grToolkit/model/src/main/yang/gr-toolkit.yang b/grToolkit/model/src/main/yang/gr-toolkit.yang index 8b22d666a..cc21400a7 100755 --- a/grToolkit/model/src/main/yang/gr-toolkit.yang +++ b/grToolkit/model/src/main/yang/gr-toolkit.yang @@ -93,6 +93,7 @@ module gr-toolkit{ output { leaf status { type string; } leaf message { type string; } + leaf served-by { type string; } leaf site1-health { type string; } leaf site2-health { type string; } list members { @@ -107,6 +108,7 @@ module gr-toolkit{ output { leaf status { type string; } leaf health { type string; } + leaf served-by { type string; } } } @@ -116,6 +118,7 @@ module gr-toolkit{ output { leaf status { type string; } leaf health { type string; } + leaf served-by { type string; } } } @@ -125,6 +128,7 @@ module gr-toolkit{ to determine if the entire site is in a healthy state."; output { leaf status { type string; } + leaf served-by { type string; } list sites { uses site; } @@ -136,6 +140,7 @@ module gr-toolkit{ "Returns the unique site identifier."; output { leaf status { type string; } + leaf served-by { type string; } leaf id { type string; mandatory true; } } } @@ -150,6 +155,7 @@ module gr-toolkit{ } output { leaf status { type string; } + leaf served-by { type string; } } } @@ -163,6 +169,7 @@ module gr-toolkit{ } output { leaf status { type string; } + leaf served-by { type string; } } } @@ -186,6 +193,7 @@ module gr-toolkit{ output { leaf status { type string; } leaf message { type string; } + leaf served-by { type string; } } } } diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java index 4e121e345..39bc16181 100755 --- a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java @@ -244,6 +244,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT DatabaseHealthOutputBuilder outputBuilder = new DatabaseHealthOutputBuilder(); outputBuilder.setStatus("200"); outputBuilder.setHealth(getDatabaseHealth()); + outputBuilder.setServedBy(member); return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); } @@ -254,6 +255,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT AdminHealthOutputBuilder outputBuilder = new AdminHealthOutputBuilder(); outputBuilder.setStatus("200"); outputBuilder.setHealth(getAdminHealth()); + outputBuilder.setServedBy(member); return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); } @@ -264,6 +266,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT HaltAkkaTrafficOutputBuilder outputBuilder = new HaltAkkaTrafficOutputBuilder(); outputBuilder.setStatus("200"); modifyIpTables(IpTables.ADD, input.getNodeInfo().toArray()); + outputBuilder.setServedBy(member); return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); } @@ -274,6 +277,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT ResumeAkkaTrafficOutputBuilder outputBuilder = new ResumeAkkaTrafficOutputBuilder(); outputBuilder.setStatus("200"); modifyIpTables(IpTables.DELETE, input.getNodeInfo().toArray()); + outputBuilder.setServedBy(member); return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); } @@ -284,6 +288,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT SiteIdentifierOutputBuilder outputBuilder = new SiteIdentifierOutputBuilder(); outputBuilder.setStatus("200"); outputBuilder.setId(siteIdentifier); + outputBuilder.setServedBy(member); return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); } @@ -292,6 +297,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT public ListenableFuture> failover(FailoverInput input) { log.info("{}:failover invoked.", APP_NAME); FailoverOutputBuilder outputBuilder = new FailoverOutputBuilder(); + outputBuilder.setServedBy(member); if(siteConfiguration != SiteConfiguration.GEO) { log.info("Cannot failover non-GEO site."); outputBuilder.setMessage("Failover aborted. This is not a GEO configuration."); @@ -476,6 +482,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT outputBuilder.setSite2Health(FAULTY); } + outputBuilder.setServedBy(member); RpcResult rpcResult = RpcResultBuilder.status(true).withResult(outputBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -589,6 +596,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT } } + outputBuilder.setServedBy(member); RpcResult rpcResult = RpcResultBuilder.status(true).withResult(outputBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -836,9 +844,9 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT log.info("Determining database health..."); try { Connection connection = dbLib.getConnection(); - log.info("DBLib isActive(): {}", dbLib.isActive()); - log.info("DBLib isReadOnly(): {}", connection.isReadOnly()); - log.info("DBLib isClosed(): {}", connection.isClosed()); + log.debug("DBLib isActive(): {}", dbLib.isActive()); + log.debug("DBLib isReadOnly(): {}", connection.isReadOnly()); + log.debug("DBLib isClosed(): {}", connection.isClosed()); if(!dbLib.isActive() || connection.isClosed() || connection.isReadOnly()) { log.warn("Database is FAULTY"); connection.close(); @@ -876,7 +884,10 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT } bufferedReader.close(); connection.disconnect(); - return content.toString(); + + String response = content.toString(); + log.debug("getRequestContent(): Response:\n{}", response); + return response; } private int getRequestStatus(String path, HttpMethod method) throws IOException { -- cgit From d5f883f63b0faf2b0c8a7c9bc9e384c4f893d766 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 30 Apr 2019 11:54:52 -0400 Subject: Roll master to El Alto Roll master version to El Alto versions Change-Id: Ifec94aaab874709c18ffcb03c2b7aa82c23ba2f9 Issue-ID: CCSDK-1222 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 4 ++-- features/ccsdk-sli-plugins-all/pom.xml | 4 ++-- features/features-sli-plugins/pom.xml | 4 ++-- features/installer/pom.xml | 4 ++-- features/pom.xml | 4 ++-- grToolkit/features/ccsdk-gr-toolkit/pom.xml | 4 ++-- grToolkit/features/features-gr-toolkit/pom.xml | 4 ++-- grToolkit/features/pom.xml | 4 ++-- grToolkit/installer/pom.xml | 4 ++-- grToolkit/model/pom.xml | 4 ++-- grToolkit/pom.xml | 4 ++-- grToolkit/provider/pom.xml | 4 ++-- pom.xml | 4 ++-- properties-node/features/ccsdk-properties-node/pom.xml | 4 ++-- properties-node/features/features-properties-node/pom.xml | 4 ++-- properties-node/features/pom.xml | 4 ++-- properties-node/installer/pom.xml | 4 ++-- properties-node/pom.xml | 4 ++-- properties-node/provider/pom.xml | 4 ++-- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/features-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/pom.xml | 4 ++-- restapi-call-node/installer/pom.xml | 4 ++-- restapi-call-node/pom.xml | 4 ++-- restapi-call-node/provider/pom.xml | 4 ++-- restconf-client/features/ccsdk-restconf-client/pom.xml | 4 ++-- restconf-client/features/features-restconf-client/pom.xml | 4 ++-- restconf-client/features/pom.xml | 4 ++-- restconf-client/installer/pom.xml | 4 ++-- restconf-client/pom.xml | 4 ++-- restconf-client/provider/pom.xml | 8 ++++---- sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/features/features-sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/features/pom.xml | 4 ++-- sshapi-call-node/installer/pom.xml | 4 ++-- sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/provider/pom.xml | 4 ++-- template-node/features/ccsdk-template-node/pom.xml | 4 ++-- template-node/features/features-template-node/pom.xml | 4 ++-- template-node/features/pom.xml | 4 ++-- template-node/installer/pom.xml | 4 ++-- template-node/pom.xml | 4 ++-- template-node/provider/pom.xml | 4 ++-- version.properties | 4 ++-- 44 files changed, 90 insertions(+), 90 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 2daa2c5b2..261b955e4 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.plugins sli-plugins-artifacts - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-plugins :: sli-plugins-artifacts @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.2.2 + 1.3.0-SNAPSHOT diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index 0ca186002..f36956a9c 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins-all - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index c30fb147a..931e46063 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-sli-plugins - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 9f0276044..58143e79f 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins sliplugins-features-installer - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 2aa82953c..d8553b42f 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins sliplugins-feature-aggregator - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-plugins :: features diff --git a/grToolkit/features/ccsdk-gr-toolkit/pom.xml b/grToolkit/features/ccsdk-gr-toolkit/pom.xml index 0ca01cd3f..37343c53c 100755 --- a/grToolkit/features/ccsdk-gr-toolkit/pom.xml +++ b/grToolkit/features/ccsdk-gr-toolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-gr-toolkit - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/features/features-gr-toolkit/pom.xml b/grToolkit/features/features-gr-toolkit/pom.xml index 2d9a6933a..441e2e855 100755 --- a/grToolkit/features/features-gr-toolkit/pom.xml +++ b/grToolkit/features/features-gr-toolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-gr-toolkit - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/features/pom.xml b/grToolkit/features/pom.xml index caadecac8..a27e71853 100755 --- a/grToolkit/features/pom.xml +++ b/grToolkit/features/pom.xml @@ -4,14 +4,14 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} gr-toolkit-features org.onap.ccsdk.sli.plugins - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom diff --git a/grToolkit/installer/pom.xml b/grToolkit/installer/pom.xml index 4f5780683..831edf707 100755 --- a/grToolkit/installer/pom.xml +++ b/grToolkit/installer/pom.xml @@ -4,14 +4,14 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-installer - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-gr-toolkit diff --git a/grToolkit/model/pom.xml b/grToolkit/model/pom.xml index 67b94d1ce..439b05f0c 100755 --- a/grToolkit/model/pom.xml +++ b/grToolkit/model/pom.xml @@ -4,13 +4,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.2 + 1.3.0-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-model - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT bundle diff --git a/grToolkit/pom.xml b/grToolkit/pom.xml index c0be3d858..2cdc71d08 100755 --- a/grToolkit/pom.xml +++ b/grToolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins gr-toolkit - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-plugins :: gr-toolkit diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index f2dad8b86..ee61d7d41 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -4,13 +4,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.2 + 1.3.0-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-provider - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT bundle diff --git a/pom.xml b/pom.xml index af41ee390..e66a40794 100755 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index a8e642ea0..ae007d6e4 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-properties-node - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index 56945da4b..0db5a9042 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-properties-node - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 06d45f638..79d56ff04 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-features - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index c8354be31..42732871b 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-installer - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 52a9539f8..de936d9f2 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-plugins :: properties-node diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index c819973c9..2e3b5e76c 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-provider - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT bundle ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index c0703ce16..7062d6102 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restapi-call-node - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index 943ebbcac..b5329ea8f 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-restapi-call-node - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index ab665203f..4820b7dd5 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-features - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index c6c722765..d51cc610e 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-installer - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 3498bdc4c..a84d3232d 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index d22e3edcc..a7a0842a4 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT bundle ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index 3a143282d..677a24671 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restconf-client - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml index a99be46ba..032a781e1 100644 --- a/restconf-client/features/features-restconf-client/pom.xml +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-restconf-client - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml index ee2f035c6..ae4000266 100755 --- a/restconf-client/features/pom.xml +++ b/restconf-client/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-features - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index 321b5b524..bcf9e998d 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-installer - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index 067166f8b..b9cad2629 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 24db30ad4..70f84e09d 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-provider - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT bundle ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} @@ -49,7 +49,7 @@ org.onap.ccsdk.sli.plugins properties-node-provider - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.yangtools @@ -73,7 +73,7 @@ org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT org.opendaylight.netconf diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index 18cfe9abc..a34b4aeee 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sshapi-call-node - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml index 34cecd0e0..04338facf 100644 --- a/sshapi-call-node/features/features-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/features-sshapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-sshapi-call-node - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml index ec1125d6b..35be47a4e 100755 --- a/sshapi-call-node/features/pom.xml +++ b/sshapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-features - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index 844e52fe1..029b94dea 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-installer - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index bd5dd54ba..99c6d9edd 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index 13d5b0aaa..81ab8811e 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-provider - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT bundle ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index 9a876be5d..f7a708729 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-template-node - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml index a6d9681de..3c6f6d853 100644 --- a/template-node/features/features-template-node/pom.xml +++ b/template-node/features/features-template-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-template-node - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml index 71ab77898..f919d1c09 100644 --- a/template-node/features/pom.xml +++ b/template-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-features - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index 98ade668b..35161b8e5 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-installer - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/template-node/pom.xml b/template-node/pom.xml index 2fd3cfdef..b65c40e24 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index 4a44b6d5a..b47c60409 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-provider - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT bundle ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/version.properties b/version.properties index 80a47aef7..c8bc76801 100644 --- a/version.properties +++ b/version.properties @@ -6,8 +6,8 @@ # Comment release_name=0 -sprint_number=4 -feature_revision=2 +sprint_number=5 +feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit From a8287a9b4c1b679e04307669fffee6eb1d5f4ab5 Mon Sep 17 00:00:00 2001 From: Stan Bonev Date: Mon, 6 May 2019 10:09:48 -0400 Subject: Restapi: DELETE with payload doesn't work Change-Id: I50eeea493197010aba4b37af97dcedb446ed5d10 Issue-ID: CCSDK-1305 Signed-off-by: Stan Bonev --- .../sli/plugins/restapicall/RestapiCallNode.java | 25 ++++--- .../plugins/restapicall/TestRestapiCallNode.java | 81 +++++++++++++--------- 2 files changed, 64 insertions(+), 42 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index a7235fcb5..9b50eaa44 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -25,7 +25,6 @@ package org.onap.ccsdk.sli.plugins.restapicall; import static java.lang.Boolean.valueOf; import static javax.ws.rs.client.Entity.entity; import static org.onap.ccsdk.sli.plugins.restapicall.AuthType.fromString; - import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -52,8 +51,12 @@ import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Entity; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.*; - +import javax.ws.rs.core.EntityTag; +import javax.ws.rs.core.Feature; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; import org.apache.commons.lang3.StringUtils; import org.glassfish.jersey.client.ClientProperties; import org.glassfish.jersey.client.HttpUrlConnectorProvider; @@ -94,8 +97,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { try (FileInputStream in = new FileInputStream(configDir + "/" + DME2_PROPERTIES_FILE_NAME)) { Properties props = new Properties(); props.load(in); - this.retryPolicyStore = new RetryPolicyStore(); - this.retryPolicyStore.setProxyServers(props.getProperty("proxyUrl")); + retryPolicyStore = new RetryPolicyStore(); + retryPolicyStore.setProxyServers(props.getProperty("proxyUrl")); log.info("DME2 support enabled"); } catch (Exception e) { log.warn("DME2 properties could not be read, DME2 support will not be enabled.", e); @@ -104,7 +107,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { try (FileInputStream in = new FileInputStream(configDir + "/" + UEB_PROPERTIES_FILE_NAME)) { Properties props = new Properties(); props.load(in); - this.uebServers = props.getProperty("servers"); + uebServers = props.getProperty("servers"); log.info("UEB support enabled"); } catch (Exception e) { log.warn("UEB properties could not be read, UEB support will not be enabled.", e); @@ -462,7 +465,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } long t2 = System.currentTimeMillis(); - log.info("Building {} completed. Time: {}", format, (t2 - t1)); + log.info("Building {} completed. Time: {}", format, t2 - t1); return req; } @@ -669,6 +672,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { invocationBuilder.header("X-ECOMP-RequestID", org.slf4j.MDC.get("X-ECOMP-RequestID")); + invocationBuilder.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true); + Response response; try { @@ -739,7 +744,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } long t2 = System.currentTimeMillis(); - log.info(responseReceivedMessage, (t2 - t1)); + log.info(responseReceivedMessage, t2 - t1); log.info(responseHttpCodeMessage, r.code); log.info("HTTP response message: {}", r.message); logHeaders(r.headers); @@ -942,7 +947,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } long t2 = System.currentTimeMillis(); - log.info(responseReceivedMessage, (t2 - t1)); + log.info(responseReceivedMessage, t2 - t1); log.info(responseHttpCodeMessage, r.code); log.info("HTTP response message: {}", r.message); logHeaders(r.headers); @@ -1035,7 +1040,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } long t2 = System.currentTimeMillis(); - log.info(responseReceivedMessage, (t2 - t1)); + log.info(responseReceivedMessage, t2 - t1); log.info(responseHttpCodeMessage, r.code); logHeaders(r.headers); log.info("HTTP response:\n {}", r.body); diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index 52da46157..3752a9c3f 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -21,23 +21,21 @@ package jtest.org.onap.ccsdk.sli.plugins.restapicall; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; import java.net.URI; import java.util.HashMap; import java.util.Map; - import org.glassfish.grizzly.http.server.HttpServer; import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; import org.glassfish.jersey.media.multipart.MultiPartFeature; +import org.glassfish.jersey.server.ResourceConfig; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.glassfish.jersey.server.ResourceConfig; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; public class TestRestapiCallNode { @@ -48,7 +46,26 @@ public class TestRestapiCallNode { public void testDelete() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); - Map p = new HashMap(); + Map p = new HashMap<>(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "pwd1"); + p.put("httpMethod", "delete"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteWithPayload() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + ctx.setAttribute("prop.name", "site1"); + + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/sdwan-site.json"); p.put("restapiUrl", "https://echo.getpostman.com/delete"); p.put("restapiUser", "user1"); p.put("restapiPassword", "pwd1"); @@ -79,7 +96,7 @@ public class TestRestapiCallNode { ctx.setAttribute("prop.siteAttachement[1].roles_length", "1"); ctx.setAttribute("prop.siteAttachement[1].roles[0]", "role2"); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("templateFileName", "src/test/resources/sdwan-vpn-topology.json"); p.put("restapiUrl", "http://echo.getpostman.com"); p.put("restapiUser", "user1"); @@ -100,7 +117,7 @@ public class TestRestapiCallNode { ctx.setAttribute("prop.name", "site1"); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("templateFileName", "src/test/resources/sdwan-site.json"); p.put("restapiUrl", "http://echo.getpostman.com"); p.put("restapiUser", "user1"); @@ -140,7 +157,7 @@ public class TestRestapiCallNode { ctx.setAttribute("tmp.sdn-circuit-req-row[2].service-clfi", "testClfi1"); ctx.setAttribute("tmp.sdn-circuit-req-row[2].clci", "clci"); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("templateFileName", "src/test/resources/test-template.json"); p.put("restapiUrl", "http://echo.getpostman.com"); p.put("restapiUser", "user1"); @@ -166,7 +183,7 @@ public class TestRestapiCallNode { ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("templateFileName", "src/test/resources/test-template.json"); p.put("restapiUrl", "http://echo.getpostman.com"); p.put("restapiUser", "user1"); @@ -192,7 +209,7 @@ public class TestRestapiCallNode { ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("templateFileName", "src/test/resourcess/test-template.json"); p.put("restapiUrl", "http://echo.getpostman.com"); p.put("restapiUser", "user1"); @@ -218,7 +235,7 @@ public class TestRestapiCallNode { ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("templateFileName", "src/test/resources/test-template.json"); p.put("restapiUrl", "http://echo.getpostman.com"); p.put("restapiUser", "user1"); @@ -244,7 +261,7 @@ public class TestRestapiCallNode { ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("templateFileName", "src/test/resources/test-template.json"); p.put("restapiUrl", "http://echo.getpostman.com"); p.put("restapiUser", "user1"); @@ -272,7 +289,7 @@ public class TestRestapiCallNode { ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("templateFileName", "src/test/resources/test-template.json"); p.put("restapiUrl", "http://echo. getpostman.com"); p.put("restapiUser", "user1"); @@ -292,7 +309,7 @@ public class TestRestapiCallNode { ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"); p.put("restapiUser", "admin"); @@ -338,7 +355,7 @@ public class TestRestapiCallNode { ctx.setAttribute("prop.l3vpn.peer2-ip", "192.168.1.7"); ctx.setAttribute("prop.l3vpn.ac2_protocol_bgp_as", "200"); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("templateFileName", "src/test/resources/l3smsitetemplate.json"); p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/sites"); p.put("restapiUser", "admin"); @@ -362,7 +379,7 @@ public class TestRestapiCallNode { ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006"); ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a"); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("templateFileName", "src/test/resources/l3smvrftemplate.json"); p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vrf-attributes"); p.put("restapiUser", "admin"); @@ -382,7 +399,7 @@ public class TestRestapiCallNode { ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); - Map p = new HashMap(); + Map p = new HashMap<>(); //p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services" + "/vpnservice=10000000-0000-0000-0000-000000000001"); @@ -410,7 +427,7 @@ public class TestRestapiCallNode { ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2"); ctx.setAttribute("prop.dci-connects.vni", "1"); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("templateFileName", "src/test/resources/l2-dci-connects-template.json"); p.put("restapiUrl", "http://echo.getpostman.com"); p.put("restapiUser", "user1"); @@ -438,7 +455,7 @@ public class TestRestapiCallNode { ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2"); ctx.setAttribute("prop.dci-connects.vni", "1"); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("templateFileName", "src/test/resources/l3-dci-connects-template.json"); p.put("restapiUrl", "http://echo.getpostman.com"); p.put("restapiUser", "user1"); @@ -459,7 +476,7 @@ public class TestRestapiCallNode { ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.user", "admin"); ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.password", "admin123"); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("templateFileName", "src/test/resources/actokentemplate.json"); p.put("restapiUrl", "https://ipwan:18002/controller/v2/tokens"); p.put("format", "json"); @@ -476,7 +493,7 @@ public class TestRestapiCallNode { public void testDeleteNoneAsContentType() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("restapiUrl", "https://echo.getpostman.com/delete"); p.put("restapiUser", "user1"); p.put("restapiPassword", "pwd1"); @@ -494,7 +511,7 @@ public class TestRestapiCallNode { ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"); p.put("restapiUser", "admin"); @@ -512,7 +529,7 @@ public class TestRestapiCallNode { public void testDeleteOAuthType() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("restapiUrl", "https://echo.getpostman.com/delete"); p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); p.put("oAuthConsumerSecret", "secret"); @@ -530,7 +547,7 @@ public class TestRestapiCallNode { public void testDeleteAuthTypeBasic() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("restapiUrl", "https://echo.getpostman.com/delete"); p.put("authType", "basic"); p.put("restapiUser", "admin"); @@ -547,7 +564,7 @@ public class TestRestapiCallNode { public void testDeleteAuthTypeDigest() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("restapiUrl", "https://echo.getpostman.com/delete"); p.put("authType", "digest"); p.put("restapiUser", "admin"); @@ -564,7 +581,7 @@ public class TestRestapiCallNode { public void testDeleteAuthTypeOAuth() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("restapiUrl", "https://echo.getpostman.com/delete"); p.put("authType", "oauth"); p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); @@ -583,7 +600,7 @@ public class TestRestapiCallNode { public void testDeleteAuthTypeNoneOAuth() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("restapiUrl", "https://echo.getpostman.com/delete"); p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); p.put("oAuthConsumerSecret", "secret"); @@ -600,7 +617,7 @@ public class TestRestapiCallNode { public void testDeleteAuthTypeNoneBasic() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("restapiUrl", "https://echo.getpostman.com/delete"); p.put("restapiUser", "admin"); p.put("restapiPassword", "admin123"); @@ -616,7 +633,7 @@ public class TestRestapiCallNode { public void testInvalidDeleteAuthTypeOAuth() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("restapiUrl", "https://echo.getpostman.com/delete"); p.put("authType", "oauth"); p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); @@ -633,7 +650,7 @@ public class TestRestapiCallNode { public void testInvalidDeleteAuthTypeBasic() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("restapiUrl", "https://echo.getpostman.com/delete"); p.put("authType", "basic"); p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); @@ -650,7 +667,7 @@ public class TestRestapiCallNode { public void testInvalidDeleteAuthTypeDigest() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); - Map p = new HashMap(); + Map p = new HashMap<>(); p.put("restapiUrl", "https://echo.getpostman.com/delete"); p.put("authType", "digest"); p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); -- cgit From 06c30ec3fa1dbdf26b7e1abce89c68e3efc632c7 Mon Sep 17 00:00:00 2001 From: "Haddox, Anthony" Date: Tue, 7 May 2019 11:52:12 -0700 Subject: Replace output with static constant Replacing "output" with static constant OUTPUT. This also resolves an issue with cross site health check not being able to parse the health check. Change-Id: Ie4d3b30b241620d00365d58db7797a5052f60827 Signed-off-by: Haddox, Anthony Issue-ID: CCSDK-1312 --- .../ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java index 39bc16181..f10055a1a 100755 --- a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java @@ -48,7 +48,6 @@ import javax.annotation.Nonnull; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import org.onap.ccsdk.sli.core.dblib.DBLibConnection; import org.onap.ccsdk.sli.core.dblib.DbLibService; import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterActor; import org.onap.ccsdk.sli.plugins.grtoolkit.data.MemberBuilder; @@ -103,6 +102,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT private static final String HEALTHY = "HEALTHY"; private static final String FAULTY = "FAULTY"; private static final String VALUE = "value"; + private static final String OUTPUT = "output"; private String akkaConfig; private String jolokiaClusterPath; private String shardManagerPath; @@ -540,12 +540,13 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT if(!performedCrossSiteHealthCheck) { try { String content = getRequestContent(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:site-identifier", HttpMethod.POST); - crossSiteIdentifier = new JSONObject(content).getJSONObject("output").getString("id"); + crossSiteIdentifier = new JSONObject(content).getJSONObject(OUTPUT).getString("id"); crossSiteDbHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:database-health"); crossSiteAdminHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:admin-health"); performedCrossSiteHealthCheck = true; } catch(Exception e) { - log.info("Cannot get site identifier from {}", clusterActor.getNode()); + log.info("Cannot get cross site health from {}", clusterActor.getNode()); + log.info("siteIdentifier: {} | dbHealth: {} | adminHealth: {}", crossSiteIdentifier, crossSiteDbHealthy, crossSiteAdminHealthy); log.error("Site Health Error", e); } } @@ -570,12 +571,13 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT if(!performedCrossSiteHealthCheck) { try { String content = getRequestContent(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:site-identifier", HttpMethod.POST); - crossSiteIdentifier = new JSONObject(content).getJSONObject("output").getString("id"); + crossSiteIdentifier = new JSONObject(content).getJSONObject(OUTPUT).getString("id"); crossSiteDbHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:database-health"); crossSiteAdminHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:admin-health"); performedCrossSiteHealthCheck = true; } catch(Exception e) { - log.info("Cannot get site identifier from {}", clusterActor.getNode()); + log.info("Cannot get cross site health from {}", clusterActor.getNode()); + log.info("siteIdentifier: {} | dbHealth: {} | adminHealth: {}", crossSiteIdentifier, crossSiteDbHealthy, crossSiteAdminHealthy); log.error("Site Health Error", e); } } @@ -815,7 +817,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT String content = getRequestContent(path, HttpMethod.POST); try { JSONObject responseJson = new JSONObject(content); - JSONObject responseValue = responseJson.getJSONObject(VALUE); + JSONObject responseValue = responseJson.getJSONObject(OUTPUT); return HEALTHY.equals(responseValue.getString("health")); } catch(JSONException e) { log.error("Error parsing JSON", e); -- cgit From c75880b15cebc206d43721b35299453f49406f20 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 22 May 2019 16:34:44 +0000 Subject: rest api call node unit tests rest api call node unit test added for the case in which a template mixes simple and complex json objects. Change-Id: I6921d6e328b3593464d82b7a45b1844cd88c3476 Issue-ID: CCSDK-1355 Signed-off-by: Smokowski, Kevin (ks6305) --- .../plugins/restapicall/MockCookieAuthServer.java | 40 -- .../plugins/restapicall/MultipartServerMock.java | 44 -- .../sli/plugins/restapicall/TestJsonParser.java | 73 -- .../plugins/restapicall/TestRestapiCallNode.java | 724 -------------------- .../sli/plugins/restapicall/TestXmlJsonUtil.java | 262 -------- .../sli/plugins/restapicall/TestXmlParser.java | 121 ---- .../plugins/restapicall/MockCookieAuthServer.java | 40 ++ .../plugins/restapicall/MultipartServerMock.java | 44 ++ .../sli/plugins/restapicall/TestJsonParser.java | 73 ++ .../plugins/restapicall/TestRestapiCallNode.java | 741 +++++++++++++++++++++ .../sli/plugins/restapicall/TestXmlJsonUtil.java | 262 ++++++++ .../sli/plugins/restapicall/TestXmlParser.java | 121 ++++ .../src/test/resources/testEmbeddedTemplate.json | 20 + 13 files changed, 1301 insertions(+), 1264 deletions(-) delete mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java delete mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MultipartServerMock.java delete mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java delete mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java delete mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java delete mode 100644 restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java create mode 100644 restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java create mode 100644 restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/MultipartServerMock.java create mode 100644 restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java create mode 100644 restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java create mode 100644 restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java create mode 100644 restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java create mode 100644 restapi-call-node/provider/src/test/resources/testEmbeddedTemplate.json diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java deleted file mode 100644 index b4a30d3ab..000000000 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2019 Huawei Technologies Co., Ltd. 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.restapicall; - -import javax.ws.rs.Consumes; -import javax.ws.rs.Produces; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.NewCookie; -import javax.ws.rs.core.Response; - -@Path("get-cookie") -public class MockCookieAuthServer { - @GET - @Path("cookie") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - public Response getCookie() { - return Response.status(200).entity("success").cookie(new NewCookie("cookieResponse", "cookieValueInReturn")).build(); - } -} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MultipartServerMock.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MultipartServerMock.java deleted file mode 100644 index 9646272b4..000000000 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MultipartServerMock.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2019 Huawei Technologies Co., Ltd. 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.restapicall; - -import org.glassfish.jersey.media.multipart.FormDataContentDisposition; -import org.glassfish.jersey.media.multipart.FormDataParam; - -import javax.ws.rs.Consumes; - -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.io.InputStream; - -@Path("file-upload") -public class MultipartServerMock { - - @POST - @Path("upload") - @Consumes(MediaType.MULTIPART_FORM_DATA) - public Response uploadFile( - @FormDataParam("file") InputStream inputStream, - @FormDataParam("file") FormDataContentDisposition fileDetail) { - return Response.status(200).entity(fileDetail.getFileName()).build(); - } -} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java deleted file mode 100644 index 5526be81f..000000000 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============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 jtest.org.onap.ccsdk.sli.plugins.restapicall; - -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.restapicall.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 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 mm) { - List 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/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java deleted file mode 100644 index 3752a9c3f..000000000 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ /dev/null @@ -1,724 +0,0 @@ -/*- - * ============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 jtest.org.onap.ccsdk.sli.plugins.restapicall; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import java.net.URI; -import java.util.HashMap; -import java.util.Map; -import org.glassfish.grizzly.http.server.HttpServer; -import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; -import org.glassfish.jersey.media.multipart.MultiPartFeature; -import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestRestapiCallNode { - - private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class); - - - @Test - public void testDelete() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "pwd1"); - p.put("httpMethod", "delete"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteWithPayload() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - ctx.setAttribute("prop.name", "site1"); - - - Map p = new HashMap<>(); - p.put("templateFileName", "src/test/resources/sdwan-site.json"); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "pwd1"); - p.put("httpMethod", "delete"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testJsonSdwanVpnTopologyTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - ctx.setAttribute("prop.topology", "topoType"); - - ctx.setAttribute("prop.roles_length", "1"); - ctx.setAttribute("prop.roles[0]", "role1"); - - ctx.setAttribute("prop.siteAttachement_length", "2"); - - ctx.setAttribute("prop.siteAttachement[0].siteId", "site1"); - ctx.setAttribute("prop.siteAttachement[0].roles_length", "0"); - ctx.setAttribute("prop.siteAttachement[0].roles[0]", "role1"); - ctx.setAttribute("prop.siteAttachement[0].roles[1]", "role3"); - - ctx.setAttribute("prop.siteAttachement[1].siteId", "site2"); - ctx.setAttribute("prop.siteAttachement[1].roles_length", "1"); - ctx.setAttribute("prop.siteAttachement[1].roles[0]", "role2"); - - Map p = new HashMap<>(); - p.put("templateFileName", "src/test/resources/sdwan-vpn-topology.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testJsonSdwanSiteTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - ctx.setAttribute("prop.name", "site1"); - - - Map p = new HashMap<>(); - p.put("templateFileName", "src/test/resources/sdwan-site.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testJsonTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.sdn-circuit-req-row_length", "3"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[1].clci", "clci"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[2].clci", "clci"); - - Map p = new HashMap<>(); - p.put("templateFileName", "src/test/resources/test-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testInvalidRepeatTimes() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.sdn-circuit-req-row_length", "a"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - - Map p = new HashMap<>(); - p.put("templateFileName", "src/test/resources/test-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testInvalidTemplatePath() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - - Map p = new HashMap<>(); - p.put("templateFileName", "src/test/resourcess/test-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testWithoutSkipSending() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - - Map p = new HashMap<>(); - p.put("templateFileName", "src/test/resources/test-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "false"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testFormData() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - - Map p = new HashMap<>(); - p.put("templateFileName", "src/test/resources/test-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "false"); - p.put("multipartFormData", "true"); - p.put("multipartFile", "src/test/resources/test-template.json"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testWithInvalidURI() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - - Map p = new HashMap<>(); - p.put("templateFileName", "src/test/resources/test-template.json"); - p.put("restapiUrl", "http://echo. getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "false"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testVpnJsonTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); - ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); - - Map p = new HashMap<>(); - p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); - p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "restapi-result"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testSiteJsonTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); - ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); - - ctx.setAttribute("prop.l3vpn.site1_name", "10000000-0000-0000-0000-000000000002"); - ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003"); - ctx.setAttribute("prop.l3vpn.entry1-id", "1"); - ctx.setAttribute("prop.l3vpn.sna1_name", "10000000-0000-0000-0000-000000000004"); - ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e"); - ctx.setAttribute("prop.l3vpn.ac1_id", "a8098c1a-f86e-11da-bd1a-00112444be1b"); - ctx.setAttribute("prop.l3vpn.ac1-peer-ip", "192.168.1.1"); - ctx.setAttribute("prop.l3vpn.ac1-ip", "192.168.1.2"); - ctx.setAttribute("prop.l3vpn.sna1_svlan", "100"); - ctx.setAttribute("prop.l3vpn.ac1_protocol", "static"); - ctx.setAttribute("prop.l3vpn.sna1-route.ip-prefix", "192.168.1.1/24"); - ctx.setAttribute("prop.l3vpn.sna1-route.next-hop", "192.168.1.4"); - - ctx.setAttribute("prop.l3vpn.site2_name", "10000000-0000-0000-0000-000000000005"); - ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006"); - ctx.setAttribute("prop.l3vpn.entry2-id", "1"); - ctx.setAttribute("prop.l3vpn.sna2_name", "10000000-0000-0000-0000-000000000007"); - ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a"); - ctx.setAttribute("prop.l3vpn.ac2_id", "a8098c1a-f86e-11da-bd1a-00112444be1c"); - ctx.setAttribute("prop.l3vpn.ac2-peer-ip", "192.168.1.6"); - ctx.setAttribute("prop.l3vpn.ac2-ip", "192.168.1.5"); - ctx.setAttribute("prop.l3vpn.sna2_svlan", "200"); - ctx.setAttribute("prop.l3vpn.ac2_protocol", "bgp"); - ctx.setAttribute("prop.l3vpn.peer2-ip", "192.168.1.7"); - ctx.setAttribute("prop.l3vpn.ac2_protocol_bgp_as", "200"); - - Map p = new HashMap<>(); - p.put("templateFileName", "src/test/resources/l3smsitetemplate.json"); - p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/sites"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "restapi-result"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testVrfJsonTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.l3vpn.vrf1-id", "10000000-0000-0000-0000-000000000007"); - ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003"); - ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e"); - ctx.setAttribute("prop.l3vpn.vrf2-id", "10000000-0000-0000-0000-000000000009"); - ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006"); - ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a"); - - Map p = new HashMap<>(); - p.put("templateFileName", "src/test/resources/l3smvrftemplate.json"); - p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vrf-attributes"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "restapi-result"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteVpnJsonTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); - ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); - - Map p = new HashMap<>(); - //p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); - p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services" - + "/vpnservice=10000000-0000-0000-0000-000000000001"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("format", "json"); - p.put("httpMethod", "delete"); - p.put("responsePrefix", "restapi-result"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testL2DciTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.dci-connects.id", "Id1"); - ctx.setAttribute("prop.dci-connects.name", "Name1"); - ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1"); - ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2"); - ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1"); - ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2"); - ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1"); - ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2"); - ctx.setAttribute("prop.dci-connects.vni", "1"); - - Map p = new HashMap<>(); - p.put("templateFileName", "src/test/resources/l2-dci-connects-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testL3DciTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.dci-connects.id", "Id1"); - ctx.setAttribute("prop.dci-connects.name", "Name1"); - ctx.setAttribute("prop.dci-connects.local_networks_length", "2"); - ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1"); - ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2"); - ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1"); - ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2"); - ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1"); - ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2"); - ctx.setAttribute("prop.dci-connects.vni", "1"); - - Map p = new HashMap<>(); - p.put("templateFileName", "src/test/resources/l3-dci-connects-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - - } - - @Test - public void testControllerTokenTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.user", "admin"); - ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.password", "admin123"); - - Map p = new HashMap<>(); - p.put("templateFileName", "src/test/resources/actokentemplate.json"); - p.put("restapiUrl", "https://ipwan:18002/controller/v2/tokens"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "restapi-result"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - - @Test - public void testDeleteNoneAsContentType() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "pwd1"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testPostNoneAsContentType() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); - ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); - - Map p = new HashMap<>(); - p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); - p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("format", "none"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "restapi-result"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteOAuthType() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("oAuthSignatureMethod", "plainTEXT"); - p.put("oAuthVersion", "1.0"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteAuthTypeBasic() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "basic"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteAuthTypeDigest() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "digest"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteAuthTypeOAuth() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "oauth"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("oAuthSignatureMethod", "plainTEXT"); - p.put("oAuthVersion", "1.0"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteAuthTypeNoneOAuth() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("oAuthSignatureMethod", "plainTEXT"); - p.put("oAuthVersion", "1.0"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - @Test - public void testDeleteAuthTypeNoneBasic() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testInvalidDeleteAuthTypeOAuth() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "oauth"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testInvalidDeleteAuthTypeBasic() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "basic"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testInvalidDeleteAuthTypeDigest() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "digest"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testMultipartFormData() throws SvcLogicException { - final ResourceConfig resourceConfig = new ResourceConfig( - MultipartServerMock.class, MultiPartFeature.class); - HttpServer server = GrizzlyHttpServerFactory.createHttpServer( - URI.create("http://localhost:8080/"),resourceConfig); - - Map p = new HashMap<>(); - p.put("multipartFormData", "true"); - p.put("format", "none"); - p.put("multipartFile", "src/test/resources/test-template.json"); - p.put("restapiUrl", "http://localhost:8080/file-upload/upload"); - - SvcLogicContext ctx = new SvcLogicContext(); - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - assertThat(ctx.getAttribute("response-code"), is("200")); - assertThat(ctx.getAttribute("httpResponse"), is( "test-template.json")); - server.shutdownNow(); - } - - @Test - public void testCookieResponse() throws SvcLogicException { - final ResourceConfig resourceConfig = new ResourceConfig( - MockCookieAuthServer.class); - HttpServer server = GrizzlyHttpServerFactory.createHttpServer( - URI.create("http://localhost:8080/"),resourceConfig); - - Map p = new HashMap<>(); - p.put("format", "none"); - p.put("httpMethod", "get"); - p.put("restapiUrl", "http://localhost:8080/get-cookie/cookie"); - p.put("dumpHeaders", "true"); - - SvcLogicContext ctx = new SvcLogicContext(); - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - assertThat(ctx.getAttribute("response-code"), is("200")); - assertThat(ctx.getAttribute("header.Set-Cookie"), is("cookieResponse=cookieValueInReturn;Version=1")); - server.shutdownNow(); - } -} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java deleted file mode 100644 index 11eeba7f0..000000000 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java +++ /dev/null @@ -1,262 +0,0 @@ -/*- - * ============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 jtest.org.onap.ccsdk.sli.plugins.restapicall; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.sli.plugins.restapicall.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 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 = "" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " blah\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " blah blah\n" + - "\n"; - - String xmloutexpected = "" + - "\n" + - " \n" + - " blah\n" + - " \n" + - " blah blah\n" + - "\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(null, xmlin); - log.info(xmlout); - - Assert.assertEquals(xmloutexpected, xmlout); - } -} diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java deleted file mode 100644 index c6bf4a8b9..000000000 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java +++ /dev/null @@ -1,121 +0,0 @@ -/*- - * ============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 jtest.org.onap.ccsdk.sli.plugins.restapicall; - -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.restapicall.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 listNameList = new HashSet(); - 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 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 listNameList = new HashSet(); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); - - Map 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 listNameList = new HashSet(); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); - - Map mm = XmlParser.convertToProperties(b.toString(), listNameList); - logProperties(mm); - in.close(); - } - - private void logProperties(Map mm) { - List 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/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java new file mode 100644 index 000000000..7e1e0d505 --- /dev/null +++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2019 Huawei Technologies Co., Ltd. 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.restapicall; + +import javax.ws.rs.Consumes; +import javax.ws.rs.Produces; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.NewCookie; +import javax.ws.rs.core.Response; + +@Path("get-cookie") +public class MockCookieAuthServer { + @GET + @Path("cookie") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public Response getCookie() { + return Response.status(200).entity("success").cookie(new NewCookie("cookieResponse", "cookieValueInReturn")).build(); + } +} diff --git a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/MultipartServerMock.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/MultipartServerMock.java new file mode 100644 index 000000000..00b5c324d --- /dev/null +++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/MultipartServerMock.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2019 Huawei Technologies Co., Ltd. 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.restapicall; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; +import org.glassfish.jersey.media.multipart.FormDataParam; + +import javax.ws.rs.Consumes; + +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.io.InputStream; + +@Path("file-upload") +public class MultipartServerMock { + + @POST + @Path("upload") + @Consumes(MediaType.MULTIPART_FORM_DATA) + public Response uploadFile( + @FormDataParam("file") InputStream inputStream, + @FormDataParam("file") FormDataContentDisposition fileDetail) { + return Response.status(200).entity(fileDetail.getFileName()).build(); + } +} diff --git a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java new file mode 100644 index 000000000..e4ec9147c --- /dev/null +++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java @@ -0,0 +1,73 @@ +/*- + * ============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.restapicall; + +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.restapicall.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 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 mm) { + List 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/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java new file mode 100644 index 000000000..bdf67dc45 --- /dev/null +++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -0,0 +1,741 @@ +/*- + * ============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.restapicall; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import java.net.URI; +import java.util.HashMap; +import java.util.Map; +import org.codehaus.jettison.json.JSONObject; +import org.glassfish.grizzly.http.server.HttpServer; +import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; +import org.glassfish.jersey.media.multipart.MultiPartFeature; +import org.glassfish.jersey.server.ResourceConfig; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestRestapiCallNode { + + private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class); + + + @Test + public void testDelete() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap<>(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "pwd1"); + p.put("httpMethod", "delete"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteWithPayload() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + ctx.setAttribute("prop.name", "site1"); + + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/sdwan-site.json"); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "pwd1"); + p.put("httpMethod", "delete"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testJsonSdwanVpnTopologyTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + ctx.setAttribute("prop.topology", "topoType"); + + ctx.setAttribute("prop.roles_length", "1"); + ctx.setAttribute("prop.roles[0]", "role1"); + + ctx.setAttribute("prop.siteAttachement_length", "2"); + + ctx.setAttribute("prop.siteAttachement[0].siteId", "site1"); + ctx.setAttribute("prop.siteAttachement[0].roles_length", "0"); + ctx.setAttribute("prop.siteAttachement[0].roles[0]", "role1"); + ctx.setAttribute("prop.siteAttachement[0].roles[1]", "role3"); + + ctx.setAttribute("prop.siteAttachement[1].siteId", "site2"); + ctx.setAttribute("prop.siteAttachement[1].roles_length", "1"); + ctx.setAttribute("prop.siteAttachement[1].roles[0]", "role2"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/sdwan-vpn-topology.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testJsonSdwanSiteTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + ctx.setAttribute("prop.name", "site1"); + + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/sdwan-site.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "3"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].clci", "clci"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].clci", "clci"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testInvalidRepeatTimes() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "a"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testInvalidTemplatePath() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resourcess/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testWithoutSkipSending() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "false"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testFormData() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "false"); + p.put("multipartFormData", "true"); + p.put("multipartFile", "src/test/resources/test-template.json"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testWithInvalidURI() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo. getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "false"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testVpnJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testSiteJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + ctx.setAttribute("prop.l3vpn.site1_name", "10000000-0000-0000-0000-000000000002"); + ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003"); + ctx.setAttribute("prop.l3vpn.entry1-id", "1"); + ctx.setAttribute("prop.l3vpn.sna1_name", "10000000-0000-0000-0000-000000000004"); + ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e"); + ctx.setAttribute("prop.l3vpn.ac1_id", "a8098c1a-f86e-11da-bd1a-00112444be1b"); + ctx.setAttribute("prop.l3vpn.ac1-peer-ip", "192.168.1.1"); + ctx.setAttribute("prop.l3vpn.ac1-ip", "192.168.1.2"); + ctx.setAttribute("prop.l3vpn.sna1_svlan", "100"); + ctx.setAttribute("prop.l3vpn.ac1_protocol", "static"); + ctx.setAttribute("prop.l3vpn.sna1-route.ip-prefix", "192.168.1.1/24"); + ctx.setAttribute("prop.l3vpn.sna1-route.next-hop", "192.168.1.4"); + + ctx.setAttribute("prop.l3vpn.site2_name", "10000000-0000-0000-0000-000000000005"); + ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006"); + ctx.setAttribute("prop.l3vpn.entry2-id", "1"); + ctx.setAttribute("prop.l3vpn.sna2_name", "10000000-0000-0000-0000-000000000007"); + ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a"); + ctx.setAttribute("prop.l3vpn.ac2_id", "a8098c1a-f86e-11da-bd1a-00112444be1c"); + ctx.setAttribute("prop.l3vpn.ac2-peer-ip", "192.168.1.6"); + ctx.setAttribute("prop.l3vpn.ac2-ip", "192.168.1.5"); + ctx.setAttribute("prop.l3vpn.sna2_svlan", "200"); + ctx.setAttribute("prop.l3vpn.ac2_protocol", "bgp"); + ctx.setAttribute("prop.l3vpn.peer2-ip", "192.168.1.7"); + ctx.setAttribute("prop.l3vpn.ac2_protocol_bgp_as", "200"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/l3smsitetemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/sites"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testVrfJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.vrf1-id", "10000000-0000-0000-0000-000000000007"); + ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003"); + ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e"); + ctx.setAttribute("prop.l3vpn.vrf2-id", "10000000-0000-0000-0000-000000000009"); + ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006"); + ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/l3smvrftemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vrf-attributes"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteVpnJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + Map p = new HashMap<>(); + //p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services" + + "/vpnservice=10000000-0000-0000-0000-000000000001"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "delete"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testL2DciTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.dci-connects.id", "Id1"); + ctx.setAttribute("prop.dci-connects.name", "Name1"); + ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1"); + ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2"); + ctx.setAttribute("prop.dci-connects.vni", "1"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/l2-dci-connects-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testL3DciTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.dci-connects.id", "Id1"); + ctx.setAttribute("prop.dci-connects.name", "Name1"); + ctx.setAttribute("prop.dci-connects.local_networks_length", "2"); + ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1"); + ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2"); + ctx.setAttribute("prop.dci-connects.vni", "1"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/l3-dci-connects-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + + } + + @Test + public void testControllerTokenTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.user", "admin"); + ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.password", "admin123"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/actokentemplate.json"); + p.put("restapiUrl", "https://ipwan:18002/controller/v2/tokens"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + + @Test + public void testDeleteNoneAsContentType() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap<>(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "pwd1"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testPostNoneAsContentType() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "none"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteOAuthType() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap<>(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("oAuthSignatureMethod", "plainTEXT"); + p.put("oAuthVersion", "1.0"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteAuthTypeBasic() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap<>(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "basic"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteAuthTypeDigest() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap<>(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "digest"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteAuthTypeOAuth() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap<>(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "oauth"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("oAuthSignatureMethod", "plainTEXT"); + p.put("oAuthVersion", "1.0"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteAuthTypeNoneOAuth() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap<>(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("oAuthSignatureMethod", "plainTEXT"); + p.put("oAuthVersion", "1.0"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + @Test + public void testDeleteAuthTypeNoneBasic() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap<>(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testInvalidDeleteAuthTypeOAuth() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap<>(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "oauth"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testInvalidDeleteAuthTypeBasic() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap<>(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "basic"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testInvalidDeleteAuthTypeDigest() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap<>(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("authType", "digest"); + p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); + p.put("oAuthConsumerSecret", "secret"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testMultipartFormData() throws SvcLogicException { + final ResourceConfig resourceConfig = new ResourceConfig( + MultipartServerMock.class, MultiPartFeature.class); + HttpServer server = GrizzlyHttpServerFactory.createHttpServer( + URI.create("http://localhost:8080/"),resourceConfig); + + Map p = new HashMap<>(); + p.put("multipartFormData", "true"); + p.put("format", "none"); + p.put("multipartFile", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://localhost:8080/file-upload/upload"); + + SvcLogicContext ctx = new SvcLogicContext(); + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + assertThat(ctx.getAttribute("response-code"), is("200")); + assertThat(ctx.getAttribute("httpResponse"), is( "test-template.json")); + server.shutdownNow(); + } + + @Test + public void testCookieResponse() throws SvcLogicException { + final ResourceConfig resourceConfig = new ResourceConfig( + MockCookieAuthServer.class); + HttpServer server = GrizzlyHttpServerFactory.createHttpServer( + URI.create("http://localhost:8080/"),resourceConfig); + + Map p = new HashMap<>(); + p.put("format", "none"); + p.put("httpMethod", "get"); + p.put("restapiUrl", "http://localhost:8080/get-cookie/cookie"); + p.put("dumpHeaders", "true"); + + SvcLogicContext ctx = new SvcLogicContext(); + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + assertThat(ctx.getAttribute("response-code"), is("200")); + assertThat(ctx.getAttribute("header.Set-Cookie"), is("cookieResponse=cookieValueInReturn;Version=1")); + server.shutdownNow(); + } + + @Test + public void testEmbeddedJsonTemplate() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + String complexObj = "{\"image_name\":\"Ubuntu 14.04\",\"service-instance-id\":\"1\",\"vnf-model-customization-uuid\":\"2f\",\"vnf-id\":\"3b\"}"; + ctx.setAttribute("reqId", "1235"); + ctx.setAttribute("subReqId", "054243"); + ctx.setAttribute("actionName", "CREATE"); + ctx.setAttribute("myPrefix", "2016-09-09 16:30:35.0"); + ctx.setAttribute("complexObj", complexObj); + RestapiCallNode rcn = new RestapiCallNode(); + String request = rcn.buildXmlJsonRequest(ctx, rcn.readFile("src/test/resources/testEmbeddedTemplate.json"), Format.JSON); + //This will throw a JSONException and fail the test case if rest api call node doesn't form valid JSON + JSONObject requestObj = new JSONObject(request); + } + +} diff --git a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java new file mode 100644 index 000000000..9812f2a11 --- /dev/null +++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java @@ -0,0 +1,262 @@ +/*- + * ============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.restapicall; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.ccsdk.sli.plugins.restapicall.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 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 = "" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " blah\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " blah blah\n" + + "\n"; + + String xmloutexpected = "" + + "\n" + + " \n" + + " blah\n" + + " \n" + + " blah blah\n" + + "\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(null, xmlin); + log.info(xmlout); + + Assert.assertEquals(xmloutexpected, xmlout); + } +} diff --git a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java new file mode 100644 index 000000000..326c9ca89 --- /dev/null +++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java @@ -0,0 +1,121 @@ +/*- + * ============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.restapicall; + +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.restapicall.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 listNameList = new HashSet(); + 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 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 listNameList = new HashSet(); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); + + Map 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 listNameList = new HashSet(); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); + listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); + + Map mm = XmlParser.convertToProperties(b.toString(), listNameList); + logProperties(mm); + in.close(); + } + + private void logProperties(Map mm) { + List 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/restapi-call-node/provider/src/test/resources/testEmbeddedTemplate.json b/restapi-call-node/provider/src/test/resources/testEmbeddedTemplate.json new file mode 100644 index 000000000..7f2377813 --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/testEmbeddedTemplate.json @@ -0,0 +1,20 @@ +{ + "commonHeader": { + "origin": "earth", + "requestId": ${reqId}, + "subRequestId": ${subReqId} + }, + "actions": { + "actionName": ${actionName}, + "mode": "sync" + }, + "payload": { + "assignment-request": { + "prefix": [ + ${myPrefix} + ], + "assignment-properties": ${'"complexObj} + } + } +} + -- cgit From bea0f101d0a4c7d1fbe8cb9d4a27491ba7d66dbf Mon Sep 17 00:00:00 2001 From: janani Date: Thu, 23 May 2019 15:45:14 +0530 Subject: Bug fix to add anyxml node. Anyxml node fix Change-Id: Ice40fde63ac8f589fa9358ebaf12c32247b0ae96 Issue-ID: CCSDK-1344 Signed-off-by: janani --- .../restconfapicall/RestconfApiCallNode.java | 35 +++++- .../plugins/restconfapicall/RestconfApiUtils.java | 12 ++ .../dfserializer/JsonSerializer.java | 12 +- .../dfserializer/PropertiesNodeJsonListener.java | 28 +++-- .../pnserializer/DefaultPropertiesNodeWalker.java | 5 +- .../yangserializers/pnserializer/InnerNode.java | 21 ++-- .../MdsalPropertiesNodeSerializer.java | 21 +++- .../pnserializer/MdsalPropertiesNodeUtils.java | 7 +- .../yangserializers/pnserializer/NodeType.java | 3 +- .../pnserializer/PropertiesNode.java | 20 ++++ .../dfserializer/DataFormatSerializerTest.java | 132 +++++++++++++++++++++ .../dfserializer/DataFormatUtilsTest.java | 64 ++++++++++ .../src/test/resources/yang/execution-service.yang | 43 +++++++ 13 files changed, 373 insertions(+), 30 deletions(-) create mode 100644 restconf-client/provider/src/test/resources/yang/execution-service.yang diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java index 3007b5a1b..ac0897e8f 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java @@ -43,10 +43,12 @@ import org.dom4j.DocumentHelper; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.plugins.restapicall.Format; import org.onap.ccsdk.sli.plugins.restapicall.HttpResponse; import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; import org.onap.ccsdk.sli.plugins.restapicall.RetryException; import org.onap.ccsdk.sli.plugins.restapicall.RetryPolicy; +import org.onap.ccsdk.sli.plugins.restapicall.XmlParser; import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatSerializer; import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatSerializerContext; import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerFactory; @@ -195,10 +197,14 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { String response = getResponse(ctx, p, pp, r); if (response != null) { - Map resProp = serializeResponse( - p, uri, response, insIdCtx); - for (Map.Entry pro : resProp.entrySet()) { - ctx.setAttribute(pro.getKey(), pro.getValue()); + try { + Map resProp = serializeResponse( + p, uri, response, insIdCtx); + for (Map.Entry pro : resProp.entrySet()) { + ctx.setAttribute(pro.getKey(), pro.getValue()); + } + } catch (SvcLogicException e) { + convertToNormalRes(ctx, p, pp, response); } } } catch (SvcLogicException e) { @@ -241,6 +247,27 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { } } + private void convertToNormalRes(SvcLogicContext ctx , + YangParameters p, String pp, String body) + throws SvcLogicException { + if (p.convertResponse) { + Map mm = null; + if (p.format == Format.XML) { + mm = XmlParser.convertToProperties(body, p.listNameList); + } else if (p.format == Format.JSON) { + mm = org.onap.ccsdk.sli.plugins.restapicall.JsonParser + .convertToProperties(body); + } + + if (mm != null) { + for (Map.Entry entry : mm.entrySet()) { + ctx.setAttribute(pp + entry.getKey(), + entry.getValue()); + } + } + } + } + /** * Serializes the request message to JSON or XML from the properties. * diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java index 505089c44..1309102b3 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiUtils.java @@ -167,6 +167,18 @@ public final class RestconfApiUtils { } secondHalf = path.substring(p[0].length() + 1); return firstHalf + COLON + secondHalf; + } else if (path.contains(SLASH)) { + String[] p = path.split(SLASH); + if (p.length > 4) { + String actual = p[3] + COLON + p[4]; + if (p.length > 5) { + secondHalf = path.substring( + p[1].length() + p[2].length() + actual.length() + 3); + path = actual + secondHalf; + } else { + path = actual; + } + } } return path; } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java index 1be1309bb..91adb8126 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/JsonSerializer.java @@ -22,18 +22,20 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.DefaultPropertiesNodeWalker; -import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; -import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNodeWalker; import java.io.IOException; import java.io.Writer; import java.util.List; import java.util.Map; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.DefaultPropertiesNodeWalker; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; +import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNodeWalker; + import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormat.JSON; -import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.*; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.JSON_LIS_ERR; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.JSON_TREE_ERR; /** * Representation of JSON serializer which encodes properties to JSON and diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeJsonListener.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeJsonListener.java index e51ccf7a6..0f03039e5 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeJsonListener.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/PropertiesNodeJsonListener.java @@ -21,6 +21,13 @@ package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer; import com.google.gson.stream.JsonWriter; + +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Collection; +import java.util.Map; + import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.DefaultPropertiesNodeWalker; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.LeafNode; @@ -29,12 +36,6 @@ import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNode; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.PropertiesNodeListener; import org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.RootNode; -import java.io.IOException; -import java.io.StringWriter; -import java.io.Writer; -import java.util.Collection; -import java.util.Map; - import static com.google.common.base.Strings.repeat; import static java.lang.String.format; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DfSerializerUtil.JSON_WRITE_ERR; @@ -116,6 +117,16 @@ public class PropertiesNodeJsonListener implements PropertiesNodeListener{ jsonWriter.value(val); break; + case ANY_XML_NODE: + jsonWriter.name(nodeName); + val = ((LeafNode) node).value(); + try { + jsonWriter.jsonValue(val); + } catch (IOException e) { + throw new SvcLogicException(JSON_WRITE_ERR, e); + } + break; + default: throw new SvcLogicException(format( NODE_TYPE_ERR, node.nodeType().toString())); @@ -143,6 +154,7 @@ public class PropertiesNodeJsonListener implements PropertiesNodeListener{ case SINGLE_INSTANCE_LEAF_NODE: case MULTI_INSTANCE_LEAF_NODE: + case ANY_XML_NODE: break; default: @@ -174,7 +186,9 @@ public class PropertiesNodeJsonListener implements PropertiesNodeListener{ PropertiesNode parent = node.parent(); if (parent instanceof RootNode || !parent.namespace().moduleName() .equals(node.namespace().moduleName())) { - return node.namespace().moduleName() + ":" + node.name(); + if (!parent.nonAppend()) { + return node.namespace().moduleName() + ":" + node.name(); + } } return node.name(); } diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeWalker.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeWalker.java index f23452653..5034530d5 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeWalker.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/DefaultPropertiesNodeWalker.java @@ -20,11 +20,11 @@ package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; - import java.util.Collection; import java.util.Map; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + /** * Implementation of properties node walker which helps in forming a new tree from properties node. * @@ -110,6 +110,7 @@ public class DefaultPropertiesNodeWalker implements Propert .children()); case SINGLE_INSTANCE_LEAF_NODE: case MULTI_INSTANCE_LEAF_NODE: + case ANY_XML_NODE: return null; default: throw new IllegalArgumentException("No more types allowed"); diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java index 0711a7cff..1cf99b2d4 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/InnerNode.java @@ -20,13 +20,13 @@ package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer; +import java.util.HashMap; +import java.util.Map; + import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import java.util.HashMap; -import java.util.Map; - import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.addToAugmentations; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.createNode; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getAugmentationNode; @@ -112,15 +112,18 @@ public abstract class InnerNode extends PropertiesNode { } AugmentationSchemaNode augSchema = null; - if (((DataSchemaNode) appInfo).isAugmenting()) { - augSchema = findCorrespondingAugment(((DataSchemaNode) this.appInfo()), - ((DataSchemaNode) appInfo)); - } - String uri = getUri(this, name, namespace); node = new LeafNode(name, namespace, uri, this, appInfo, type, value); - node.valueNs(valueNs); + + if (type != NodeType.ANY_XML_NODE) { + if (((DataSchemaNode) appInfo).isAugmenting()) { + augSchema = findCorrespondingAugment( + ((DataSchemaNode) this.appInfo()), + ((DataSchemaNode) appInfo)); + } + node.valueNs(valueNs); + } if (augSchema != null && !isNamespaceAsParent(this, node)) { addToAugmentations(augSchema, this, node); diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java index 0eca40d06..8a6e75668 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/MdsalPropertiesNodeSerializer.java @@ -44,6 +44,7 @@ import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPrope import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getRevision; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.getValueNamespace; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.MdsalPropertiesNodeUtils.resolveName; +import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.ANY_XML_NODE; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_LEAF_NODE; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.MULTI_INSTANCE_NODE; import static org.onap.ccsdk.sli.plugins.yangserializers.pnserializer.NodeType.SINGLE_INSTANCE_LEAF_NODE; @@ -81,6 +82,8 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer entry : paramMap.entrySet()) { String[] names = entry.getKey().split("\\."); for (int i = 0; i < names.length; i++) { @@ -97,6 +100,15 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer paramMap, + String rootUri) { + String isReqStr = rootUri + "." + "isNonAppend"; + String val = paramMap.get(isReqStr); + if (val != null && val.equals("true")) { + node.nonAppend(true); + } + } + /** * Converts all the params in the svc logic context into a valid param by * replacing the underscore in module name to colon at necessary places. @@ -150,7 +162,7 @@ public class MdsalPropertiesNodeSerializer extends PropertiesNodeSerializer augmentations = ArrayListMultimap.create(); /** @@ -106,6 +107,16 @@ public abstract class PropertiesNode { this.appInfo = appInfo; } + /** + * Sets to true if module name is required in forming a request; false + * otherwise. + * + * @param isNotReq true if required; false otherwise + */ + public void nonAppend(boolean isNotReq) { + this.nonAppend = isNotReq; + } + /** * Returns parent. * @@ -160,6 +171,15 @@ public abstract class PropertiesNode { return nodeType; } + /** + * Returns if module name is required. + * + * @return status of module name if required + */ + public boolean nonAppend() { + return nonAppend; + } + /** * Returns augmentations. * diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java index 45e8eb3f1..aa1e50d6a 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java @@ -46,8 +46,10 @@ import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.PATCH; import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.POST; import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.PUT; import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.parseUrl; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.DECODE_ANYXML_RESPONSE; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.DECODE_FROM_JSON_RPC; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.DECODE_FROM_XML_RPC; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_ANYXML; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_ID; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_ID_PUT; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_RPC; @@ -148,6 +150,24 @@ public class DataFormatSerializerTest { assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_ID)); } + /** + * Verifies encoding of parameters to JSON data format any xml in it. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeForAnyXml() throws SvcLogicException { + String pre = "execution-service_process."; + SvcLogicContext ctx = createAnyXmlAttList(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/api/v1/execution-service/process"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_ANYXML)); + } + /** * Verifies encoding of parameters to JSON data format with identity-ref * and inter-file linking for put operation-type. @@ -500,6 +520,27 @@ public class DataFormatSerializerTest { verifyAttListRpc(ctx, outPre); } + /** + * Verifies encoding of and decoding from, JSON for ANYXML. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void codecForNormalAnyXml() throws SvcLogicException { + createMockForDecode(DECODE_ANYXML_RESPONSE); + String inPre = "execution-service_process."; + SvcLogicContext ctx = createAnyXmlAttList(inPre); + p.put("dirPath", "src/test/resources"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "pp"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/api/v1/execution-service/process"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_ANYXML)); + verifyOutputOfAnyXml(ctx); + } + /** * Verifies encoding of and decoding from, XML respectively for data * format with containers, grouping and augment. @@ -546,6 +587,12 @@ public class DataFormatSerializerTest { String url8 = "https://localhost:8282/restconf/data/" + actVal; String url9 = "http://182.2.61.24:2250/restconf/data/" + actVal; String url10 = "https://182.2.61.24:2250/restconf/operations/" + actVal; + String url11 = "https://182.2.61.24:2250/api/v1/execution-service" + + "/process"; + String url12 = "https://182.2.61.24:2250/api/v1/execution-service" + + "/process/payload"; + String url13 = "https://182.2.61.24:2250/api/v1/execution-service" + + "/process/payload/"; String val1 = parseUrl(url1, POST); String val2 = parseUrl(url2, GET); String val3 = parseUrl(url3, PATCH); @@ -556,6 +603,9 @@ public class DataFormatSerializerTest { String val8 = parseUrl(url8, POST); String val9 = parseUrl(url9, GET); String val10 = parseUrl(url10, POST); + String val11 = parseUrl(url11, POST); + String val12 = parseUrl(url12, POST); + String val13 = parseUrl(url13, POST); assertThat(val1, is(actVal)); assertThat(val2, is(actVal)); assertThat(val3, is(actVal)); @@ -566,6 +616,43 @@ public class DataFormatSerializerTest { assertThat(val8, is(actVal)); assertThat(val9, is(actVal)); assertThat(val10, is(actVal)); + assertThat(val11, is("execution-service:process")); + assertThat(val12, is("execution-service:process/payload")); + assertThat(val13, is("execution-service:process/payload/")); + } + + /** + * Creates attribute list for encoding JSON or XML with ANYXML YANG + * file. + * + * @param pre prefix + * @return service logic context + */ + private SvcLogicContext createAnyXmlAttList(String pre) { + SvcLogicContext ctx = new SvcLogicContext(); + String pre1 = pre + "commonHeader."; + String pre2 = pre + "actionIdentifiers."; + ctx.setAttribute(pre + "isNonAppend", "true"); + ctx.setAttribute(pre1 + "originatorId", "SDNC_DG"); + ctx.setAttribute(pre1 + "requestId", "123456-1000"); + ctx.setAttribute(pre1 + "subRequestId", "sub-123456-1000"); + ctx.setAttribute(pre2 + "blueprintName", + "baseconfiguration"); + ctx.setAttribute(pre2 + "blueprintVersion", "1.0.0"); + ctx.setAttribute(pre2 + "actionName", "assign-activate"); + ctx.setAttribute(pre2 + "mode", "sync"); + ctx.setAttribute(pre + "payload." + + "template-prefix", "vDNS-test"); + ctx.setAttribute(pre + "payload.resource-assignment-request" + + ".resource-assignment-properties", + "{\n" + + " \"service-instance-id\": " + + "\"1234\",\n" + + " \"vnf-id\": \"3526\",\n" + + " \"customer-name\": \"htipl\",\n" + + " \"subscriber-name\": \"huawei\"\n" + + " }"); + return ctx; } /** @@ -834,6 +921,51 @@ public class DataFormatSerializerTest { assertThat(ctx.getAttribute(pre + "cont13.leaf28"), is("abc")); } + /** + * Verifies the attribute list for decoding from JSON or XML with + * ANYXML YANG file. + * + * @param ctx service logic context + */ + private void verifyOutputOfAnyXml(SvcLogicContext ctx) { + System.out.println(ctx.getAttribute("pp.status.eventType")); + assertThat(ctx.getAttribute("pp.status.eventType"), is( + "EVENT_COMPONENT_EXECUTED")); + assertThat(ctx.getAttribute("pp.actionIdentifiers.blueprintName"), + is("golden")); + assertThat(ctx.getAttribute("pp.actionIdentifiers.mode"), + is("sync")); + assertThat(ctx.getAttribute("pp.stepData.name"), + is("resource-assignment")); + assertThat(ctx.getAttribute("pp.status.message"), + is("success")); + assertThat(ctx.getAttribute("pp.commonHeader.originatorId"), + is("System")); + assertThat(ctx.getAttribute("pp.status.code"), + is("200")); + assertThat(ctx.getAttribute("pp.commonHeader.requestId"), + is("1234")); + assertThat(ctx.getAttribute("pp.commonHeader.subRequestId"), + is("1234-12234")); + assertThat(ctx.getAttribute("pp.commonHeader.timestamp"), + is("2019-05-18T23:42:41.658Z")); + assertThat(ctx.getAttribute("pp.status.timestamp"), + is("2019-05-18T23:42:41.950Z")); + assertThat(ctx.getAttribute("pp.actionIdentifiers.blueprintV" + + "ersion"), is("1.0.0")); + assertThat(ctx.getAttribute("pp.actionIdentifiers.actionName"), + is("resource-assignment")); + assertThat(ctx.getAttribute("pp.payload.resource-assignment-resp" + + "onse.meshed-template.vf-module-1"), + is("\n This i" + + "s the Virtual Firewall entity\n" + + " 10.0.101.20/24\n" + + "")); + assertThat(ctx.getAttribute("pp.actionIdentifiers.actionName"), + is("resource-assignment")); + } + + /** * Captures the data format messages by mocking it, which can be used in * testing the value. diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java index a7814e10e..c1bb71985 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java @@ -69,6 +69,31 @@ public final class DataFormatUtilsTest { " \"identity-test:l\": \"abc\"\n" + "}"; + static final String ENCODE_TO_ANYXML = "{\n" + + " \"actionIdentifiers\": {\n" + + " \"mode\": \"sync\",\n" + + " \"blueprintName\": \"baseconfiguration\",\n" + + " \"blueprintVersion\": \"1.0.0\",\n" + + " \"actionName\": \"assign-activate\"\n" + + " },\n" + + " \"payload\": {\n" + + " \"template-prefix\": \"vDNS-test\",\n" + + " \"resource-assignment-request\": {\n" + + " \"resource-assignment-properties\": {\n" + + " \"service-instance-id\": \"1234\",\n" + + " \"vnf-id\": \"3526\",\n" + + " \"customer-name\": \"htipl\",\n" + + " \"subscriber-name\": \"huawei\"\n" + + " }\n" + + " }\n" + + " },\n" + + " \"commonHeader\": {\n" + + " \"subRequestId\": \"sub-123456-1000\",\n" + + " \"requestId\": \"123456-1000\",\n" + + " \"originatorId\": \"SDNC_DG\"\n" + + " }\n" + + "}"; + static final String ENCODE_TO_JSON_ID_PUT = "{\n" + " \"identity-test:test\": {\n" + " \"con1\": {" + addSpace(ENCODE_TO_JSON_ID_COMMON, 4) + @@ -485,6 +510,45 @@ public final class DataFormatUtilsTest { " }\n" + "}"; + static final String DECODE_ANYXML_RESPONSE = "{\n" + + " \"commonHeader\": {\n" + + " \"timestamp\": \"2019-05-18T23:42:41.658Z\",\n" + + " \"originatorId\": \"System\",\n" + + " \"requestId\": \"1234\",\n" + + " \"subRequestId\": \"1234-12234\",\n" + + " \"flags\": null\n" + + " },\n" + + " \"actionIdentifiers\": {\n" + + " \"blueprintName\": \"golden\",\n" + + " \"blueprintVersion\": \"1.0.0\",\n" + + " \"actionName\": \"resource-assignment\",\n" + + " \"mode\": \"sync\"\n" + + " },\n" + + " \"status\": {\n" + + " \"code\": 200,\n" + + " \"eventType\": \"EVENT_COMPONENT_EXECUTED\",\n" + + " \"timestamp\": \"2019-05-18T23:42:41.950Z\",\n" + + " \"errorMessage\": null,\n" + + " \"message\": \"success\"\n" + + " },\n" + + " \"payload\": {\n" + + " \"resource-assignment-response\": {\n" + + " \"meshed-template\": {\n" + + " \"vf-module-1\": \"\\n " + + " This is the Virtual Firewall entity\\n 10.0.101.20/24\\n\"\n" + + " }\n" + + " }\n" + + " },\n" + + " \"stepData\": {\n" + + " \"name\": \"resource-assignment\",\n" + + " \"properties\": {\n" + + " \"resource-assignment-params\": null,\n" + + " \"status\": null\n" + + " }\n" + + " }\n" + + "}"; + static final String ENCODE_TO_XML_RPC = "\n" + "\n" + diff --git a/restconf-client/provider/src/test/resources/yang/execution-service.yang b/restconf-client/provider/src/test/resources/yang/execution-service.yang new file mode 100644 index 000000000..d7cf68f12 --- /dev/null +++ b/restconf-client/provider/src/test/resources/yang/execution-service.yang @@ -0,0 +1,43 @@ +module execution-service { + yang-version 1.1; + namespace "cds:workflow:rest"; + prefix "cds"; + + revision "2019-05-21"; + + container process { + container commonHeader { + leaf originatorId { + type string; + } + leaf requestId { + type string; + } + leaf subRequestId { + type string; + } + } + container actionIdentifiers { + leaf blueprintName { + type string; + } + leaf blueprintVersion { + type string; + } + leaf actionName { + type string; + } + leaf mode { + type string; + } + } + container payload { + leaf-list template-prefix { + type string; + } + container resource-assignment-request { + anyxml resource-assignment-properties; + } + } + } +} -- cgit From a7430938d2b83b6fe9b03360ff54206fd1259885 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Fri, 17 May 2019 21:09:28 +0000 Subject: implement generic retry and partners in restapicallnode implement generic retry and partners in restapicallnode Change-Id: I436622dda5a5a83b029c935b929f43e05d37a2a0 Issue-ID: CCSDK-1343 Signed-off-by: Smokowski, Kevin (ks6305) --- .../ccsdk/sli/plugins/restapicall/Parameters.java | 1 + .../sli/plugins/restapicall/PartnerDetails.java | 14 + .../sli/plugins/restapicall/RestapiCallNode.java | 169 ++++--- .../ccsdk/sli/plugins/restapicall/RetryPolicy.java | 59 +-- .../sli/plugins/restapicall/RetryPolicyStore.java | 50 -- .../plugins/restapicall/TestRestapiCallNode.java | 348 +++----------- .../plugins/restapicall/TestRestapiCallNode.java | 511 +++++++++++++++++++++ .../provider/src/test/resources/partners.json | 16 + .../restconfapicall/RestconfApiCallNode.java | 57 +-- 9 files changed, 747 insertions(+), 478 deletions(-) mode change 100644 => 100755 restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java create mode 100755 restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/PartnerDetails.java mode change 100644 => 100755 restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java delete mode 100644 restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java mode change 100644 => 100755 restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java create mode 100755 restapi-call-node/provider/src/test/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java create mode 100755 restapi-call-node/provider/src/test/resources/partners.json diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java old mode 100644 new mode 100755 index aeb07c4d6..8b9cdc39c --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java @@ -26,6 +26,7 @@ import java.util.Set; public class Parameters { public String templateFileName; public String restapiUrl; + public String restapiUrlSuffix; public String restapiUser; public String restapiPassword; public Format format; diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/PartnerDetails.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/PartnerDetails.java new file mode 100755 index 000000000..1cd4b99bb --- /dev/null +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/PartnerDetails.java @@ -0,0 +1,14 @@ +package org.onap.ccsdk.sli.plugins.restapicall; + +public class PartnerDetails { + protected String username; + protected String password; + protected String url; + + public PartnerDetails(String username, String password, String url) { + this.username = username; + this.password = password; + this.url = url; + } + +} diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java old mode 100644 new mode 100755 index 9b50eaa44..34e5dec21 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -37,6 +37,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -57,7 +58,10 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; +import javax.ws.rs.core.Response; import org.apache.commons.lang3.StringUtils; +import org.codehaus.jettison.json.JSONException; +import org.codehaus.jettison.json.JSONObject; import org.glassfish.jersey.client.ClientProperties; import org.glassfish.jersey.client.HttpUrlConnectorProvider; import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; @@ -66,6 +70,8 @@ import org.glassfish.jersey.client.oauth1.OAuth1ClientSupport; import org.glassfish.jersey.media.multipart.MultiPart; import org.glassfish.jersey.media.multipart.MultiPartFeature; import org.glassfish.jersey.media.multipart.file.FileDataBodyPart; +import org.glassfish.jersey.client.oauth1.ConsumerCredentials; +import org.glassfish.jersey.client.oauth1.OAuth1ClientSupport; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; @@ -74,34 +80,36 @@ import org.slf4j.LoggerFactory; public class RestapiCallNode implements SvcLogicJavaPlugin { - protected static final String DME2_PROPERTIES_FILE_NAME = "dme2.properties"; + protected static final String PARTNERS_FILE_NAME = "partners.json"; protected static final String UEB_PROPERTIES_FILE_NAME = "ueb.properties"; protected static final String DEFAULT_PROPERTIES_DIR = "/opt/onap/ccsdk/data/properties"; protected static final String PROPERTIES_DIR_KEY = "SDNC_CONFIG_DIR"; private static final Logger log = LoggerFactory.getLogger(RestapiCallNode.class); - protected RetryPolicyStore retryPolicyStore; private String uebServers; private String defaultUebTemplateFileName = "/opt/bvc/restapi/templates/default-ueb-message.json"; private String responseReceivedMessage = "Response received. Time: {}"; private String responseHttpCodeMessage = "HTTP response code: {}"; private String requestPostingException = "Exception while posting http request to client "; - private static String skipSendingMessage = "skipSending"; - private static String responsePrefix = "responsePrefix"; - private static String restapiUrlString = "restapiUrl"; + protected static final String skipSendingMessage = "skipSending"; + protected static final String responsePrefix = "responsePrefix"; + protected static final String restapiUrlString = "restapiUrl"; + protected static final String restapiUserKey = "restapiUser"; + protected static final String restapiPasswordKey = "restapiPassword"; - public RestapiCallNode() { - String configDir = System.getProperty(PROPERTIES_DIR_KEY, DEFAULT_PROPERTIES_DIR); + protected HashMap partnerStore; - try (FileInputStream in = new FileInputStream(configDir + "/" + DME2_PROPERTIES_FILE_NAME)) { - Properties props = new Properties(); - props.load(in); - retryPolicyStore = new RetryPolicyStore(); - retryPolicyStore.setProxyServers(props.getProperty("proxyUrl")); - log.info("DME2 support enabled"); + public RestapiCallNode() { + String configDir = System.getProperty(PROPERTIES_DIR_KEY, DEFAULT_PROPERTIES_DIR); + try { + String jsonString = readFile(configDir + "/" + PARTNERS_FILE_NAME); + JSONObject partners = new JSONObject(jsonString); + partnerStore = new HashMap(); + loadPartners(partners); + log.info("Partners support enabled"); } catch (Exception e) { - log.warn("DME2 properties could not be read, DME2 support will not be enabled.", e); + log.warn("Partners file could not be read, Partner support will not be enabled.", e); } try (FileInputStream in = new FileInputStream(configDir + "/" + UEB_PROPERTIES_FILE_NAME)) { @@ -114,6 +122,35 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } } + protected void loadPartners(JSONObject partners) { + Iterator keys = partners.keys(); + String partnerUserKey = "user"; + String partnerPasswordKey = "password"; + String partnerUrlKey = "url"; + + while (keys.hasNext()) { + String partnerKey = keys.next(); + try { + JSONObject partnerObject = (JSONObject) partners.get(partnerKey); + if (partnerObject.has(partnerUserKey) && partnerObject.has(partnerPasswordKey)) { + String url = null; + if (partnerObject.has(partnerUrlKey)) { + url = partnerObject.getString(partnerUrlKey); + } + String userName = partnerObject.getString(partnerUserKey); + String password = partnerObject.getString(partnerPasswordKey); + PartnerDetails details = new PartnerDetails(userName, password, url); + partnerStore.put(partnerKey, details); + log.info("mapped partner using partner key " + partnerKey); + } else { + log.info("Partner " + partnerKey + " is missing required keys, it won't be mapped"); + } + } catch (JSONException e) { + log.info("Couldn't map the partner using partner key " + partnerKey, e); + } + } + } + /** * Returns parameters from the parameter map. * @@ -125,14 +162,21 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { public static Parameters getParameters(Map paramMap, Parameters p) throws SvcLogicException { - p.templateFileName = parseParam(paramMap, "templateFileName", + + p.templateFileName = parseParam(paramMap, "templateFileName", false, null); p.requestBody = parseParam(paramMap, "requestBody", false, null); p.restapiUrl = parseParam(paramMap, restapiUrlString, true, null); validateUrl(p.restapiUrl); - p.restapiUser = parseParam(paramMap, "restapiUser", false, null); - p.restapiPassword = parseParam(paramMap, "restapiPassword", false, + p.restapiUrlSuffix = parseParam(paramMap, "restapiUrlSuffix", + false, null); + p.restapiUser = parseParam(paramMap, restapiUserKey, false, null); + p.restapiPassword = parseParam(paramMap, restapiPasswordKey, false, null); + if(p.restapiUrlSuffix != null) { + p.restapiUrl = p.restapiUrl + p.restapiUrlSuffix; + validateUrl(p.restapiUrl); + } p.oAuthConsumerKey = parseParam(paramMap, "oAuthConsumerKey", false, null); p.oAuthConsumerSecret = parseParam(paramMap, "oAuthConsumerSecret", @@ -185,14 +229,19 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { * @param restapiUrl rest api URL * @throws SvcLogicException when URL validation fails */ - private static void validateUrl(String restapiUrl) - throws SvcLogicException { - try { - URI.create(restapiUrl); - } catch (IllegalArgumentException e) { - throw new SvcLogicException("Invalid input of url " - + e.getLocalizedMessage(), e); - } + private static void validateUrl(String restapiUrl) throws SvcLogicException { + if (restapiUrl.contains(",")) { + String[] urls = restapiUrl.split(","); + for(String url : urls) { + validateUrl(url); + } + } else { + try { + URI.create(restapiUrl); + } catch (IllegalArgumentException e) { + throw new SvcLogicException("Invalid input of url " + e.getLocalizedMessage(), e); + } + } } /** @@ -262,14 +311,6 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { return value.toString(); } - public RetryPolicyStore getRetryPolicyStore() { - return retryPolicyStore; - } - - public void setRetryPolicyStore(RetryPolicyStore retryPolicyStore) { - this.retryPolicyStore = retryPolicyStore; - } - /** * Allows Directed Graphs the ability to interact with REST APIs. * @param paramMap HashMap of parameters passed by the DG to this function @@ -293,7 +334,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { * * * - * + * * * *
convertResponse Optionalwhether the response should be convertedtrue or false
customHttpHeadersOptionala list additional http headers to be passed in, follow the format in the exampleX-CSI-MessageId=messageId,headerFieldName=headerFieldValue
dumpHeadersOptionalwhen true writes http header content to context memorytrue or false
partnerOptionalneeded for DME2 callsdme2proxy
partnerOptionalused to retrieve username, password and url if partner store existsaaf
returnRequestPayloadOptionalused to return payload built in the requesttrue or false
@@ -306,15 +347,17 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { sendRequest(paramMap, ctx, null); } - public void sendRequest(Map paramMap, SvcLogicContext ctx, Integer retryCount) + protected void sendRequest(Map paramMap, SvcLogicContext ctx, RetryPolicy retryPolicy) throws SvcLogicException { - RetryPolicy retryPolicy = null; HttpResponse r = new HttpResponse(); try { + handlePartner(paramMap); Parameters p = getParameters(paramMap, new Parameters()); - if (p.partner != null) { - retryPolicy = retryPolicyStore.getRetryPolicy(p.partner); + if(p.restapiUrl.contains(",") && retryPolicy == null) { + String[] urls = p.restapiUrl.split(","); + retryPolicy = new RetryPolicy(urls,urls.length * 2); + p.restapiUrl = urls[0]; } String pp = p.responsePrefix != null ? p.responsePrefix + '.' : ""; @@ -367,36 +410,20 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { if (retryPolicy == null || !shouldRetry) { setFailureResponseStatus(ctx, prefix, e.getMessage(), r); } else { - if (retryCount == null) { - retryCount = 0; - } - String retryMessage = retryCount + " attempts were made out of " + retryPolicy.getMaximumRetries() + - " maximum retries."; - log.debug(retryMessage); + log.debug(retryPolicy.getRetryMessage()); try { - retryCount = retryCount + 1; - if (retryCount < retryPolicy.getMaximumRetries() + 1) { - URI uri = new URI(paramMap.get(restapiUrlString)); - String hostname = uri.getHost(); - String retryString = retryPolicy.getNextHostName(uri.toString()); - URI uriTwo = new URI(retryString); - URI retryUri = UriBuilder.fromUri(uri).host(uriTwo.getHost()).port(uriTwo.getPort()).scheme( - uriTwo.getScheme()).build(); - paramMap.put(restapiUrlString, retryUri.toString()); - log.debug("URL was set to {}", retryUri.toString()); - log.debug("Failed to communicate with host {}. Request will be re-attempted using the host {}.", - hostname, retryString); - log.debug("This is retry attempt {} out of {}", retryCount, retryPolicy.getMaximumRetries()); - sendRequest(paramMap, ctx, retryCount); + //calling getNextHostName increments the retry count so it should be called before shouldRetry + String retryString = retryPolicy.getNextHostName(); + if (retryPolicy.shouldRetry()) { + paramMap.put(restapiUrlString, retryString); + log.debug("retry attempt {} will use the retry url {}", retryPolicy.getRetryCount(), retryString); + sendRequest(paramMap, ctx, retryPolicy); } else { - log.debug("Maximum retries reached, calling setFailureResponseStatus."); + log.debug("Maximum retries reached, won't attempt to retry. Calling setFailureResponseStatus."); setFailureResponseStatus(ctx, prefix, e.getMessage(), r); } } catch (Exception ex) { - log.error("Could not attempt retry.", ex); - String retryErrorMessage = - "Retry attempt has failed. No further retry shall be attempted, calling " + - "setFailureResponseStatus."; + String retryErrorMessage = "Retry attempt " + retryPolicy.getRetryCount() + "has failed with error message " + ex.getMessage(); setFailureResponseStatus(ctx, prefix, retryErrorMessage, r); } } @@ -407,6 +434,18 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } } + protected void handlePartner(Map paramMap) { + String partner = paramMap.get("partner"); + if (partner != null && partner.length() > 0) { + PartnerDetails details = partnerStore.get(partner); + paramMap.put(restapiUserKey, details.username); + paramMap.put(restapiPasswordKey, details.password); + if(paramMap.get(restapiUrlString) == null) { + paramMap.put(restapiUrlString, details.url); + } + } + } + protected String buildXmlJsonRequest(SvcLogicContext ctx, String template, Format format) throws SvcLogicException { log.info("Building {} started", format); @@ -571,6 +610,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { .builder(new ConsumerCredentials(p.oAuthConsumerKey, p.oAuthConsumerSecret)) .version(p.oAuthVersion).signatureMethod(p.oAuthSignatureMethod).feature().build(); client.register(oAuth1Feature); + } } else { if (p.authtype == AuthType.DIGEST) { @@ -636,13 +676,12 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { WebTarget webTarget = addAuthType(client, p).target(p.restapiUrl); - log.info("Sending request:"); + log.info("Sending request below to url " + p.restapiUrl); log.info(request); long t1 = System.currentTimeMillis(); HttpResponse r = new HttpResponse(); r.code = 200; - String accept = p.accept; if(accept == null) { accept = p.format == Format.XML ? "application/xml" : "application/json"; diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java index 54c86fefc..65684d937 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java @@ -21,40 +21,41 @@ */ package org.onap.ccsdk.sli.plugins.restapicall; - public class RetryPolicy { private String[] hostnames; private Integer maximumRetries; - - public RetryPolicy(String[] hostnames, Integer maximumRetries){ - this.hostnames = hostnames; - this.maximumRetries = maximumRetries; + + private int position; + + private int retryCount; + public RetryPolicy(String[] hostnames, Integer maximumRetries) { + this.hostnames = hostnames; + this.maximumRetries = maximumRetries; + + this.position = 0; + + this.retryCount = 0; } - public Integer getMaximumRetries() { - return maximumRetries; + return maximumRetries; + } + public int getRetryCount() { + return retryCount; + } + public Boolean shouldRetry() { + return retryCount < maximumRetries + 1; + } + public String getRetryMessage() { + return retryCount + " retry attempts were made out of " + maximumRetries + " maximum retry attempts."; } - 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 String getNextHostName() throws RetryException { + retryCount++; + position++; + + if (position > hostnames.length - 1) { + position = 0; + } + return hostnames[position]; } - -} +} \ No newline at end of file diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java deleted file mode 100644 index f68b851d3..000000000 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicyStore.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * Modifications Copyright © 2018 IBM. - * ================================================================================ - * 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.restapicall; - -import java.util.HashMap; - -public class RetryPolicyStore { - HashMap retryPolicies; - public String proxyServers; - - public RetryPolicyStore() { - retryPolicies = new HashMap<>(); - } - - 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 RetryPolicy getRetryPolicy(String policyName) { - return (this.retryPolicies.get(policyName)); - } - -} diff --git a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java old mode 100644 new mode 100755 index bdf67dc45..0704d297a --- a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -21,16 +21,19 @@ package org.onap.ccsdk.sli.plugins.restapicall; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import java.net.URI; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import java.util.HashMap; import java.util.Map; + import org.codehaus.jettison.json.JSONObject; import org.glassfish.grizzly.http.server.HttpServer; import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; import org.glassfish.jersey.media.multipart.MultiPartFeature; import org.glassfish.jersey.server.ResourceConfig; + import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; @@ -40,9 +43,9 @@ import org.slf4j.LoggerFactory; public class TestRestapiCallNode { + @SuppressWarnings("unused") private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class); - @Test public void testDelete() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); @@ -64,7 +67,6 @@ public class TestRestapiCallNode { ctx.setAttribute("prop.name", "site1"); - Map p = new HashMap<>(); p.put("templateFileName", "src/test/resources/sdwan-site.json"); p.put("restapiUrl", "https://echo.getpostman.com/delete"); @@ -77,61 +79,6 @@ public class TestRestapiCallNode { rcn.sendRequest(p, ctx); } - @Test - public void testJsonSdwanVpnTopologyTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - ctx.setAttribute("prop.topology", "topoType"); - - ctx.setAttribute("prop.roles_length", "1"); - ctx.setAttribute("prop.roles[0]", "role1"); - - ctx.setAttribute("prop.siteAttachement_length", "2"); - - ctx.setAttribute("prop.siteAttachement[0].siteId", "site1"); - ctx.setAttribute("prop.siteAttachement[0].roles_length", "0"); - ctx.setAttribute("prop.siteAttachement[0].roles[0]", "role1"); - ctx.setAttribute("prop.siteAttachement[0].roles[1]", "role3"); - - ctx.setAttribute("prop.siteAttachement[1].siteId", "site2"); - ctx.setAttribute("prop.siteAttachement[1].roles_length", "1"); - ctx.setAttribute("prop.siteAttachement[1].roles[0]", "role2"); - - Map p = new HashMap<>(); - p.put("templateFileName", "src/test/resources/sdwan-vpn-topology.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testJsonSdwanSiteTemplate() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - ctx.setAttribute("prop.name", "site1"); - - - Map p = new HashMap<>(); - p.put("templateFileName", "src/test/resources/sdwan-site.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - @Test public void testJsonTemplate() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); @@ -250,33 +197,6 @@ public class TestRestapiCallNode { rcn.sendRequest(p, ctx); } - @Test(expected = SvcLogicException.class) - public void testFormData() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); - ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); - - Map p = new HashMap<>(); - p.put("templateFileName", "src/test/resources/test-template.json"); - p.put("restapiUrl", "http://echo.getpostman.com"); - p.put("restapiUser", "user1"); - p.put("restapiPassword", "abc123"); - p.put("format", "json"); - p.put("httpMethod", "post"); - p.put("responsePrefix", "response"); - p.put("skipSending", "false"); - p.put("multipartFormData", "true"); - p.put("multipartFile", "src/test/resources/test-template.json"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } @Test(expected = SvcLogicException.class) public void testWithInvalidURI() throws SvcLogicException { @@ -525,202 +445,74 @@ public class TestRestapiCallNode { RestapiCallNode rcn = new RestapiCallNode(); rcn.sendRequest(p, ctx); } - - @Test - public void testDeleteOAuthType() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("oAuthSignatureMethod", "plainTEXT"); - p.put("oAuthVersion", "1.0"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteAuthTypeBasic() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "basic"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteAuthTypeDigest() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "digest"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteAuthTypeOAuth() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "oauth"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("oAuthSignatureMethod", "plainTEXT"); - p.put("oAuthVersion", "1.0"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test - public void testDeleteAuthTypeNoneOAuth() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("oAuthSignatureMethod", "plainTEXT"); - p.put("oAuthVersion", "1.0"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - @Test - public void testDeleteAuthTypeNoneBasic() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("restapiUser", "admin"); - p.put("restapiPassword", "admin123"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testInvalidDeleteAuthTypeOAuth() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "oauth"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testInvalidDeleteAuthTypeBasic() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "basic"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testInvalidDeleteAuthTypeDigest() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - - Map p = new HashMap<>(); - p.put("restapiUrl", "https://echo.getpostman.com/delete"); - p.put("authType", "digest"); - p.put("oAuthConsumerKey", "f2a1ed52710d4533bde25be6da03b6e3"); - p.put("oAuthConsumerSecret", "secret"); - p.put("httpMethod", "delete"); - p.put("format", "none"); - p.put("skipSending", "true"); - - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - } - + /* + * { + "partnerOne": { + "url": "http://localhost:7001" 4 http://uebsb93kcdc.it.att.com:3904", + "test": "/metrics" + }, + "partnerTwo": { + "url": "http://localhost:7002", + "user": "controller_user", + "password": "P@ssword", + "test": "/metrics" + }, + "partnerThree": { + "url": "http://localhost:7003", + "user": "controller_admin" + } +} + */ @Test - public void testMultipartFormData() throws SvcLogicException { - final ResourceConfig resourceConfig = new ResourceConfig( - MultipartServerMock.class, MultiPartFeature.class); - HttpServer server = GrizzlyHttpServerFactory.createHttpServer( - URI.create("http://localhost:8080/"),resourceConfig); + public void testPartners() throws Exception{ + String partnerTwoKey = "partnerTwo"; + String partnerTwoUsername = "controller_user"; + String partnerTwoPassword = "P@ssword"; - Map p = new HashMap<>(); - p.put("multipartFormData", "true"); - p.put("format", "none"); - p.put("multipartFile", "src/test/resources/test-template.json"); - p.put("restapiUrl", "http://localhost:8080/file-upload/upload"); - - SvcLogicContext ctx = new SvcLogicContext(); + System.setProperty("SDNC_CONFIG_DIR", "src/test/resources"); RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - assertThat(ctx.getAttribute("response-code"), is("200")); - assertThat(ctx.getAttribute("httpResponse"), is( "test-template.json")); - server.shutdownNow(); + assertNull(rcn.partnerStore.get("partnerOne")); + PartnerDetails details = rcn.partnerStore.get(partnerTwoKey); + assertEquals(partnerTwoUsername,details.username); + assertEquals(partnerTwoPassword,details.password); + assertNull(rcn.partnerStore.get("partnerThree")); + + //In this scenario the caller expects username, password and url to be picked up from the partners json + Map paramMap = new HashMap(); + paramMap.put("partner", partnerTwoKey); + rcn.handlePartner(paramMap ); + assertEquals(partnerTwoUsername,paramMap.get(rcn.restapiUserKey)); + assertEquals(partnerTwoPassword,paramMap.get(rcn.restapiPasswordKey)); + assertEquals("http://localhost:7002",paramMap.get(rcn.restapiUrlString)); + + //In this scenario the caller expects username, password and url to be picked up from the partners json + //the provided suffix will be appended to the default url from the partners json + paramMap = new HashMap(); + paramMap.put("partner", partnerTwoKey); + paramMap.put("restapiUrlSuffix", "/networking/v1/instance/3"); + rcn.handlePartner(paramMap); + Parameters p = new Parameters(); + RestapiCallNode.getParameters(paramMap, p); + assertEquals(partnerTwoUsername,p.restapiUser); + assertEquals(partnerTwoPassword,p.restapiPassword); + assertEquals("http://localhost:7002/networking/v1/instance/3",p.restapiUrl); } - + @Test - public void testCookieResponse() throws SvcLogicException { - final ResourceConfig resourceConfig = new ResourceConfig( - MockCookieAuthServer.class); - HttpServer server = GrizzlyHttpServerFactory.createHttpServer( - URI.create("http://localhost:8080/"),resourceConfig); - - Map p = new HashMap<>(); - p.put("format", "none"); - p.put("httpMethod", "get"); - p.put("restapiUrl", "http://localhost:8080/get-cookie/cookie"); - p.put("dumpHeaders", "true"); - - SvcLogicContext ctx = new SvcLogicContext(); - RestapiCallNode rcn = new RestapiCallNode(); - rcn.sendRequest(p, ctx); - assertThat(ctx.getAttribute("response-code"), is("200")); - assertThat(ctx.getAttribute("header.Set-Cookie"), is("cookieResponse=cookieValueInReturn;Version=1")); - server.shutdownNow(); + public void retryPolicyBean() throws Exception { + Integer retries = 3; + String first = "http://localhost:7001"; + String second = "http://localhost:7001"; + + RetryPolicy p = new RetryPolicy(new String[] {first,second}, retries); + assertEquals(retries,p.getMaximumRetries()); + assertNotNull(p.getRetryMessage()); + String next = p.getNextHostName(); + assertEquals(second,next); + assertEquals(1,p.getRetryCount()); + next = p.getNextHostName(); + assertEquals(first,next); + assertEquals(2,p.getRetryCount()); } @Test diff --git a/restapi-call-node/provider/src/test/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java new file mode 100755 index 000000000..50371278a --- /dev/null +++ b/restapi-call-node/provider/src/test/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -0,0 +1,511 @@ +/*- + * ============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.restapicall; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.util.HashMap; +import java.util.Map; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestRestapiCallNode { + + @SuppressWarnings("unused") + private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class); + + + @Test + public void testDelete() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap<>(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "pwd1"); + p.put("httpMethod", "delete"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteWithPayload() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + ctx.setAttribute("prop.name", "site1"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/sdwan-site.json"); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "pwd1"); + p.put("httpMethod", "delete"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "3"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[1].clci", "clci"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[2].clci", "clci"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testInvalidRepeatTimes() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "a"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testInvalidTemplatePath() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resourcess/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testWithoutSkipSending() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "false"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + + @Test(expected = SvcLogicException.class) + public void testWithInvalidURI() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1"); + ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://echo. getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "false"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testVpnJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testSiteJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + ctx.setAttribute("prop.l3vpn.site1_name", "10000000-0000-0000-0000-000000000002"); + ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003"); + ctx.setAttribute("prop.l3vpn.entry1-id", "1"); + ctx.setAttribute("prop.l3vpn.sna1_name", "10000000-0000-0000-0000-000000000004"); + ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e"); + ctx.setAttribute("prop.l3vpn.ac1_id", "a8098c1a-f86e-11da-bd1a-00112444be1b"); + ctx.setAttribute("prop.l3vpn.ac1-peer-ip", "192.168.1.1"); + ctx.setAttribute("prop.l3vpn.ac1-ip", "192.168.1.2"); + ctx.setAttribute("prop.l3vpn.sna1_svlan", "100"); + ctx.setAttribute("prop.l3vpn.ac1_protocol", "static"); + ctx.setAttribute("prop.l3vpn.sna1-route.ip-prefix", "192.168.1.1/24"); + ctx.setAttribute("prop.l3vpn.sna1-route.next-hop", "192.168.1.4"); + + ctx.setAttribute("prop.l3vpn.site2_name", "10000000-0000-0000-0000-000000000005"); + ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006"); + ctx.setAttribute("prop.l3vpn.entry2-id", "1"); + ctx.setAttribute("prop.l3vpn.sna2_name", "10000000-0000-0000-0000-000000000007"); + ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a"); + ctx.setAttribute("prop.l3vpn.ac2_id", "a8098c1a-f86e-11da-bd1a-00112444be1c"); + ctx.setAttribute("prop.l3vpn.ac2-peer-ip", "192.168.1.6"); + ctx.setAttribute("prop.l3vpn.ac2-ip", "192.168.1.5"); + ctx.setAttribute("prop.l3vpn.sna2_svlan", "200"); + ctx.setAttribute("prop.l3vpn.ac2_protocol", "bgp"); + ctx.setAttribute("prop.l3vpn.peer2-ip", "192.168.1.7"); + ctx.setAttribute("prop.l3vpn.ac2_protocol_bgp_as", "200"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/l3smsitetemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/sites"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testVrfJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.vrf1-id", "10000000-0000-0000-0000-000000000007"); + ctx.setAttribute("prop.l3vpn.vpn-policy1-id", "10000000-0000-0000-0000-000000000003"); + ctx.setAttribute("prop.l3vpn.pe1_id", "a8098c1a-f86e-11da-bd1a-00112444be1e"); + ctx.setAttribute("prop.l3vpn.vrf2-id", "10000000-0000-0000-0000-000000000009"); + ctx.setAttribute("prop.l3vpn.vpn-policy2-id", "10000000-0000-0000-0000-000000000006"); + ctx.setAttribute("prop.l3vpn.pe2_id", "a8098c1a-f86e-11da-bd1a-00112444be1a"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/l3smvrftemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vrf-attributes"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testDeleteVpnJsonTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + Map p = new HashMap<>(); + //p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services" + + "/vpnservice=10000000-0000-0000-0000-000000000001"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "json"); + p.put("httpMethod", "delete"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testL2DciTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.dci-connects.id", "Id1"); + ctx.setAttribute("prop.dci-connects.name", "Name1"); + ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1"); + ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2"); + ctx.setAttribute("prop.dci-connects.vni", "1"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/l2-dci-connects-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testL3DciTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.dci-connects.id", "Id1"); + ctx.setAttribute("prop.dci-connects.name", "Name1"); + ctx.setAttribute("prop.dci-connects.local_networks_length", "2"); + ctx.setAttribute("prop.dci-connects.local_networks[0]", "NetId1"); + ctx.setAttribute("prop.dci-connects.local_networks[1]", "NetId2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[0]", "100:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[0]", "100:2"); + ctx.setAttribute("prop.dci-connects.evpn_irts[1]", "200:1"); + ctx.setAttribute("prop.dci-connects.evpn_erts[1]", "200:2"); + ctx.setAttribute("prop.dci-connects.vni", "1"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/l3-dci-connects-template.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + + } + + @Test + public void testControllerTokenTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.user", "admin"); + ctx.setAttribute("prop.sdncRestApi.thirdpartySdnc.password", "admin123"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/actokentemplate.json"); + p.put("restapiUrl", "https://ipwan:18002/controller/v2/tokens"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + + @Test + public void testDeleteNoneAsContentType() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap<>(); + p.put("restapiUrl", "https://echo.getpostman.com/delete"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "pwd1"); + p.put("httpMethod", "delete"); + p.put("format", "none"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testPostNoneAsContentType() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("prop.l3vpn.name", "10000000-0000-0000-0000-000000000001"); + ctx.setAttribute("prop.l3vpn.topology", "point_to_point"); + + Map p = new HashMap<>(); + p.put("templateFileName", "src/test/resources/l3smvpntemplate.json"); + p.put("restapiUrl", "http://ipwan:18002/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services"); + p.put("restapiUser", "admin"); + p.put("restapiPassword", "admin123"); + p.put("format", "none"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "restapi-result"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + /* + * { + "partnerOne": { + "url": "http://localhost:7001" 4 http://uebsb93kcdc.it.att.com:3904", + "test": "/metrics" + }, + "partnerTwo": { + "url": "http://localhost:7002", + "user": "controller_user", + "password": "P@ssword", + "test": "/metrics" + }, + "partnerThree": { + "url": "http://localhost:7003", + "user": "controller_admin" + } +} + */ + @Test + public void testPartners() throws Exception{ + String partnerTwoKey = "partnerTwo"; + String partnerTwoUsername = "controller_user"; + String partnerTwoPassword = "P@ssword"; + + System.setProperty("SDNC_CONFIG_DIR", "src/test/resources"); + RestapiCallNode rcn = new RestapiCallNode(); + assertNull(rcn.partnerStore.get("partnerOne")); + PartnerDetails details = rcn.partnerStore.get(partnerTwoKey); + assertEquals(partnerTwoUsername,details.username); + assertEquals(partnerTwoPassword,details.password); + assertNull(rcn.partnerStore.get("partnerThree")); + + //In this scenario the caller expects username, password and url to be picked up from the partners json + Map paramMap = new HashMap(); + paramMap.put("partner", partnerTwoKey); + rcn.handlePartner(paramMap ); + assertEquals(partnerTwoUsername,paramMap.get(rcn.restapiUserKey)); + assertEquals(partnerTwoPassword,paramMap.get(rcn.restapiPasswordKey)); + assertEquals("http://localhost:7002",paramMap.get(rcn.restapiUrlString)); + + //In this scenario the caller expects username, password and url to be picked up from the partners json + //the provided suffix will be appended to the default url from the partners json + paramMap = new HashMap(); + paramMap.put("partner", partnerTwoKey); + paramMap.put("restapiUrlSuffix", "/networking/v1/instance/3"); + rcn.handlePartner(paramMap); + Parameters p = new Parameters(); + RestapiCallNode.getParameters(paramMap, p); + assertEquals(partnerTwoUsername,p.restapiUser); + assertEquals(partnerTwoPassword,p.restapiPassword); + assertEquals("http://localhost:7002/networking/v1/instance/3",p.restapiUrl); + } + + @Test + public void retryPolicyBean() throws Exception { + Integer retries = 3; + String first = "http://localhost:7001"; + String second = "http://localhost:7001"; + + RetryPolicy p = new RetryPolicy(new String[] {first,second}, retries); + assertEquals(retries,p.getMaximumRetries()); + assertNotNull(p.getRetryMessage()); + String next = p.getNextHostName(); + assertEquals(second,next); + assertEquals(1,p.getRetryCount()); + next = p.getNextHostName(); + assertEquals(first,next); + assertEquals(2,p.getRetryCount()); + } +} diff --git a/restapi-call-node/provider/src/test/resources/partners.json b/restapi-call-node/provider/src/test/resources/partners.json new file mode 100755 index 000000000..9a17a1acf --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/partners.json @@ -0,0 +1,16 @@ +{ + "partnerOne": { + "url": "http://localhost:7001", + "test": "/metrics" + }, + "partnerTwo": { + "url": "http://localhost:7002", + "user": "controller_user", + "password": "P@ssword", + "test": "/metrics" + }, + "partnerThree": { + "url": "http://localhost:7003", + "user": "controller_admin" + } +} diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java index ac0897e8f..620df282f 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java @@ -46,8 +46,6 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; import org.onap.ccsdk.sli.plugins.restapicall.Format; import org.onap.ccsdk.sli.plugins.restapicall.HttpResponse; import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; -import org.onap.ccsdk.sli.plugins.restapicall.RetryException; -import org.onap.ccsdk.sli.plugins.restapicall.RetryPolicy; import org.onap.ccsdk.sli.plugins.restapicall.XmlParser; import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatSerializer; import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatSerializerContext; @@ -165,14 +163,9 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { public void sendRequest(Map paramMap, SvcLogicContext ctx, Integer retryCount) throws SvcLogicException { RestapiCallNode rest = getRestapiCallNode(); - RetryPolicy retryPolicy = null; HttpResponse r = new HttpResponse(); try { YangParameters p = getYangParameters(paramMap); - if (p.partner != null) { - retryPolicy = rest.getRetryPolicyStore() - .getRetryPolicy(p.partner); - } String pp = p.responsePrefix != null ? p.responsePrefix + '.' : ""; Map props = new HashMap<>((Map)ctx.toProperties()); @@ -215,30 +208,7 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { log.error(REQ_ERR + e.getMessage(), e); String prefix = parseParam(paramMap, RES_PRE, false, null); - if (retryPolicy == null || !shouldRetry) { - setFailureResponseStatus(ctx, prefix, e.getMessage()); - } else { - if (retryCount == null) { - retryCount = 0; - } - log.debug(format(ATTEMPTS_MSG, retryCount, - retryPolicy.getMaximumRetries())); - try { - retryCount = retryCount + 1; - if (retryCount < retryPolicy.getMaximumRetries() + 1) { - setRetryUri(paramMap, retryPolicy); - log.debug(format(RETRY_COUNT, retryCount, retryPolicy - .getMaximumRetries())); - sendRequest(paramMap, ctx, retryCount); - } else { - log.debug(MAX_RETRY_ERR); - setFailureResponseStatus(ctx, prefix, e.getMessage()); - } - } catch (Exception ex) { - log.error(NO_MORE_RETRY, ex); - setFailureResponseStatus(ctx, prefix, RETRY_FAIL); - } - } + setFailureResponseStatus(ctx, prefix, e.getMessage()); } if (r != null && r.code >= 300) { @@ -402,31 +372,6 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { ctx.setAttribute(prefix + RES_MSG, res.message); } - /** - * Sets the retry URI to the param map from the retry policies different - * host. - * - * @param paramMap parameter map - * @param retryPolicy retry policy - * @throws URISyntaxException when new URI creation fails - * @throws RetryException when retry policy cannot give another host - */ - private void setRetryUri(Map paramMap, - RetryPolicy retryPolicy) - throws URISyntaxException, RetryException { - URI uri = new URI(paramMap.get(REST_API_URL)); - String hostName = uri.getHost(); - String retryString = retryPolicy.getNextHostName(uri.toString()); - - URI uriTwo = new URI(retryString); - URI retryUri = UriBuilder.fromUri(uri).host(uriTwo.getHost()).port( - uriTwo.getPort()).scheme(uriTwo.getScheme()).build(); - - paramMap.put(REST_API_URL, retryUri.toString()); - log.debug(UPDATED_URL + retryUri.toString()); - log.debug(format(COMM_FAIL, hostName, retryString)); - } - /** * Updates request message for JSON and XML data format, when the HTTP * method points it as PUT or PATCH. -- cgit From b43008aa2dce75efdf704d1a5e2529e58b4fbde1 Mon Sep 17 00:00:00 2001 From: Stan Bonev Date: Fri, 7 Jun 2019 14:31:33 -0400 Subject: Remove logging passwords in clear text Change-Id: I21c70038bc19c3bab137fc9604b7b593b6d529e1 Issue-ID: CCSDK-1385 Signed-off-by: Stan Bonev --- .../ccsdk/sli/plugins/prop/PropertiesNode.java | 66 +-- .../sli/plugins/restapicall/RestapiCallNode.java | 451 ++++++++++++--------- 2 files changed, 305 insertions(+), 212 deletions(-) diff --git a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java index 612592b58..f0c7e0b45 100644 --- a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java +++ b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java @@ -8,9 +8,9 @@ * 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. @@ -29,7 +29,6 @@ import java.util.HashSet; import java.util.Map; import java.util.Properties; import java.util.Set; - import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; @@ -45,10 +44,10 @@ public class PropertiesNode implements SvcLogicJavaPlugin { Properties prop = new Properties(); try { File file = new File(param.fileName); - try(InputStream in = new FileInputStream(file)){ + try (InputStream in = new FileInputStream(file)) { Map mm = null; String pfx = param.contextPrefix != null ? param.contextPrefix + '.' : ""; - if(param.fileBasedParsing){ + if (param.fileBasedParsing) { byte[] data = new byte[(int) file.length()]; if ("json".equalsIgnoreCase(getFileExtension(param.fileName))) { in.read(data); @@ -65,14 +64,15 @@ public class PropertiesNode implements SvcLogicJavaPlugin { String value = prop.getProperty(name); if (value != null && value.trim().length() > 0) { ctx.setAttribute(pfx + name, value.trim()); - log.info("+++ " + pfx + name + ": [" + value + "]"); + log.info("+++ " + pfx + name + ": [" + maskPassword(pfx + name, value) + "]"); } } } - if (mm != null){ - for (Map.Entry entry : mm.entrySet()){ + if (mm != null) { + for (Map.Entry entry : mm.entrySet()) { ctx.setAttribute(pfx + entry.getKey(), entry.getValue()); - log.info("+++ " + pfx + entry.getKey() + ": [" + entry.getValue() + "]"); + log.info("+++ " + pfx + entry.getKey() + ": [" + + maskPassword(pfx + entry.getKey(), entry.getValue()) + "]"); } } } else { @@ -82,7 +82,7 @@ public class PropertiesNode implements SvcLogicJavaPlugin { String value = prop.getProperty(name); if (value != null && value.trim().length() > 0) { ctx.setAttribute(pfx + name, value.trim()); - log.info("+++ " + pfx + name + ": [" + value + "]"); + log.info("+++ " + pfx + name + ": [" + maskPassword(pfx + name, value) + "]"); } } } @@ -92,17 +92,16 @@ public class PropertiesNode implements SvcLogicJavaPlugin { } } - /* Getting extension has to do the following - * "" --> "" - * "name" --> "" - * "name.txt" --> "txt" - * ".htpasswd" --> "" - * "name.with.many.dots.myext" --> "myext" - */ + /* + * Getting extension has to do the following "" --> "" "name" --> "" "name.txt" --> "txt" + * ".htpasswd" --> "" "name.with.many.dots.myext" --> "myext" + */ private static String getFileExtension(String fileName) { - if(fileName.lastIndexOf(".") != -1 && fileName.lastIndexOf(".") != 0) - return fileName.substring(fileName.lastIndexOf(".")+1); - else return ""; + if (fileName.lastIndexOf(".") != -1 && fileName.lastIndexOf(".") != 0) { + return fileName.substring(fileName.lastIndexOf(".") + 1); + } else { + return ""; + } } protected Parameters getParameters(Map paramMap) throws SvcLogicException { @@ -117,9 +116,11 @@ public class PropertiesNode implements SvcLogicJavaPlugin { protected Set getListNameList(Map paramMap) { Set ll = new HashSet<>(); - for (Map.Entry entry : paramMap.entrySet()) - if (entry.getKey().startsWith("listName")) + for (Map.Entry entry : paramMap.entrySet()) { + if (entry.getKey().startsWith("listName")) { ll.add(entry.getValue()); + } + } return ll; } @@ -128,8 +129,9 @@ public class PropertiesNode implements SvcLogicJavaPlugin { String s = paramMap.get(name); if (s == null || s.trim().length() == 0) { - if (!required) + if (!required) { return def; + } throw new SvcLogicException("Parameter " + name + " is required in PropertiesNode"); } @@ -139,13 +141,15 @@ public class PropertiesNode implements SvcLogicJavaPlugin { int i1 = s.indexOf('%'); while (i1 >= 0) { int i2 = s.indexOf('%', i1 + 1); - if (i2 < 0) + if (i2 < 0) { throw new SvcLogicException("Cannot parse parameter " + name + ": " + s + ": no matching %"); + } String varName = s.substring(i1 + 1, i2); String varValue = System.getenv(varName); - if (varValue == null) + if (varValue == null) { varValue = ""; + } value += s.substring(i, i1); value += varValue; @@ -155,7 +159,17 @@ public class PropertiesNode implements SvcLogicJavaPlugin { } value += s.substring(i); - log.info("Parameter " + name + ": " + value); + log.info("Parameter " + name + ": " + maskPassword(name, value)); + return value; + } + + private static Object maskPassword(String name, Object value) { + String[] pwdNames = {"pwd", "passwd", "password", "Pwd", "Passwd", "Password"}; + for (String pwdName : pwdNames) { + if (name.contains(pwdName)) { + return "**********"; + } + } return value; } } diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 34e5dec21..adf723b8b 100755 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -57,8 +57,6 @@ import javax.ws.rs.core.Feature; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; -import javax.ws.rs.core.Response; import org.apache.commons.lang3.StringUtils; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; @@ -70,8 +68,6 @@ import org.glassfish.jersey.client.oauth1.OAuth1ClientSupport; import org.glassfish.jersey.media.multipart.MultiPart; import org.glassfish.jersey.media.multipart.MultiPartFeature; import org.glassfish.jersey.media.multipart.file.FileDataBodyPart; -import org.glassfish.jersey.client.oauth1.ConsumerCredentials; -import org.glassfish.jersey.client.oauth1.OAuth1ClientSupport; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; @@ -98,14 +94,14 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { protected static final String restapiUserKey = "restapiUser"; protected static final String restapiPasswordKey = "restapiPassword"; - protected HashMap partnerStore; + protected HashMap partnerStore; public RestapiCallNode() { - String configDir = System.getProperty(PROPERTIES_DIR_KEY, DEFAULT_PROPERTIES_DIR); + String configDir = System.getProperty(PROPERTIES_DIR_KEY, DEFAULT_PROPERTIES_DIR); try { String jsonString = readFile(configDir + "/" + PARTNERS_FILE_NAME); JSONObject partners = new JSONObject(jsonString); - partnerStore = new HashMap(); + partnerStore = new HashMap<>(); loadPartners(partners); log.info("Partners support enabled"); } catch (Exception e) { @@ -123,103 +119,81 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } protected void loadPartners(JSONObject partners) { - Iterator keys = partners.keys(); - String partnerUserKey = "user"; - String partnerPasswordKey = "password"; - String partnerUrlKey = "url"; - - while (keys.hasNext()) { - String partnerKey = keys.next(); - try { - JSONObject partnerObject = (JSONObject) partners.get(partnerKey); - if (partnerObject.has(partnerUserKey) && partnerObject.has(partnerPasswordKey)) { - String url = null; - if (partnerObject.has(partnerUrlKey)) { - url = partnerObject.getString(partnerUrlKey); - } - String userName = partnerObject.getString(partnerUserKey); - String password = partnerObject.getString(partnerPasswordKey); - PartnerDetails details = new PartnerDetails(userName, password, url); - partnerStore.put(partnerKey, details); - log.info("mapped partner using partner key " + partnerKey); - } else { - log.info("Partner " + partnerKey + " is missing required keys, it won't be mapped"); - } - } catch (JSONException e) { - log.info("Couldn't map the partner using partner key " + partnerKey, e); - } - } + Iterator keys = partners.keys(); + String partnerUserKey = "user"; + String partnerPasswordKey = "password"; + String partnerUrlKey = "url"; + + while (keys.hasNext()) { + String partnerKey = keys.next(); + try { + JSONObject partnerObject = (JSONObject) partners.get(partnerKey); + if (partnerObject.has(partnerUserKey) && partnerObject.has(partnerPasswordKey)) { + String url = null; + if (partnerObject.has(partnerUrlKey)) { + url = partnerObject.getString(partnerUrlKey); + } + String userName = partnerObject.getString(partnerUserKey); + String password = partnerObject.getString(partnerPasswordKey); + PartnerDetails details = new PartnerDetails(userName, password, url); + partnerStore.put(partnerKey, details); + log.info("mapped partner using partner key " + partnerKey); + } else { + log.info("Partner " + partnerKey + " is missing required keys, it won't be mapped"); + } + } catch (JSONException e) { + log.info("Couldn't map the partner using partner key " + partnerKey, e); + } + } } /** * Returns parameters from the parameter map. * * @param paramMap parameter map - * @param p parameters instance + * @param p parameters instance * @return parameters filed instance * @throws SvcLogicException when svc logic exception occurs */ - public static Parameters getParameters(Map paramMap, - Parameters p) - throws SvcLogicException { + public static Parameters getParameters(Map paramMap, Parameters p) throws SvcLogicException { - p.templateFileName = parseParam(paramMap, "templateFileName", - false, null); + p.templateFileName = parseParam(paramMap, "templateFileName", false, null); p.requestBody = parseParam(paramMap, "requestBody", false, null); p.restapiUrl = parseParam(paramMap, restapiUrlString, true, null); validateUrl(p.restapiUrl); - p.restapiUrlSuffix = parseParam(paramMap, "restapiUrlSuffix", - false, null); + p.restapiUrlSuffix = parseParam(paramMap, "restapiUrlSuffix", false, null); p.restapiUser = parseParam(paramMap, restapiUserKey, false, null); - p.restapiPassword = parseParam(paramMap, restapiPasswordKey, false, - null); - if(p.restapiUrlSuffix != null) { + p.restapiPassword = parseParam(paramMap, restapiPasswordKey, false, null); + if (p.restapiUrlSuffix != null) { p.restapiUrl = p.restapiUrl + p.restapiUrlSuffix; validateUrl(p.restapiUrl); } - p.oAuthConsumerKey = parseParam(paramMap, "oAuthConsumerKey", - false, null); - p.oAuthConsumerSecret = parseParam(paramMap, "oAuthConsumerSecret", - false, null); - p.oAuthSignatureMethod = parseParam(paramMap, "oAuthSignatureMethod", - false, null); + p.oAuthConsumerKey = parseParam(paramMap, "oAuthConsumerKey", false, null); + p.oAuthConsumerSecret = parseParam(paramMap, "oAuthConsumerSecret", false, null); + p.oAuthSignatureMethod = parseParam(paramMap, "oAuthSignatureMethod", false, null); p.oAuthVersion = parseParam(paramMap, "oAuthVersion", false, null); p.contentType = parseParam(paramMap, "contentType", false, null); - p.format = Format.fromString(parseParam(paramMap, "format", false, - "json")); - p.authtype = fromString(parseParam(paramMap, "authType", false, - "unspecified")); - p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", - false, "post")); + p.format = Format.fromString(parseParam(paramMap, "format", false, "json")); + p.authtype = fromString(parseParam(paramMap, "authType", false, "unspecified")); + p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post")); p.responsePrefix = parseParam(paramMap, responsePrefix, false, null); p.listNameList = getListNameList(paramMap); String skipSendingStr = paramMap.get(skipSendingMessage); p.skipSending = "true".equalsIgnoreCase(skipSendingStr); - p.convertResponse = valueOf(parseParam(paramMap, "convertResponse", - false, "true")); - p.trustStoreFileName = parseParam(paramMap, "trustStoreFileName", - false, null); - p.trustStorePassword = parseParam(paramMap, "trustStorePassword", - false, null); - p.keyStoreFileName = parseParam(paramMap, "keyStoreFileName", - false, null); - p.keyStorePassword = parseParam(paramMap, "keyStorePassword", - false, null); - p.ssl = p.trustStoreFileName != null && p.trustStorePassword != null - && p.keyStoreFileName != null && p.keyStorePassword != null; - p.customHttpHeaders = parseParam(paramMap, "customHttpHeaders", - false, null); + p.convertResponse = valueOf(parseParam(paramMap, "convertResponse", false, "true")); + p.trustStoreFileName = parseParam(paramMap, "trustStoreFileName", false, null); + p.trustStorePassword = parseParam(paramMap, "trustStorePassword", false, null); + p.keyStoreFileName = parseParam(paramMap, "keyStoreFileName", false, null); + p.keyStorePassword = parseParam(paramMap, "keyStorePassword", false, null); + p.ssl = p.trustStoreFileName != null && p.trustStorePassword != null && p.keyStoreFileName != null + && p.keyStorePassword != null; + p.customHttpHeaders = parseParam(paramMap, "customHttpHeaders", false, null); p.partner = parseParam(paramMap, "partner", false, null); - p.dumpHeaders = valueOf(parseParam(paramMap, "dumpHeaders", - false, null)); - p.returnRequestPayload = valueOf(parseParam( - paramMap, "returnRequestPayload", false, null)); - p.accept = parseParam(paramMap, "accept", - false, null); - p.multipartFormData = valueOf(parseParam(paramMap, "multipartFormData", - false, "false")); - p.multipartFile = parseParam(paramMap, "multipartFile", - false, null); + p.dumpHeaders = valueOf(parseParam(paramMap, "dumpHeaders", false, null)); + p.returnRequestPayload = valueOf(parseParam(paramMap, "returnRequestPayload", false, null)); + p.accept = parseParam(paramMap, "accept", false, null); + p.multipartFormData = valueOf(parseParam(paramMap, "multipartFormData", false, "false")); + p.multipartFile = parseParam(paramMap, "multipartFile", false, null); return p; } @@ -230,18 +204,18 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { * @throws SvcLogicException when URL validation fails */ private static void validateUrl(String restapiUrl) throws SvcLogicException { - if (restapiUrl.contains(",")) { - String[] urls = restapiUrl.split(","); - for(String url : urls) { - validateUrl(url); - } - } else { - try { - URI.create(restapiUrl); - } catch (IllegalArgumentException e) { - throw new SvcLogicException("Invalid input of url " + e.getLocalizedMessage(), e); - } - } + if (restapiUrl.contains(",")) { + String[] urls = restapiUrl.split(","); + for (String url : urls) { + validateUrl(url); + } + } else { + try { + URI.create(restapiUrl); + } catch (IllegalArgumentException e) { + throw new SvcLogicException("Invalid input of url " + e.getLocalizedMessage(), e); + } + } } /** @@ -261,19 +235,18 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } /** - * Parses the parameter string map of property, validates if required, - * assigns default value if present and returns the value. + * Parses the parameter string map of property, validates if required, assigns default value if + * present and returns the value. * * @param paramMap string param map - * @param name name of the property + * @param name name of the property * @param required if value required - * @param def default value + * @param def default value * @return value of the property * @throws SvcLogicException if required parameter value is empty */ - public static String parseParam(Map paramMap, String name, - boolean required, String def) - throws SvcLogicException { + public static String parseParam(Map paramMap, String name, boolean required, String def) + throws SvcLogicException { String s = paramMap.get(name); if (s == null || s.trim().length() == 0) { @@ -307,37 +280,148 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } value.append(s.substring(i)); - log.info("Parameter {}: [{}]", name, value); + log.info("Parameter {}: [{}]", name, maskPassword(name, value)); + return value.toString(); } + private static Object maskPassword(String name, Object value) { + String[] pwdNames = {"pwd", "passwd", "password", "Pwd", "Passwd", "Password"}; + for (String pwdName : pwdNames) { + if (name.contains(pwdName)) { + return "**********"; + } + } + return value; + } + /** - * Allows Directed Graphs the ability to interact with REST APIs. + * Allows Directed Graphs the ability to interact with REST APIs. + * * @param paramMap HashMap of parameters passed by the DG to this function - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * vpn-information.vrf-details - * - * - * - * - * - * - * - *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/restapi/templates/vnf_service-configuration-operation_minimal.json
restapiUrlMandatoryurl to send the request tohttps://sdncodl:8543/restconf/operations/L3VNF-API:create-update-vnf-request
restapiUserOptionaluser name to use for http basic authenticationsdnc_ws
restapiPasswordOptionalunencrypted password to use for http basic authenticationplain_password
oAuthConsumerKeyOptionalConsumer key to use for http oAuth authenticationplain_key
oAuthConsumerSecretOptionalConsumer secret to use for http oAuth authenticationplain_secret
oAuthSignatureMethodOptionalConsumer method to use for http oAuth authenticationmethod
oAuthVersionOptionalVersion http oAuth authenticationversion
contentTypeOptionalhttp content type to set in the http headerusually application/json or application/xml
formatOptionalshould match request body formatjson or xml
httpMethodOptionalhttp method to use when sending the requestget post put delete patch
responsePrefixOptionallocation the response will be written to in context memorytmp.restapi.result
listName[i]OptionalUsed for processing XML responses with repeating elements.
skipSendingOptionaltrue or false
convertResponse Optionalwhether the response should be convertedtrue or false
customHttpHeadersOptionala list additional http headers to be passed in, follow the format in the exampleX-CSI-MessageId=messageId,headerFieldName=headerFieldValue
dumpHeadersOptionalwhen true writes http header content to context memorytrue or false
partnerOptionalused to retrieve username, password and url if partner store existsaaf
returnRequestPayloadOptionalused to return payload built in the requesttrue or false
+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * vpn-information.vrf-details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
parameterMandatory/Optionaldescriptionexample values
templateFileNameOptionalfull path to template file that can be used to build a request/sdncopt/bvc/restapi/templates/vnf_service-configuration-operation_minimal.json
restapiUrlMandatoryurl to send the request tohttps://sdncodl:8543/restconf/operations/L3VNF-API:create-update-vnf-request
restapiUserOptionaluser name to use for http basic authenticationsdnc_ws
restapiPasswordOptionalunencrypted password to use for http basic authenticationplain_password
oAuthConsumerKeyOptionalConsumer key to use for http oAuth authenticationplain_key
oAuthConsumerSecretOptionalConsumer secret to use for http oAuth authenticationplain_secret
oAuthSignatureMethodOptionalConsumer method to use for http oAuth authenticationmethod
oAuthVersionOptionalVersion http oAuth authenticationversion
contentTypeOptionalhttp content type to set in the http headerusually application/json or application/xml
formatOptionalshould match request body formatjson or xml
httpMethodOptionalhttp method to use when sending the requestget post put delete patch
responsePrefixOptionallocation the response will be written to in context memorytmp.restapi.result
listName[i]OptionalUsed for processing XML responses with repeating + * elements.
skipSendingOptionaltrue or false
convertResponseOptionalwhether the response should be convertedtrue or false
customHttpHeadersOptionala list additional http headers to be passed in, follow the format in the exampleX-CSI-MessageId=messageId,headerFieldName=headerFieldValue
dumpHeadersOptionalwhen true writes http header content to context memorytrue or false
partnerOptionalused to retrieve username, password and url if partner store existsaaf
returnRequestPayloadOptionalused to return payload built in the requesttrue or false
* @param ctx Reference to context memory * @throws SvcLogicException * @since 11.0.2 @@ -348,16 +432,16 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } protected void sendRequest(Map paramMap, SvcLogicContext ctx, RetryPolicy retryPolicy) - throws SvcLogicException { + throws SvcLogicException { HttpResponse r = new HttpResponse(); try { - handlePartner(paramMap); + handlePartner(paramMap); Parameters p = getParameters(paramMap, new Parameters()); - if(p.restapiUrl.contains(",") && retryPolicy == null) { - String[] urls = p.restapiUrl.split(","); - retryPolicy = new RetryPolicy(urls,urls.length * 2); - p.restapiUrl = urls[0]; + if (p.restapiUrl.contains(",") && retryPolicy == null) { + String[] urls = p.restapiUrl.split(","); + retryPolicy = new RetryPolicy(urls, urls.length * 2); + p.restapiUrl = urls[0]; } String pp = p.responsePrefix != null ? p.responsePrefix + '.' : ""; @@ -412,18 +496,20 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } else { log.debug(retryPolicy.getRetryMessage()); try { - //calling getNextHostName increments the retry count so it should be called before shouldRetry + // calling getNextHostName increments the retry count so it should be called before shouldRetry String retryString = retryPolicy.getNextHostName(); if (retryPolicy.shouldRetry()) { paramMap.put(restapiUrlString, retryString); - log.debug("retry attempt {} will use the retry url {}", retryPolicy.getRetryCount(), retryString); + log.debug("retry attempt {} will use the retry url {}", retryPolicy.getRetryCount(), + retryString); sendRequest(paramMap, ctx, retryPolicy); } else { log.debug("Maximum retries reached, won't attempt to retry. Calling setFailureResponseStatus."); setFailureResponseStatus(ctx, prefix, e.getMessage(), r); } } catch (Exception ex) { - String retryErrorMessage = "Retry attempt " + retryPolicy.getRetryCount() + "has failed with error message " + ex.getMessage(); + String retryErrorMessage = "Retry attempt " + retryPolicy.getRetryCount() + + "has failed with error message " + ex.getMessage(); setFailureResponseStatus(ctx, prefix, retryErrorMessage, r); } } @@ -436,18 +522,17 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { protected void handlePartner(Map paramMap) { String partner = paramMap.get("partner"); - if (partner != null && partner.length() > 0) { - PartnerDetails details = partnerStore.get(partner); - paramMap.put(restapiUserKey, details.username); - paramMap.put(restapiPasswordKey, details.password); - if(paramMap.get(restapiUrlString) == null) { - paramMap.put(restapiUrlString, details.url); - } - } + if (partner != null && partner.length() > 0) { + PartnerDetails details = partnerStore.get(partner); + paramMap.put(restapiUserKey, details.username); + paramMap.put(restapiPasswordKey, details.password); + if (paramMap.get(restapiUrlString) == null) { + paramMap.put(restapiUrlString, details.url); + } + } } - protected String buildXmlJsonRequest(SvcLogicContext ctx, String template, Format format) - throws SvcLogicException { + protected String buildXmlJsonRequest(SvcLogicContext ctx, String template, Format format) throws SvcLogicException { log.info("Building {} started", format); long t1 = System.currentTimeMillis(); String originalTemplate = template; @@ -496,8 +581,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } } - String req = format == Format.XML - ? XmlJsonUtil.removeEmptyStructXml(ss.toString()) : XmlJsonUtil.removeEmptyStructJson(originalTemplate, ss.toString()); + String req = format == Format.XML ? XmlJsonUtil.removeEmptyStructXml(ss.toString()) + : XmlJsonUtil.removeEmptyStructJson(originalTemplate, ss.toString()); if (format == Format.JSON) { req = XmlJsonUtil.removeLastCommaJson(req); @@ -522,7 +607,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { int i2 = template.indexOf(':', i1 + 9); if (i2 < 0) { throw new SvcLogicException( - "Template error: Context variable name followed by : is required after repeat"); + "Template error: Context variable name followed by : is required after repeat"); } // Find the closing }, store in i3 @@ -604,11 +689,10 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { if (p.authtype == AuthType.Unspecified) { if (p.restapiUser != null && p.restapiPassword != null) { client.register(HttpAuthenticationFeature.basic(p.restapiUser, p.restapiPassword)); - } else if (p.oAuthConsumerKey != null && p.oAuthConsumerSecret != null - && p.oAuthSignatureMethod != null) { - Feature oAuth1Feature = OAuth1ClientSupport - .builder(new ConsumerCredentials(p.oAuthConsumerKey, p.oAuthConsumerSecret)) - .version(p.oAuthVersion).signatureMethod(p.oAuthSignatureMethod).feature().build(); + } else if (p.oAuthConsumerKey != null && p.oAuthConsumerSecret != null && p.oAuthSignatureMethod != null) { + Feature oAuth1Feature = + OAuth1ClientSupport.builder(new ConsumerCredentials(p.oAuthConsumerKey, p.oAuthConsumerSecret)) + .version(p.oAuthVersion).signatureMethod(p.oAuthSignatureMethod).feature().build(); client.register(oAuth1Feature); } @@ -618,27 +702,30 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { client.register(HttpAuthenticationFeature.digest(p.restapiUser, p.restapiPassword)); } else { throw new SvcLogicException( - "oAUTH authentication type selected but all restapiUser and restapiPassword " + - "parameters doesn't exist", new Throwable()); + "oAUTH authentication type selected but all restapiUser and restapiPassword " + + "parameters doesn't exist", + new Throwable()); } } else if (p.authtype == AuthType.BASIC) { if (p.restapiUser != null && p.restapiPassword != null) { client.register(HttpAuthenticationFeature.basic(p.restapiUser, p.restapiPassword)); } else { throw new SvcLogicException( - "oAUTH authentication type selected but all restapiUser and restapiPassword " + - "parameters doesn't exist", new Throwable()); + "oAUTH authentication type selected but all restapiUser and restapiPassword " + + "parameters doesn't exist", + new Throwable()); } } else if (p.authtype == AuthType.OAUTH) { if (p.oAuthConsumerKey != null && p.oAuthConsumerSecret != null && p.oAuthSignatureMethod != null) { Feature oAuth1Feature = OAuth1ClientSupport - .builder(new ConsumerCredentials(p.oAuthConsumerKey, p.oAuthConsumerSecret)) - .version(p.oAuthVersion).signatureMethod(p.oAuthSignatureMethod).feature().build(); + .builder(new ConsumerCredentials(p.oAuthConsumerKey, p.oAuthConsumerSecret)) + .version(p.oAuthVersion).signatureMethod(p.oAuthSignatureMethod).feature().build(); client.register(oAuth1Feature); } else { throw new SvcLogicException( - "oAUTH authentication type selected but all oAuthConsumerKey, oAuthConsumerSecret " + - "and oAuthSignatureMethod parameters doesn't exist", new Throwable()); + "oAUTH authentication type selected but all oAuthConsumerKey, oAuthConsumerSecret " + + "and oAuthSignatureMethod parameters doesn't exist", + new Throwable()); } } } @@ -649,12 +736,11 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { * Receives the http response for the http request sent. * * @param request request msg - * @param p parameters + * @param p parameters * @return HTTP response * @throws SvcLogicException when sending http request fails */ - public HttpResponse sendHttpRequest(String request, Parameters p) - throws SvcLogicException { + public HttpResponse sendHttpRequest(String request, Parameters p) throws SvcLogicException { SSLContext ssl = null; if (p.ssl && p.restapiUrl.startsWith("https")) { @@ -664,11 +750,9 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { if (ssl != null) { HttpsURLConnection.setDefaultSSLSocketFactory(ssl.getSocketFactory()); - client = ClientBuilder.newBuilder().sslContext(ssl).hostnameVerifier((s, sslSession) -> true) - .build(); + client = ClientBuilder.newBuilder().sslContext(ssl).hostnameVerifier((s, sslSession) -> true).build(); } else { - client = ClientBuilder.newBuilder().hostnameVerifier((s, sslSession) -> true) - .build(); + client = ClientBuilder.newBuilder().hostnameVerifier((s, sslSession) -> true).build(); } client.property(ClientProperties.CONNECT_TIMEOUT, 5000); // Needed to support additional HTTP methods such as PATCH @@ -683,12 +767,12 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { HttpResponse r = new HttpResponse(); r.code = 200; String accept = p.accept; - if(accept == null) { + if (accept == null) { accept = p.format == Format.XML ? "application/xml" : "application/json"; } String contentType = p.contentType; - if(contentType == null) { + if (contentType == null) { contentType = accept + ";charset=UTF-8"; } @@ -705,7 +789,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { for (String singlePair : keyValuePairs) { int equalPosition = singlePair.indexOf('='); invocationBuilder.header(singlePair.substring(0, equalPosition), - singlePair.substring(equalPosition + 1, singlePair.length())); + singlePair.substring(equalPosition + 1, singlePair.length())); } } @@ -718,8 +802,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { try { response = invocationBuilder.method(p.httpMethod.toString(), entity(request, contentType)); } catch (ProcessingException | IllegalStateException e) { - throw new SvcLogicException(requestPostingException + - e.getLocalizedMessage(), e); + throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e); } r.code = response.getStatus(); @@ -738,9 +821,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { MultiPart multiPart = new MultiPart(); multiPart.setMediaType(MediaType.MULTIPART_FORM_DATA_TYPE); - FileDataBodyPart fileDataBodyPart = new FileDataBodyPart("file", - new File(p.multipartFile), - MediaType.APPLICATION_OCTET_STREAM_TYPE); + FileDataBodyPart fileDataBodyPart = + new FileDataBodyPart("file", new File(p.multipartFile), MediaType.APPLICATION_OCTET_STREAM_TYPE); multiPart.bodyPart(fileDataBodyPart); @@ -764,10 +846,10 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { Response response; try { - response = invocationBuilder.method(p.httpMethod.toString(), entity(multiPart, multiPart.getMediaType())); + response = + invocationBuilder.method(p.httpMethod.toString(), entity(multiPart, multiPart.getMediaType())); } catch (ProcessingException | IllegalStateException e) { - throw new SvcLogicException(requestPostingException + - e.getLocalizedMessage(), e); + throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e); } r.code = response.getStatus(); @@ -816,7 +898,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } protected void setFailureResponseStatus(SvcLogicContext ctx, String prefix, String errorMessage, - HttpResponse resp) { + HttpResponse resp) { resp.code = 500; resp.message = errorMessage; String pp = prefix != null ? prefix + '.' : ""; @@ -939,8 +1021,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { throw new SvcLogicException("Http operation" + p.httpMethod + "not supported"); } } catch (ProcessingException e) { - throw new SvcLogicException(requestPostingException + - e.getLocalizedMessage(), e); + throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e); } r.code = response.getStatus(); @@ -958,7 +1039,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { log.info("Got response code 301. Sending same request to URL: {}", newUrl); - webTarget = client.target(newUrl); + webTarget = client.target(newUrl); invocationBuilder = webTarget.request(tt).accept(tt); try { @@ -970,8 +1051,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { throw new SvcLogicException("Http operation" + p.httpMethod + "not supported"); } } catch (ProcessingException e) { - throw new SvcLogicException(requestPostingException + - e.getLocalizedMessage(), e); + throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e); } r.code = response.getStatus(); @@ -1068,8 +1148,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { try { response = invocationBuilder.post(Entity.entity(request, tt1)); } catch (ProcessingException e) { - throw new SvcLogicException(requestPostingException + - e.getLocalizedMessage(), e); + throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e); } r.code = response.getStatus(); r.headers = response.getStringHeaders(); -- cgit From bd8a4d04337eed46be669f70272e6583f48ba249 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 21 Jun 2019 17:22:27 -0400 Subject: Remove versions from project poms Remove versions from project poms and instead drive version from dependencyManagement to ensure consistency. Change-Id: I2a3238163e49878c4c7528db1271c83b488263c3 Issue-ID: CCSDK-1416 Signed-off-by: Timoney, Dan (dt5972) --- grToolkit/provider/pom.xml | 4 ---- restapi-call-node/provider/pom.xml | 7 ------- restconf-client/provider/pom.xml | 19 ++++++------------- sshapi-call-node/provider/pom.xml | 1 + template-node/provider/pom.xml | 1 - 5 files changed, 7 insertions(+), 25 deletions(-) diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index ee61d7d41..b624e069e 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -74,13 +74,11 @@ junit junit - 4.11 test org.mockito mockito-core - 1.10.19 test @@ -95,13 +93,11 @@ com.typesafe.akka akka-cluster_2.12 - ${akka.version} provided com.github.stefanbirkner system-rules - 1.19.0 test diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index a7a0842a4..0d23912fd 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -47,17 +47,14 @@ org.glassfish.jersey.bundles.repackaged jersey-guava - 2.22.2 org.glassfish.jersey.security oauth1-signature - ${jersey.version} org.glassfish.jersey.security oauth1-client - ${jersey.version} org.codehaus.jettison @@ -66,12 +63,10 @@ org.glassfish.jersey.core jersey-client - ${jersey.version} org.glassfish.jersey.media jersey-media-multipart - ${jersey.version} @@ -83,13 +78,11 @@ org.glassfish.jersey.containers jersey-container-servlet - ${jersey.version} test org.glassfish.jersey.containers jersey-container-grizzly2-http - ${jersey.version} test diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 70f84e09d..9fa247557 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -36,7 +36,6 @@ org.glassfish.jersey.media jersey-media-sse - ${jersey.version} javax.ws.rs @@ -46,15 +45,18 @@ org.onap.ccsdk.sli.core sli-common + + org.onap.ccsdk.sli.core + sli-provider + org.onap.ccsdk.sli.plugins properties-node-provider - 0.5.0-SNAPSHOT + ${project.version} org.opendaylight.yangtools yang-data-impl - 2.0.6.1 com.fasterxml.jackson.core @@ -63,17 +65,15 @@ dom4j dom4j - 1.6.1 com.google.code.gson gson - ${gson.version} org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.5.0-SNAPSHOT + ${project.version} org.opendaylight.netconf @@ -82,7 +82,6 @@ org.opendaylight.yangtools yang-parser-impl - 2.0.6.1 org.osgi @@ -99,37 +98,31 @@ org.mockito mockito-core - ${mockito.version} test org.glassfish.jersey.containers jersey-container-servlet - ${jersey.version} test org.glassfish.jersey.containers jersey-container-grizzly2-http - ${jersey.version} test org.hamcrest hamcrest-library - 1.3 test org.opendaylight.yangtools yang-test-util - 2.0.6.1 test org.glassfish.jersey.core jersey-client - ${jersey.version} test diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index 81ab8811e..39f99d4bc 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -46,6 +46,7 @@ org.onap.ccsdk.sli.core sli-provider + org.onap.appc appc-ssh-adapter-api diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index b47c60409..08ff17caf 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -44,7 +44,6 @@ org.apache.velocity velocity - 1.7
-- cgit From 50afefc403c7ae8d0c54f1602c580fbc7f5dd884 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Tue, 25 Jun 2019 14:53:01 +0000 Subject: Better support for timeouts in RestApiCallNode Support connect timeout and read timeout in a configurable way Issue-ID: CCSDK-1433 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I58d77dfcb48adc2cf917aff29b0eb4a69acb9c17 --- .../sli/plugins/restapicall/RestapiCallNode.java | 32 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index adf723b8b..220e18fd0 100755 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -80,6 +80,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { protected static final String UEB_PROPERTIES_FILE_NAME = "ueb.properties"; protected static final String DEFAULT_PROPERTIES_DIR = "/opt/onap/ccsdk/data/properties"; protected static final String PROPERTIES_DIR_KEY = "SDNC_CONFIG_DIR"; + protected static final int DEFAULT_HTTP_CONNECT_TIMEOUT_MS = 30000; // 30 seconds + protected static final int DEFAULT_HTTP_READ_TIMEOUT_MS = 600000; // 10 minutes private static final Logger log = LoggerFactory.getLogger(RestapiCallNode.class); private String uebServers; @@ -93,7 +95,9 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { protected static final String restapiUrlString = "restapiUrl"; protected static final String restapiUserKey = "restapiUser"; protected static final String restapiPasswordKey = "restapiPassword"; - + protected Integer httpConnectTimeout; + protected Integer httpReadTimeout; + protected HashMap partnerStore; public RestapiCallNode() { @@ -116,6 +120,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } catch (Exception e) { log.warn("UEB properties could not be read, UEB support will not be enabled.", e); } + httpConnectTimeout = readOptionalInteger("HTTP_CONNECT_TIMEOUT_MS",DEFAULT_HTTP_CONNECT_TIMEOUT_MS); + httpReadTimeout = readOptionalInteger("HTTP_READ_TIMEOUT_MS",DEFAULT_HTTP_READ_TIMEOUT_MS); } protected void loadPartners(JSONObject partners) { @@ -754,7 +760,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } else { client = ClientBuilder.newBuilder().hostnameVerifier((s, sslSession) -> true).build(); } - client.property(ClientProperties.CONNECT_TIMEOUT, 5000); + setClientTimeouts(client); // Needed to support additional HTTP methods such as PATCH client.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true); @@ -996,7 +1002,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { protected HttpResponse sendHttpData(byte[] data, FileParam p) throws SvcLogicException { Client client = ClientBuilder.newBuilder().build(); - client.property(ClientProperties.CONNECT_TIMEOUT, 5000); + setClientTimeouts(client); client.property(ClientProperties.FOLLOW_REDIRECTS, true); WebTarget webTarget = addAuthType(client, p).target(p.url); @@ -1127,7 +1133,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } Client client = ClientBuilder.newBuilder().build(); - client.property(ClientProperties.CONNECT_TIMEOUT, 5000); + setClientTimeouts(client); WebTarget webTarget = client.target(urls[0]); log.info("UEB URL: {}", urls[0]); @@ -1173,7 +1179,25 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { public void setDefaultUebTemplateFileName(String defaultUebTemplateFileName) { this.defaultUebTemplateFileName = defaultUebTemplateFileName; } + + protected void setClientTimeouts(Client client) { + client.property(ClientProperties.CONNECT_TIMEOUT, httpConnectTimeout); + client.property(ClientProperties.READ_TIMEOUT, httpReadTimeout); + } + + protected Integer readOptionalInteger(String propertyName, Integer defaultValue) { + String stringValue = System.getProperty(propertyName); + if (stringValue != null && stringValue.length() > 0) { + try { + return Integer.valueOf(stringValue); + } catch (NumberFormatException e) { + log.warn("property " + propertyName + " had the value " + stringValue + " that could not be converted to an Integer, default " + defaultValue + " will be used instead", e); + } + } + return defaultValue; + } + private static class FileParam { public String fileName; -- cgit From bc136f3650f150b96e8940c5d6cf321376338510 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 29 May 2019 21:25:31 +0000 Subject: feature file cleanup instead of each feature file starting ccsdk-sli let it be handled by bootfeatures Change-Id: Ie7f20c8861bf329471c6317ede8128a9c420a9f8 Issue-ID: CCSDK-1370 Signed-off-by: Smokowski, Kevin (ks6305) --- grToolkit/features/ccsdk-gr-toolkit/pom.xml | 7 ---- .../ccsdk-gr-toolkit/src/main/feature/feature.xml | 7 ---- grToolkit/provider/pom.xml | 2 + .../features/ccsdk-properties-node/pom.xml | 8 +--- properties-node/provider/pom.xml | 10 +---- .../features/ccsdk-restapi-call-node/pom.xml | 8 +--- .../features/src/main/resources/features.xml | 42 -------------------- restapi-call-node/provider/pom.xml | 5 +-- .../features/ccsdk-restconf-client/pom.xml | 8 +--- restconf-client/provider/pom.xml | 13 ++++--- .../features/src/main/resources/features.xml | 45 ---------------------- sshapi-call-node/provider/pom.xml | 10 +---- template-node/features/ccsdk-template-node/pom.xml | 8 +--- template-node/provider/pom.xml | 1 + 14 files changed, 17 insertions(+), 157 deletions(-) mode change 100755 => 100644 grToolkit/features/ccsdk-gr-toolkit/pom.xml delete mode 100755 grToolkit/features/ccsdk-gr-toolkit/src/main/feature/feature.xml delete mode 100644 restapi-call-node/features/src/main/resources/features.xml delete mode 100644 sshapi-call-node/features/src/main/resources/features.xml diff --git a/grToolkit/features/ccsdk-gr-toolkit/pom.xml b/grToolkit/features/ccsdk-gr-toolkit/pom.xml old mode 100755 new mode 100644 index 37343c53c..fdbc61b78 --- a/grToolkit/features/ccsdk-gr-toolkit/pom.xml +++ b/grToolkit/features/ccsdk-gr-toolkit/pom.xml @@ -23,13 +23,6 @@ xml features
- - org.onap.ccsdk.sli.core - ccsdk-sli - ${ccsdk.sli.core.version} - xml - features - ${project.groupId} gr-toolkit-model diff --git a/grToolkit/features/ccsdk-gr-toolkit/src/main/feature/feature.xml b/grToolkit/features/ccsdk-gr-toolkit/src/main/feature/feature.xml deleted file mode 100755 index 4a21ca550..000000000 --- a/grToolkit/features/ccsdk-gr-toolkit/src/main/feature/feature.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - mvn:org.onap.ccsdk.sli.core/ccsdk-sli/LATEST/xml/features - - ccsdk-sli - - diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index b624e069e..67c711775 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -48,11 +48,13 @@ org.onap.ccsdk.sli.core sli-common ${ccsdk.sli.core.version} + provided org.onap.ccsdk.sli.core sli-provider ${ccsdk.sli.core.version} + provided sal-test-model diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index ae007d6e4..c919c8434 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -19,13 +19,7 @@ - - org.onap.ccsdk.sli.core - ccsdk-sli - ${ccsdk.sli.core.version} - xml - features - + ${project.groupId} properties-node-provider diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 2e3b5e76c..3ecd80d59 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -14,12 +14,7 @@ bundle ccsdk-sli-plugins :: properties-node :: ${project.artifactId} - http://maven.apache.org - - UTF-8 - - @@ -46,10 +41,7 @@ org.onap.ccsdk.sli.core sli-common - - - org.onap.ccsdk.sli.core - sli-provider + provided org.slf4j diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 7062d6102..09657337c 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -22,13 +22,7 @@ javax.ws.rs javax.ws.rs-api - - org.onap.ccsdk.sli.core - ccsdk-sli - ${ccsdk.sli.core.version} - xml - features - + ${project.groupId} restapi-call-node-provider diff --git a/restapi-call-node/features/src/main/resources/features.xml b/restapi-call-node/features/src/main/resources/features.xml deleted file mode 100644 index 3734a951a..000000000 --- a/restapi-call-node/features/src/main/resources/features.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features - - - sdnc-sli - spring - spring-dm - mvn:com.sun.jersey/jersey-client/${jersey.version} - mvn:com.sun.jersey.contribs.jersey-oauth/oauth-signature/${jersey.version} - mvn:com.sun.jersey.contribs.jersey-oauth/oauth-client/${jersey.version} - mvn:org.codehaus.jettison/jettison/${jettison.version} - mvn:org.onap.ccsdk.sli.plugins/restapi-call-node-provider/${project.version} - - - diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 0d23912fd..57af60727 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -15,10 +15,6 @@ ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} - - UTF-8 - - @@ -39,6 +35,7 @@ org.onap.ccsdk.sli.core sli-common + provided org.slf4j diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index 677a24671..985cc8daf 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -25,13 +25,7 @@ - - org.onap.ccsdk.sli.core - ccsdk-sli - ${ccsdk.sli.core.version} - xml - features - + ${project.groupId} restconf-client-provider diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 9fa247557..2c4b8c3ea 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -14,11 +14,6 @@ bundle ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} - http://maven.apache.org - - - UTF-8 - @@ -44,7 +39,13 @@ org.onap.ccsdk.sli.core sli-common - + provided + + + org.onap.ccsdk.sli.core + sli-provider + provided + org.onap.ccsdk.sli.core sli-provider diff --git a/sshapi-call-node/features/src/main/resources/features.xml b/sshapi-call-node/features/src/main/resources/features.xml deleted file mode 100644 index fd7caf535..000000000 --- a/sshapi-call-node/features/src/main/resources/features.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features - - - - sdnc-sli - spring - spring-dm - mvn:org.codehaus.jettison/jettison/${jettison.version} - mvn:org.onap.ccsdk.sli.core/sli-common/${project.version} - mvn:org.onap.ccsdk.sli.core/sli-provider/${project.version} - mvn:org.onap.appc/appc-ssh-adapter-api/1.3.0 - mvn:org.onap.ccsdk.sli.plugins/sshapi-call-node-provider/${project.version} - - - diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index 39f99d4bc..b71e15765 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -14,11 +14,6 @@ bundle ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} - http://maven.apache.org - - - UTF-8 - @@ -41,10 +36,7 @@ org.onap.ccsdk.sli.core sli-common - - - org.onap.ccsdk.sli.core - sli-provider + provided diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index f7a708729..115329bf5 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -17,13 +17,7 @@ ccsdk-sli-plugins :: template-node :: ${project.artifactId} - - org.onap.ccsdk.sli.core - ccsdk-sli - ${ccsdk.sli.core.version} - xml - features - + ${project.groupId} template-node-provider diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index 08ff17caf..543a40d5e 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -36,6 +36,7 @@ org.onap.ccsdk.sli.core sli-common + provided org.slf4j -- cgit From 6b569b470a01b78f09bbed112c3787783eab4794 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 12 Jul 2019 08:34:30 -0400 Subject: Add Brinda as committer Added Brinda as committer to INFO.yaml Change-Id: I05c80a149f0429065fe42703d655cd89a87d0fec Issue-ID: CCSDK-1480 Signed-off-by: Timoney, Dan (dt5972) --- INFO.yaml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/INFO.yaml b/INFO.yaml index df82604b7..566a7971e 100644 --- a/INFO.yaml +++ b/INFO.yaml @@ -22,7 +22,7 @@ realtime_discussion: '' meetings: - type: 'zoom' agenda: 'https://wiki.onap.org/display/DW/Common+Controller+SDK+Project' - url: 'https://wiki.onap.org/display/DW/Common+Controller+SDK+Project#CommonControllerSDKProject-MeetingMinutes' + url: 'https://wiki.onap.org/display/DW/Common+Controller+SDK+Project' server: 'n/a' channel: 'n/a' repeats: 'weekly' @@ -44,6 +44,11 @@ committers: company: 'Huawei' id: 'agrawalgaurav' timezone: 'Asia/Kolkata' + - name: 'Brinda Santh Muthuramalingam' + email: 'brindasanth@in.ibm.com' + company: 'IBM' + id: 'brindasanthm' + timezone: 'America/New York' repositories: - ccsdk-apps - ccsdk-cds @@ -64,8 +69,9 @@ tsc: - type: 'Deletion' name: 'Ryan Goulding' link: 'https://lists.onap.org/g/onap-tsc/message/4261' - changes: - type: 'Addition' name: 'Gaurav Agrawal' link: 'https://lists.onap.org/g/onap-tsc/message/4324' - + - type: 'Addition' + name: 'Brinda Santh Muthuramalingam' + link: 'https://lists.onap.org/g/onap-tsc/message/5208' -- cgit From 1201ff98e4c7856b03b268302e4aed2cdc6e1dbb Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 17 Jul 2019 11:01:32 -0400 Subject: Update parent version to 1.3.1 Update parent poms to version 1.3.1-SNAPSHOT Change-Id: Ie3039a7d625a78b4ef1bf5170dcfe0553f9e9594 Issue-ID: CCSDK-1496 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 2 +- features/ccsdk-sli-plugins-all/pom.xml | 2 +- features/features-sli-plugins/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- grToolkit/features/ccsdk-gr-toolkit/pom.xml | 2 +- grToolkit/features/features-gr-toolkit/pom.xml | 2 +- grToolkit/features/pom.xml | 2 +- grToolkit/installer/pom.xml | 2 +- grToolkit/model/pom.xml | 2 +- grToolkit/pom.xml | 2 +- grToolkit/provider/pom.xml | 2 +- pom.xml | 2 +- properties-node/features/ccsdk-properties-node/pom.xml | 2 +- properties-node/features/features-properties-node/pom.xml | 2 +- properties-node/features/pom.xml | 2 +- properties-node/installer/pom.xml | 2 +- properties-node/pom.xml | 2 +- properties-node/provider/pom.xml | 2 +- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/features-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/pom.xml | 2 +- restapi-call-node/installer/pom.xml | 2 +- restapi-call-node/pom.xml | 2 +- restapi-call-node/provider/pom.xml | 2 +- restconf-client/features/ccsdk-restconf-client/pom.xml | 2 +- restconf-client/features/features-restconf-client/pom.xml | 2 +- restconf-client/features/pom.xml | 2 +- restconf-client/installer/pom.xml | 2 +- restconf-client/pom.xml | 2 +- restconf-client/provider/pom.xml | 2 +- sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml | 2 +- sshapi-call-node/features/features-sshapi-call-node/pom.xml | 2 +- sshapi-call-node/features/pom.xml | 2 +- sshapi-call-node/installer/pom.xml | 2 +- sshapi-call-node/pom.xml | 2 +- sshapi-call-node/provider/pom.xml | 2 +- template-node/features/ccsdk-template-node/pom.xml | 2 +- template-node/features/features-template-node/pom.xml | 2 +- template-node/features/pom.xml | 2 +- template-node/installer/pom.xml | 2 +- template-node/pom.xml | 2 +- template-node/provider/pom.xml | 2 +- 43 files changed, 43 insertions(+), 43 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 261b955e4..3ffab5542 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index f36956a9c..b34bb0e9a 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index 931e46063..75038f559 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 58143e79f..ac3f7f9ab 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/features/pom.xml b/features/pom.xml index d8553b42f..20653b8c4 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/grToolkit/features/ccsdk-gr-toolkit/pom.xml b/grToolkit/features/ccsdk-gr-toolkit/pom.xml index fdbc61b78..3e6c0934f 100644 --- a/grToolkit/features/ccsdk-gr-toolkit/pom.xml +++ b/grToolkit/features/ccsdk-gr-toolkit/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/grToolkit/features/features-gr-toolkit/pom.xml b/grToolkit/features/features-gr-toolkit/pom.xml index 441e2e855..b40c67403 100755 --- a/grToolkit/features/features-gr-toolkit/pom.xml +++ b/grToolkit/features/features-gr-toolkit/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/grToolkit/features/pom.xml b/grToolkit/features/pom.xml index a27e71853..ea5d00d54 100755 --- a/grToolkit/features/pom.xml +++ b/grToolkit/features/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/grToolkit/installer/pom.xml b/grToolkit/installer/pom.xml index 831edf707..13949b096 100755 --- a/grToolkit/installer/pom.xml +++ b/grToolkit/installer/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/grToolkit/model/pom.xml b/grToolkit/model/pom.xml index 439b05f0c..ab85fccfd 100755 --- a/grToolkit/model/pom.xml +++ b/grToolkit/model/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent binding-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/pom.xml b/grToolkit/pom.xml index 2cdc71d08..2b47ba604 100755 --- a/grToolkit/pom.xml +++ b/grToolkit/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index 67c711775..9e30d1e35 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent binding-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index e66a40794..7c9feb460 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index c919c8434..69bdaddaa 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index 0db5a9042..a4479ad33 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 79d56ff04..ac155ad59 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 42732871b..1f5806477 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/properties-node/pom.xml b/properties-node/pom.xml index de936d9f2..4e66bc700 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 3ecd80d59..da88c07f0 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 09657337c..ab2f8b659 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index b5329ea8f..f230f0a1c 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index 4820b7dd5..b9afd7ff4 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index d51cc610e..647e3a437 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index a84d3232d..37d53f563 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 57af60727..8c51f9974 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index 985cc8daf..cde001de7 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml index 032a781e1..a902f9d72 100644 --- a/restconf-client/features/features-restconf-client/pom.xml +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml index ae4000266..bc658c9d9 100755 --- a/restconf-client/features/pom.xml +++ b/restconf-client/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index bcf9e998d..47c5a4059 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index b9cad2629..2b1643062 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 2c4b8c3ea..c064394d1 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index a34b4aeee..a50f17893 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml index 04338facf..cf12bca82 100644 --- a/sshapi-call-node/features/features-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/features-sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml index 35be47a4e..6c77b070a 100755 --- a/sshapi-call-node/features/pom.xml +++ b/sshapi-call-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index 029b94dea..64c352796 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index 99c6d9edd..d820e871d 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index b71e15765..60abe7560 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index 115329bf5..c72f76951 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml index 3c6f6d853..837b1c138 100644 --- a/template-node/features/features-template-node/pom.xml +++ b/template-node/features/features-template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml index f919d1c09..10c74b8d3 100644 --- a/template-node/features/pom.xml +++ b/template-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index 35161b8e5..93d56bb05 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/template-node/pom.xml b/template-node/pom.xml index b65c40e24..6244c8d10 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index 543a40d5e..2a99c1029 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT org.onap.ccsdk.sli.plugins -- cgit From 57bfbb05e485fb11b620b1bf12e70aa063aaa3c8 Mon Sep 17 00:00:00 2001 From: "Agarwal, Ruchira (ra1926)" Date: Mon, 22 Jul 2019 20:26:50 +0000 Subject: configurable param resolution support config parameter resolution to k8s secret value Issue-ID: CCSDK-1502 Signed-off-by: Agarwal, Ruchira (ra1926) Change-Id: I8acc98fa3fdd9ba46c617b4d0113086c1e889997 --- properties-node/provider/pom.xml | 24 +++++--- .../ccsdk/sli/plugins/prop/PropertiesNode.java | 27 +++++++-- .../ccsdk/sli/plugins/prop/TestPropertiesNode.java | 9 +++ .../provider/src/test/resources/test.txt | 3 +- restapi-call-node/provider/pom.xml | 24 +++++--- .../sli/plugins/restapicall/RestapiCallNode.java | 21 ++++++- .../plugins/restapicall/TestRestapiCallNode.java | 64 ++++++++++++++-------- .../provider/src/test/resources/partners.json | 6 ++ .../provider/src/test/resources/ueb.properties | 6 ++ 9 files changed, 138 insertions(+), 46 deletions(-) create mode 100644 restapi-call-node/provider/src/test/resources/ueb.properties diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index da88c07f0..46c0dbac4 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -16,15 +16,15 @@ ccsdk-sli-plugins :: properties-node :: ${project.artifactId} - - - org.onap.ccsdk.sli.core - sli-core-artifacts - ${ccsdk.sli.core.version} - pom - import - - + + + org.onap.ccsdk.sli.core + sli-core-artifacts + ${ccsdk.sli.core.version} + pom + import + + @@ -33,6 +33,12 @@ junit test + + com.github.stefanbirkner + system-rules + 1.19.0 + test + org.springframework spring-test diff --git a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java index f0c7e0b45..b4bc84747 100644 --- a/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java +++ b/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. + * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,14 +63,14 @@ public class PropertiesNode implements SvcLogicJavaPlugin { String name = (String) key; String value = prop.getProperty(name); if (value != null && value.trim().length() > 0) { - ctx.setAttribute(pfx + name, value.trim()); + ctx.setAttribute(pfx + name, getObfuscatedVal(value.trim())); log.info("+++ " + pfx + name + ": [" + maskPassword(pfx + name, value) + "]"); } } } if (mm != null) { for (Map.Entry entry : mm.entrySet()) { - ctx.setAttribute(pfx + entry.getKey(), entry.getValue()); + ctx.setAttribute(pfx + entry.getKey(), getObfuscatedVal(entry.getValue())); log.info("+++ " + pfx + entry.getKey() + ": [" + maskPassword(pfx + entry.getKey(), entry.getValue()) + "]"); } @@ -81,7 +81,7 @@ public class PropertiesNode implements SvcLogicJavaPlugin { String name = (String) key; String value = prop.getProperty(name); if (value != null && value.trim().length() > 0) { - ctx.setAttribute(pfx + name, value.trim()); + ctx.setAttribute(pfx + name, getObfuscatedVal(value.trim())); log.info("+++ " + pfx + name + ": [" + maskPassword(pfx + name, value) + "]"); } } @@ -92,6 +92,25 @@ public class PropertiesNode implements SvcLogicJavaPlugin { } } + /* Unobfuscate param value */ + private static String getObfuscatedVal(String paramValue) { + String resValue = paramValue; + if (paramValue != null && paramValue.startsWith("${") && paramValue.endsWith("}")) + { + String paramStr = paramValue.substring(2, paramValue.length()-1); + if (paramStr != null && paramStr.length() > 0) + { + String val = System.getenv(paramStr); + if (val != null && val.length() > 0) + { + resValue=val; + log.info("Obfuscated value RESET for param value:" + paramValue); + } + } + } + return resValue; + } + /* * Getting extension has to do the following "" --> "" "name" --> "" "name.txt" --> "txt" * ".htpasswd" --> "" "name.with.many.dots.myext" --> "myext" diff --git a/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java b/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java index f1e0ab627..a858c49b3 100644 --- a/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java +++ b/properties-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/prop/TestPropertiesNode.java @@ -5,7 +5,9 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.junit.Rule; import org.junit.Test; +import org.junit.contrib.java.lang.system.EnvironmentVariables; import static org.junit.Assert.assertEquals; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; @@ -16,6 +18,8 @@ import org.slf4j.LoggerFactory; public class TestPropertiesNode { private static final Logger log = LoggerFactory.getLogger(TestPropertiesNode.class); + @Rule + public EnvironmentVariables environmentVariables = new EnvironmentVariables(); @Test public void testJSONFileParsing() throws SvcLogicException { @@ -129,6 +133,10 @@ public class TestPropertiesNode { @Test public void testTXTFileParsing() throws SvcLogicException { + + environmentVariables.set("deployer_pass", "sdncp-123"); + assertEquals("sdncp-123", System.getenv("deployer_pass")); + SvcLogicContext ctx = new SvcLogicContext(); Map p = new HashMap(); @@ -147,6 +155,7 @@ public class TestPropertiesNode { "access-information.l1-customer-handoff"),"_1000BASELX"); assertEquals(ctx.getAttribute("test-txt.service-data.avpn-ip-port-information.avpn-" + "access-information.vlan-tag-control"),"_1Q"); + assertEquals(ctx.getAttribute("test-txt.obfuscated-var"), "sdncp-123"); } @Test diff --git a/properties-node/provider/src/test/resources/test.txt b/properties-node/provider/src/test/resources/test.txt index 79e8acff4..68b916cbb 100644 --- a/properties-node/provider/src/test/resources/test.txt +++ b/properties-node/provider/src/test/resources/test.txt @@ -27,4 +27,5 @@ service-data.avpn-ip-port-information.contracted-port-speed-units = Kbps service-data.avpn-ip-port-information.endpoint-information.bundle-id = 33 service-data.avpn-ip-port-information.endpoint-information.interface-string = ae0 service-data.service-information.service-instance-id = ICORESITE-2751508 -service-data.service-information.service-type = AVPN \ No newline at end of file +service-data.service-information.service-type = AVPN +obfuscated-var=${deployer_pass} diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 8c51f9974..0373d1784 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -16,15 +16,15 @@ ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} - - - org.onap.ccsdk.sli.core - sli-core-artifacts - ${ccsdk.sli.core.version} - pom - import - - + + + org.onap.ccsdk.sli.core + sli-core-artifacts + ${ccsdk.sli.core.version} + pom + import + + @@ -72,6 +72,12 @@ junit test + + com.github.stefanbirkner + system-rules + 1.19.0 + test + org.glassfish.jersey.containers jersey-container-servlet diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 220e18fd0..c539010fb 100755 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -141,7 +141,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } String userName = partnerObject.getString(partnerUserKey); String password = partnerObject.getString(partnerPasswordKey); - PartnerDetails details = new PartnerDetails(userName, password, url); + PartnerDetails details = new PartnerDetails(userName, getObfuscatedVal(password), url); partnerStore.put(partnerKey, details); log.info("mapped partner using partner key " + partnerKey); } else { @@ -153,6 +153,25 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } } + /* Unobfuscate param value */ + private static String getObfuscatedVal(String paramValue) { + String resValue = paramValue; + if (paramValue != null && paramValue.startsWith("${") && paramValue.endsWith("}")) + { + String paramStr = paramValue.substring(2, paramValue.length()-1); + if (paramStr != null && paramStr.length() > 0) + { + String val = System.getenv(paramStr); + if (val != null && val.length() > 0) + { + resValue=val; + log.info("Obfuscated value RESET for param value:" + paramValue); + } + } + } + return resValue; + } + /** * Returns parameters from the parameter map. * diff --git a/restapi-call-node/provider/src/test/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index 50371278a..a130d4390 100755 --- a/restapi-call-node/provider/src/test/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -3,7 +3,7 @@ * openECOMP : SDN-C * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. + * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,9 @@ import static org.junit.Assert.assertNull; import java.util.HashMap; import java.util.Map; +import org.junit.Rule; import org.junit.Test; +import org.junit.contrib.java.lang.system.EnvironmentVariables; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; @@ -38,6 +40,9 @@ public class TestRestapiCallNode { @SuppressWarnings("unused") private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class); + @Rule + public EnvironmentVariables environmentVariables = new EnvironmentVariables(); + @Test @@ -459,11 +464,15 @@ public class TestRestapiCallNode { */ @Test public void testPartners() throws Exception{ - String partnerTwoKey = "partnerTwo"; - String partnerTwoUsername = "controller_user"; - String partnerTwoPassword = "P@ssword"; - System.setProperty("SDNC_CONFIG_DIR", "src/test/resources"); + environmentVariables.set("deployer_pass", "sdncp-123"); + assertEquals("sdncp-123", System.getenv("deployer_pass")); + + String partnerTwoKey = "partnerTwo"; + String partnerTwoUsername = "controller_user"; + String partnerTwoPassword = "P@ssword"; + + System.setProperty("SDNC_CONFIG_DIR", "src/test/resources"); RestapiCallNode rcn = new RestapiCallNode(); assertNull(rcn.partnerStore.get("partnerOne")); PartnerDetails details = rcn.partnerStore.get(partnerTwoKey); @@ -474,7 +483,7 @@ public class TestRestapiCallNode { //In this scenario the caller expects username, password and url to be picked up from the partners json Map paramMap = new HashMap(); paramMap.put("partner", partnerTwoKey); - rcn.handlePartner(paramMap ); + rcn.handlePartner(paramMap ); assertEquals(partnerTwoUsername,paramMap.get(rcn.restapiUserKey)); assertEquals(partnerTwoPassword,paramMap.get(rcn.restapiPasswordKey)); assertEquals("http://localhost:7002",paramMap.get(rcn.restapiUrlString)); @@ -484,28 +493,39 @@ public class TestRestapiCallNode { paramMap = new HashMap(); paramMap.put("partner", partnerTwoKey); paramMap.put("restapiUrlSuffix", "/networking/v1/instance/3"); - rcn.handlePartner(paramMap); - Parameters p = new Parameters(); - RestapiCallNode.getParameters(paramMap, p); + rcn.handlePartner(paramMap); + p = new Parameters(); + RestapiCallNode.getParameters(paramMap, p); assertEquals(partnerTwoUsername,p.restapiUser); assertEquals(partnerTwoPassword,p.restapiPassword); assertEquals("http://localhost:7002/networking/v1/instance/3",p.restapiUrl); + + paramMap = new HashMap(); + paramMap.put("partner","partnerFour" ); + paramMap.put("httpMethod", "delete"); + paramMap.put("skipSending", "true"); + rcn.handlePartner(paramMap); + Parameters p = new Parameters(); + RestapiCallNode.getParameters(paramMap, p); + assertEquals(p.restapiPassword, "sdncp-123"); + assertEquals(p.restapiUser, "m30402@sdncp.att.com"); + assertEquals(p.restapiUrl, "http://localhost:7004"); } @Test public void retryPolicyBean() throws Exception { - Integer retries = 3; - String first = "http://localhost:7001"; - String second = "http://localhost:7001"; - - RetryPolicy p = new RetryPolicy(new String[] {first,second}, retries); - assertEquals(retries,p.getMaximumRetries()); - assertNotNull(p.getRetryMessage()); - String next = p.getNextHostName(); - assertEquals(second,next); - assertEquals(1,p.getRetryCount()); - next = p.getNextHostName(); - assertEquals(first,next); - assertEquals(2,p.getRetryCount()); + Integer retries = 3; + String first = "http://localhost:7001"; + String second = "http://localhost:7001"; + + RetryPolicy p = new RetryPolicy(new String[] {first,second}, retries); + assertEquals(retries,p.getMaximumRetries()); + assertNotNull(p.getRetryMessage()); + String next = p.getNextHostName(); + assertEquals(second,next); + assertEquals(1,p.getRetryCount()); + next = p.getNextHostName(); + assertEquals(first,next); + assertEquals(2,p.getRetryCount()); } } diff --git a/restapi-call-node/provider/src/test/resources/partners.json b/restapi-call-node/provider/src/test/resources/partners.json index 9a17a1acf..2562d69c0 100755 --- a/restapi-call-node/provider/src/test/resources/partners.json +++ b/restapi-call-node/provider/src/test/resources/partners.json @@ -12,5 +12,11 @@ "partnerThree": { "url": "http://localhost:7003", "user": "controller_admin" + }, + "partnerFour": { + "url": "http://localhost:7004", + "user": "m30402@sdncp.att.com", + "password": "${deployer_pass}", + "test": "/metrics" } } diff --git a/restapi-call-node/provider/src/test/resources/ueb.properties b/restapi-call-node/provider/src/test/resources/ueb.properties new file mode 100644 index 000000000..96657ee1a --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/ueb.properties @@ -0,0 +1,6 @@ +#for other servers see http://sa2020.it.att.com:8888/sw/cambria/installs + +#to check connectivity http://hostname:3904/metrics + +servers=http://uebsb91kcdc.it.att.com:3904 http://uebsb92kcdc.it.att.com:3904 http://uebsb93kcdc.it.att.com:3904 + -- cgit From e4d32693d7006cd9f8687a99ef5bf5d8136e2bcd Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 2 Aug 2019 16:05:58 -0400 Subject: Release sli/plugins 0.5.0 Release sli/plugins version 0.5.0 Change-Id: Ib1f75577de0fd486b1ef83b6b41c237bbec95617 Issue-ID: CCSDK-1563 Signed-off-by: Timoney, Dan (dt5972) --- releases/0.5.0.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releases/0.5.0.yaml diff --git a/releases/0.5.0.yaml b/releases/0.5.0.yaml new file mode 100644 index 000000000..37ba918ab --- /dev/null +++ b/releases/0.5.0.yaml @@ -0,0 +1,5 @@ +--- +distribution_type: 'maven' +version: '0.5.0' +project: 'ccsdk-sli-plugins' +log_dir: 'ccsdk-sli-plugins-maven-stage-master/160/' -- cgit From ca4d38ae43092c4daab3eb172decc71c9ce1339a Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 6 Aug 2019 11:40:00 -0400 Subject: Roll version to recreate artifacts Roll version to 0.5.1 to recreate El Alto early drop artifacts Change-Id: Iccd4d14f5e0f55ab994a72cbf5b661c5790e2ae8 Issue-ID: CCSDK-1563 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 4 ++-- features/ccsdk-sli-plugins-all/pom.xml | 4 ++-- features/features-sli-plugins/pom.xml | 4 ++-- features/installer/pom.xml | 4 ++-- features/pom.xml | 4 ++-- grToolkit/features/ccsdk-gr-toolkit/pom.xml | 4 ++-- grToolkit/features/features-gr-toolkit/pom.xml | 4 ++-- grToolkit/features/pom.xml | 4 ++-- grToolkit/installer/pom.xml | 4 ++-- grToolkit/model/pom.xml | 4 ++-- grToolkit/pom.xml | 4 ++-- grToolkit/provider/pom.xml | 4 ++-- pom.xml | 4 ++-- properties-node/features/ccsdk-properties-node/pom.xml | 4 ++-- properties-node/features/features-properties-node/pom.xml | 4 ++-- properties-node/features/pom.xml | 4 ++-- properties-node/installer/pom.xml | 4 ++-- properties-node/pom.xml | 4 ++-- properties-node/provider/pom.xml | 4 ++-- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/features-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/pom.xml | 4 ++-- restapi-call-node/installer/pom.xml | 4 ++-- restapi-call-node/pom.xml | 4 ++-- restapi-call-node/provider/pom.xml | 4 ++-- restconf-client/features/ccsdk-restconf-client/pom.xml | 4 ++-- restconf-client/features/features-restconf-client/pom.xml | 4 ++-- restconf-client/features/pom.xml | 4 ++-- restconf-client/installer/pom.xml | 4 ++-- restconf-client/pom.xml | 4 ++-- restconf-client/provider/pom.xml | 4 ++-- sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/features/features-sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/features/pom.xml | 4 ++-- sshapi-call-node/installer/pom.xml | 4 ++-- sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/provider/pom.xml | 4 ++-- template-node/features/ccsdk-template-node/pom.xml | 4 ++-- template-node/features/features-template-node/pom.xml | 4 ++-- template-node/features/pom.xml | 4 ++-- template-node/installer/pom.xml | 4 ++-- template-node/pom.xml | 4 ++-- template-node/provider/pom.xml | 4 ++-- version.properties | 2 +- 44 files changed, 87 insertions(+), 87 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 3ffab5542..71e315341 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.plugins sli-plugins-artifacts - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-plugins :: sli-plugins-artifacts @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.3.1-SNAPSHOT + 1.3.2 diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index b34bb0e9a..2522ce584 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins ccsdk-sli-plugins-all - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index 75038f559..da9a571b0 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins features-sli-plugins - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index ac3f7f9ab..baa4fc381 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins sliplugins-features-installer - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 20653b8c4..77bc51efe 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins sliplugins-feature-aggregator - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-plugins :: features diff --git a/grToolkit/features/ccsdk-gr-toolkit/pom.xml b/grToolkit/features/ccsdk-gr-toolkit/pom.xml index 3e6c0934f..a25d95c67 100644 --- a/grToolkit/features/ccsdk-gr-toolkit/pom.xml +++ b/grToolkit/features/ccsdk-gr-toolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins ccsdk-gr-toolkit - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/features/features-gr-toolkit/pom.xml b/grToolkit/features/features-gr-toolkit/pom.xml index b40c67403..33a713524 100755 --- a/grToolkit/features/features-gr-toolkit/pom.xml +++ b/grToolkit/features/features-gr-toolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins features-gr-toolkit - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/features/pom.xml b/grToolkit/features/pom.xml index ea5d00d54..a91fdeef7 100755 --- a/grToolkit/features/pom.xml +++ b/grToolkit/features/pom.xml @@ -4,14 +4,14 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} gr-toolkit-features org.onap.ccsdk.sli.plugins - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom diff --git a/grToolkit/installer/pom.xml b/grToolkit/installer/pom.xml index 13949b096..59b5d4e91 100755 --- a/grToolkit/installer/pom.xml +++ b/grToolkit/installer/pom.xml @@ -4,14 +4,14 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-installer - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-gr-toolkit diff --git a/grToolkit/model/pom.xml b/grToolkit/model/pom.xml index ab85fccfd..a1d5ac47f 100755 --- a/grToolkit/model/pom.xml +++ b/grToolkit/model/pom.xml @@ -4,13 +4,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.1-SNAPSHOT + 1.3.2 ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-model - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT bundle diff --git a/grToolkit/pom.xml b/grToolkit/pom.xml index 2b47ba604..e2b77ca33 100755 --- a/grToolkit/pom.xml +++ b/grToolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins gr-toolkit - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-plugins :: gr-toolkit diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index 9e30d1e35..6d6164354 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -4,13 +4,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.1-SNAPSHOT + 1.3.2 ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-provider - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT bundle diff --git a/pom.xml b/pom.xml index 7c9feb460..d695012d2 100755 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index 69bdaddaa..11ed8b4d7 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins ccsdk-properties-node - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index a4479ad33..118a272ed 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins features-properties-node - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index ac155ad59..adeb6fed3 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins properties-node-features - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 1f5806477..d0403454a 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins properties-node-installer - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 4e66bc700..576bb5b69 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins properties-node - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-plugins :: properties-node diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 46c0dbac4..812f7cb70 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins properties-node-provider - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT bundle ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index ab2f8b659..31140f805 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins ccsdk-restapi-call-node - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index f230f0a1c..e14e04be0 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins features-restapi-call-node - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index b9afd7ff4..5a80ef1ab 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins restapi-call-node-features - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 647e3a437..6824f5024 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins restapi-call-node-installer - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 37d53f563..530a449f6 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins restapi-call-node - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 0373d1784..c4a83539e 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT bundle ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index cde001de7..f9cc2e5f7 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins ccsdk-restconf-client - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml index a902f9d72..64501ff40 100644 --- a/restconf-client/features/features-restconf-client/pom.xml +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins features-restconf-client - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml index bc658c9d9..713b42f2c 100755 --- a/restconf-client/features/pom.xml +++ b/restconf-client/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins restconf-client-features - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index 47c5a4059..33e874171 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins restconf-client-installer - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index 2b1643062..069494eab 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins restconf-client - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index c064394d1..7b1f2cbfe 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins restconf-client-provider - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT bundle ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index a50f17893..e34271786 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins ccsdk-sshapi-call-node - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml index cf12bca82..9f43dbf42 100644 --- a/sshapi-call-node/features/features-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/features-sshapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins features-sshapi-call-node - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml index 6c77b070a..b91af1fa2 100755 --- a/sshapi-call-node/features/pom.xml +++ b/sshapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins sshapi-call-node-features - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index 64c352796..12a744e29 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins sshapi-call-node-installer - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index d820e871d..bb1a0dfc4 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins sshapi-call-node - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index 60abe7560..45e3bb5ce 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins sshapi-call-node-provider - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT bundle ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index c72f76951..5ee4d0fe1 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins ccsdk-template-node - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml index 837b1c138..0641a5a32 100644 --- a/template-node/features/features-template-node/pom.xml +++ b/template-node/features/features-template-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins features-template-node - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml index 10c74b8d3..9fa5fc199 100644 --- a/template-node/features/pom.xml +++ b/template-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins template-node-features - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index 93d56bb05..d522ba52a 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins template-node-installer - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/template-node/pom.xml b/template-node/pom.xml index 6244c8d10..b75227f6a 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins template-node - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index 2a99c1029..21ef16e99 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.plugins template-node-provider - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT bundle ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/version.properties b/version.properties index c8bc76801..2cb9acc8c 100644 --- a/version.properties +++ b/version.properties @@ -7,7 +7,7 @@ release_name=0 sprint_number=5 -feature_revision=0 +feature_revision=1 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit From d8417485eafee8c767714e35e38a9701a885fe8a Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 7 Aug 2019 15:55:44 -0400 Subject: Release CCSDK version 0.5.1 Release version 0.5.1 of CCSDK artifacts Change-Id: I171d9e1f89afb5ce2f51a455ad75202a51923c6c Issue-ID: CCSDK-1563 Signed-off-by: Timoney, Dan (dt5972) --- releases/0.5.1.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releases/0.5.1.yaml diff --git a/releases/0.5.1.yaml b/releases/0.5.1.yaml new file mode 100644 index 000000000..ca3ff0c0e --- /dev/null +++ b/releases/0.5.1.yaml @@ -0,0 +1,5 @@ +--- +distribution_type: 'maven' +version: '0.5.1' +project: 'ccsdk-sli-plugins' +log_dir: 'ccsdk-sli-plugins-maven-stage-master/166/' -- cgit From 7ebd5f81dbe0f852c1383712270dae1bbd96527e Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 9 Aug 2019 13:55:10 -0400 Subject: Roll to next snapshot Roll to next snapshot version Change-Id: Ic49a7e77c9234ade7cf0e0c36cb830de2ef870ca Issue-ID: CCSDK-1563 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 4 ++-- features/ccsdk-sli-plugins-all/pom.xml | 4 ++-- features/features-sli-plugins/pom.xml | 4 ++-- features/installer/pom.xml | 4 ++-- features/pom.xml | 4 ++-- grToolkit/features/ccsdk-gr-toolkit/pom.xml | 4 ++-- grToolkit/features/features-gr-toolkit/pom.xml | 4 ++-- grToolkit/features/pom.xml | 4 ++-- grToolkit/installer/pom.xml | 4 ++-- grToolkit/model/pom.xml | 4 ++-- grToolkit/pom.xml | 4 ++-- grToolkit/provider/pom.xml | 4 ++-- pom.xml | 4 ++-- properties-node/features/ccsdk-properties-node/pom.xml | 4 ++-- properties-node/features/features-properties-node/pom.xml | 4 ++-- properties-node/features/pom.xml | 4 ++-- properties-node/installer/pom.xml | 4 ++-- properties-node/pom.xml | 4 ++-- properties-node/provider/pom.xml | 4 ++-- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/features-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/pom.xml | 4 ++-- restapi-call-node/installer/pom.xml | 4 ++-- restapi-call-node/pom.xml | 4 ++-- restapi-call-node/provider/pom.xml | 4 ++-- restconf-client/features/ccsdk-restconf-client/pom.xml | 4 ++-- restconf-client/features/features-restconf-client/pom.xml | 4 ++-- restconf-client/features/pom.xml | 4 ++-- restconf-client/installer/pom.xml | 4 ++-- restconf-client/pom.xml | 4 ++-- restconf-client/provider/pom.xml | 4 ++-- sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/features/features-sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/features/pom.xml | 4 ++-- sshapi-call-node/installer/pom.xml | 4 ++-- sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/provider/pom.xml | 4 ++-- template-node/features/ccsdk-template-node/pom.xml | 4 ++-- template-node/features/features-template-node/pom.xml | 4 ++-- template-node/features/pom.xml | 4 ++-- template-node/installer/pom.xml | 4 ++-- template-node/pom.xml | 4 ++-- template-node/provider/pom.xml | 4 ++-- version.properties | 2 +- 44 files changed, 87 insertions(+), 87 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 71e315341..9bc3a9c9b 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.plugins sli-plugins-artifacts - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-plugins :: sli-plugins-artifacts @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.3.2 + 1.3.3-SNAPSHOT diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index 2522ce584..6b7bf94d6 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins-all - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index da9a571b0..436306765 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins features-sli-plugins - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index baa4fc381..3d662e444 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins sliplugins-features-installer - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 77bc51efe..29a67a820 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins sliplugins-feature-aggregator - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-plugins :: features diff --git a/grToolkit/features/ccsdk-gr-toolkit/pom.xml b/grToolkit/features/ccsdk-gr-toolkit/pom.xml index a25d95c67..1f4aec3f8 100644 --- a/grToolkit/features/ccsdk-gr-toolkit/pom.xml +++ b/grToolkit/features/ccsdk-gr-toolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-gr-toolkit - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/features/features-gr-toolkit/pom.xml b/grToolkit/features/features-gr-toolkit/pom.xml index 33a713524..65b1a5d57 100755 --- a/grToolkit/features/features-gr-toolkit/pom.xml +++ b/grToolkit/features/features-gr-toolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins features-gr-toolkit - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/features/pom.xml b/grToolkit/features/pom.xml index a91fdeef7..c7f8ffea7 100755 --- a/grToolkit/features/pom.xml +++ b/grToolkit/features/pom.xml @@ -4,14 +4,14 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} gr-toolkit-features org.onap.ccsdk.sli.plugins - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom diff --git a/grToolkit/installer/pom.xml b/grToolkit/installer/pom.xml index 59b5d4e91..64e172cc2 100755 --- a/grToolkit/installer/pom.xml +++ b/grToolkit/installer/pom.xml @@ -4,14 +4,14 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-installer - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-gr-toolkit diff --git a/grToolkit/model/pom.xml b/grToolkit/model/pom.xml index a1d5ac47f..f400a04cc 100755 --- a/grToolkit/model/pom.xml +++ b/grToolkit/model/pom.xml @@ -4,13 +4,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.2 + 1.3.3-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-model - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT bundle diff --git a/grToolkit/pom.xml b/grToolkit/pom.xml index e2b77ca33..c36c1a08d 100755 --- a/grToolkit/pom.xml +++ b/grToolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins gr-toolkit - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-plugins :: gr-toolkit diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index 6d6164354..1d8149592 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -4,13 +4,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.2 + 1.3.3-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-provider - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT bundle diff --git a/pom.xml b/pom.xml index d695012d2..32ce564cd 100755 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index 11ed8b4d7..45adc9364 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-properties-node - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index 118a272ed..16588adbd 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins features-properties-node - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index adeb6fed3..96121c6bc 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-features - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index d0403454a..cfc02dd3d 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-installer - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 576bb5b69..aa5e75a52 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-plugins :: properties-node diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 812f7cb70..1f9fd46e2 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-provider - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT bundle ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 31140f805..6578de4e9 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restapi-call-node - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index e14e04be0..dd3af78a3 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins features-restapi-call-node - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index 5a80ef1ab..48b91821e 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-features - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 6824f5024..f63597c57 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-installer - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 530a449f6..10497fd36 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index c4a83539e..74f0a98be 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT bundle ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index f9cc2e5f7..af235f856 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restconf-client - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml index 64501ff40..17065acbe 100644 --- a/restconf-client/features/features-restconf-client/pom.xml +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins features-restconf-client - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml index 713b42f2c..455987fcb 100755 --- a/restconf-client/features/pom.xml +++ b/restconf-client/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-features - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index 33e874171..e7d8b4af4 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-installer - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index 069494eab..296282a56 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 7b1f2cbfe..1a734cdd2 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-provider - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT bundle ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index e34271786..3f6c97c1d 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sshapi-call-node - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml index 9f43dbf42..8a496684f 100644 --- a/sshapi-call-node/features/features-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/features-sshapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins features-sshapi-call-node - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml index b91af1fa2..4db5892e3 100755 --- a/sshapi-call-node/features/pom.xml +++ b/sshapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-features - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index 12a744e29..5d4ef718d 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-installer - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index bb1a0dfc4..90bb6d511 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index 45e3bb5ce..8af4faac5 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-provider - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT bundle ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index 5ee4d0fe1..a1b16a5ff 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-template-node - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml index 0641a5a32..c220d4fb8 100644 --- a/template-node/features/features-template-node/pom.xml +++ b/template-node/features/features-template-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins features-template-node - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml index 9fa5fc199..143d9742f 100644 --- a/template-node/features/pom.xml +++ b/template-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-features - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index d522ba52a..5de128457 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-installer - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/template-node/pom.xml b/template-node/pom.xml index b75227f6a..519388292 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins template-node - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index 21ef16e99..d3dd79412 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-provider - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT bundle ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/version.properties b/version.properties index 2cb9acc8c..dc2c5ad2a 100644 --- a/version.properties +++ b/version.properties @@ -7,7 +7,7 @@ release_name=0 sprint_number=5 -feature_revision=1 +feature_revision=2 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit From 36b83bd4c1b5e20b23cc2986aca15ed31107c2a3 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 14 Aug 2019 14:55:50 -0400 Subject: Release version 0.5.2 Release version 0.5.2 (last Fluorine SR2 version of CCSDK) Change-Id: Iee99b136a4c7646a78c17c423e3822a9bc5b7ff5 Issue-ID: CCSDK-1401 Signed-off-by: Timoney, Dan (dt5972) --- releases/0.5.2.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releases/0.5.2.yaml diff --git a/releases/0.5.2.yaml b/releases/0.5.2.yaml new file mode 100644 index 000000000..4c7946b28 --- /dev/null +++ b/releases/0.5.2.yaml @@ -0,0 +1,5 @@ +--- +distribution_type: 'maven' +version: '0.5.2' +project: 'ccsdk-sli-plugins' +log_dir: 'ccsdk-sli-plugins-maven-stage-master/173/' -- cgit From 9e7f1417df26d634482f053be2cf39b920a22106 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 9 Jul 2019 13:41:32 -0400 Subject: Code changes for Neon Updated code via ccsdk/parent/tools/fluorine2neon.sh script. Change-Id: Ice154214e118ca6ad5043eb0fe337095fd2246d9 Issue-ID: CCSDK-1389 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 4 +- features/ccsdk-sli-plugins-all/pom.xml | 4 +- features/features-sli-plugins/pom.xml | 4 +- features/installer/pom.xml | 4 +- features/pom.xml | 4 +- grToolkit/features/ccsdk-gr-toolkit/pom.xml | 4 +- grToolkit/features/features-gr-toolkit/pom.xml | 4 +- grToolkit/features/pom.xml | 4 +- grToolkit/installer/pom.xml | 4 +- grToolkit/model/pom.xml | 14 +++--- grToolkit/pom.xml | 4 +- grToolkit/provider/pom.xml | 4 +- .../resources/OSGI-INF/blueprint/GrToolkit.xml | 33 ++++++++++++++ pom.xml | 4 +- .../features/ccsdk-properties-node/pom.xml | 4 +- .../features/features-properties-node/pom.xml | 4 +- properties-node/features/pom.xml | 4 +- properties-node/installer/pom.xml | 4 +- properties-node/pom.xml | 4 +- properties-node/provider/pom.xml | 4 +- .../blueprint/properties-node-blueprint.xml | 16 +++++++ .../features/ccsdk-restapi-call-node/pom.xml | 4 +- .../features/features-restapi-call-node/pom.xml | 4 +- restapi-call-node/features/pom.xml | 4 +- restapi-call-node/installer/pom.xml | 4 +- restapi-call-node/pom.xml | 4 +- restapi-call-node/provider/pom.xml | 4 +- .../blueprint/restapi-call-node-blueprint.xml | 16 +++++++ .../features/ccsdk-restconf-client/pom.xml | 4 +- .../features/features-restconf-client/pom.xml | 4 +- restconf-client/features/pom.xml | 4 +- restconf-client/installer/pom.xml | 4 +- restconf-client/pom.xml | 4 +- restconf-client/provider/pom.xml | 4 +- .../blueprint/restconf-client-blueprint.xml | 51 ++++++++++++++++++++++ .../features/ccsdk-sshapi-call-node/pom.xml | 4 +- .../features/features-sshapi-call-node/pom.xml | 4 +- sshapi-call-node/features/pom.xml | 4 +- sshapi-call-node/installer/pom.xml | 4 +- sshapi-call-node/pom.xml | 4 +- sshapi-call-node/provider/pom.xml | 4 +- .../blueprint/sshapi-call-node-blueprint.xml | 16 +++++++ template-node/features/ccsdk-template-node/pom.xml | 4 +- .../features/features-template-node/pom.xml | 4 +- template-node/features/pom.xml | 4 +- template-node/installer/pom.xml | 4 +- template-node/pom.xml | 4 +- template-node/provider/pom.xml | 4 +- version.properties | 4 +- 49 files changed, 224 insertions(+), 94 deletions(-) create mode 100755 grToolkit/provider/src/main/resources/OSGI-INF/blueprint/GrToolkit.xml create mode 100755 properties-node/provider/src/main/resources/OSGI-INF/blueprint/properties-node-blueprint.xml create mode 100755 restapi-call-node/provider/src/main/resources/OSGI-INF/blueprint/restapi-call-node-blueprint.xml create mode 100755 restconf-client/provider/src/main/resources/OSGI-INF/blueprint/restconf-client-blueprint.xml create mode 100755 sshapi-call-node/provider/src/main/resources/OSGI-INF/blueprint/sshapi-call-node-blueprint.xml diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 9bc3a9c9b..7e395c9f9 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.plugins sli-plugins-artifacts - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: sli-plugins-artifacts @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index 6b7bf94d6..bbcfb7570 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins-all - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index 436306765..1ace61b96 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-sli-plugins - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 3d662e444..334748748 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins sliplugins-features-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 29a67a820..6e349ca4a 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins sliplugins-feature-aggregator - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: features diff --git a/grToolkit/features/ccsdk-gr-toolkit/pom.xml b/grToolkit/features/ccsdk-gr-toolkit/pom.xml index 1f4aec3f8..3266f6604 100644 --- a/grToolkit/features/ccsdk-gr-toolkit/pom.xml +++ b/grToolkit/features/ccsdk-gr-toolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-gr-toolkit - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/features/features-gr-toolkit/pom.xml b/grToolkit/features/features-gr-toolkit/pom.xml index 65b1a5d57..511ba38a0 100755 --- a/grToolkit/features/features-gr-toolkit/pom.xml +++ b/grToolkit/features/features-gr-toolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-gr-toolkit - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/features/pom.xml b/grToolkit/features/pom.xml index c7f8ffea7..34f706c8f 100755 --- a/grToolkit/features/pom.xml +++ b/grToolkit/features/pom.xml @@ -4,14 +4,14 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} gr-toolkit-features org.onap.ccsdk.sli.plugins - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom diff --git a/grToolkit/installer/pom.xml b/grToolkit/installer/pom.xml index 64e172cc2..8c7ec32b2 100755 --- a/grToolkit/installer/pom.xml +++ b/grToolkit/installer/pom.xml @@ -4,14 +4,14 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-gr-toolkit diff --git a/grToolkit/model/pom.xml b/grToolkit/model/pom.xml index f400a04cc..8abf89a08 100755 --- a/grToolkit/model/pom.xml +++ b/grToolkit/model/pom.xml @@ -4,23 +4,21 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-model - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle - org.opendaylight.mdsal.model - ietf-inet-types-2013-07-15 - - - org.opendaylight.mdsal.model - ietf-yang-types-20130715 + org.opendaylight.mdsal.binding.model.ietf + rfc6991 + + diff --git a/grToolkit/pom.xml b/grToolkit/pom.xml index c36c1a08d..916df4427 100755 --- a/grToolkit/pom.xml +++ b/grToolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins gr-toolkit - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: gr-toolkit diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index 1d8149592..0267f2488 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -4,13 +4,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-provider - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle diff --git a/grToolkit/provider/src/main/resources/OSGI-INF/blueprint/GrToolkit.xml b/grToolkit/provider/src/main/resources/OSGI-INF/blueprint/GrToolkit.xml new file mode 100755 index 000000000..5a4492c56 --- /dev/null +++ b/grToolkit/provider/src/main/resources/OSGI-INF/blueprint/GrToolkit.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index 32ce564cd..6ee7dea9d 100755 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index 45adc9364..4781ac382 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-properties-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index 16588adbd..58944cceb 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-properties-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 96121c6bc..bd93644d7 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-features - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index cfc02dd3d..536e20478 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index aa5e75a52..09991f46f 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: properties-node diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 1f9fd46e2..8ca58c45c 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-provider - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/provider/src/main/resources/OSGI-INF/blueprint/properties-node-blueprint.xml b/properties-node/provider/src/main/resources/OSGI-INF/blueprint/properties-node-blueprint.xml new file mode 100755 index 000000000..6e1d48efd --- /dev/null +++ b/properties-node/provider/src/main/resources/OSGI-INF/blueprint/properties-node-blueprint.xml @@ -0,0 +1,16 @@ + + + + + + + + + + org.onap.ccsdk.sli.plugins.prop.PropertiesNode + + + + \ No newline at end of file diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 6578de4e9..2697c4ea7 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restapi-call-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index dd3af78a3..41a5d8a4b 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-restapi-call-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index 48b91821e..981db516a 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-features - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index f63597c57..8b2d60ba6 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 10497fd36..d6fb0b49c 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 74f0a98be..7a03a38c3 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/provider/src/main/resources/OSGI-INF/blueprint/restapi-call-node-blueprint.xml b/restapi-call-node/provider/src/main/resources/OSGI-INF/blueprint/restapi-call-node-blueprint.xml new file mode 100755 index 000000000..390bb0a35 --- /dev/null +++ b/restapi-call-node/provider/src/main/resources/OSGI-INF/blueprint/restapi-call-node-blueprint.xml @@ -0,0 +1,16 @@ + + + + + + + + + + org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode + + + + \ No newline at end of file diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index af235f856..8faa16a00 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restconf-client - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml index 17065acbe..790e5b128 100644 --- a/restconf-client/features/features-restconf-client/pom.xml +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-restconf-client - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml index 455987fcb..4537098fb 100755 --- a/restconf-client/features/pom.xml +++ b/restconf-client/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-features - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index e7d8b4af4..09d290044 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index 296282a56..e8b0123c3 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 1a734cdd2..ab685bb8b 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-provider - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/provider/src/main/resources/OSGI-INF/blueprint/restconf-client-blueprint.xml b/restconf-client/provider/src/main/resources/OSGI-INF/blueprint/restconf-client-blueprint.xml new file mode 100755 index 000000000..45c335b13 --- /dev/null +++ b/restconf-client/provider/src/main/resources/OSGI-INF/blueprint/restconf-client-blueprint.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode + + + + + + org.onap.ccsdk.sli.plugins.restconfdiscovery.RestconfDiscoveryNode + + + + \ No newline at end of file diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index 3f6c97c1d..44c5540f3 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sshapi-call-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml index 8a496684f..893b68a76 100644 --- a/sshapi-call-node/features/features-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/features-sshapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-sshapi-call-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml index 4db5892e3..6e31170a7 100755 --- a/sshapi-call-node/features/pom.xml +++ b/sshapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-features - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index 5d4ef718d..1b248a3d6 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index 90bb6d511..66e2af306 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index 8af4faac5..cd920a875 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-provider - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/provider/src/main/resources/OSGI-INF/blueprint/sshapi-call-node-blueprint.xml b/sshapi-call-node/provider/src/main/resources/OSGI-INF/blueprint/sshapi-call-node-blueprint.xml new file mode 100755 index 000000000..7a5424329 --- /dev/null +++ b/sshapi-call-node/provider/src/main/resources/OSGI-INF/blueprint/sshapi-call-node-blueprint.xml @@ -0,0 +1,16 @@ + + + + + + + + + + org.onap.ccsdk.sli.plugins.sshapicall.SshApiCallNode + + + + \ No newline at end of file diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index a1b16a5ff..91658ae62 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-template-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml index c220d4fb8..105a03245 100644 --- a/template-node/features/features-template-node/pom.xml +++ b/template-node/features/features-template-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-template-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml index 143d9742f..391a6ce14 100644 --- a/template-node/features/pom.xml +++ b/template-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-features - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index 5de128457..2a5891dd4 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/template-node/pom.xml b/template-node/pom.xml index 519388292..0c811f714 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index d3dd79412..f9cd3ef2d 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-provider - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/version.properties b/version.properties index dc2c5ad2a..3fc281cbc 100644 --- a/version.properties +++ b/version.properties @@ -6,8 +6,8 @@ # Comment release_name=0 -sprint_number=5 -feature_revision=2 +sprint_number=6 +feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit From c08a8a7b8ce929195bff089f7743b5f31d609849 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Wed, 21 Aug 2019 13:53:30 -0400 Subject: RestapiCallNode URL Formatting Fix URL should be Encoded to related space or speical chars with respective encoded values. Example: space should be replaced with %20 Change-Id: Id58ffdb7d68c5440a33d229a2ac8683d5428a81e Issue-ID: CCSDK-1631 Signed-off-by: Singal, Kapil (ks220y) --- .../sli/plugins/restapicall/RestapiCallNode.java | 109 +++++++++++---------- 1 file changed, 56 insertions(+), 53 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index c539010fb..8038b94ce 100755 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -57,6 +57,7 @@ import javax.ws.rs.core.Feature; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; import org.apache.commons.lang3.StringUtils; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; @@ -97,7 +98,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { protected static final String restapiPasswordKey = "restapiPassword"; protected Integer httpConnectTimeout; protected Integer httpReadTimeout; - + protected HashMap partnerStore; public RestapiCallNode() { @@ -121,7 +122,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { log.warn("UEB properties could not be read, UEB support will not be enabled.", e); } httpConnectTimeout = readOptionalInteger("HTTP_CONNECT_TIMEOUT_MS",DEFAULT_HTTP_CONNECT_TIMEOUT_MS); - httpReadTimeout = readOptionalInteger("HTTP_READ_TIMEOUT_MS",DEFAULT_HTTP_READ_TIMEOUT_MS); + httpReadTimeout = readOptionalInteger("HTTP_READ_TIMEOUT_MS",DEFAULT_HTTP_READ_TIMEOUT_MS); } protected void loadPartners(JSONObject partners) { @@ -153,21 +154,21 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } } - /* Unobfuscate param value */ + /* Unobfuscate param value */ private static String getObfuscatedVal(String paramValue) { String resValue = paramValue; if (paramValue != null && paramValue.startsWith("${") && paramValue.endsWith("}")) { - String paramStr = paramValue.substring(2, paramValue.length()-1); - if (paramStr != null && paramStr.length() > 0) + String paramStr = paramValue.substring(2, paramValue.length()-1); + if (paramStr != null && paramStr.length() > 0) + { + String val = System.getenv(paramStr); + if (val != null && val.length() > 0) { - String val = System.getenv(paramStr); - if (val != null && val.length() > 0) - { - resValue=val; - log.info("Obfuscated value RESET for param value:" + paramValue); - } - } + resValue=val; + log.info("Obfuscated value RESET for param value:" + paramValue); + } + } } return resValue; } @@ -185,14 +186,16 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { p.templateFileName = parseParam(paramMap, "templateFileName", false, null); p.requestBody = parseParam(paramMap, "requestBody", false, null); p.restapiUrl = parseParam(paramMap, restapiUrlString, true, null); - validateUrl(p.restapiUrl); p.restapiUrlSuffix = parseParam(paramMap, "restapiUrlSuffix", false, null); - p.restapiUser = parseParam(paramMap, restapiUserKey, false, null); - p.restapiPassword = parseParam(paramMap, restapiPasswordKey, false, null); if (p.restapiUrlSuffix != null) { p.restapiUrl = p.restapiUrl + p.restapiUrlSuffix; - validateUrl(p.restapiUrl); } + + p.restapiUrl = UriBuilder.fromUri(p.restapiUrl).toTemplate(); + validateUrl(p.restapiUrl); + + p.restapiUser = parseParam(paramMap, restapiUserKey, false, null); + p.restapiPassword = parseParam(paramMap, restapiPasswordKey, false, null); p.oAuthConsumerKey = parseParam(paramMap, "oAuthConsumerKey", false, null); p.oAuthConsumerSecret = parseParam(paramMap, "oAuthConsumerSecret", false, null); p.oAuthSignatureMethod = parseParam(paramMap, "oAuthSignatureMethod", false, null); @@ -211,7 +214,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { p.keyStoreFileName = parseParam(paramMap, "keyStoreFileName", false, null); p.keyStorePassword = parseParam(paramMap, "keyStorePassword", false, null); p.ssl = p.trustStoreFileName != null && p.trustStorePassword != null && p.keyStoreFileName != null - && p.keyStorePassword != null; + && p.keyStorePassword != null; p.customHttpHeaders = parseParam(paramMap, "customHttpHeaders", false, null); p.partner = parseParam(paramMap, "partner", false, null); p.dumpHeaders = valueOf(parseParam(paramMap, "dumpHeaders", false, null)); @@ -271,7 +274,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { * @throws SvcLogicException if required parameter value is empty */ public static String parseParam(Map paramMap, String name, boolean required, String def) - throws SvcLogicException { + throws SvcLogicException { String s = paramMap.get(name); if (s == null || s.trim().length() == 0) { @@ -457,7 +460,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } protected void sendRequest(Map paramMap, SvcLogicContext ctx, RetryPolicy retryPolicy) - throws SvcLogicException { + throws SvcLogicException { HttpResponse r = new HttpResponse(); try { @@ -526,7 +529,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { if (retryPolicy.shouldRetry()) { paramMap.put(restapiUrlString, retryString); log.debug("retry attempt {} will use the retry url {}", retryPolicy.getRetryCount(), - retryString); + retryString); sendRequest(paramMap, ctx, retryPolicy); } else { log.debug("Maximum retries reached, won't attempt to retry. Calling setFailureResponseStatus."); @@ -534,7 +537,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } } catch (Exception ex) { String retryErrorMessage = "Retry attempt " + retryPolicy.getRetryCount() - + "has failed with error message " + ex.getMessage(); + + "has failed with error message " + ex.getMessage(); setFailureResponseStatus(ctx, prefix, retryErrorMessage, r); } } @@ -607,7 +610,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } String req = format == Format.XML ? XmlJsonUtil.removeEmptyStructXml(ss.toString()) - : XmlJsonUtil.removeEmptyStructJson(originalTemplate, ss.toString()); + : XmlJsonUtil.removeEmptyStructJson(originalTemplate, ss.toString()); if (format == Format.JSON) { req = XmlJsonUtil.removeLastCommaJson(req); @@ -632,7 +635,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { int i2 = template.indexOf(':', i1 + 9); if (i2 < 0) { throw new SvcLogicException( - "Template error: Context variable name followed by : is required after repeat"); + "Template error: Context variable name followed by : is required after repeat"); } // Find the closing }, store in i3 @@ -716,8 +719,8 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { client.register(HttpAuthenticationFeature.basic(p.restapiUser, p.restapiPassword)); } else if (p.oAuthConsumerKey != null && p.oAuthConsumerSecret != null && p.oAuthSignatureMethod != null) { Feature oAuth1Feature = - OAuth1ClientSupport.builder(new ConsumerCredentials(p.oAuthConsumerKey, p.oAuthConsumerSecret)) - .version(p.oAuthVersion).signatureMethod(p.oAuthSignatureMethod).feature().build(); + OAuth1ClientSupport.builder(new ConsumerCredentials(p.oAuthConsumerKey, p.oAuthConsumerSecret)) + .version(p.oAuthVersion).signatureMethod(p.oAuthSignatureMethod).feature().build(); client.register(oAuth1Feature); } @@ -727,30 +730,30 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { client.register(HttpAuthenticationFeature.digest(p.restapiUser, p.restapiPassword)); } else { throw new SvcLogicException( - "oAUTH authentication type selected but all restapiUser and restapiPassword " - + "parameters doesn't exist", - new Throwable()); + "oAUTH authentication type selected but all restapiUser and restapiPassword " + + "parameters doesn't exist", + new Throwable()); } } else if (p.authtype == AuthType.BASIC) { if (p.restapiUser != null && p.restapiPassword != null) { client.register(HttpAuthenticationFeature.basic(p.restapiUser, p.restapiPassword)); } else { throw new SvcLogicException( - "oAUTH authentication type selected but all restapiUser and restapiPassword " - + "parameters doesn't exist", - new Throwable()); + "oAUTH authentication type selected but all restapiUser and restapiPassword " + + "parameters doesn't exist", + new Throwable()); } } else if (p.authtype == AuthType.OAUTH) { if (p.oAuthConsumerKey != null && p.oAuthConsumerSecret != null && p.oAuthSignatureMethod != null) { Feature oAuth1Feature = OAuth1ClientSupport - .builder(new ConsumerCredentials(p.oAuthConsumerKey, p.oAuthConsumerSecret)) - .version(p.oAuthVersion).signatureMethod(p.oAuthSignatureMethod).feature().build(); + .builder(new ConsumerCredentials(p.oAuthConsumerKey, p.oAuthConsumerSecret)) + .version(p.oAuthVersion).signatureMethod(p.oAuthSignatureMethod).feature().build(); client.register(oAuth1Feature); } else { throw new SvcLogicException( - "oAUTH authentication type selected but all oAuthConsumerKey, oAuthConsumerSecret " - + "and oAuthSignatureMethod parameters doesn't exist", - new Throwable()); + "oAUTH authentication type selected but all oAuthConsumerKey, oAuthConsumerSecret " + + "and oAuthSignatureMethod parameters doesn't exist", + new Throwable()); } } } @@ -814,7 +817,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { for (String singlePair : keyValuePairs) { int equalPosition = singlePair.indexOf('='); invocationBuilder.header(singlePair.substring(0, equalPosition), - singlePair.substring(equalPosition + 1, singlePair.length())); + singlePair.substring(equalPosition + 1, singlePair.length())); } } @@ -847,7 +850,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { multiPart.setMediaType(MediaType.MULTIPART_FORM_DATA_TYPE); FileDataBodyPart fileDataBodyPart = - new FileDataBodyPart("file", new File(p.multipartFile), MediaType.APPLICATION_OCTET_STREAM_TYPE); + new FileDataBodyPart("file", new File(p.multipartFile), MediaType.APPLICATION_OCTET_STREAM_TYPE); multiPart.bodyPart(fileDataBodyPart); @@ -862,7 +865,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { for (String singlePair : keyValuePairs) { int equalPosition = singlePair.indexOf('='); invocationBuilder.header(singlePair.substring(0, equalPosition), - singlePair.substring(equalPosition + 1, singlePair.length())); + singlePair.substring(equalPosition + 1, singlePair.length())); } } @@ -872,7 +875,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { try { response = - invocationBuilder.method(p.httpMethod.toString(), entity(multiPart, multiPart.getMediaType())); + invocationBuilder.method(p.httpMethod.toString(), entity(multiPart, multiPart.getMediaType())); } catch (ProcessingException | IllegalStateException e) { throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e); } @@ -923,7 +926,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } protected void setFailureResponseStatus(SvcLogicContext ctx, String prefix, String errorMessage, - HttpResponse resp) { + HttpResponse resp) { resp.code = 500; resp.message = errorMessage; String pp = prefix != null ? prefix + '.' : ""; @@ -1198,25 +1201,25 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { public void setDefaultUebTemplateFileName(String defaultUebTemplateFileName) { this.defaultUebTemplateFileName = defaultUebTemplateFileName; } - + protected void setClientTimeouts(Client client) { client.property(ClientProperties.CONNECT_TIMEOUT, httpConnectTimeout); - client.property(ClientProperties.READ_TIMEOUT, httpReadTimeout); + client.property(ClientProperties.READ_TIMEOUT, httpReadTimeout); } protected Integer readOptionalInteger(String propertyName, Integer defaultValue) { - String stringValue = System.getProperty(propertyName); - if (stringValue != null && stringValue.length() > 0) { - try { - return Integer.valueOf(stringValue); - } catch (NumberFormatException e) { - log.warn("property " + propertyName + " had the value " + stringValue + " that could not be converted to an Integer, default " + defaultValue + " will be used instead", e); - } - } - return defaultValue; + String stringValue = System.getProperty(propertyName); + if (stringValue != null && stringValue.length() > 0) { + try { + return Integer.valueOf(stringValue); + } catch (NumberFormatException e) { + log.warn("property " + propertyName + " had the value " + stringValue + " that could not be converted to an Integer, default " + defaultValue + " will be used instead", e); + } + } + return defaultValue; } - + private static class FileParam { public String fileName; -- cgit From 7a37199ebccccd03bbea9b37df09ef610f89bb01 Mon Sep 17 00:00:00 2001 From: Matej Perina Date: Thu, 4 Apr 2019 09:27:16 +0200 Subject: Proposal to remove OSGi dependencies from the CCSDK project Dependencies on the OSGi frameworks and libraries are removed by integrating the CCSDK project with the lighty.io. It's a toolkit that allows to use ODL services (in this case core services and the Restconf) without the dependency on the Karaf framework and the Blueprint DI. In this change are created the lighty.io modules which initialize and expose same services as the Blueprint DI in the blueprint.xml files. More info about the lighty.io - https://lighty.io Change-Id: I3e549e19374ccf04bc430b515e1df7d8d61d8ea7 Signed-off-by: Matej Perina Signed-off-by: Samuel Kontris --- ccsdk-plugins-lighty/pom.xml | 49 ++++++++ .../plugins/lighty/CcsdkPluginsLightyModule.java | 133 +++++++++++++++++++++ pom.xml | 1 + properties-node/lighty/pom.xml | 47 ++++++++ .../plugins/prop/lighty/PropertiesNodeModule.java | 45 +++++++ properties-node/pom.xml | 1 + restapi-call-node/lighty/pom.xml | 47 ++++++++ .../plugins/prop/lighty/RestApiCallNodeModule.java | 46 +++++++ restapi-call-node/pom.xml | 1 + restconf-client/lighty/pom.xml | 47 ++++++++ .../restconf/lighty/RestconfClientModule.java | 59 +++++++++ restconf-client/pom.xml | 1 + sshapi-call-node/lighty/pom.xml | 47 ++++++++ .../sshapicall/lighty/SshApiCallModule.java | 45 +++++++ sshapi-call-node/pom.xml | 1 + template-node/lighty/pom.xml | 47 ++++++++ .../template/lighty/TemplateNodeModule.java | 45 +++++++ template-node/pom.xml | 1 + 18 files changed, 663 insertions(+) create mode 100755 ccsdk-plugins-lighty/pom.xml create mode 100644 ccsdk-plugins-lighty/src/main/java/org/onap/ccsdk/sli/plugins/lighty/CcsdkPluginsLightyModule.java create mode 100755 properties-node/lighty/pom.xml create mode 100644 properties-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/prop/lighty/PropertiesNodeModule.java create mode 100755 restapi-call-node/lighty/pom.xml create mode 100644 restapi-call-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/prop/lighty/RestApiCallNodeModule.java create mode 100755 restconf-client/lighty/pom.xml create mode 100644 restconf-client/lighty/src/main/java/org/onap/ccsdk/sli/plugins/restconf/lighty/RestconfClientModule.java create mode 100755 sshapi-call-node/lighty/pom.xml create mode 100644 sshapi-call-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/lighty/SshApiCallModule.java create mode 100755 template-node/lighty/pom.xml create mode 100644 template-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/template/lighty/TemplateNodeModule.java diff --git a/ccsdk-plugins-lighty/pom.xml b/ccsdk-plugins-lighty/pom.xml new file mode 100755 index 000000000..6b9d8ebab --- /dev/null +++ b/ccsdk-plugins-lighty/pom.xml @@ -0,0 +1,49 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.4.0-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + ccsdk-plugins-lighty + 0.6.0-SNAPSHOT + jar + + + + org.onap.ccsdk.sli.core + ccsdk-core-lighty + ${project.version} + + + org.onap.ccsdk.sli.northbound + properties-node-lighty + ${project.version} + + + org.onap.ccsdk.sli.northbound + restapi-call-node-lighty + ${project.version} + + + org.onap.ccsdk.sli.northbound + restconf-client-lighty + ${project.version} + + + org.onap.ccsdk.sli.northbound + sshapi-call-node-lighty + ${project.version} + + + org.onap.ccsdk.sli.northbound + template-node-lighty + ${project.version} + + + diff --git a/ccsdk-plugins-lighty/src/main/java/org/onap/ccsdk/sli/plugins/lighty/CcsdkPluginsLightyModule.java b/ccsdk-plugins-lighty/src/main/java/org/onap/ccsdk/sli/plugins/lighty/CcsdkPluginsLightyModule.java new file mode 100644 index 000000000..a6d662b85 --- /dev/null +++ b/ccsdk-plugins-lighty/src/main/java/org/onap/ccsdk/sli/plugins/lighty/CcsdkPluginsLightyModule.java @@ -0,0 +1,133 @@ +/* + * ============LICENSE_START========================================== + * Copyright (c) 2019 PANTHEON.tech s.r.o. + * =================================================================== + * 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.lighty; + +import io.lighty.core.controller.api.AbstractLightyModule; +import org.onap.ccsdk.sli.core.lighty.common.CcsdkLightyUtils; +import org.onap.ccsdk.sli.plugins.prop.lighty.PropertiesNodeModule; +import org.onap.ccsdk.sli.plugins.prop.lighty.RestApiCallNodeModule; +import org.onap.ccsdk.sli.plugins.restconf.lighty.RestconfClientModule; +import org.onap.ccsdk.sli.plugins.sshapicall.lighty.SshApiCallModule; +import org.onap.ccsdk.sli.plugins.template.lighty.TemplateNodeModule; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that groups all other LightyModules + * from the ccsdk-sli-plugins repository so they can be all treated as one component (for example started/stopped at once). + * For more information about the lighty.io visit the website https://lighty.io. + */ +public class CcsdkPluginsLightyModule extends AbstractLightyModule { + + private static final Logger LOG = LoggerFactory.getLogger(CcsdkPluginsLightyModule.class); + + private PropertiesNodeModule propertiesNodeModule; + private RestApiCallNodeModule restApiCallNodeModule; + private RestconfClientModule restconfClientModule; + private SshApiCallModule sshApiCallModule; + private TemplateNodeModule templateNodeModule; + + protected boolean initProcedure() { + LOG.debug("Initializing CCSDK Plugins Lighty module..."); + + this.propertiesNodeModule = new PropertiesNodeModule(); + if (!CcsdkLightyUtils.startLightyModule(propertiesNodeModule)) { + LOG.error("Unable to start PropertiesNodeModule in CCSDK Plugins Lighty module!"); + return false; + } + + this.restApiCallNodeModule = new RestApiCallNodeModule(); + if (!CcsdkLightyUtils.startLightyModule(restApiCallNodeModule)) { + LOG.error("Unable to start RestApiCallNodeModule in CCSDK Plugins Lighty module!"); + return false; + } + + this.restconfClientModule = new RestconfClientModule(restApiCallNodeModule.getPropertiesNode()); + if (!CcsdkLightyUtils.startLightyModule(restconfClientModule)) { + LOG.error("Unable to start RestconfClientModule in CCSDK Plugins Lighty module!"); + return false; + } + + this.sshApiCallModule = new SshApiCallModule(); + if (!CcsdkLightyUtils.startLightyModule(sshApiCallModule)) { + LOG.error("Unable to start SshApiCallModule in CCSDK Plugins Lighty module!"); + return false; + } + + this.templateNodeModule = new TemplateNodeModule(); + if (!CcsdkLightyUtils.startLightyModule(templateNodeModule)) { + LOG.error("Unable to start TemplateNodeModule in CCSDK Plugins Lighty module!"); + return false; + } + + LOG.debug("CCSDK Plugins Lighty module was initialized successfully"); + return true; + } + + protected boolean stopProcedure() { + LOG.debug("Stopping CCSDK Plugins Lighty module..."); + + boolean stopSuccessful = true; + + if (!CcsdkLightyUtils.stopLightyModule(templateNodeModule)) { + stopSuccessful = false; + } + + if (!CcsdkLightyUtils.stopLightyModule(sshApiCallModule)) { + stopSuccessful = false; + } + + if (!CcsdkLightyUtils.stopLightyModule(restconfClientModule)) { + stopSuccessful = false; + } + + if (!CcsdkLightyUtils.stopLightyModule(restApiCallNodeModule)) { + stopSuccessful = false; + } + + if (!CcsdkLightyUtils.stopLightyModule(propertiesNodeModule)) { + stopSuccessful = false; + } + + if (stopSuccessful) { + LOG.debug("CCSDK Plugins Lighty module was stopped successfully"); + } else { + LOG.error("CCSDK Plugins Lighty module was not stopped successfully!"); + } + return stopSuccessful; + } + + public PropertiesNodeModule getPropertiesNodeModule() { + return propertiesNodeModule; + } + + public RestApiCallNodeModule getRestApiCallNodeModule() { + return restApiCallNodeModule; + } + + public RestconfClientModule getRestconfClientModule() { + return restconfClientModule; + } + + public SshApiCallModule getSshApiCallModule() { + return sshApiCallModule; + } + + public TemplateNodeModule getTemplateNodeModule() { + return templateNodeModule; + } +} diff --git a/pom.xml b/pom.xml index 6ee7dea9d..9fa01554d 100755 --- a/pom.xml +++ b/pom.xml @@ -29,6 +29,7 @@ grToolkit features artifacts + ccsdk-plugins-lighty diff --git a/properties-node/lighty/pom.xml b/properties-node/lighty/pom.xml new file mode 100755 index 000000000..6778f3c22 --- /dev/null +++ b/properties-node/lighty/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + binding-parent + 1.4.0-SNAPSHOT + + + + org.onap.ccsdk.sli.northbound + properties-node-lighty + 0.6.0-SNAPSHOT + jar + + ccsdk-sli-plugins :: properties-node :: ${project.artifactId} + http://maven.apache.org + + + UTF-8 + + + + + + org.onap.ccsdk.sli.core + ccsdk-lighty-dependency-versions + ${project.version} + pom + import + + + + + + + io.lighty.core + lighty-controller + + + org.onap.ccsdk.sli.plugins + properties-node-provider + ${project.version} + + + diff --git a/properties-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/prop/lighty/PropertiesNodeModule.java b/properties-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/prop/lighty/PropertiesNodeModule.java new file mode 100644 index 000000000..345381120 --- /dev/null +++ b/properties-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/prop/lighty/PropertiesNodeModule.java @@ -0,0 +1,45 @@ +/* + * ============LICENSE_START========================================== + * Copyright (c) 2019 PANTHEON.tech s.r.o. + * =================================================================== + * 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.prop.lighty; + +import io.lighty.core.controller.api.AbstractLightyModule; +import io.lighty.core.controller.api.LightyModule; +import org.onap.ccsdk.sli.plugins.prop.PropertiesNode; + +/** + * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from + * the properties-node-provider artifact. + */ +public class PropertiesNodeModule extends AbstractLightyModule implements LightyModule { + + private PropertiesNode propertiesNode; + + @Override + protected boolean initProcedure() { + this.propertiesNode = new PropertiesNode(); + return true; + } + + @Override + protected boolean stopProcedure() { + return true; + } + + public PropertiesNode getPropertiesNode() { + return this.propertiesNode; + } +} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 09991f46f..64036f7b1 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -21,5 +21,6 @@ provider features installer + lighty diff --git a/restapi-call-node/lighty/pom.xml b/restapi-call-node/lighty/pom.xml new file mode 100755 index 000000000..fa4ad5c22 --- /dev/null +++ b/restapi-call-node/lighty/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + binding-parent + 1.4.0-SNAPSHOT + + + + org.onap.ccsdk.sli.northbound + restapi-call-node-lighty + 0.6.0-SNAPSHOT + jar + + ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} + http://maven.apache.org + + + UTF-8 + + + + + + org.onap.ccsdk.sli.core + ccsdk-lighty-dependency-versions + ${project.version} + pom + import + + + + + + + io.lighty.core + lighty-controller + + + org.onap.ccsdk.sli.plugins + restapi-call-node-provider + ${project.version} + + + diff --git a/restapi-call-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/prop/lighty/RestApiCallNodeModule.java b/restapi-call-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/prop/lighty/RestApiCallNodeModule.java new file mode 100644 index 000000000..01fa03e53 --- /dev/null +++ b/restapi-call-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/prop/lighty/RestApiCallNodeModule.java @@ -0,0 +1,46 @@ +/* + * ============LICENSE_START========================================== + * Copyright (c) 2019 PANTHEON.tech s.r.o. + * =================================================================== + * 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.prop.lighty; + +import io.lighty.core.controller.api.AbstractLightyModule; +import io.lighty.core.controller.api.LightyModule; +import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; + +/** + * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from + * the restapi-call-node-provider artifact. + */ +public class RestApiCallNodeModule extends AbstractLightyModule implements LightyModule { + + private RestapiCallNode restapiCallNode; + + @Override + protected boolean initProcedure() { + this.restapiCallNode = new RestapiCallNode(); + return true; + } + + @Override + protected boolean stopProcedure() { + return true; + } + + public RestapiCallNode getPropertiesNode() { + return this.restapiCallNode; + } + +} diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index d6fb0b49c..7fbce0243 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -20,5 +20,6 @@ provider features installer + lighty diff --git a/restconf-client/lighty/pom.xml b/restconf-client/lighty/pom.xml new file mode 100755 index 000000000..86e8af30d --- /dev/null +++ b/restconf-client/lighty/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + binding-parent + 1.4.0-SNAPSHOT + + + + org.onap.ccsdk.sli.northbound + restconf-client-lighty + 0.6.0-SNAPSHOT + jar + + ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} + http://maven.apache.org + + + UTF-8 + + + + + + org.onap.ccsdk.sli.core + ccsdk-lighty-dependency-versions + ${project.version} + pom + import + + + + + + + io.lighty.core + lighty-controller + + + org.onap.ccsdk.sli.plugins + restconf-client-provider + ${project.version} + + + diff --git a/restconf-client/lighty/src/main/java/org/onap/ccsdk/sli/plugins/restconf/lighty/RestconfClientModule.java b/restconf-client/lighty/src/main/java/org/onap/ccsdk/sli/plugins/restconf/lighty/RestconfClientModule.java new file mode 100644 index 000000000..bb0fc90da --- /dev/null +++ b/restconf-client/lighty/src/main/java/org/onap/ccsdk/sli/plugins/restconf/lighty/RestconfClientModule.java @@ -0,0 +1,59 @@ +/* + * ============LICENSE_START========================================== + * Copyright (c) 2019 PANTHEON.tech s.r.o. + * =================================================================== + * 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.restconf.lighty; + +import io.lighty.core.controller.api.AbstractLightyModule; +import io.lighty.core.controller.api.LightyModule; +import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; +import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode; +import org.onap.ccsdk.sli.plugins.restconfdiscovery.RestconfDiscoveryNode; + +/** + * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from + * the restconf-client-provider artifact. + */ +public class RestconfClientModule extends AbstractLightyModule implements LightyModule { + + private final RestapiCallNode restapiCallNode; + + private RestconfApiCallNode restconfApiCallNode; + private RestconfDiscoveryNode restconfDiscoveryNode; + + public RestconfClientModule(final RestapiCallNode restapiCallNode) { + this.restapiCallNode = restapiCallNode; + } + + @Override + protected boolean initProcedure() { + this.restconfApiCallNode = new RestconfApiCallNode(restapiCallNode); + this.restconfDiscoveryNode = new RestconfDiscoveryNode(restconfApiCallNode); + return true; + } + + @Override + protected boolean stopProcedure() { + return true; + } + + public RestconfApiCallNode getRestconfApiCallNode() { + return this.restconfApiCallNode; + } + + public RestconfDiscoveryNode getRestconfDiscoveryNode() { + return this.restconfDiscoveryNode; + } +} diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index e8b0123c3..221987d8c 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -20,5 +20,6 @@ provider features installer + lighty diff --git a/sshapi-call-node/lighty/pom.xml b/sshapi-call-node/lighty/pom.xml new file mode 100755 index 000000000..a28c1332c --- /dev/null +++ b/sshapi-call-node/lighty/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + binding-parent + 1.4.0-SNAPSHOT + + + + org.onap.ccsdk.sli.northbound + sshapi-call-node-lighty + 0.6.0-SNAPSHOT + jar + + ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} + http://maven.apache.org + + + UTF-8 + + + + + + org.onap.ccsdk.sli.core + ccsdk-lighty-dependency-versions + ${project.version} + pom + import + + + + + + + io.lighty.core + lighty-controller + + + org.onap.ccsdk.sli.plugins + sshapi-call-node-provider + ${project.version} + + + diff --git a/sshapi-call-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/lighty/SshApiCallModule.java b/sshapi-call-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/lighty/SshApiCallModule.java new file mode 100644 index 000000000..d8f1932d5 --- /dev/null +++ b/sshapi-call-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/lighty/SshApiCallModule.java @@ -0,0 +1,45 @@ +/* + * ============LICENSE_START========================================== + * Copyright (c) 2019 PANTHEON.tech s.r.o. + * =================================================================== + * 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.lighty; + +import io.lighty.core.controller.api.AbstractLightyModule; +import io.lighty.core.controller.api.LightyModule; +import org.onap.ccsdk.sli.plugins.sshapicall.SshApiCallNode; + +/** + * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from + * the sshapi-call-node-provider artifact. + */ +public class SshApiCallModule extends AbstractLightyModule implements LightyModule { + + private SshApiCallNode sshApiCallNode; + + @Override + protected boolean initProcedure() { + this.sshApiCallNode = new SshApiCallNode(); + return true; + } + + @Override + protected boolean stopProcedure() { + return true; + } + + public SshApiCallNode getSshApiCallNode() { + return this.sshApiCallNode; + } +} diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index 66e2af306..4238e7737 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -20,5 +20,6 @@ provider features installer + lighty diff --git a/template-node/lighty/pom.xml b/template-node/lighty/pom.xml new file mode 100755 index 000000000..cb55c57fb --- /dev/null +++ b/template-node/lighty/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + binding-parent + 1.4.0-SNAPSHOT + + + + org.onap.ccsdk.sli.northbound + template-node-lighty + 0.6.0-SNAPSHOT + jar + + ccsdk-sli-plugins :: template-node :: ${project.artifactId} + http://maven.apache.org + + + UTF-8 + + + + + + org.onap.ccsdk.sli.core + ccsdk-lighty-dependency-versions + ${project.version} + pom + import + + + + + + + io.lighty.core + lighty-controller + + + org.onap.ccsdk.sli.plugins + template-node-provider + ${project.version} + + + diff --git a/template-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/template/lighty/TemplateNodeModule.java b/template-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/template/lighty/TemplateNodeModule.java new file mode 100644 index 000000000..1cd836bbb --- /dev/null +++ b/template-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/template/lighty/TemplateNodeModule.java @@ -0,0 +1,45 @@ +/* + * ============LICENSE_START========================================== + * Copyright (c) 2019 PANTHEON.tech s.r.o. + * =================================================================== + * 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.template.lighty; + +import io.lighty.core.controller.api.AbstractLightyModule; +import io.lighty.core.controller.api.LightyModule; +import org.onap.ccsdk.sli.plugins.template.TemplateNode; + +/** + * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from + * the template-node-provider artifact. + */ +public class TemplateNodeModule extends AbstractLightyModule implements LightyModule { + + private TemplateNode templateNode; + + @Override + protected boolean initProcedure() { + this.templateNode = new TemplateNode(); + return true; + } + + @Override + protected boolean stopProcedure() { + return true; + } + + public TemplateNode getTemplateNode() { + return this.templateNode; + } +} diff --git a/template-node/pom.xml b/template-node/pom.xml index 0c811f714..4149f8746 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -17,5 +17,6 @@ provider features installer + lighty -- cgit From f396b85b5815ea0cdfeed96f999ed360e2a9ee9d Mon Sep 17 00:00:00 2001 From: Samuel Kontris Date: Tue, 27 Aug 2019 17:23:46 +0200 Subject: Fix groupId in lighty.io artifacts Signed-off-by: Samuel Kontris Change-Id: I77dd64ebda9b361eab7673e9da389aad810e23f6 --- ccsdk-plugins-lighty/pom.xml | 10 +++++----- properties-node/lighty/pom.xml | 2 +- restapi-call-node/lighty/pom.xml | 2 +- restconf-client/lighty/pom.xml | 2 +- sshapi-call-node/lighty/pom.xml | 2 +- template-node/lighty/pom.xml | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ccsdk-plugins-lighty/pom.xml b/ccsdk-plugins-lighty/pom.xml index 6b9d8ebab..5630f3bc0 100755 --- a/ccsdk-plugins-lighty/pom.xml +++ b/ccsdk-plugins-lighty/pom.xml @@ -21,27 +21,27 @@ ${project.version} - org.onap.ccsdk.sli.northbound + org.onap.ccsdk.sli.plugins properties-node-lighty ${project.version} - org.onap.ccsdk.sli.northbound + org.onap.ccsdk.sli.plugins restapi-call-node-lighty ${project.version} - org.onap.ccsdk.sli.northbound + org.onap.ccsdk.sli.plugins restconf-client-lighty ${project.version} - org.onap.ccsdk.sli.northbound + org.onap.ccsdk.sli.plugins sshapi-call-node-lighty ${project.version} - org.onap.ccsdk.sli.northbound + org.onap.ccsdk.sli.plugins template-node-lighty ${project.version} diff --git a/properties-node/lighty/pom.xml b/properties-node/lighty/pom.xml index 6778f3c22..4e0fdb303 100755 --- a/properties-node/lighty/pom.xml +++ b/properties-node/lighty/pom.xml @@ -9,7 +9,7 @@ - org.onap.ccsdk.sli.northbound + org.onap.ccsdk.sli.plugins properties-node-lighty 0.6.0-SNAPSHOT jar diff --git a/restapi-call-node/lighty/pom.xml b/restapi-call-node/lighty/pom.xml index fa4ad5c22..5faa654b1 100755 --- a/restapi-call-node/lighty/pom.xml +++ b/restapi-call-node/lighty/pom.xml @@ -9,7 +9,7 @@ - org.onap.ccsdk.sli.northbound + org.onap.ccsdk.sli.plugins restapi-call-node-lighty 0.6.0-SNAPSHOT jar diff --git a/restconf-client/lighty/pom.xml b/restconf-client/lighty/pom.xml index 86e8af30d..7fdf6b8fc 100755 --- a/restconf-client/lighty/pom.xml +++ b/restconf-client/lighty/pom.xml @@ -9,7 +9,7 @@ - org.onap.ccsdk.sli.northbound + org.onap.ccsdk.sli.plugins restconf-client-lighty 0.6.0-SNAPSHOT jar diff --git a/sshapi-call-node/lighty/pom.xml b/sshapi-call-node/lighty/pom.xml index a28c1332c..ecc411424 100755 --- a/sshapi-call-node/lighty/pom.xml +++ b/sshapi-call-node/lighty/pom.xml @@ -9,7 +9,7 @@ - org.onap.ccsdk.sli.northbound + org.onap.ccsdk.sli.plugins sshapi-call-node-lighty 0.6.0-SNAPSHOT jar diff --git a/template-node/lighty/pom.xml b/template-node/lighty/pom.xml index cb55c57fb..f9bc94d81 100755 --- a/template-node/lighty/pom.xml +++ b/template-node/lighty/pom.xml @@ -9,7 +9,7 @@ - org.onap.ccsdk.sli.northbound + org.onap.ccsdk.sli.plugins template-node-lighty 0.6.0-SNAPSHOT jar -- cgit From e72c116b00d819fe19ebf8648c646ae485d72b16 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 27 Aug 2019 16:36:20 -0400 Subject: Release version 0.6.0 Release version 0.6.0 of ccsdk artifacts Change-Id: Ifc88da2fdb575ae74a7d279bac89faa89b9ffd9c Signed-off-by: Timoney, Dan (dt5972) --- releases/0.6.0.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releases/0.6.0.yaml diff --git a/releases/0.6.0.yaml b/releases/0.6.0.yaml new file mode 100644 index 000000000..8f32b423b --- /dev/null +++ b/releases/0.6.0.yaml @@ -0,0 +1,5 @@ +--- +distribution_type: 'maven' +version: '0.6.0' +project: 'ccsdk-sli-plugins' +log_dir: 'ccsdk-sli-plugins-maven-stage-master/187/' -- cgit From 43c9e83b3cc9b3dfaf55f08fc25813a77a4f2784 Mon Sep 17 00:00:00 2001 From: "Agarwal, Ruchira (ra1926)" Date: Wed, 28 Aug 2019 01:48:21 +0000 Subject: sync restapi-call-node with ecomp sync onap rest-api-call-node with ecomp Issue-ID: CCSDK-1659 Signed-off-by: Agarwal, Ruchira (ra1926) Change-Id: I08b0b8332b68a22710cd412997f3763de4b5b8d3 --- .../sli/plugins/restapicall/HttpResponse.java | 7 +- .../ccsdk/sli/plugins/restapicall/JsonParser.java | 12 ++- .../ccsdk/sli/plugins/restapicall/RetryPolicy.java | 43 ++++---- .../ccsdk/sli/plugins/restapicall/XmlJsonUtil.java | 119 +++++++++++++-------- .../ccsdk/sli/plugins/restapicall/XmlParser.java | 11 +- .../sli/plugins/restapicall/TestXmlJsonUtil.java | 59 ++++++++++ .../provider/src/test/resources/test-template.json | 1 + 7 files changed, 181 insertions(+), 71 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpResponse.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpResponse.java index 66993aabc..574089528 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpResponse.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/HttpResponse.java @@ -8,9 +8,9 @@ * 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. @@ -21,6 +21,8 @@ package org.onap.ccsdk.sli.plugins.restapicall; +import java.util.List; +import java.util.Map; import javax.ws.rs.core.MultivaluedMap; public class HttpResponse { @@ -28,4 +30,5 @@ public class HttpResponse { public String message; public String body; public MultivaluedMap headers; + public Map> headers2; } diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java index 189ddde31..910baf52b 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java @@ -8,7 +8,7 @@ * 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 @@ -50,7 +50,15 @@ public final class JsonParser { checkNotNull(s, "Input should not be null."); try { - JSONObject json = new JSONObject(s); + JSONObject json = null; + //support top level list in json response + if (s.startsWith("[")) { + JSONArray jsonArr = new JSONArray(s); + json = jsonArr.getJSONObject(0); + } else { + json = new JSONObject(s); + } + Map wm = new HashMap<>(); Iterator ii = json.keys(); while (ii.hasNext()) { diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java index 65684d937..8d5143be3 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java @@ -21,41 +21,44 @@ */ package org.onap.ccsdk.sli.plugins.restapicall; + public class RetryPolicy { private String[] hostnames; private Integer maximumRetries; - private int position; - private int retryCount; + public RetryPolicy(String[] hostnames, Integer maximumRetries) { - this.hostnames = hostnames; - this.maximumRetries = maximumRetries; - - this.position = 0; - - this.retryCount = 0; + this.hostnames = hostnames; + this.maximumRetries = maximumRetries; + this.position = 0; + this.retryCount = 0; + } + public Integer getMaximumRetries() { - return maximumRetries; + return maximumRetries; } + public int getRetryCount() { - return retryCount; + return retryCount; } + public Boolean shouldRetry() { - return retryCount < maximumRetries + 1; + return retryCount < maximumRetries + 1; } + public String getRetryMessage() { - return retryCount + " retry attempts were made out of " + maximumRetries + " maximum retry attempts."; + return retryCount + " retry attempts were made out of " + maximumRetries + " maximum retry attempts."; } public String getNextHostName() throws RetryException { - retryCount++; - position++; - - if (position > hostnames.length - 1) { - position = 0; - } - return hostnames[position]; + retryCount++; + position++; + if (position > hostnames.length - 1) { + position = 0; } -} \ No newline at end of file + return hostnames[position]; + } + +} diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java index 4712b4298..bc6afd84c 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java @@ -8,9 +8,9 @@ * 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. @@ -25,7 +25,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -67,38 +66,45 @@ public final class XmlJsonUtil { private static Object createStructure(Map flatmap, String var) { if (flatmap.containsKey(var)) { - if (var.endsWith("_length") || var.endsWith("].key")) + if (var.endsWith("_length") || var.endsWith("].key")) { return null; + } return flatmap.get(var); } Map mm = new HashMap<>(); - for (String k : flatmap.keySet()) + 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) + if (i1 > 0 && i1 < i3) { i3 = i1; - if (i2 > 0 && i2 < i3) + } + 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)) + if (str != null && (!(str instanceof String) || ((String) str).trim().length() > 0)) { mm.put(k1, str); + } } } - if (!mm.isEmpty()) + } + if (!mm.isEmpty()) { return mm; + } boolean arrayFound = false; - for (String k : flatmap.keySet()) + for (String k : flatmap.keySet()) { if (k.startsWith(var + "[")) { arrayFound = true; break; } + } if (arrayFound) { List ll = new ArrayList<>(); @@ -115,13 +121,15 @@ public final class XmlJsonUtil { for (int i = 0; i < length; i++) { Object v = createStructure(flatmap, var + '[' + i + ']'); - if (v == null) + if (v == null) { break; + } ll.add(v); } - if (!ll.isEmpty()) + if (!ll.isEmpty()) { return ll; + } } return null; @@ -129,16 +137,18 @@ public final class XmlJsonUtil { @SuppressWarnings("unchecked") private static String generateXml(Object o, int indent, boolean escape) { - if (o == null) + if (o == null) { return null; + } - if (o instanceof String) - return escape ? escapeXml((String) o) : (String) o;; + if (o instanceof String) { + return escape ? escapeXml((String) o) : (String) o; + }; if (o instanceof Map) { StringBuilder ss = new StringBuilder(); Map mm = (Map) o; - for (Map.Entry entry: mm.entrySet()) { + for (Map.Entry entry : mm.entrySet()) { Object v = entry.getValue(); String key = entry.getKey(); if (v instanceof String) { @@ -164,10 +174,13 @@ public final class XmlJsonUtil { return null; } - private static String generateJson(Object o, boolean escape, boolean quotes) { - if (o == null) + if (o == null) { return null; + } + if (o instanceof String && ((String) o).length() == 0) { + return null; + } StringBuilder ss = new StringBuilder(); generateJson(ss, o, 0, false, escape, quotes); @@ -178,8 +191,9 @@ public final class XmlJsonUtil { 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) + if (padFirst) { ss.append(pad(indent)); + } if (quotes) { ss.append('"').append(s).append('"'); } else { @@ -191,14 +205,16 @@ public final class XmlJsonUtil { if (o instanceof Map) { Map mm = (Map) o; - if (padFirst) + if (padFirst) { ss.append(pad(indent)); + } ss.append("{\n"); boolean first = true; for (Map.Entry entry : mm.entrySet()) { - if (!first) + if (!first) { ss.append(",\n"); + } first = false; Object v = entry.getValue(); String key = entry.getKey(); @@ -215,14 +231,16 @@ public final class XmlJsonUtil { if (o instanceof List) { List ll = (List) o; - if (padFirst) + if (padFirst) { ss.append(pad(indent)); + } ss.append("[\n"); boolean first = true; for (Object o1 : ll) { - if (!first) + if (!first) { ss.append(",\n"); + } first = false; generateJson(ss, o1, indent + 1, true, escape, quotes); @@ -241,14 +259,16 @@ public final class XmlJsonUtil { int i11 = s.indexOf('}', k); int i12 = s.indexOf(']', k); int i1 = -1; - if (i11 < 0) + if (i11 < 0) { i1 = i12; - else if (i12 < 0) + } else if (i12 < 0) { i1 = i11; - else + } else { i1 = i11 < i12 ? i11 : i12; - if (i1 < 0) + } + if (i1 < 0) { break; + } int i2 = s.lastIndexOf(',', i1); if (i2 < 0) { @@ -282,15 +302,14 @@ public final class XmlJsonUtil { if (i11 < 0) { i1 = i12; curly = false; - } else if (i12 < 0) + } else if (i12 < 0) { i1 = i11; - else - if (i11 < i12) - i1 = i11; - else { - i1 = i12; - curly = false; - } + } else if (i11 < i12) { + i1 = i11; + } else { + i1 = i12; + curly = false; + } if (i1 >= 0) { int i2 = curly ? s.indexOf('}', i1) : s.indexOf(']', i1); @@ -298,25 +317,31 @@ public final class XmlJsonUtil { String value = s.substring(i1 + 1, i2); if (value.trim().length() == 0) { int i4 = s.lastIndexOf('\n', i1); - if (i4 < 0) + if (i4 < 0) { i4 = 0; + } int i5 = s.indexOf('\n', i2); - if (i5 < 0) + if (i5 < 0) { i5 = s.length(); + } + /*If template mandates empty construct to be present, those should not be removed.*/ - if ((template != null) && template.contains(s.substring(i4))) { + if (template != null && template.contains(s.substring(i4))) { k = i1 + 1; } else { s = s.substring(0, i4) + s.substring(i5); k = 0; } - } else + } else { k = i1 + 1; - } else + } + } else { break; - } else + } + } else { break; + } } return s; @@ -326,8 +351,9 @@ public final class XmlJsonUtil { int k = 0; while (k < s.length()) { int i1 = s.indexOf('<', k); - if (i1 < 0 || i1 == s.length() - 1) + if (i1 < 0 || i1 == s.length() - 1) { break; + } char c1 = s.charAt(i1 + 1); if (c1 == '?' || c1 == '!') { @@ -355,11 +381,13 @@ public final class XmlJsonUtil { } int i4 = s.lastIndexOf('\n', i1); - if (i4 < 0) + if (i4 < 0) { i4 = 0; + } int i5 = s.indexOf('\n', i3); - if (i5 < 0) + if (i5 < 0) { i5 = s.length(); + } s = s.substring(0, i4) + s.substring(i5); k = 0; @@ -385,8 +413,9 @@ public final class XmlJsonUtil { private static String pad(int n) { StringBuilder s = new StringBuilder(); - for (int i = 0; i < n; i++) + for (int i = 0; i < n; i++) { s.append(Character.toString('\t')); + } return s.toString(); } } diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java index cf6af66f2..42e9e57ad 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlParser.java @@ -35,6 +35,7 @@ import java.util.Set; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import javax.xml.XMLConstants; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.slf4j.Logger; @@ -42,6 +43,7 @@ import org.slf4j.LoggerFactory; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; +import org.xml.sax.XMLReader; public final class XmlParser { @@ -58,10 +60,15 @@ public final class XmlParser { Handler handler = new Handler(listNameList); try { - SAXParserFactory factory = SAXParserFactory.newInstance(); - SAXParser saxParser = factory.newSAXParser(); + SAXParserFactory spf = SAXParserFactory.newInstance(); + spf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); + spf.setFeature("http://xml.org/sax/features/external-general-entities", false); + spf.setFeature("http://xml.org/sax/features/external-parameter-entities", false); + spf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); InputStream in = new ByteArrayInputStream(s.getBytes()); + SAXParser saxParser = spf.newSAXParser(); saxParser.parse(in, handler); + } catch (ParserConfigurationException | IOException | SAXException | NumberFormatException e) { throw new SvcLogicException("Unable to convert XML to properties" + e.getLocalizedMessage(), e); } diff --git a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java index 9812f2a11..ac6d3b78b 100644 --- a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java +++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java @@ -152,6 +152,65 @@ public class TestXmlJsonUtil { log.info(ss); } + public void testRemoveEmptyStructJson1() { + String xmlin = "{\n" + + " \"policyName\" : \"default-domain.ECOM_Tenant_DND.ECOM_Tenant_DND_mtn6_HngwOamNetVto." + + "HNGWOAMNETVTO.OAM_landing-network-role_policy_05\",\n" + + " \"policyConfigType\": \"MicroService\",\n" + + " \"ecompName\": \"SDNC\",\n" + + " \"configBody\": \"{\\\"service\\\": \\\"NetworkPolicy\\\"," + + "\\\"location\\\": \\\"Search\\\",\\\"uuid\\\": \\\"Search\\\"," + + "\\\"policyName\\\": \\\"default-domain.ECOM_Tenant_DND.ECOM_Tenant_DND_mtn6_HngwOamNetVto." + + "HNGWOAMNETVTO.OAM_landing-network-role_policy_05\\\"," + + "\\\"description\\\": \\\"default-domain.ECOM_Tenant_DND.ECOM_Tenant_DND_mtn6_HngwOamNetVto." + + "HNGWOAMNETVTO.OAM_landing-network-role_policy_05\\\",\\\"configName\\\": \\\"Search\\\"," + + "\\\"templateVersion\\\": \\\"1607\\\",\\\"version\\\": \\\"1.3.0.1\\\"," + + "\\\"priority\\\": \\\"2\\\",\\\"policyScope\\\": \\\"SDNC\\\",\\\"riskType\\\": \\\"low\\\"," + + "\\\"riskLevel\\\": \\\"2\\\",\\\"guard\\\": \\\"True\\\",\\\"content\\\":{ " + + "\\\"network-policy\\\": { \\\"display_name\\\": \\\"default-domain.ECOM_Tenant_DND." + + "ECOM_Tenant_DND_mtn6_HngwOamNetVto.HNGWOAMNETVTO.OAM_landing-network-role_policy_05\\\", " + + "\\\"fq_name\\\": [ \\\"default-domain\\\", " + + "\\\"ECOM_Tenant_DND\\\", \\\"default-domain." + + "ECOM_Tenant_DND.ECOM_Tenant_DND_mtn6_HngwOamNetVto." + + "HNGWOAMNETVTO.OAM_landing-network-role_policy_05\\\" ], " + + "\\\"id_perms\\\": { \\\"user_visible\\\": true }, " + + "\\\"parent_type\\\": \\\"project\\\", \\\"network_policy_entries\\\": { " + + "\\\"policy_rule\\\": [ { " + + "\\\"action_list\\\": { \\\"apply_service\\\": [ " + + "\\\"testfqdn\\\" ], " + + "\\\"gateway_name\\\": null, \\\"qos_action\\\": null, " + + "\\\"log\\\": false , \\\"mirror_to\\\": null, " + + "\\\"simple_action\\\": null }, " + + "\\\"ethertype\\\": null, \\\"application\\\": [], " + + "\\\"direction\\\": \\\"<>\\\", \\\"dst_addresses\\\": [ " + + "{ \\\"network_policy\\\": null, " + + "\\\"security_group\\\": null, " + + "\\\"subnet\\\": null, \\\"virtual_network\\\": " + + "\\\"default-domain:ECOM_Tenant_DND:ECOM_Tenant_DND_int_HngwOamNetVto." + + "HNGWOAMNETVTO.OAM_net_10\\\" } ], " + + "\\\"dst_ports\\\": [ { " + + "\\\"end_port\\\": -1, \\\"start_port\\\": -1 " + + "} ], \\\"protocol\\\": \\\"any\\\", " + + "\\\"src_addresses\\\": [ { " + + "\\\"network_policy\\\": null, " + + "\\\"security_group\\\": null, " + + "\\\"subnet\\\": null, \\\"virtual_network\\\": " + + "\\\"default-domain:ECOM_Tenant_DND:ECOM_Tenant_DND_int_HngwOamNetVto." + + "HNGWOAMNETVTO.OAM_net_9\\\" } ], " + + "\\\"src_ports\\\": [ { " + + "\\\"end_port\\\": -1, " + + "\\\"start_port\\\": -1 } ] } " + + "] } }}}\"\n" + + "}"; + + String xmloutexpected = xmlin; + + String xmlout = XmlJsonUtil.removeEmptyStructJson(null, xmlin); + log.info(xmlout); + + Assert.assertEquals(xmloutexpected, xmlout); + } + @Test public void testRemoveEmptyStructXml() { String xmlin = "" + diff --git a/restapi-call-node/provider/src/test/resources/test-template.json b/restapi-call-node/provider/src/test/resources/test-template.json index 4adc6637a..faefef31e 100644 --- a/restapi-call-node/provider/src/test/resources/test-template.json +++ b/restapi-call-node/provider/src/test/resources/test-template.json @@ -51,6 +51,7 @@ "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} + "test-empty-value": ${tmp.sdn-circuit-req-row[${1}].test-empty-value} }, } ] -- cgit From b6455c548b7003019c8f8b6e1ecc3966f3aca278 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 28 Aug 2019 13:16:09 -0400 Subject: Roll versions Roll versions in master branch Change-Id: I38f82f09f8cdf7324145895a053f5513117502ea Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 4 ++-- ccsdk-plugins-lighty/pom.xml | 4 ++-- features/ccsdk-sli-plugins-all/pom.xml | 4 ++-- features/features-sli-plugins/pom.xml | 4 ++-- features/installer/pom.xml | 4 ++-- features/pom.xml | 4 ++-- grToolkit/features/ccsdk-gr-toolkit/pom.xml | 4 ++-- grToolkit/features/features-gr-toolkit/pom.xml | 4 ++-- grToolkit/features/pom.xml | 4 ++-- grToolkit/installer/pom.xml | 4 ++-- grToolkit/model/pom.xml | 4 ++-- grToolkit/pom.xml | 4 ++-- grToolkit/provider/pom.xml | 4 ++-- pom.xml | 4 ++-- properties-node/features/ccsdk-properties-node/pom.xml | 4 ++-- properties-node/features/features-properties-node/pom.xml | 4 ++-- properties-node/features/pom.xml | 4 ++-- properties-node/installer/pom.xml | 4 ++-- properties-node/lighty/pom.xml | 4 ++-- properties-node/pom.xml | 4 ++-- properties-node/provider/pom.xml | 4 ++-- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/features-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/pom.xml | 4 ++-- restapi-call-node/installer/pom.xml | 4 ++-- restapi-call-node/lighty/pom.xml | 4 ++-- restapi-call-node/pom.xml | 4 ++-- restapi-call-node/provider/pom.xml | 4 ++-- restconf-client/features/ccsdk-restconf-client/pom.xml | 4 ++-- restconf-client/features/features-restconf-client/pom.xml | 4 ++-- restconf-client/features/pom.xml | 4 ++-- restconf-client/installer/pom.xml | 4 ++-- restconf-client/lighty/pom.xml | 4 ++-- restconf-client/pom.xml | 4 ++-- restconf-client/provider/pom.xml | 4 ++-- sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/features/features-sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/features/pom.xml | 4 ++-- sshapi-call-node/installer/pom.xml | 4 ++-- sshapi-call-node/lighty/pom.xml | 4 ++-- sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/provider/pom.xml | 4 ++-- template-node/features/ccsdk-template-node/pom.xml | 4 ++-- template-node/features/features-template-node/pom.xml | 4 ++-- template-node/features/pom.xml | 4 ++-- template-node/installer/pom.xml | 4 ++-- template-node/lighty/pom.xml | 4 ++-- template-node/pom.xml | 4 ++-- template-node/provider/pom.xml | 4 ++-- version.properties | 2 +- 50 files changed, 99 insertions(+), 99 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 7e395c9f9..59e334acf 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.plugins sli-plugins-artifacts - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-plugins :: sli-plugins-artifacts @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT diff --git a/ccsdk-plugins-lighty/pom.xml b/ccsdk-plugins-lighty/pom.xml index 5630f3bc0..8ac8ffcc1 100755 --- a/ccsdk-plugins-lighty/pom.xml +++ b/ccsdk-plugins-lighty/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-plugins-lighty - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT jar diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index bbcfb7570..1054f1903 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins-all - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index 1ace61b96..dff558c6a 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins features-sli-plugins - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 334748748..529588c58 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins sliplugins-features-installer - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 6e349ca4a..3780233ec 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins sliplugins-feature-aggregator - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-plugins :: features diff --git a/grToolkit/features/ccsdk-gr-toolkit/pom.xml b/grToolkit/features/ccsdk-gr-toolkit/pom.xml index 3266f6604..88d931d33 100644 --- a/grToolkit/features/ccsdk-gr-toolkit/pom.xml +++ b/grToolkit/features/ccsdk-gr-toolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-gr-toolkit - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/features/features-gr-toolkit/pom.xml b/grToolkit/features/features-gr-toolkit/pom.xml index 511ba38a0..f22ed5d29 100755 --- a/grToolkit/features/features-gr-toolkit/pom.xml +++ b/grToolkit/features/features-gr-toolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins features-gr-toolkit - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/features/pom.xml b/grToolkit/features/pom.xml index 34f706c8f..37179a551 100755 --- a/grToolkit/features/pom.xml +++ b/grToolkit/features/pom.xml @@ -4,14 +4,14 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} gr-toolkit-features org.onap.ccsdk.sli.plugins - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom diff --git a/grToolkit/installer/pom.xml b/grToolkit/installer/pom.xml index 8c7ec32b2..4d097054f 100755 --- a/grToolkit/installer/pom.xml +++ b/grToolkit/installer/pom.xml @@ -4,14 +4,14 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-installer - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-gr-toolkit diff --git a/grToolkit/model/pom.xml b/grToolkit/model/pom.xml index 8abf89a08..646564a90 100755 --- a/grToolkit/model/pom.xml +++ b/grToolkit/model/pom.xml @@ -4,13 +4,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-model - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT bundle diff --git a/grToolkit/pom.xml b/grToolkit/pom.xml index 916df4427..b55df5cd7 100755 --- a/grToolkit/pom.xml +++ b/grToolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins gr-toolkit - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-plugins :: gr-toolkit diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index 0267f2488..f8228c2b5 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -4,13 +4,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-provider - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT bundle diff --git a/pom.xml b/pom.xml index 9fa01554d..a8f8584f3 100755 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index 4781ac382..b80d8f429 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-properties-node - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index 58944cceb..485d29534 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins features-properties-node - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index bd93644d7..83bc1da13 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-features - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 536e20478..3af5efc7a 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-installer - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/lighty/pom.xml b/properties-node/lighty/pom.xml index 4e0fdb303..6a5023d51 100755 --- a/properties-node/lighty/pom.xml +++ b/properties-node/lighty/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-lighty - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT jar ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 64036f7b1..53fa2b2d9 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-plugins :: properties-node diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 8ca58c45c..262c4968d 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-provider - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT bundle ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 2697c4ea7..6f3109e4d 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restapi-call-node - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index 41a5d8a4b..4350f75b4 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins features-restapi-call-node - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index 981db516a..a49633d5a 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-features - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 8b2d60ba6..697cfdcc8 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-installer - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/lighty/pom.xml b/restapi-call-node/lighty/pom.xml index 5faa654b1..f6af499cb 100755 --- a/restapi-call-node/lighty/pom.xml +++ b/restapi-call-node/lighty/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-lighty - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT jar ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 7fbce0243..ece6a5695 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 7a03a38c3..a8d3cd886 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT bundle ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index 8faa16a00..28f3fc509 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restconf-client - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml index 790e5b128..49360057e 100644 --- a/restconf-client/features/features-restconf-client/pom.xml +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins features-restconf-client - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml index 4537098fb..d3123f7ec 100755 --- a/restconf-client/features/pom.xml +++ b/restconf-client/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-features - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index 09d290044..7f80aa951 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-installer - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/lighty/pom.xml b/restconf-client/lighty/pom.xml index 7fdf6b8fc..84e940bb5 100755 --- a/restconf-client/lighty/pom.xml +++ b/restconf-client/lighty/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-lighty - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT jar ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index 221987d8c..1da628e8e 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index ab685bb8b..953db6933 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-provider - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT bundle ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index 44c5540f3..c0539c4d2 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sshapi-call-node - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml index 893b68a76..6b9827c5c 100644 --- a/sshapi-call-node/features/features-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/features-sshapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins features-sshapi-call-node - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml index 6e31170a7..7e367cea1 100755 --- a/sshapi-call-node/features/pom.xml +++ b/sshapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-features - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index 1b248a3d6..475da0c7d 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-installer - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/lighty/pom.xml b/sshapi-call-node/lighty/pom.xml index ecc411424..13c11cd10 100755 --- a/sshapi-call-node/lighty/pom.xml +++ b/sshapi-call-node/lighty/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-lighty - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT jar ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index 4238e7737..1494def32 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index cd920a875..0ad9e2a7b 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-provider - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT bundle ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index 91658ae62..e34106988 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-template-node - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml index 105a03245..11e459d0a 100644 --- a/template-node/features/features-template-node/pom.xml +++ b/template-node/features/features-template-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins features-template-node - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml index 391a6ce14..40574a1f9 100644 --- a/template-node/features/pom.xml +++ b/template-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-features - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index 2a5891dd4..7fbbeec74 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-installer - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/template-node/lighty/pom.xml b/template-node/lighty/pom.xml index f9bc94d81..8759f0273 100755 --- a/template-node/lighty/pom.xml +++ b/template-node/lighty/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-lighty - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT jar ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/template-node/pom.xml b/template-node/pom.xml index 4149f8746..959d119c4 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins template-node - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index f9cd3ef2d..477a539f2 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-provider - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT bundle ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/version.properties b/version.properties index 3fc281cbc..24c154ada 100644 --- a/version.properties +++ b/version.properties @@ -7,7 +7,7 @@ release_name=0 sprint_number=6 -feature_revision=0 +feature_revision=1 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit From 8d3a2693ec1b5f326cd6028673ff063c0d93369f Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 29 Aug 2019 11:18:43 -0400 Subject: Revert "Proposal to remove OSGi dependencies from the CCSDK project" This reverts commit 7a37199ebccccd03bbea9b37df09ef610f89bb01. This must be reverted due to lack of jUnit testing Change-Id: I0050a6052d5daddb0a5e8474d96c1f6b1055d1a4 Signed-off-by: Timoney, Dan (dt5972) --- ccsdk-plugins-lighty/pom.xml | 49 -------- .../plugins/lighty/CcsdkPluginsLightyModule.java | 133 --------------------- pom.xml | 1 - properties-node/lighty/pom.xml | 47 -------- .../plugins/prop/lighty/PropertiesNodeModule.java | 45 ------- properties-node/pom.xml | 1 - restapi-call-node/lighty/pom.xml | 47 -------- .../plugins/prop/lighty/RestApiCallNodeModule.java | 46 ------- restapi-call-node/pom.xml | 1 - restconf-client/lighty/pom.xml | 47 -------- .../restconf/lighty/RestconfClientModule.java | 59 --------- restconf-client/pom.xml | 1 - sshapi-call-node/lighty/pom.xml | 47 -------- .../sshapicall/lighty/SshApiCallModule.java | 45 ------- sshapi-call-node/pom.xml | 1 - template-node/lighty/pom.xml | 47 -------- .../template/lighty/TemplateNodeModule.java | 45 ------- template-node/pom.xml | 1 - 18 files changed, 663 deletions(-) delete mode 100755 ccsdk-plugins-lighty/pom.xml delete mode 100644 ccsdk-plugins-lighty/src/main/java/org/onap/ccsdk/sli/plugins/lighty/CcsdkPluginsLightyModule.java delete mode 100755 properties-node/lighty/pom.xml delete mode 100644 properties-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/prop/lighty/PropertiesNodeModule.java delete mode 100755 restapi-call-node/lighty/pom.xml delete mode 100644 restapi-call-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/prop/lighty/RestApiCallNodeModule.java delete mode 100755 restconf-client/lighty/pom.xml delete mode 100644 restconf-client/lighty/src/main/java/org/onap/ccsdk/sli/plugins/restconf/lighty/RestconfClientModule.java delete mode 100755 sshapi-call-node/lighty/pom.xml delete mode 100644 sshapi-call-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/lighty/SshApiCallModule.java delete mode 100755 template-node/lighty/pom.xml delete mode 100644 template-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/template/lighty/TemplateNodeModule.java diff --git a/ccsdk-plugins-lighty/pom.xml b/ccsdk-plugins-lighty/pom.xml deleted file mode 100755 index 8ac8ffcc1..000000000 --- a/ccsdk-plugins-lighty/pom.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.4.1-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - ccsdk-plugins-lighty - 0.6.1-SNAPSHOT - jar - - - - org.onap.ccsdk.sli.core - ccsdk-core-lighty - ${project.version} - - - org.onap.ccsdk.sli.plugins - properties-node-lighty - ${project.version} - - - org.onap.ccsdk.sli.plugins - restapi-call-node-lighty - ${project.version} - - - org.onap.ccsdk.sli.plugins - restconf-client-lighty - ${project.version} - - - org.onap.ccsdk.sli.plugins - sshapi-call-node-lighty - ${project.version} - - - org.onap.ccsdk.sli.plugins - template-node-lighty - ${project.version} - - - diff --git a/ccsdk-plugins-lighty/src/main/java/org/onap/ccsdk/sli/plugins/lighty/CcsdkPluginsLightyModule.java b/ccsdk-plugins-lighty/src/main/java/org/onap/ccsdk/sli/plugins/lighty/CcsdkPluginsLightyModule.java deleted file mode 100644 index a6d662b85..000000000 --- a/ccsdk-plugins-lighty/src/main/java/org/onap/ccsdk/sli/plugins/lighty/CcsdkPluginsLightyModule.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * ============LICENSE_START========================================== - * Copyright (c) 2019 PANTHEON.tech s.r.o. - * =================================================================== - * 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.lighty; - -import io.lighty.core.controller.api.AbstractLightyModule; -import org.onap.ccsdk.sli.core.lighty.common.CcsdkLightyUtils; -import org.onap.ccsdk.sli.plugins.prop.lighty.PropertiesNodeModule; -import org.onap.ccsdk.sli.plugins.prop.lighty.RestApiCallNodeModule; -import org.onap.ccsdk.sli.plugins.restconf.lighty.RestconfClientModule; -import org.onap.ccsdk.sli.plugins.sshapicall.lighty.SshApiCallModule; -import org.onap.ccsdk.sli.plugins.template.lighty.TemplateNodeModule; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that groups all other LightyModules - * from the ccsdk-sli-plugins repository so they can be all treated as one component (for example started/stopped at once). - * For more information about the lighty.io visit the website https://lighty.io. - */ -public class CcsdkPluginsLightyModule extends AbstractLightyModule { - - private static final Logger LOG = LoggerFactory.getLogger(CcsdkPluginsLightyModule.class); - - private PropertiesNodeModule propertiesNodeModule; - private RestApiCallNodeModule restApiCallNodeModule; - private RestconfClientModule restconfClientModule; - private SshApiCallModule sshApiCallModule; - private TemplateNodeModule templateNodeModule; - - protected boolean initProcedure() { - LOG.debug("Initializing CCSDK Plugins Lighty module..."); - - this.propertiesNodeModule = new PropertiesNodeModule(); - if (!CcsdkLightyUtils.startLightyModule(propertiesNodeModule)) { - LOG.error("Unable to start PropertiesNodeModule in CCSDK Plugins Lighty module!"); - return false; - } - - this.restApiCallNodeModule = new RestApiCallNodeModule(); - if (!CcsdkLightyUtils.startLightyModule(restApiCallNodeModule)) { - LOG.error("Unable to start RestApiCallNodeModule in CCSDK Plugins Lighty module!"); - return false; - } - - this.restconfClientModule = new RestconfClientModule(restApiCallNodeModule.getPropertiesNode()); - if (!CcsdkLightyUtils.startLightyModule(restconfClientModule)) { - LOG.error("Unable to start RestconfClientModule in CCSDK Plugins Lighty module!"); - return false; - } - - this.sshApiCallModule = new SshApiCallModule(); - if (!CcsdkLightyUtils.startLightyModule(sshApiCallModule)) { - LOG.error("Unable to start SshApiCallModule in CCSDK Plugins Lighty module!"); - return false; - } - - this.templateNodeModule = new TemplateNodeModule(); - if (!CcsdkLightyUtils.startLightyModule(templateNodeModule)) { - LOG.error("Unable to start TemplateNodeModule in CCSDK Plugins Lighty module!"); - return false; - } - - LOG.debug("CCSDK Plugins Lighty module was initialized successfully"); - return true; - } - - protected boolean stopProcedure() { - LOG.debug("Stopping CCSDK Plugins Lighty module..."); - - boolean stopSuccessful = true; - - if (!CcsdkLightyUtils.stopLightyModule(templateNodeModule)) { - stopSuccessful = false; - } - - if (!CcsdkLightyUtils.stopLightyModule(sshApiCallModule)) { - stopSuccessful = false; - } - - if (!CcsdkLightyUtils.stopLightyModule(restconfClientModule)) { - stopSuccessful = false; - } - - if (!CcsdkLightyUtils.stopLightyModule(restApiCallNodeModule)) { - stopSuccessful = false; - } - - if (!CcsdkLightyUtils.stopLightyModule(propertiesNodeModule)) { - stopSuccessful = false; - } - - if (stopSuccessful) { - LOG.debug("CCSDK Plugins Lighty module was stopped successfully"); - } else { - LOG.error("CCSDK Plugins Lighty module was not stopped successfully!"); - } - return stopSuccessful; - } - - public PropertiesNodeModule getPropertiesNodeModule() { - return propertiesNodeModule; - } - - public RestApiCallNodeModule getRestApiCallNodeModule() { - return restApiCallNodeModule; - } - - public RestconfClientModule getRestconfClientModule() { - return restconfClientModule; - } - - public SshApiCallModule getSshApiCallModule() { - return sshApiCallModule; - } - - public TemplateNodeModule getTemplateNodeModule() { - return templateNodeModule; - } -} diff --git a/pom.xml b/pom.xml index a8f8584f3..8e9cc52d2 100755 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,6 @@ grToolkit features artifacts - ccsdk-plugins-lighty diff --git a/properties-node/lighty/pom.xml b/properties-node/lighty/pom.xml deleted file mode 100755 index 6a5023d51..000000000 --- a/properties-node/lighty/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 1.4.1-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - properties-node-lighty - 0.6.1-SNAPSHOT - jar - - ccsdk-sli-plugins :: properties-node :: ${project.artifactId} - http://maven.apache.org - - - UTF-8 - - - - - - org.onap.ccsdk.sli.core - ccsdk-lighty-dependency-versions - ${project.version} - pom - import - - - - - - - io.lighty.core - lighty-controller - - - org.onap.ccsdk.sli.plugins - properties-node-provider - ${project.version} - - - diff --git a/properties-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/prop/lighty/PropertiesNodeModule.java b/properties-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/prop/lighty/PropertiesNodeModule.java deleted file mode 100644 index 345381120..000000000 --- a/properties-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/prop/lighty/PropertiesNodeModule.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * ============LICENSE_START========================================== - * Copyright (c) 2019 PANTHEON.tech s.r.o. - * =================================================================== - * 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.prop.lighty; - -import io.lighty.core.controller.api.AbstractLightyModule; -import io.lighty.core.controller.api.LightyModule; -import org.onap.ccsdk.sli.plugins.prop.PropertiesNode; - -/** - * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from - * the properties-node-provider artifact. - */ -public class PropertiesNodeModule extends AbstractLightyModule implements LightyModule { - - private PropertiesNode propertiesNode; - - @Override - protected boolean initProcedure() { - this.propertiesNode = new PropertiesNode(); - return true; - } - - @Override - protected boolean stopProcedure() { - return true; - } - - public PropertiesNode getPropertiesNode() { - return this.propertiesNode; - } -} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 53fa2b2d9..0e5d576d3 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -21,6 +21,5 @@ provider features installer - lighty diff --git a/restapi-call-node/lighty/pom.xml b/restapi-call-node/lighty/pom.xml deleted file mode 100755 index f6af499cb..000000000 --- a/restapi-call-node/lighty/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 1.4.1-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - restapi-call-node-lighty - 0.6.1-SNAPSHOT - jar - - ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} - http://maven.apache.org - - - UTF-8 - - - - - - org.onap.ccsdk.sli.core - ccsdk-lighty-dependency-versions - ${project.version} - pom - import - - - - - - - io.lighty.core - lighty-controller - - - org.onap.ccsdk.sli.plugins - restapi-call-node-provider - ${project.version} - - - diff --git a/restapi-call-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/prop/lighty/RestApiCallNodeModule.java b/restapi-call-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/prop/lighty/RestApiCallNodeModule.java deleted file mode 100644 index 01fa03e53..000000000 --- a/restapi-call-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/prop/lighty/RestApiCallNodeModule.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * ============LICENSE_START========================================== - * Copyright (c) 2019 PANTHEON.tech s.r.o. - * =================================================================== - * 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.prop.lighty; - -import io.lighty.core.controller.api.AbstractLightyModule; -import io.lighty.core.controller.api.LightyModule; -import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; - -/** - * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from - * the restapi-call-node-provider artifact. - */ -public class RestApiCallNodeModule extends AbstractLightyModule implements LightyModule { - - private RestapiCallNode restapiCallNode; - - @Override - protected boolean initProcedure() { - this.restapiCallNode = new RestapiCallNode(); - return true; - } - - @Override - protected boolean stopProcedure() { - return true; - } - - public RestapiCallNode getPropertiesNode() { - return this.restapiCallNode; - } - -} diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index ece6a5695..5bbd4d7b4 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -20,6 +20,5 @@ provider features installer - lighty diff --git a/restconf-client/lighty/pom.xml b/restconf-client/lighty/pom.xml deleted file mode 100755 index 84e940bb5..000000000 --- a/restconf-client/lighty/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 1.4.1-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - restconf-client-lighty - 0.6.1-SNAPSHOT - jar - - ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} - http://maven.apache.org - - - UTF-8 - - - - - - org.onap.ccsdk.sli.core - ccsdk-lighty-dependency-versions - ${project.version} - pom - import - - - - - - - io.lighty.core - lighty-controller - - - org.onap.ccsdk.sli.plugins - restconf-client-provider - ${project.version} - - - diff --git a/restconf-client/lighty/src/main/java/org/onap/ccsdk/sli/plugins/restconf/lighty/RestconfClientModule.java b/restconf-client/lighty/src/main/java/org/onap/ccsdk/sli/plugins/restconf/lighty/RestconfClientModule.java deleted file mode 100644 index bb0fc90da..000000000 --- a/restconf-client/lighty/src/main/java/org/onap/ccsdk/sli/plugins/restconf/lighty/RestconfClientModule.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * ============LICENSE_START========================================== - * Copyright (c) 2019 PANTHEON.tech s.r.o. - * =================================================================== - * 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.restconf.lighty; - -import io.lighty.core.controller.api.AbstractLightyModule; -import io.lighty.core.controller.api.LightyModule; -import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; -import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode; -import org.onap.ccsdk.sli.plugins.restconfdiscovery.RestconfDiscoveryNode; - -/** - * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from - * the restconf-client-provider artifact. - */ -public class RestconfClientModule extends AbstractLightyModule implements LightyModule { - - private final RestapiCallNode restapiCallNode; - - private RestconfApiCallNode restconfApiCallNode; - private RestconfDiscoveryNode restconfDiscoveryNode; - - public RestconfClientModule(final RestapiCallNode restapiCallNode) { - this.restapiCallNode = restapiCallNode; - } - - @Override - protected boolean initProcedure() { - this.restconfApiCallNode = new RestconfApiCallNode(restapiCallNode); - this.restconfDiscoveryNode = new RestconfDiscoveryNode(restconfApiCallNode); - return true; - } - - @Override - protected boolean stopProcedure() { - return true; - } - - public RestconfApiCallNode getRestconfApiCallNode() { - return this.restconfApiCallNode; - } - - public RestconfDiscoveryNode getRestconfDiscoveryNode() { - return this.restconfDiscoveryNode; - } -} diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index 1da628e8e..2d1893f6d 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -20,6 +20,5 @@ provider features installer - lighty diff --git a/sshapi-call-node/lighty/pom.xml b/sshapi-call-node/lighty/pom.xml deleted file mode 100755 index 13c11cd10..000000000 --- a/sshapi-call-node/lighty/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 1.4.1-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - sshapi-call-node-lighty - 0.6.1-SNAPSHOT - jar - - ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} - http://maven.apache.org - - - UTF-8 - - - - - - org.onap.ccsdk.sli.core - ccsdk-lighty-dependency-versions - ${project.version} - pom - import - - - - - - - io.lighty.core - lighty-controller - - - org.onap.ccsdk.sli.plugins - sshapi-call-node-provider - ${project.version} - - - diff --git a/sshapi-call-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/lighty/SshApiCallModule.java b/sshapi-call-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/lighty/SshApiCallModule.java deleted file mode 100644 index d8f1932d5..000000000 --- a/sshapi-call-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/sshapicall/lighty/SshApiCallModule.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * ============LICENSE_START========================================== - * Copyright (c) 2019 PANTHEON.tech s.r.o. - * =================================================================== - * 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.lighty; - -import io.lighty.core.controller.api.AbstractLightyModule; -import io.lighty.core.controller.api.LightyModule; -import org.onap.ccsdk.sli.plugins.sshapicall.SshApiCallNode; - -/** - * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from - * the sshapi-call-node-provider artifact. - */ -public class SshApiCallModule extends AbstractLightyModule implements LightyModule { - - private SshApiCallNode sshApiCallNode; - - @Override - protected boolean initProcedure() { - this.sshApiCallNode = new SshApiCallNode(); - return true; - } - - @Override - protected boolean stopProcedure() { - return true; - } - - public SshApiCallNode getSshApiCallNode() { - return this.sshApiCallNode; - } -} diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index 1494def32..d46da1973 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -20,6 +20,5 @@ provider features installer - lighty diff --git a/template-node/lighty/pom.xml b/template-node/lighty/pom.xml deleted file mode 100755 index 8759f0273..000000000 --- a/template-node/lighty/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 1.4.1-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - template-node-lighty - 0.6.1-SNAPSHOT - jar - - ccsdk-sli-plugins :: template-node :: ${project.artifactId} - http://maven.apache.org - - - UTF-8 - - - - - - org.onap.ccsdk.sli.core - ccsdk-lighty-dependency-versions - ${project.version} - pom - import - - - - - - - io.lighty.core - lighty-controller - - - org.onap.ccsdk.sli.plugins - template-node-provider - ${project.version} - - - diff --git a/template-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/template/lighty/TemplateNodeModule.java b/template-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/template/lighty/TemplateNodeModule.java deleted file mode 100644 index 1cd836bbb..000000000 --- a/template-node/lighty/src/main/java/org/onap/ccsdk/sli/plugins/template/lighty/TemplateNodeModule.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * ============LICENSE_START========================================== - * Copyright (c) 2019 PANTHEON.tech s.r.o. - * =================================================================== - * 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.template.lighty; - -import io.lighty.core.controller.api.AbstractLightyModule; -import io.lighty.core.controller.api.LightyModule; -import org.onap.ccsdk.sli.plugins.template.TemplateNode; - -/** - * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from - * the template-node-provider artifact. - */ -public class TemplateNodeModule extends AbstractLightyModule implements LightyModule { - - private TemplateNode templateNode; - - @Override - protected boolean initProcedure() { - this.templateNode = new TemplateNode(); - return true; - } - - @Override - protected boolean stopProcedure() { - return true; - } - - public TemplateNode getTemplateNode() { - return this.templateNode; - } -} diff --git a/template-node/pom.xml b/template-node/pom.xml index 959d119c4..58a83c841 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -17,6 +17,5 @@ provider features installer - lighty -- cgit From ad212f7c41322f85e4352ea3ddffe2e0ed7acaab Mon Sep 17 00:00:00 2001 From: "steigerwald, christopher (cs741q)" Date: Thu, 29 Aug 2019 21:03:27 +0000 Subject: iptables fix Update modifyIpTables() in GRToolkitProvider.java. Signed-off-by: steigerwald, christopher (cs741q) Issue-ID: CCSDK-1664 Change-Id: I7a6c93aed540c083b4b1eb05c42f6e614fcdb4b0 --- .../java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java index f10055a1a..119c0b9c7 100755 --- a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java @@ -779,7 +779,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.halt.akka.traffic.input.NodeInfo) node; log.info("Isolating {}", n.getNode()); executeCommand(String.format("sudo /sbin/iptables -A INPUT -p tcp --destination-port %s -j DROP -s %s", properties.get(PropertyKeys.CONTROLLER_PORT_AKKA), n.getNode())); - executeCommand(String.format("sudo /sbin/iptables -A OUTPUT -p tcp --destination-port %s -j DROP -s %s", n.getPort(), n.getNode())); + executeCommand(String.format("sudo /sbin/iptables -A OUTPUT -p tcp --destination-port %s -j DROP -d %s", n.getPort(), n.getNode())); } } else if(task == IpTables.DELETE) { @@ -788,7 +788,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.resume.akka.traffic.input.NodeInfo) node; log.info("De-isolating {}", n.getNode()); executeCommand(String.format("sudo /sbin/iptables -D INPUT -p tcp --destination-port %s -j DROP -s %s", properties.get(PropertyKeys.CONTROLLER_PORT_AKKA), n.getNode())); - executeCommand(String.format("sudo /sbin/iptables -D OUTPUT -p tcp --destination-port %s -j DROP -s %s", n.getPort(), n.getNode())); + executeCommand(String.format("sudo /sbin/iptables -D OUTPUT -p tcp --destination-port %s -j DROP -d %s", n.getPort(), n.getNode())); } } -- cgit From e8ada464913852ca53f77fcede795d81662bb900 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 6 Sep 2019 09:51:43 -0400 Subject: Fix errors in INFO.yaml Fix errors in INFO.yaml file Change-Id: If31a4e259580c1014389b57ebcfbbb44e5285e47 Issue-ID: CCSDK-1696 Signed-off-by: Timoney, Dan (dt5972) --- INFO.yaml | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/INFO.yaml b/INFO.yaml index 566a7971e..fc1128836 100644 --- a/INFO.yaml +++ b/INFO.yaml @@ -8,7 +8,7 @@ project_lead: &onap_releng_ptl email: 'dtimoney@att.com' id: 'djtimoney' company: 'ATT' - timezone: 'America/New York' + timezone: 'America/New_York' primary_contact: *onap_releng_ptl issue_tracking: type: 'jira' @@ -33,12 +33,12 @@ committers: email: 'jflucas@research.att.com' company: 'ATT' id: 'jackl' - timezone: 'America/New York' + timezone: 'America/New_York' - name: 'Jun (Nicolas) Hu' email: 'jh245g@att.com' company: 'ATT' id: 'jh245g' - timezone: 'America/New York' + timezone: 'America/New_York' - name: 'Gaurav Agrawal' email: 'gaurav.agrawal@huawei.com' company: 'Huawei' @@ -48,21 +48,9 @@ committers: email: 'brindasanth@in.ibm.com' company: 'IBM' id: 'brindasanthm' - timezone: 'America/New York' + timezone: 'America/New_York' repositories: - - ccsdk-apps - - ccsdk-cds - - ccsdk-distribution - - ccsdk-features - - ccsdk-parent - - ccsdk-platform-blueprints - - ccsdk-platform-plugins - - ccsdk-sli-adaptors - - ccsdk-sli-core - - ccsdk-sli-northbound - - ccsdk-sli-plugins - - ccsdk-storage-esaas - - ccsdk-utils + - ccsdk/sli/plugins tsc: approval: 'https://lists.onap.org/pipermail/onap-tsc' changes: -- cgit From 11024639bc19d62e2f2e177bbcfaeb04b5e27737 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 10 Sep 2019 16:38:56 -0400 Subject: Release version 0.6.1 Release CCSDK version 0.6.1 Change-Id: Ib29832bdc531512b6d527195e968b0692e34d3e1 Issue-ID: CCSDK-1701 Signed-off-by: Timoney, Dan (dt5972) --- releases/0.6.1.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releases/0.6.1.yaml diff --git a/releases/0.6.1.yaml b/releases/0.6.1.yaml new file mode 100644 index 000000000..7739acdeb --- /dev/null +++ b/releases/0.6.1.yaml @@ -0,0 +1,5 @@ +--- +distribution_type: 'maven' +version: '0.6.1' +project: 'ccsdk-sli-plugins' +log_dir: 'ccsdk-sli-plugins-maven-stage-master/204/' -- cgit From cd53f2f4488e8521cd2461526a66fa7021ef6ced Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 11 Sep 2019 10:41:38 -0400 Subject: Roll versions for Frankfurt development Roll master version for Frankfurt development Change-Id: Ibdc691d8ff93b74ac9bc4baae95c5988dd7e34d4 Issue-ID: CCSDK-1701 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 4 ++-- features/ccsdk-sli-plugins-all/pom.xml | 4 ++-- features/features-sli-plugins/pom.xml | 4 ++-- features/installer/pom.xml | 4 ++-- features/pom.xml | 4 ++-- grToolkit/features/ccsdk-gr-toolkit/pom.xml | 4 ++-- grToolkit/features/features-gr-toolkit/pom.xml | 4 ++-- grToolkit/features/pom.xml | 4 ++-- grToolkit/installer/pom.xml | 4 ++-- grToolkit/model/pom.xml | 4 ++-- grToolkit/pom.xml | 4 ++-- grToolkit/provider/pom.xml | 4 ++-- pom.xml | 4 ++-- properties-node/features/ccsdk-properties-node/pom.xml | 4 ++-- properties-node/features/features-properties-node/pom.xml | 4 ++-- properties-node/features/pom.xml | 4 ++-- properties-node/installer/pom.xml | 4 ++-- properties-node/pom.xml | 4 ++-- properties-node/provider/pom.xml | 4 ++-- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/features-restapi-call-node/pom.xml | 4 ++-- restapi-call-node/features/pom.xml | 4 ++-- restapi-call-node/installer/pom.xml | 4 ++-- restapi-call-node/pom.xml | 4 ++-- restapi-call-node/provider/pom.xml | 4 ++-- restconf-client/features/ccsdk-restconf-client/pom.xml | 4 ++-- restconf-client/features/features-restconf-client/pom.xml | 4 ++-- restconf-client/features/pom.xml | 4 ++-- restconf-client/installer/pom.xml | 4 ++-- restconf-client/pom.xml | 4 ++-- restconf-client/provider/pom.xml | 4 ++-- sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/features/features-sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/features/pom.xml | 4 ++-- sshapi-call-node/installer/pom.xml | 4 ++-- sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/provider/pom.xml | 4 ++-- template-node/features/ccsdk-template-node/pom.xml | 4 ++-- template-node/features/features-template-node/pom.xml | 4 ++-- template-node/features/pom.xml | 4 ++-- template-node/installer/pom.xml | 4 ++-- template-node/pom.xml | 4 ++-- template-node/provider/pom.xml | 4 ++-- version.properties | 4 ++-- 44 files changed, 88 insertions(+), 88 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 59e334acf..ef2d3541a 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.plugins sli-plugins-artifacts - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-plugins :: sli-plugins-artifacts @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index 1054f1903..fe21e42fe 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins-all - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index dff558c6a..070979220 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-sli-plugins - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 529588c58..5f6d1b442 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins sliplugins-features-installer - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 3780233ec..d551c350a 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins sliplugins-feature-aggregator - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-plugins :: features diff --git a/grToolkit/features/ccsdk-gr-toolkit/pom.xml b/grToolkit/features/ccsdk-gr-toolkit/pom.xml index 88d931d33..fb5523902 100644 --- a/grToolkit/features/ccsdk-gr-toolkit/pom.xml +++ b/grToolkit/features/ccsdk-gr-toolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-gr-toolkit - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/features/features-gr-toolkit/pom.xml b/grToolkit/features/features-gr-toolkit/pom.xml index f22ed5d29..3e6c967ad 100755 --- a/grToolkit/features/features-gr-toolkit/pom.xml +++ b/grToolkit/features/features-gr-toolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-gr-toolkit - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/features/pom.xml b/grToolkit/features/pom.xml index 37179a551..aebb98e9f 100755 --- a/grToolkit/features/pom.xml +++ b/grToolkit/features/pom.xml @@ -4,14 +4,14 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} gr-toolkit-features org.onap.ccsdk.sli.plugins - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom diff --git a/grToolkit/installer/pom.xml b/grToolkit/installer/pom.xml index 4d097054f..0fd397232 100755 --- a/grToolkit/installer/pom.xml +++ b/grToolkit/installer/pom.xml @@ -4,14 +4,14 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-installer - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-gr-toolkit diff --git a/grToolkit/model/pom.xml b/grToolkit/model/pom.xml index 646564a90..39239a08c 100755 --- a/grToolkit/model/pom.xml +++ b/grToolkit/model/pom.xml @@ -4,13 +4,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-model - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT bundle diff --git a/grToolkit/pom.xml b/grToolkit/pom.xml index b55df5cd7..9de96ec8c 100755 --- a/grToolkit/pom.xml +++ b/grToolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins gr-toolkit - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-plugins :: gr-toolkit diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index f8228c2b5..d36643a77 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -4,13 +4,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-provider - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT bundle diff --git a/pom.xml b/pom.xml index 8e9cc52d2..c0be21440 100755 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index b80d8f429..c496d20d8 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-properties-node - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index 485d29534..e25ba5808 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-properties-node - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 83bc1da13..97f12cf24 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-features - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 3af5efc7a..9ba85b91c 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-installer - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 0e5d576d3..0c9c28464 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-plugins :: properties-node diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 262c4968d..059870974 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-provider - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT bundle ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 6f3109e4d..1100f223b 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restapi-call-node - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index 4350f75b4..26c986a3b 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-restapi-call-node - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index a49633d5a..6736bd1d2 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-features - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 697cfdcc8..06e77b411 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-installer - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 5bbd4d7b4..26a237f7b 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index a8d3cd886..0e6babb39 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT bundle ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index 28f3fc509..276d6e8fb 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restconf-client - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml index 49360057e..d4c78ca35 100644 --- a/restconf-client/features/features-restconf-client/pom.xml +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-restconf-client - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml index d3123f7ec..a5d75807e 100755 --- a/restconf-client/features/pom.xml +++ b/restconf-client/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-features - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index 7f80aa951..6fb08e311 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-installer - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index 2d1893f6d..9492f9eaf 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 953db6933..d6f996ae6 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-provider - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT bundle ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index c0539c4d2..604c4c83d 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sshapi-call-node - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml index 6b9827c5c..32d50d7e1 100644 --- a/sshapi-call-node/features/features-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/features-sshapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-sshapi-call-node - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml index 7e367cea1..08c53e084 100755 --- a/sshapi-call-node/features/pom.xml +++ b/sshapi-call-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-features - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index 475da0c7d..94b28f215 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-installer - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index d46da1973..91fe43507 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index 0ad9e2a7b..d616db767 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-provider - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT bundle ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index e34106988..8bf76afa9 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-template-node - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml index 11e459d0a..6934d2f0b 100644 --- a/template-node/features/features-template-node/pom.xml +++ b/template-node/features/features-template-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins features-template-node - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml index 40574a1f9..9dfebb7e6 100644 --- a/template-node/features/pom.xml +++ b/template-node/features/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-features - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index 7fbbeec74..92f3bdeaf 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-installer - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/template-node/pom.xml b/template-node/pom.xml index 58a83c841..efcb5efd0 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index 477a539f2..65df5c6dc 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-provider - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT bundle ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/version.properties b/version.properties index 24c154ada..f23ce8f9e 100644 --- a/version.properties +++ b/version.properties @@ -6,8 +6,8 @@ # Comment release_name=0 -sprint_number=6 -feature_revision=1 +sprint_number=7 +feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit From 300ec08d358c3b23bd65e96a0f642b9a8e86106e Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 11 Sep 2019 15:32:30 -0400 Subject: Specify sli scope as provided Specify scope of sli dependency as provided to avoid issue in generated feature.xml Change-Id: I16caad2df85b1a8c103d942815c08e9ea037372a Issue-ID: CCSDK-1445 Signed-off-by: Timoney, Dan (dt5972) --- restconf-client/provider/pom.xml | 43 +++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index d6f996ae6..ec9e151e8 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 @@ -14,17 +15,17 @@ bundle ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} - + - - - org.onap.ccsdk.sli.core - sli-core-artifacts - ${ccsdk.sli.core.version} - pom - import - - + + + org.onap.ccsdk.sli.core + sli-core-artifacts + ${ccsdk.sli.core.version} + pom + import + + @@ -39,16 +40,12 @@ org.onap.ccsdk.sli.core sli-common - provided - - - org.onap.ccsdk.sli.core - sli-provider - provided - + provided + org.onap.ccsdk.sli.core sli-provider + provided org.onap.ccsdk.sli.plugins @@ -84,11 +81,11 @@ org.opendaylight.yangtools yang-parser-impl - - org.osgi - org.osgi.core - provided - + + org.osgi + org.osgi.core + provided + -- cgit From eb00a7cdf2828a3030595e14e142ad1250b45e5b Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 11 Sep 2019 20:28:15 +0000 Subject: rest api call node content type fix Don't set content-type header when there is no content/body Issue-ID: CCSDK-1703 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I247f571bf0d4fc021a1b32936b3dc33473b35f89 --- .../onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 8038b94ce..b93887ffc 100755 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -788,8 +788,6 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { WebTarget webTarget = addAuthType(client, p).target(p.restapiUrl); - log.info("Sending request below to url " + p.restapiUrl); - log.info(request); long t1 = System.currentTimeMillis(); HttpResponse r = new HttpResponse(); @@ -828,7 +826,15 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { Response response; try { - response = invocationBuilder.method(p.httpMethod.toString(), entity(request, contentType)); + // When the HTTP operation has no body do not set the content-type + //setting content-type has caused errors with some servers when no body is present + if (request == null) { + response = invocationBuilder.method(p.httpMethod.toString()); + } else { + log.info("Sending request below to url " + p.restapiUrl); + log.info(request); + response = invocationBuilder.method(p.httpMethod.toString(), entity(request, contentType)); + } } catch (ProcessingException | IllegalStateException e) { throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e); } -- cgit From 0eee231b5d1a598e7381be0d733e69357847768f Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Thu, 17 Oct 2019 18:22:47 +0000 Subject: add metric log filter integrate restapicallnode with MetricLogClientFilter Issue-ID: CCSDK-1846 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I2be5ff327caedfc93cec31d3273c97aa4f924eb7 --- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 7 +++++++ restapi-call-node/provider/pom.xml | 6 +++++- .../org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java | 5 ++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index 1100f223b..cd7f0351c 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -27,6 +27,13 @@ ${project.groupId} restapi-call-node-provider ${project.version} + + + + org.onap.logging-analytics + logging-filter-base + + diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 0e6babb39..711597d73 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -65,7 +65,11 @@ org.glassfish.jersey.media jersey-media-multipart - + + org.onap.logging-analytics + logging-filter-base + 1.5.0 + junit diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index b93887ffc..b4d7e1ba8 100755 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -72,6 +72,7 @@ import org.glassfish.jersey.media.multipart.file.FileDataBodyPart; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.logging.filter.base.MetricLogClientFilter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -785,7 +786,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { setClientTimeouts(client); // Needed to support additional HTTP methods such as PATCH client.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true); - + client.register(new MetricLogClientFilter()); WebTarget webTarget = addAuthType(client, p).target(p.restapiUrl); long t1 = System.currentTimeMillis(); @@ -819,8 +820,6 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } } - invocationBuilder.header("X-ECOMP-RequestID", org.slf4j.MDC.get("X-ECOMP-RequestID")); - invocationBuilder.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true); Response response; -- cgit From 0edd4f12d88179a9e0c1e304097f1c3f416b5e7f Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Thu, 31 Oct 2019 14:38:02 +0000 Subject: pom updates inherit version for org.onap.logging-analytics artifacts Issue-ID: CCSDK-1882 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I0d4d1dce823d9d826ad88eeb8f42e1b61eacc69c --- restapi-call-node/provider/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 711597d73..76e7bd238 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -68,7 +68,6 @@ org.onap.logging-analytics logging-filter-base - 1.5.0 -- cgit From 6ee70eedd709d90ff0ddf7f12d45b03f1c8930b6 Mon Sep 17 00:00:00 2001 From: "Haddox, Anthony (ah0647)" Date: Tue, 12 Nov 2019 19:13:38 +0000 Subject: [CCSDK-1921]Connection Timeout and Info Logging Add connection timeout when creating HTTPUrlConnection. Additionally, add some logging verbosity to the health check RPCs for at-a-glance recognition. Signed-off-by: Haddox, Anthony Issue-ID: CCSDK-1921 Change-Id: I5dcf8c4b4899f121080eedd546e1a1f6fe120a94 --- .../onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java index 119c0b9c7..116afb3a4 100755 --- a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java @@ -103,6 +103,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT private static final String FAULTY = "FAULTY"; private static final String VALUE = "value"; private static final String OUTPUT = "output"; + private static final int CONNECTION_TIMEOUT = 5000; // 5 second timeout private String akkaConfig; private String jolokiaClusterPath; private String shardManagerPath; @@ -256,7 +257,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT outputBuilder.setStatus("200"); outputBuilder.setHealth(getAdminHealth()); outputBuilder.setServedBy(member); - + log.info(outputBuilder.build().toString()); return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); } @@ -484,6 +485,10 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT outputBuilder.setServedBy(member); RpcResult rpcResult = RpcResultBuilder.status(true).withResult(outputBuilder.build()).build(); + log.info("{}:cluster-health: Site 1 | Healthy ODLs {}", APP_NAME, site1Health); + if(siteConfiguration == SiteConfiguration.GEO) { + log.info("{}:cluster-health: Site 2 | Healthy ODLs {}", APP_NAME, site2Health); + } return Futures.immediateFuture(rpcResult); } @@ -557,6 +562,8 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT outputBuilder.getSites().add(builder.build()); builder = getSitesBuilder(site2HealthyODLs, site2Voting, crossSiteAdminHealthy, crossSiteDbHealthy, crossSiteIdentifier); outputBuilder.getSites().add(builder.build()); + log.info("{}:site-health: Site 1 ({}) | hasVotingMembers?: {} | Healthy ODLs: {} | ADM isHealthy?: {} | DB isHealthy?: {}", APP_NAME, siteIdentifier, site1Voting, site1HealthyODLs, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth)); + log.info("{}:site-health: Site 2 ({}) | hasVotingMembers?: {} | Healthy ODLs: {} | ADM isHealthy?: {} | DB isHealthy?: {}", APP_NAME, crossSiteIdentifier, site2Voting, site2HealthyODLs, crossSiteAdminHealthy, crossSiteDbHealthy); } else { // Make calls over to site 1 healthchecks @@ -595,6 +602,8 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT outputBuilder.getSites().add(builder.build()); builder = getSitesBuilder(site2HealthyODLs, site2Voting, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), siteIdentifier); outputBuilder.getSites().add(builder.build()); + log.info("{}:site-health: Site 1 ({}) | hasVotingMembers?: {} | Healthy ODLs: {} | ADM isHealthy?: {} | DB isHealthy?: {}", APP_NAME, siteIdentifier, site1Voting, site1HealthyODLs, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth)); + log.info("{}:site-health: Site 2 ({}) | hasVotingMembers?: {} | Healthy ODLs: {} | ADM isHealthy?: {} | DB isHealthy?: {}", APP_NAME, crossSiteIdentifier, site2Voting, site2HealthyODLs, crossSiteAdminHealthy, crossSiteDbHealthy); } } @@ -931,6 +940,8 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT connection.addRequestProperty("Authorization", auth); connection.setRequestProperty("Connection", "keep-alive"); connection.setRequestProperty("Proxy-Connection", "keep-alive"); + connection.setConnectTimeout(CONNECTION_TIMEOUT); + connection.setReadTimeout(CONNECTION_TIMEOUT); return connection; } -- cgit From 54e11e9ee8bc35cc5e4b9f9b2a72b534e3217f2b Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 13 Nov 2019 10:30:06 -0500 Subject: Use 1.5.0 parent pom Use released 1.5.0 version of parent pom Change-Id: I16d9e82401447829e6b853790553623cc2a03117 Issue-ID: CCSDK-1920 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 2 +- features/ccsdk-sli-plugins-all/pom.xml | 2 +- features/features-sli-plugins/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- grToolkit/features/ccsdk-gr-toolkit/pom.xml | 2 +- grToolkit/features/features-gr-toolkit/pom.xml | 2 +- grToolkit/features/pom.xml | 2 +- grToolkit/installer/pom.xml | 2 +- grToolkit/model/pom.xml | 2 +- grToolkit/pom.xml | 2 +- grToolkit/provider/pom.xml | 2 +- pom.xml | 2 +- properties-node/features/ccsdk-properties-node/pom.xml | 2 +- properties-node/features/features-properties-node/pom.xml | 2 +- properties-node/features/pom.xml | 2 +- properties-node/installer/pom.xml | 2 +- properties-node/pom.xml | 2 +- properties-node/provider/pom.xml | 3 ++- restapi-call-node/features/ccsdk-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/features-restapi-call-node/pom.xml | 2 +- restapi-call-node/features/pom.xml | 2 +- restapi-call-node/installer/pom.xml | 2 +- restapi-call-node/pom.xml | 2 +- restapi-call-node/provider/pom.xml | 2 +- restconf-client/features/ccsdk-restconf-client/pom.xml | 2 +- restconf-client/features/features-restconf-client/pom.xml | 2 +- restconf-client/features/pom.xml | 2 +- restconf-client/installer/pom.xml | 2 +- restconf-client/pom.xml | 2 +- restconf-client/provider/pom.xml | 5 ++--- sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml | 2 +- sshapi-call-node/features/features-sshapi-call-node/pom.xml | 2 +- sshapi-call-node/features/pom.xml | 2 +- sshapi-call-node/installer/pom.xml | 2 +- sshapi-call-node/pom.xml | 2 +- sshapi-call-node/provider/pom.xml | 5 +++-- template-node/features/ccsdk-template-node/pom.xml | 2 +- template-node/features/features-template-node/pom.xml | 2 +- template-node/features/pom.xml | 2 +- template-node/installer/pom.xml | 2 +- template-node/pom.xml | 2 +- template-node/provider/pom.xml | 2 +- 43 files changed, 47 insertions(+), 46 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index ef2d3541a..f52c67ffd 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index fe21e42fe..17fa454d5 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index 070979220..0a42c4f92 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 5f6d1b442..b5d3d5f20 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/features/pom.xml b/features/pom.xml index d551c350a..b7267c060 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/grToolkit/features/ccsdk-gr-toolkit/pom.xml b/grToolkit/features/ccsdk-gr-toolkit/pom.xml index fb5523902..26a3ae37d 100644 --- a/grToolkit/features/ccsdk-gr-toolkit/pom.xml +++ b/grToolkit/features/ccsdk-gr-toolkit/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/grToolkit/features/features-gr-toolkit/pom.xml b/grToolkit/features/features-gr-toolkit/pom.xml index 3e6c967ad..fa044f74c 100755 --- a/grToolkit/features/features-gr-toolkit/pom.xml +++ b/grToolkit/features/features-gr-toolkit/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/grToolkit/features/pom.xml b/grToolkit/features/pom.xml index aebb98e9f..8a1945bf3 100755 --- a/grToolkit/features/pom.xml +++ b/grToolkit/features/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/grToolkit/installer/pom.xml b/grToolkit/installer/pom.xml index 0fd397232..2b3147426 100755 --- a/grToolkit/installer/pom.xml +++ b/grToolkit/installer/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/grToolkit/model/pom.xml b/grToolkit/model/pom.xml index 39239a08c..56a136b5b 100755 --- a/grToolkit/model/pom.xml +++ b/grToolkit/model/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0-SNAPSHOT + 1.5.0 ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/pom.xml b/grToolkit/pom.xml index 9de96ec8c..7f21b85fb 100755 --- a/grToolkit/pom.xml +++ b/grToolkit/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index d36643a77..a18054be8 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0-SNAPSHOT + 1.5.0 ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index c0be21440..919cbe164 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml index c496d20d8..a4f0ce2b8 100644 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ b/properties-node/features/ccsdk-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml index e25ba5808..7f25ff685 100644 --- a/properties-node/features/features-properties-node/pom.xml +++ b/properties-node/features/features-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml index 97f12cf24..f7834e1b2 100755 --- a/properties-node/features/pom.xml +++ b/properties-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 9ba85b91c..7d501f7d4 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 0c9c28464..03fbaebea 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 059870974..a2a27eb5b 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins @@ -15,6 +15,7 @@ ccsdk-sli-plugins :: properties-node :: ${project.artifactId} + diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml index cd7f0351c..bba917c94 100644 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml index 26c986a3b..a98d96737 100644 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ b/restapi-call-node/features/features-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml index 6736bd1d2..9df843837 100755 --- a/restapi-call-node/features/pom.xml +++ b/restapi-call-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 06e77b411..1d9594ffb 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 26a237f7b..5997af7a2 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 76e7bd238..bda6b00e9 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml index 276d6e8fb..831b59760 100644 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ b/restconf-client/features/ccsdk-restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml index d4c78ca35..6f241b633 100644 --- a/restconf-client/features/features-restconf-client/pom.xml +++ b/restconf-client/features/features-restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml index a5d75807e..1888dd77c 100755 --- a/restconf-client/features/pom.xml +++ b/restconf-client/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index 6fb08e311..26775a835 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index 9492f9eaf..e84258746 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index ec9e151e8..487bdf9b5 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -1,12 +1,11 @@ - + 4.0.0 org.onap.ccsdk.parent binding-parent - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index 604c4c83d..d16c6ff32 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml index 32d50d7e1..54bc88dc4 100644 --- a/sshapi-call-node/features/features-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/features-sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml index 08c53e084..af7901236 100755 --- a/sshapi-call-node/features/pom.xml +++ b/sshapi-call-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index 94b28f215..613886aee 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index 91fe43507..14d374a0c 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index d616db767..641e9af1e 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins @@ -14,7 +14,8 @@ bundle ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} - + + diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml index 8bf76afa9..a8cb85aaf 100644 --- a/template-node/features/ccsdk-template-node/pom.xml +++ b/template-node/features/ccsdk-template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml index 6934d2f0b..65837d5e1 100644 --- a/template-node/features/features-template-node/pom.xml +++ b/template-node/features/features-template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml index 9dfebb7e6..77409f694 100644 --- a/template-node/features/pom.xml +++ b/template-node/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index 92f3bdeaf..53a1ff55d 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins diff --git a/template-node/pom.xml b/template-node/pom.xml index efcb5efd0..c007e3ce7 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index 65df5c6dc..3d470c0af 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0-SNAPSHOT + 1.5.0 org.onap.ccsdk.sli.plugins -- cgit From 1efc3aad5f102988243e7579adbf4890b8bf91a8 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 15 Nov 2019 14:56:39 -0500 Subject: Add new committers Kevin and Kapil Add new committers Kevin Smokowski and Kapil Singal Change-Id: I0c0abb07d2575f51b81949d3b997cb1e9f00a8aa Issue-ID: CCSDK-1934 Signed-off-by: Timoney, Dan (dt5972) --- INFO.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/INFO.yaml b/INFO.yaml index fc1128836..a5af66950 100644 --- a/INFO.yaml +++ b/INFO.yaml @@ -49,6 +49,16 @@ committers: company: 'IBM' id: 'brindasanthm' timezone: 'America/New_York' + - name: 'Kevin Smokowski' + email: 'ks6305@att.com' + company: 'ATT' + id: 'nullop' + timezone: 'America/New_York' + - name: 'Kapil Singal' + email: 'kaggarwal@in.ibm.com' + company: 'IBM' + id: 'kasingal' + timezone: 'America/New_York' repositories: - ccsdk/sli/plugins tsc: @@ -63,3 +73,9 @@ tsc: - type: 'Addition' name: 'Brinda Santh Muthuramalingam' link: 'https://lists.onap.org/g/onap-tsc/message/5208' + - type: 'Addition' + name: 'Kevin Smokowski' + link: 'https://lists.onap.org/g/onap-tsc/message/5635' + - type: 'Addition' + name: 'Kapil Singal' + link: 'https://lists.onap.org/g/onap-tsc/message/5635' -- cgit From 83893971e01530d86d7d61324f435d8270884f5f Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 19 Nov 2019 12:44:23 -0500 Subject: Add id for Kapil Add Kapil's ATT id as committer Change-Id: Ie51725159237d9eac9903667c0b27ee83b78bc6a Issue-ID: CCSDK-1934 Signed-off-by: Timoney, Dan (dt5972) --- INFO.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/INFO.yaml b/INFO.yaml index a5af66950..221e90899 100644 --- a/INFO.yaml +++ b/INFO.yaml @@ -59,6 +59,11 @@ committers: company: 'IBM' id: 'kasingal' timezone: 'America/New_York' + - name: 'Kapil Singal' + email: 'ks220y@att.com' + company: 'IBM' + id: 'ks220y' + timezone: 'America/New_York' repositories: - ccsdk/sli/plugins tsc: -- cgit From bf59c3a6e1ae0ce2dd1703688f9f4e712d75e193 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 19 Nov 2019 13:23:49 -0500 Subject: Fix versions of sli core dependencies Fix to override ccsdk sli core version from parent pom with current version Change-Id: I0d4dfad609fb7c838d3750ef36b8656ad102dda6 Issue-ID: CCSDK-1944 Signed-off-by: Timoney, Dan (dt5972) --- grToolkit/provider/pom.xml | 4 ++++ properties-node/provider/pom.xml | 3 +++ restapi-call-node/provider/pom.xml | 4 ++++ restconf-client/provider/pom.xml | 4 ++++ sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml | 4 ++++ sshapi-call-node/provider/pom.xml | 3 +++ template-node/provider/pom.xml | 4 ++++ 7 files changed, 26 insertions(+) diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index a18054be8..8f5f17da0 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -13,6 +13,10 @@ 0.7.0-SNAPSHOT bundle + + ${project.version} + + diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index a2a27eb5b..1a2afbcb3 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -15,6 +15,9 @@ ccsdk-sli-plugins :: properties-node :: ${project.artifactId} + + ${project.version} + diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index bda6b00e9..6c956c6a1 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -15,6 +15,10 @@ ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} + + ${project.version} + + diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 487bdf9b5..0321f07b0 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -15,6 +15,10 @@ ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} + + ${project.version} + + diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml index d16c6ff32..6dfe13997 100644 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml @@ -19,6 +19,10 @@ + + + org.springframework.cloud + spring-cloud-contract-wiremock + 1.2.4.RELEASE + test + org.json json diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java index 116afb3a4..14e27ef38 100755 --- a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java @@ -27,33 +27,41 @@ import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.sql.Connection; -import java.sql.SQLException; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Collection; +import java.util.Comparator; import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import javax.annotation.Nonnull; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import org.apache.commons.lang.StringUtils; + import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.onap.ccsdk.sli.plugins.grtoolkit.connection.ConnectionManager; +import org.onap.ccsdk.sli.plugins.grtoolkit.connection.ConnectionResponse; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.AdminHealth; import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterActor; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.DatabaseHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.FailoverStatus; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.Health; import org.onap.ccsdk.sli.plugins.grtoolkit.data.MemberBuilder; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.PropertyKeys; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.SiteHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.resolver.HealthResolver; +import org.onap.ccsdk.sli.plugins.grtoolkit.resolver.SingleNodeHealthResolver; +import org.onap.ccsdk.sli.plugins.grtoolkit.resolver.SixNodeHealthResolver; +import org.onap.ccsdk.sli.plugins.grtoolkit.resolver.ThreeNodeHealthResolver; import org.json.JSONArray; -import org.json.JSONException; import org.json.JSONObject; import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface; @@ -96,19 +104,29 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * API implementation of the {@code GrToolkitService} interface generated from + * the gr-toolkit.yang model. The RPCs contained within this class are meant to + * run in an architecture agnostic fashion, where the response is repeatable + * and predictable across any given node configuration. To facilitate this, + * health checking and failover logic has been abstracted into the + * {@code HealthResolver} classes. + *

+ * Anyone who wishes to write a custom resolver for use with GR Toolkit should + * extend the {@code HealthResolver} class. The currently provided resolvers + * are useful references for further implementation. + * + * @author Anthony Haddox + * @see GrToolkitService + * @see HealthResolver + * @see SingleNodeHealthResolver + * @see ThreeNodeHealthResolver + * @see SixNodeHealthResolver + */ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataTreeChangeListener { private static final String APP_NAME = "gr-toolkit"; private static final String PROPERTIES_FILE = System.getenv("SDNC_CONFIG_DIR") + "/gr-toolkit.properties"; - private static final String HEALTHY = "HEALTHY"; - private static final String FAULTY = "FAULTY"; - private static final String VALUE = "value"; - private static final String OUTPUT = "output"; - private static final int CONNECTION_TIMEOUT = 5000; // 5 second timeout private String akkaConfig; - private String jolokiaClusterPath; - private String shardManagerPath; - private String shardPathTemplate; - private String credentials; private String httpProtocol; private String siteIdentifier = System.getenv("SITE_NAME"); private final Logger log = LoggerFactory.getLogger(GrToolkitProvider.class); @@ -121,15 +139,26 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT private String member; private ClusterActor self; private HashMap memberMap; - private SiteConfiguration siteConfiguration; private Properties properties; private DistributedDataStoreInterface configDatastore; + private HealthResolver resolver; + + /** + * Constructs the provider for the GR Toolkit API. Dependencies are + * injected using the GrToolkit.xml blueprint. + * + * @param dataBroker The Data Broker + * @param notificationProviderService The Notification Service + * @param rpcProviderRegistry The RPC Registry + * @param configDatastore The Configuration Data Store provided by the controller + * @param dbLibService Reference to the controller provided DbLibService + */ public GrToolkitProvider(DataBroker dataBroker, NotificationPublishService notificationProviderService, RpcProviderRegistry rpcProviderRegistry, DistributedDataStoreInterface configDatastore, DbLibService dbLibService) { - this.log.info("Creating provider for {}", APP_NAME); + log.info("Creating provider for {}", APP_NAME); this.executor = Executors.newFixedThreadPool(1); this.dataBroker = dataBroker; this.notificationService = notificationProviderService; @@ -139,51 +168,59 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT initialize(); } + /** + * Initializes some structures necessary to hold health check information + * and perform failovers. + */ private void initialize() { log.info("Initializing provider for {}", APP_NAME); - // Create the top level containers createContainers(); setProperties(); defineMembers(); - rpcRegistration = rpcRegistry.addRpcImplementation(GrToolkitService.class, this); log.info("Initialization complete for {}", APP_NAME); } + /** + * Creates the {@code Properties} object with the contents of + * gr-toolkit.properties, found at the {@code SDNC_CONFIG_DIR} directory, + * which should be set as an environment variable. If the properties file + * is not found, GR Toolkit will not function. + */ private void setProperties() { log.info("Loading properties from {}", PROPERTIES_FILE); properties = new Properties(); File propertiesFile = new File(PROPERTIES_FILE); if(!propertiesFile.exists()) { - log.warn("Properties file not found."); - return; - } - try(FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { - properties.load(fileInputStream); - if(!properties.containsKey(PropertyKeys.SITE_IDENTIFIER)) { - properties.put(PropertyKeys.SITE_IDENTIFIER, "Unknown Site"); - } - String port = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL).trim()) ? properties.getProperty(PropertyKeys.CONTROLLER_PORT_SSL).trim() : properties.getProperty(PropertyKeys.CONTROLLER_PORT_HTTP).trim(); - httpProtocol = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL).trim()) ? "https://" : "http://"; - akkaConfig = properties.getProperty(PropertyKeys.AKKA_CONF_LOCATION).trim(); - jolokiaClusterPath = ":" + port + properties.getProperty(PropertyKeys.MBEAN_CLUSTER).trim(); - shardManagerPath = ":" + port + properties.getProperty(PropertyKeys.MBEAN_SHARD_MANAGER).trim(); - shardPathTemplate = ":" + port + properties.getProperty(PropertyKeys.MBEAN_SHARD_CONFIG).trim(); - if(siteIdentifier == null || siteIdentifier.isEmpty()) { - siteIdentifier = properties.getProperty(PropertyKeys.SITE_IDENTIFIER).trim(); + log.warn("setProperties(): Properties file not found."); + } else { + try(FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { + properties.load(fileInputStream); + if(!properties.containsKey(PropertyKeys.SITE_IDENTIFIER)) { + properties.put(PropertyKeys.SITE_IDENTIFIER, "Unknown Site"); + } + httpProtocol = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL).trim()) ? "https://" : "http://"; + akkaConfig = properties.getProperty(PropertyKeys.AKKA_CONF_LOCATION).trim(); + if(StringUtils.isEmpty(siteIdentifier)) { + siteIdentifier = properties.getProperty(PropertyKeys.SITE_IDENTIFIER).trim(); + } + log.info("setProperties(): Loaded properties."); + } catch(IOException e) { + log.error("setProperties(): Error loading properties.", e); } - credentials = properties.getProperty(PropertyKeys.CONTROLLER_CREDENTIALS).trim(); - log.info("Loaded properties."); - } catch(IOException e) { - log.error("Error loading properties.", e); } } + /** + * Parses the akka.conf file used by the controller to define an akka + * cluster. This method requires the seed-nodes definition to exist + * on a single line. + */ private void defineMembers() { member = configDatastore.getActorContext().getCurrentMemberName().getName(); - log.info("Cluster member: {}", member); + log.info("defineMembers(): Cluster member: {}", member); - log.info("Parsing akka.conf for cluster memberMap..."); + log.info("defineMembers(): Parsing akka.conf for cluster memberMap..."); try { File akkaConfigFile = new File(this.akkaConfig); try(FileReader fileReader = new FileReader(akkaConfigFile); @@ -197,70 +234,136 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT } } } catch(IOException e) { - log.error("Couldn't load akka", e); + log.error("defineMembers(): Couldn't load akka", e); } catch(NullPointerException e) { - log.error("akkaConfig is null. Check properties file and restart {} bundle.", APP_NAME); + log.error("defineMembers(): akkaConfig is null. Check properties file and restart {} bundle.", APP_NAME); + log.error("defineMembers(): NullPointerException", e); } log.info("self:\n{}", self); } + /** + * Sets up the {@code InstanceIdentifier}s for Data Store transactions. + */ private void createContainers() { // Replace with MD-SAL write for FailoverStatus } - protected void initializeChild() { - // Override if you have custom initialization intelligence - } - + /** + * Shuts down the {@code ExecutorService} and closes the RPC Provider Registry. + */ @Override public void close() throws Exception { log.info("Closing provider for {}", APP_NAME); executor.shutdown(); rpcRegistration.close(); - log.info("Successfully closed provider for {}", APP_NAME); + log.info("close(): Successfully closed provider for {}", APP_NAME); } + /** + * Listens for changes to the Data tree. + * + * @param changes Data tree changes. + */ @Override public void onDataTreeChanged(@Nonnull Collection changes) { - log.info("onDataTreeChanged() called. but there is no change here"); - } - + log.info("onDataTreeChanged(): No changes."); + } + + /** + * Makes a call to {@code resolver.getClusterHealth()} to determine the + * health of the akka clustered controllers. + * + * @param input request body adhering to the model for + * {@code ClusterHealthInput} + * @return response adhering to the model for {@code ClusterHealthOutput} + * @see HealthResolver + * @see ClusterHealthInput + * @see ClusterHealthOutput + */ @Override public ListenableFuture> clusterHealth(ClusterHealthInput input) { log.info("{}:cluster-health invoked.", APP_NAME); - getControllerHealth(); - return buildClusterHealthOutput("200"); - } - + resolver.getClusterHealth(); + return buildClusterHealthOutput(); + } + + /** + * Makes a call to {@code resolver.getSiteHealth()} to determine the health + * of all of the application components of a site. In a multi-site config, + * this will gather the health of all sites. + * + * @param input request body adhering to the model for + * {@code SiteHealthInput} + * @return response adhering to the model for {@code SiteHealthOutput} + * @see HealthResolver + * @see SiteHealthInput + * @see SiteHealthOutput + */ @Override public ListenableFuture> siteHealth(SiteHealthInput input) { log.info("{}:site-health invoked.", APP_NAME); - getControllerHealth(); - return buildSiteHealthOutput("200", getAdminHealth(), getDatabaseHealth()); - } - + List sites = resolver.getSiteHealth(); + return buildSiteHealthOutput(sites); + } + + /** + * Makes a call to {@code resolver.getDatabaseHealth()} to determine the + * health of the database(s) used by the controller. + * + * @param input request body adhering to the model for + * {@code DatabaseHealthInput} + * @return response adhering to the model for {@code DatabaseHealthOutput} + * @see HealthResolver + * @see DatabaseHealthInput + * @see DatabaseHealthOutput + */ @Override public ListenableFuture> databaseHealth(DatabaseHealthInput input) { log.info("{}:database-health invoked.", APP_NAME); DatabaseHealthOutputBuilder outputBuilder = new DatabaseHealthOutputBuilder(); - outputBuilder.setStatus("200"); - outputBuilder.setHealth(getDatabaseHealth()); + DatabaseHealth health = resolver.getDatabaseHealth(); + outputBuilder.setStatus(health.getHealth().equals(Health.HEALTHY) ? "200" : "500"); + outputBuilder.setHealth(health.getHealth().toString()); outputBuilder.setServedBy(member); - + log.info("databaseHealth(): Health: {}", health.getHealth()); return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); } + /** + * Makes a call to {@code resolver.getAdminHealth()} to determine the + * health of the administrative portal(s) used by the controller. + * + * @param input request body adhering to the model for + * {@code AdminHealthInput} + * @return response adhering to the model for {@code AdminHealthOutput} + * @see HealthResolver + * @see AdminHealthInput + * @see AdminHealthOutput + */ @Override public ListenableFuture> adminHealth(AdminHealthInput input) { log.info("{}:admin-health invoked.", APP_NAME); AdminHealthOutputBuilder outputBuilder = new AdminHealthOutputBuilder(); - outputBuilder.setStatus("200"); - outputBuilder.setHealth(getAdminHealth()); + AdminHealth adminHealth = resolver.getAdminHealth(); + outputBuilder.setStatus(Integer.toString(adminHealth.getStatusCode())); + outputBuilder.setHealth(adminHealth.getHealth().toString()); outputBuilder.setServedBy(member); - log.info(outputBuilder.build().toString()); + log.info("adminHealth(): Status: {} | Health: {}", adminHealth.getStatusCode(), adminHealth.getHealth()); return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); } + /** + * Places IP Tables rules in place to drop akka communications traffic with + * one or mode nodes. This method does not not perform any checks to see if + * rules currently exist, and assumes success. + * + * @param input request body adhering to the model for + * {@code HaltAkkaTrafficInput} + * @return response adhering to the model for {@code HaltAkkaTrafficOutput} + * @see HaltAkkaTrafficInput + * @see HaltAkkaTrafficOutput + */ @Override public ListenableFuture> haltAkkaTraffic(HaltAkkaTrafficInput input) { log.info("{}:halt-akka-traffic invoked.", APP_NAME); @@ -272,6 +375,17 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); } + /** + * Removes IP Tables rules in place to permit akka communications traffic + * with one or mode nodes. This method does not not perform any checks to + * see if rules currently exist, and assumes success. + * + * @param input request body adhering to the model for + * {@code ResumeAkkaTrafficInput} + * @return response adhering to the model for {@code ResumeAkkaTrafficOutput} + * @see ResumeAkkaTrafficInput + * @see ResumeAkkaTrafficOutput + */ @Override public ListenableFuture> resumeAkkaTraffic(ResumeAkkaTrafficInput input) { log.info("{}:resume-akka-traffic invoked.", APP_NAME); @@ -283,6 +397,16 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); } + /** + * Returns a canned response containing the identifier for this + * controller's site. + * + * @param input request body adhering to the model for + * {@code SiteIdentifierInput} + * @return response adhering to the model for {@code SiteIdentifierOutput} + * @see SiteIdentifierInput + * @see SiteIdentifierOutput + */ @Override public ListenableFuture> siteIdentifier(SiteIdentifierInput input) { log.info("{}:site-identifier invoked.", APP_NAME); @@ -290,72 +414,50 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT outputBuilder.setStatus("200"); outputBuilder.setId(siteIdentifier); outputBuilder.setServedBy(member); - return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); } + /** + * Makes a call to {@code resolver.tryFailover()} to try a failover defined + * by the active {@code HealthResolver}. + * + * @param input request body adhering to the model for + * {@code FailoverInput} + * @return response adhering to the model for {@code FailoverOutput} + * @see HealthResolver + * @see FailoverInput + * @see FailoverOutput + */ @Override public ListenableFuture> failover(FailoverInput input) { log.info("{}:failover invoked.", APP_NAME); FailoverOutputBuilder outputBuilder = new FailoverOutputBuilder(); + FailoverStatus failoverStatus = resolver.tryFailover(input); outputBuilder.setServedBy(member); - if(siteConfiguration != SiteConfiguration.GEO) { - log.info("Cannot failover non-GEO site."); - outputBuilder.setMessage("Failover aborted. This is not a GEO configuration."); - outputBuilder.setStatus("400"); - return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); - } - ArrayList activeSite = new ArrayList<>(); - ArrayList standbySite = new ArrayList<>(); - - log.info("Performing preliminary cluster health check..."); - // Necessary to populate all member info. Health is not used for judgement calls. - getControllerHealth(); - - log.info("Determining active site..."); - for(Map.Entry entry : memberMap.entrySet()) { - String key = entry.getKey(); - ClusterActor clusterActor = entry.getValue(); - if(clusterActor.isVoting()) { - activeSite.add(clusterActor); - log.debug("Active Site member: {}", key); - } - else { - standbySite.add(clusterActor); - log.debug("Standby Site member: {}", key); - } - } - - String port = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL)) ? properties.getProperty(PropertyKeys.CONTROLLER_PORT_SSL) : properties.getProperty(PropertyKeys.CONTROLLER_PORT_HTTP); - - if(Boolean.parseBoolean(input.getBackupData())) { - backupMdSal(activeSite, port); - } - - if(!changeClusterVoting(outputBuilder, activeSite, standbySite, port)) - return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); - - if(Boolean.parseBoolean(input.getIsolate())) { - isolateSiteFromCluster(activeSite, standbySite, port); - - if(Boolean.parseBoolean(input.getDownUnreachable())) { - downUnreachableNodes(activeSite, standbySite, port); - } - } - - log.info("{}:failover complete.", APP_NAME); - - outputBuilder.setMessage("Failover complete."); - outputBuilder.setStatus("200"); + outputBuilder.setMessage(failoverStatus.getMessage()); + outputBuilder.setStatus(Integer.toString(failoverStatus.getStatusCode())); + log.info("{}:{}.", APP_NAME, failoverStatus.getMessage()); return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); } + /** + * Performs an akka traffic isolation of the active site from the standby + * site in an Active/Standby architecture. Invokes the + * {@code halt-akka-traffic} RPC against the standby site nodes using the + * information of the active site nodes. + * + * @param activeSite list of nodes in the active site + * @param standbySite list of nodes in the standby site + * @param port http or https port of the controller + * @deprecated No longer used since the refactor to use the HealthResolver + * pattern. Retained so the logic can be replicated later. + */ private void isolateSiteFromCluster(ArrayList activeSite, ArrayList standbySite, String port) { - log.info("Halting Akka traffic..."); + log.info("isolateSiteFromCluster(): Halting Akka traffic..."); for(ClusterActor actor : standbySite) { try { log.info("Halting Akka traffic for: {}", actor.getNode()); - // Build JSON with activeSite actor Node and actor AkkaPort + // Build JSON with activeSite actor Node and actor AkkaPort JSONObject akkaInput = new JSONObject(); JSONObject inputBlock = new JSONObject(); JSONArray votingStateArray = new JSONArray(); @@ -368,15 +470,24 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT } inputBlock.put("node-info", votingStateArray); akkaInput.put("input", inputBlock); - getRequestContent(httpProtocol + actor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:halt-akka-traffic", HttpMethod.POST, akkaInput.toString()); + ConnectionResponse response = ConnectionManager.getConnectionResponse(httpProtocol + actor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:halt-akka-traffic", ConnectionManager.HttpMethod.POST, akkaInput.toString(), ""); } catch(IOException e) { - log.error("Could not halt Akka traffic for: " + actor.getNode(), e); + log.error("isolateSiteFromCluster(): Could not halt Akka traffic for: " + actor.getNode(), e); } } } + /** + * Invokes the down unreachable action through the Jolokia mbean API. + * + * @param activeSite list of nodes in the active site + * @param standbySite list of nodes in the standby site + * @param port http or https port of the controller + * @deprecated No longer used since the refactor to use the HealthResolver + * pattern. Retained so the logic can be replicated later. + */ private void downUnreachableNodes(ArrayList activeSite, ArrayList standbySite, String port) { - log.info("Setting site unreachable..."); + log.info("downUnreachableNodes(): Setting site unreachable..."); JSONObject jolokiaInput = new JSONObject(); jolokiaInput.put("type", "EXEC"); jolokiaInput.put("mbean", "akka:type=Cluster"); @@ -388,223 +499,112 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT arguments.put("akka.tcp://opendaylight-cluster-data@" + actor.getNode() + ":" + properties.getProperty(PropertyKeys.CONTROLLER_PORT_AKKA)); } jolokiaInput.put("arguments", arguments); - log.debug("{}", jolokiaInput); + log.debug("downUnreachableNodes(): {}", jolokiaInput); try { - log.info("Setting nodes unreachable"); - getRequestContent(httpProtocol + standbySite.get(0).getNode() + ":" + port + "/jolokia", HttpMethod.POST, jolokiaInput.toString()); + log.info("downUnreachableNodes(): Setting nodes unreachable"); + ConnectionResponse response = ConnectionManager.getConnectionResponse(httpProtocol + standbySite.get(0).getNode() + ":" + port + "/jolokia", ConnectionManager.HttpMethod.POST, jolokiaInput.toString(), ""); } catch(IOException e) { - log.error("Error setting nodes unreachable", e); - } - } - - private boolean changeClusterVoting(FailoverOutputBuilder outputBuilder, ArrayList activeSite, ArrayList standbySite, String port) { - log.info("Changing voting for all shards to standby site..."); - try { - JSONObject votingInput = new JSONObject(); - JSONObject inputBlock = new JSONObject(); - JSONArray votingStateArray = new JSONArray(); - JSONObject memberVotingState; - for(ClusterActor actor : activeSite) { - memberVotingState = new JSONObject(); - memberVotingState.put("member-name", actor.getMember()); - memberVotingState.put("voting", false); - votingStateArray.put(memberVotingState); - } - for(ClusterActor actor : standbySite) { - memberVotingState = new JSONObject(); - memberVotingState.put("member-name", actor.getMember()); - memberVotingState.put("voting", true); - votingStateArray.put(memberVotingState); - } - inputBlock.put("member-voting-state", votingStateArray); - votingInput.put("input", inputBlock); - log.debug("{}", votingInput); - // Change voting all shards - getRequestContent(httpProtocol + self.getNode() + ":" + port + "/restconf/operations/cluster-admin:change-member-voting-states-for-all-shards", HttpMethod.POST, votingInput.toString()); - } catch(IOException e) { - log.error("Changing voting", e); - outputBuilder.setMessage("Failover aborted. Failed to change voting."); - outputBuilder.setStatus("500"); - return false; - } - return true; - } - + log.error("downUnreachableNodes(): Error setting nodes unreachable", e); + } + } + + /** + * Triggers a data backup and export sequence of MD-SAL data. Invokes the + * {@code data-export-import:schedule-export} RPC to schedule a data export + * and subsequently the {@code daexim-offsite-backup:backup-data} RPC + * against the active site to export and backup the data. Assumes the + * controllers have the org.onap.ccsdk.sli.northbound.daeximoffsitebackup + * bundle installed. + * + * @param activeSite list of nodes in the active site + * @param port http or https port of the controller + * @deprecated No longer used since the refactor to use the HealthResolver + * pattern. Retained so the logic can be replicated later. + */ private void backupMdSal(ArrayList activeSite, String port) { - log.info("Backing up data..."); + log.info("backupMdSal(): Backing up data..."); try { - log.info("Scheduling backup for: {}", activeSite.get(0).getNode()); - getRequestContent(httpProtocol + activeSite.get(0).getNode() + ":" + port + "/restconf/operations/data-export-import:schedule-export", HttpMethod.POST, "{ \"input\": { \"run-at\": \"30\" } }"); + log.info("backupMdSal(): Scheduling backup for: {}", activeSite.get(0).getNode()); + ConnectionResponse response = ConnectionManager.getConnectionResponse(httpProtocol + activeSite.get(0).getNode() + ":" + port + "/restconf/operations/data-export-import:schedule-export", ConnectionManager.HttpMethod.POST, "{ \"input\": { \"run-at\": \"30\" } }", ""); } catch(IOException e) { - log.error("Error backing up MD-SAL", e); + log.error("backupMdSal(): Error backing up MD-SAL", e); } for(ClusterActor actor : activeSite) { try { // Move data offsite - log.info("Backing up data for: {}", actor.getNode()); - getRequestContent(httpProtocol + actor.getNode() + ":" + port + "/restconf/operations/daexim-offsite-backup:backup-data", HttpMethod.POST); + log.info("backupMdSal(): Backing up data for: {}", actor.getNode()); + ConnectionResponse response = ConnectionManager.getConnectionResponse(httpProtocol + actor.getNode() + ":" + port + "/restconf/operations/daexim-offsite-backup:backup-data", ConnectionManager.HttpMethod.POST, null, ""); } catch(IOException e) { - log.error("Error backing up data.", e); + log.error("backupMdSal(): Error backing up data.", e); } } } - private ListenableFuture> buildClusterHealthOutput(String statusCode) { + /** + * Builds a response object for {@code clusterHealth()}. Sorts and iterates + * over the contents of the {@code memberMap}, which contains the health + * information of the cluster, and adds them to the {@code outputBuilder}. + * If the ClusterActor is healthy, according to + * {@code resolver.isControllerHealthy()}, the {@code ClusterHealthOutput} + * status has a {@code 0} appended, otherwise a {@code 1} is appended. A + * status of all zeroes denotes a healthy cluster. This status should be + * easily decoded by tools which use the output. + * + * @return future containing a completed {@code ClusterHealthOutput} + * @see ClusterActor + * @see ClusterHealthOutput + * @see HealthResolver + */ + @SuppressWarnings("unchecked") + private ListenableFuture> buildClusterHealthOutput() { ClusterHealthOutputBuilder outputBuilder = new ClusterHealthOutputBuilder(); - outputBuilder.setStatus(statusCode); - outputBuilder.setMembers((List) new ArrayList()); - int site1Health = 0; - int site2Health = 0; - - for(Map.Entry entry : memberMap.entrySet()) { - ClusterActor clusterActor = entry.getValue(); - if(clusterActor.isUp() && !clusterActor.isUnreachable()) { - if(ClusterActor.SITE_1.equals(clusterActor.getSite())) - site1Health++; - else if(ClusterActor.SITE_2.equals(clusterActor.getSite())) - site2Health++; - } - outputBuilder.getMembers().add(new MemberBuilder(clusterActor).build()); - } - if(siteConfiguration == SiteConfiguration.SOLO) { - outputBuilder.setSite1Health(HEALTHY); - } - else if(site1Health > 1) { - outputBuilder.setSite1Health(HEALTHY); - } - else { - outputBuilder.setSite1Health(FAULTY); - } - - if(siteConfiguration == SiteConfiguration.GEO && site2Health > 1) { - outputBuilder.setSite2Health(HEALTHY); - } - else if(siteConfiguration == SiteConfiguration.GEO) { - outputBuilder.setSite2Health(FAULTY); - } - outputBuilder.setServedBy(member); + List memberList = new ArrayList(); + StringBuilder stat = new StringBuilder(); + memberMap.values() + .stream() + .sorted(Comparator.comparingInt(member -> Integer.parseInt(member.getMember().split("-")[1]))) + .forEach(member -> { + memberList.add(new MemberBuilder(member).build()); + // 0 is a healthy controller, 1 is unhealthy. + // The list is sorted so users can decode to find unhealthy nodes + // This will also let them figure out health on a per-site basis + // Depending on any tools they use with this API + if(resolver.isControllerHealthy(member)) { + stat.append("0"); + } else { + stat.append("1"); + } + }); + outputBuilder.setStatus(stat.toString()); + outputBuilder.setMembers(memberList); RpcResult rpcResult = RpcResultBuilder.status(true).withResult(outputBuilder.build()).build(); - log.info("{}:cluster-health: Site 1 | Healthy ODLs {}", APP_NAME, site1Health); - if(siteConfiguration == SiteConfiguration.GEO) { - log.info("{}:cluster-health: Site 2 | Healthy ODLs {}", APP_NAME, site2Health); - } return Futures.immediateFuture(rpcResult); } - private ListenableFuture> buildSiteHealthOutput(String statusCode, String adminHealth, String databaseHealth) { + /** + * Builds a response object for {@code siteHealth()}. Iterates over a list + * of {@code SiteHealth} objects and populates the {@code SiteHealthOutput} + * with the information. + * + * @param sites list of sites + * @return future containing a completed {@code SiteHealthOutput} + * @see SiteHealth + * @see HealthResolver + */ + @SuppressWarnings("unchecked") + private ListenableFuture> buildSiteHealthOutput(List sites) { SiteHealthOutputBuilder outputBuilder = new SiteHealthOutputBuilder(); - outputBuilder.setStatus(statusCode); + SitesBuilder siteBuilder = new SitesBuilder(); + outputBuilder.setStatus("200"); outputBuilder.setSites((List) new ArrayList()); - if(siteConfiguration != SiteConfiguration.GEO) { - int healthyODLs = 0; - SitesBuilder builder = new SitesBuilder(); - for(Map.Entry entry : memberMap.entrySet()) { - ClusterActor clusterActor = entry.getValue(); - if(clusterActor.isUp() && !clusterActor.isUnreachable()) { - healthyODLs++; - } - } - if(siteConfiguration != SiteConfiguration.SOLO) { - builder.setHealth(HEALTHY); - builder.setRole("ACTIVE"); - builder.setId(siteIdentifier); - } - else { - builder = getSitesBuilder(healthyODLs, true, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), siteIdentifier); - } - outputBuilder.getSites().add(builder.build()); - } - else { - int site1HealthyODLs = 0; - int site2HealthyODLs = 0; - boolean site1Voting = false; - boolean site2Voting = false; - boolean performedCrossSiteHealthCheck = false; - boolean crossSiteAdminHealthy = false; - boolean crossSiteDbHealthy = false; - String crossSiteIdentifier = "UNKNOWN_SITE"; - String port = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL)) ? properties.getProperty(PropertyKeys.CONTROLLER_PORT_SSL) : properties.getProperty(PropertyKeys.CONTROLLER_PORT_HTTP); - if(isSite1()) { - // Make calls over to site 2 healthchecks - for(Map.Entry entry : memberMap.entrySet()) { - ClusterActor clusterActor = entry.getValue(); - if(clusterActor.isUp() && !clusterActor.isUnreachable()) { - if(ClusterActor.SITE_1.equals(clusterActor.getSite())) { - site1HealthyODLs++; - if(clusterActor.isVoting()) { - site1Voting = true; - } - } - else { - site2HealthyODLs++; - if(clusterActor.isVoting()) { - site2Voting = true; - } - if(!performedCrossSiteHealthCheck) { - try { - String content = getRequestContent(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:site-identifier", HttpMethod.POST); - crossSiteIdentifier = new JSONObject(content).getJSONObject(OUTPUT).getString("id"); - crossSiteDbHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:database-health"); - crossSiteAdminHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:admin-health"); - performedCrossSiteHealthCheck = true; - } catch(Exception e) { - log.info("Cannot get cross site health from {}", clusterActor.getNode()); - log.info("siteIdentifier: {} | dbHealth: {} | adminHealth: {}", crossSiteIdentifier, crossSiteDbHealthy, crossSiteAdminHealthy); - log.error("Site Health Error", e); - } - } - } - } - } - SitesBuilder builder = getSitesBuilder(site1HealthyODLs, site1Voting, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), siteIdentifier); - outputBuilder.getSites().add(builder.build()); - builder = getSitesBuilder(site2HealthyODLs, site2Voting, crossSiteAdminHealthy, crossSiteDbHealthy, crossSiteIdentifier); - outputBuilder.getSites().add(builder.build()); - log.info("{}:site-health: Site 1 ({}) | hasVotingMembers?: {} | Healthy ODLs: {} | ADM isHealthy?: {} | DB isHealthy?: {}", APP_NAME, siteIdentifier, site1Voting, site1HealthyODLs, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth)); - log.info("{}:site-health: Site 2 ({}) | hasVotingMembers?: {} | Healthy ODLs: {} | ADM isHealthy?: {} | DB isHealthy?: {}", APP_NAME, crossSiteIdentifier, site2Voting, site2HealthyODLs, crossSiteAdminHealthy, crossSiteDbHealthy); - } - else { - // Make calls over to site 1 healthchecks - for(Map.Entry entry : memberMap.entrySet()) { - ClusterActor clusterActor = entry.getValue(); - if(clusterActor.isUp() && !clusterActor.isUnreachable()) { - if(ClusterActor.SITE_1.equals(clusterActor.getSite())) { - site1HealthyODLs++; - if(clusterActor.isVoting()) { - site1Voting = true; - } - if(!performedCrossSiteHealthCheck) { - try { - String content = getRequestContent(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:site-identifier", HttpMethod.POST); - crossSiteIdentifier = new JSONObject(content).getJSONObject(OUTPUT).getString("id"); - crossSiteDbHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:database-health"); - crossSiteAdminHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:admin-health"); - performedCrossSiteHealthCheck = true; - } catch(Exception e) { - log.info("Cannot get cross site health from {}", clusterActor.getNode()); - log.info("siteIdentifier: {} | dbHealth: {} | adminHealth: {}", crossSiteIdentifier, crossSiteDbHealthy, crossSiteAdminHealthy); - log.error("Site Health Error", e); - } - } - } - else { - site2HealthyODLs++; - if(clusterActor.isVoting()) { - site2Voting = true; - } - } - } - } - // Build Output - SitesBuilder builder = getSitesBuilder(site1HealthyODLs, site1Voting, crossSiteAdminHealthy, crossSiteDbHealthy, crossSiteIdentifier); - outputBuilder.getSites().add(builder.build()); - builder = getSitesBuilder(site2HealthyODLs, site2Voting, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), siteIdentifier); - outputBuilder.getSites().add(builder.build()); - log.info("{}:site-health: Site 1 ({}) | hasVotingMembers?: {} | Healthy ODLs: {} | ADM isHealthy?: {} | DB isHealthy?: {}", APP_NAME, siteIdentifier, site1Voting, site1HealthyODLs, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth)); - log.info("{}:site-health: Site 2 ({}) | hasVotingMembers?: {} | Healthy ODLs: {} | ADM isHealthy?: {} | DB isHealthy?: {}", APP_NAME, crossSiteIdentifier, site2Voting, site2HealthyODLs, crossSiteAdminHealthy, crossSiteDbHealthy); - } + for(SiteHealth site : sites) { + siteBuilder.setHealth(site.getHealth().toString()); + siteBuilder.setRole(site.getRole()); + siteBuilder.setId(site.getId()); + outputBuilder.getSites().add(siteBuilder.build()); + log.info("buildSiteHealthOutput(): Health for {}: {}", site.getId(), site.getHealth().getHealth()); } outputBuilder.setServedBy(member); @@ -612,40 +612,21 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT return Futures.immediateFuture(rpcResult); } - private SitesBuilder getSitesBuilder(int siteHealthyODLs, boolean siteVoting, boolean adminHealthy, boolean dbHealthy, String siteIdentifier) { - SitesBuilder builder = new SitesBuilder(); - if(siteHealthyODLs > 1) { - builder.setHealth(HEALTHY); - } - else { - log.warn("{} Healthy ODLs: {}", siteIdentifier, siteHealthyODLs); - builder.setHealth(FAULTY); - } - if(!adminHealthy) { - log.warn("{} Admin Health: {}", siteIdentifier, FAULTY); - builder.setHealth(FAULTY); - } - if(!dbHealthy) { - log.warn("{} Database Health: {}", siteIdentifier, FAULTY); - builder.setHealth(FAULTY); - } - if(siteVoting) { - builder.setRole("ACTIVE"); - } - else { - builder.setRole("STANDBY"); - } - builder.setId(siteIdentifier); - return builder; - } - - private boolean isSite1() { - int memberNumber = Integer.parseInt(member.split("-")[1]); - boolean isSite1 = memberNumber < 4; - log.info("isSite1(): {}", isSite1); - return isSite1; - } - + /** + * Parses a line containing the akka networking information of the akka + * controller cluster. Assumes entries of the format: + *

+ * akka.tcp://opendaylight-cluster-data@: + *

+ * The information is stored in a {@code ClusterActor} object, and then + * added to the memberMap HashMap, with the {@code FQDN} as the key. The + * final step is a call to {@code createHealthResolver} to create the + * health resolver for the provider. + * + * @param line the line containing all of the seed nodes + * @see ClusterActor + * @see HealthResolver + */ private void parseSeedNodes(String line) { memberMap = new HashMap<>(); line = line.substring(line.indexOf("[\""), line.indexOf(']')); @@ -656,156 +637,105 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT int delimLocation = nodeName.indexOf('@'); String port = nodeName.substring(splits[ndx].indexOf(':', delimLocation) + 1, splits[ndx].indexOf('"', splits[ndx].indexOf(':'))); splits[ndx] = nodeName.substring(delimLocation + 1, splits[ndx].indexOf(':', delimLocation)); - log.info("Adding node: {}:{}", splits[ndx], port); + log.info("parseSeedNodes(): Adding node: {}:{}", splits[ndx], port); ClusterActor clusterActor = new ClusterActor(); clusterActor.setNode(splits[ndx]); clusterActor.setAkkaPort(port); clusterActor.setMember("member-" + (ndx + 1)); - if(ndx < 3) { - clusterActor.setSite(ClusterActor.SITE_1); - } - else { - clusterActor.setSite(ClusterActor.SITE_2); - } - if(member.equals(clusterActor.getMember())) { self = clusterActor; } memberMap.put(clusterActor.getNode(), clusterActor); - log.info("{}", clusterActor); + log.info("parseSeedNodes(): {}", clusterActor); } - if(memberMap.size() == 1) { - log.info("1 member found. This is a solo environment."); - siteConfiguration = SiteConfiguration.SOLO; - } - else if(memberMap.size() == 3) { - log.info("This is a single site."); - siteConfiguration = SiteConfiguration.SINGLE; - } - else if(memberMap.size() == 6) { - log.info("This is a georedundant site."); - siteConfiguration = SiteConfiguration.GEO; - } + createHealthResolver(); } - private void getMemberStatus(ClusterActor clusterActor) throws IOException { - log.info("Getting member status for {}", clusterActor.getNode()); - String content = getRequestContent(httpProtocol + clusterActor.getNode() + jolokiaClusterPath, HttpMethod.GET); - try { - JSONObject responseJson = new JSONObject(content); - JSONObject responseValue = responseJson.getJSONObject(VALUE); - clusterActor.setUp("Up".equals(responseValue.getString("MemberStatus"))); - clusterActor.setUnreachable(false); - } catch(JSONException e) { - log.error("Error parsing response from {}", clusterActor.getNode(), e); - clusterActor.setUp(false); - clusterActor.setUnreachable(true); - } - } - - private void getShardStatus(ClusterActor clusterActor) throws IOException { - log.info("Getting shard status for {}", clusterActor.getNode()); - String content = getRequestContent(httpProtocol + clusterActor.getNode() + shardManagerPath, HttpMethod.GET); - try { - JSONObject responseValue = new JSONObject(content).getJSONObject(VALUE); - JSONArray shardList = responseValue.getJSONArray("LocalShards"); - - String pattern = "-config$"; - Pattern r = Pattern.compile(pattern); - Matcher m; - for(int ndx = 0; ndx < shardList.length(); ndx++) { - String configShardName = shardList.getString(ndx); - m = r.matcher(configShardName); - String operationalShardName = m.replaceFirst("-operational"); - String shardConfigPath = String.format(shardPathTemplate, configShardName); - String shardOperationalPath = String.format(shardPathTemplate, operationalShardName).replace("Config", "Operational"); - extractShardInfo(clusterActor, configShardName, shardConfigPath); - extractShardInfo(clusterActor, operationalShardName, shardOperationalPath); - } - } catch(JSONException e) { - log.error("Error parsing response from " + clusterActor.getNode(), e); - } - } - - private void extractShardInfo(ClusterActor clusterActor, String shardName, String shardPath) throws IOException { - log.info("Extracting shard info for {}", shardName); - log.debug("Pulling config info for {} from: {}", shardName, shardPath); - String content = getRequestContent(httpProtocol + clusterActor.getNode() + shardPath, HttpMethod.GET); - log.debug("Response: {}", content); - + /** + * Creates the specific health resolver requested by the user, as specified + * in the gr-toolkit.properties file. If a resolver is not specified, or + * there is an issue creating the resolver, it will use a fallback resolver + * based on how many nodes are added to the memberMap HashMap. + * + * @see HealthResolver + * @see SingleNodeHealthResolver + * @see ThreeNodeHealthResolver + * @see SixNodeHealthResolver + */ + private void createHealthResolver() { + log.info("createHealthResolver(): Creating health resolver..."); try { - JSONObject shardValue = new JSONObject(content).getJSONObject(VALUE); - clusterActor.setVoting(shardValue.getBoolean("Voting")); - if(shardValue.getString("PeerAddresses").length() > 0) { - clusterActor.getReplicaShards().add(shardName); - if(shardValue.getString("Leader").startsWith(clusterActor.getMember())) { - clusterActor.getShardLeader().add(shardName); - } - } - else { - clusterActor.getNonReplicaShards().add(shardName); + Class resolverClass = null; + String userDefinedResolver = properties.getProperty(PropertyKeys.RESOLVER); + if(StringUtils.isEmpty(userDefinedResolver)) { + throw new InstantiationException(); } - JSONArray followerInfo = shardValue.getJSONArray("FollowerInfo"); - for(int followerNdx = 0; followerNdx < followerInfo.length(); followerNdx++) { - int commitIndex = shardValue.getInt("CommitIndex"); - int matchIndex = followerInfo.getJSONObject(followerNdx).getInt("matchIndex"); - if(commitIndex != -1 && matchIndex != -1) { - int commitsBehind = commitIndex - matchIndex; - clusterActor.getCommits().put(followerInfo.getJSONObject(followerNdx).getString("id"), commitsBehind); - } - } - } catch(JSONException e) { - log.error("Error parsing response from " + clusterActor.getNode(), e); - } - } - - private void getControllerHealth() { - for(Map.Entry entry : memberMap.entrySet()) { - ClusterActor clusterActor = entry.getValue(); - String key = entry.getKey(); - try { - // First flush out the old values - clusterActor.flush(); - log.info("Gathering info for {}", clusterActor.getNode()); - getMemberStatus(clusterActor); - getShardStatus(clusterActor); - log.info("MemberInfo:\n{}", clusterActor); - } catch(IOException e) { - log.error("Connection Error", e); - memberMap.get(key).setUnreachable(true); - memberMap.get(key).setUp(false); - log.info("MemberInfo:\n{}", memberMap.get(key)); + resolverClass = Class.forName(userDefinedResolver); + Class[] types = { Map.class , properties.getClass(), DbLibService.class }; + Constructor constructor = resolverClass.getConstructor(types); + Object[] parameters = { memberMap, properties, dbLib }; + resolver = constructor.newInstance(parameters); + log.info("createHealthResolver(): Created resolver from name {}", resolver.toString()); + } catch(ClassNotFoundException | InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { + log.warn("createHealthResolver(): Could not create user defined resolver", e); + if(memberMap.size() == 1) { + log.info("createHealthResolver(): FALLBACK: Initializing SingleNodeHealthResolver..."); + resolver = new SingleNodeHealthResolver(memberMap, properties, dbLib); + } else if(memberMap.size() == 3) { + log.info("createHealthResolver(): FALLBACK: Initializing ThreeNodeHealthResolver..."); + resolver = new ThreeNodeHealthResolver(memberMap, properties, dbLib); + } else if(memberMap.size() == 6) { + log.info("createHealthResolver(): FALLBACK: Initializing SixNodeHealthResolver..."); + resolver = new SixNodeHealthResolver(memberMap, properties, dbLib); } } } + /** + * Adds or drops IPTables rules to block or resume akka traffic for a node + * in the akka cluster. Assumes that the user or group that the controller + * is run as has the ability to run sudo /sbin/iptables without requiring a + * password. This method will run indefinitely if that assumption is not + * correct. This method does not check to see if any rules around the node + * are preexisting, so multiple uses will result in multiple additions and + * removals from IPTables. + * + * @param task the operation to be performed against IPTables + * @param nodeInfo array containing the nodes to be added or dropped from + * IPTables + */ private void modifyIpTables(IpTables task, Object[] nodeInfo) { - log.info("Modifying IPTables rules..."); + log.info("modifyIpTables(): Modifying IPTables rules..."); if(task == IpTables.ADD) { for(Object node : nodeInfo) { org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.halt.akka.traffic.input.NodeInfo n = (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.halt.akka.traffic.input.NodeInfo) node; - log.info("Isolating {}", n.getNode()); + log.info("modifyIpTables(): Isolating {}", n.getNode()); executeCommand(String.format("sudo /sbin/iptables -A INPUT -p tcp --destination-port %s -j DROP -s %s", properties.get(PropertyKeys.CONTROLLER_PORT_AKKA), n.getNode())); executeCommand(String.format("sudo /sbin/iptables -A OUTPUT -p tcp --destination-port %s -j DROP -d %s", n.getPort(), n.getNode())); } - } else if(task == IpTables.DELETE) { for(Object node : nodeInfo) { org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.resume.akka.traffic.input.NodeInfo n = (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.resume.akka.traffic.input.NodeInfo) node; - log.info("De-isolating {}", n.getNode()); + log.info("modifyIpTables(): De-isolating {}", n.getNode()); executeCommand(String.format("sudo /sbin/iptables -D INPUT -p tcp --destination-port %s -j DROP -s %s", properties.get(PropertyKeys.CONTROLLER_PORT_AKKA), n.getNode())); executeCommand(String.format("sudo /sbin/iptables -D OUTPUT -p tcp --destination-port %s -j DROP -d %s", n.getPort(), n.getNode())); } - } - executeCommand("sudo /sbin/iptables -L"); + if(nodeInfo.length > 0) { + executeCommand("sudo /sbin/iptables -L"); + } } + /** + * Opens a shell session and executes a command. + * + * @param command the shell command to execute + */ private void executeCommand(String command) { - log.info("Executing command: {}", command); + log.info("executeCommand(): Executing command: {}", command); String[] cmd = command.split(" "); try { Process p = Runtime.getRuntime().exec(cmd); @@ -816,174 +746,17 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT content.append(inputLine); } bufferedReader.close(); - log.info("{}", content); - } catch(IOException e) { - log.error("Error executing command", e); - } - } - - private boolean crossSiteHealthRequest(String path) throws IOException { - String content = getRequestContent(path, HttpMethod.POST); - try { - JSONObject responseJson = new JSONObject(content); - JSONObject responseValue = responseJson.getJSONObject(OUTPUT); - return HEALTHY.equals(responseValue.getString("health")); - } catch(JSONException e) { - log.error("Error parsing JSON", e); - throw new IOException(); - } - } - - private String getAdminHealth() { - String protocol = "true".equals(properties.getProperty(PropertyKeys.ADM_USE_SSL)) ? "https://" : "http://"; - String port = "true".equals(properties.getProperty(PropertyKeys.ADM_USE_SSL)) ? properties.getProperty(PropertyKeys.ADM_PORT_SSL) : properties.getProperty(PropertyKeys.ADM_PORT_HTTP); - String path = protocol + properties.getProperty(PropertyKeys.ADM_FQDN) + ":" + port + properties.getProperty(PropertyKeys.ADM_HEALTHCHECK); - log.info("Requesting healthcheck from {}", path); - try { - int response = getRequestStatus(path, HttpMethod.GET); - log.info("Response: {}", response); - if(response == 200) - return HEALTHY; - return FAULTY; + log.info("executeCommand(): {}", content); } catch(IOException e) { - log.error("Problem getting ADM health.", e); - return FAULTY; - } - } - - private String getDatabaseHealth() { - log.info("Determining database health..."); - try { - Connection connection = dbLib.getConnection(); - log.debug("DBLib isActive(): {}", dbLib.isActive()); - log.debug("DBLib isReadOnly(): {}", connection.isReadOnly()); - log.debug("DBLib isClosed(): {}", connection.isClosed()); - if(!dbLib.isActive() || connection.isClosed() || connection.isReadOnly()) { - log.warn("Database is FAULTY"); - connection.close(); - return FAULTY; - } - connection.close(); - log.info("Database is HEALTHY"); - } catch(SQLException e) { - log.error("Database is FAULTY"); - log.error("Error", e); - return FAULTY; - } - - return HEALTHY; - } - - private String getRequestContent(String path, HttpMethod method) throws IOException { - return getRequestContent(path, method, null); - } - - private String getRequestContent(String path, HttpMethod method, String input) throws IOException { - HttpURLConnection connection = getConnection(path); - connection.setRequestMethod(method.getMethod()); - connection.setDoInput(true); - - if(input != null) { - sendPayload(input, connection); - } - - BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream())); - String inputLine; - StringBuilder content = new StringBuilder(); - while((inputLine = bufferedReader.readLine()) != null) { - content.append(inputLine); - } - bufferedReader.close(); - connection.disconnect(); - - String response = content.toString(); - log.debug("getRequestContent(): Response:\n{}", response); - return response; - } - - private int getRequestStatus(String path, HttpMethod method) throws IOException { - return getRequestStatus(path, method, null); - } - - private int getRequestStatus(String path, HttpMethod method, String input) throws IOException { - HttpURLConnection connection = getConnection(path); - connection.setRequestMethod(method.getMethod()); - connection.setDoInput(true); - - if(input != null) { - sendPayload(input, connection); - } - int response = connection.getResponseCode(); - log.info("Received {} response code from {}", response, path); - connection.disconnect(); - return response; - } - - private void sendPayload(String input, HttpURLConnection connection) throws IOException { - byte[] out = input.getBytes(StandardCharsets.UTF_8); - int length = out.length; - - connection.setFixedLengthStreamingMode(length); - connection.setRequestProperty("Content-Type", "application/json"); - connection.setDoOutput(true); - connection.connect(); - try(OutputStream os = connection.getOutputStream()) { - os.write(out); + log.error("executeCommand(): Error executing command", e); } } - private HttpURLConnection getConnection(String host) throws IOException { - log.info("Getting connection to: {}", host); - URL url = new URL(host); - String auth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(credentials.getBytes()); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.addRequestProperty("Authorization", auth); - connection.setRequestProperty("Connection", "keep-alive"); - connection.setRequestProperty("Proxy-Connection", "keep-alive"); - connection.setConnectTimeout(CONNECTION_TIMEOUT); - connection.setReadTimeout(CONNECTION_TIMEOUT); - return connection; - } - + /** + * The IPTables operations this module can perform. + */ enum IpTables { ADD, DELETE } - - enum SiteConfiguration { - SOLO, - SINGLE, - GEO - } - - enum HttpMethod { - GET("GET"), - POST("POST"); - - private String method; - HttpMethod(String method) { - this.method = method; - } - public String getMethod() { - return method; - } - } - - class PropertyKeys { - static final String SITE_IDENTIFIER = "site.identifier"; - static final String CONTROLLER_USE_SSL = "controller.useSsl"; - static final String CONTROLLER_PORT_SSL = "controller.port.ssl"; - static final String CONTROLLER_PORT_HTTP = "controller.port.http"; - static final String CONTROLLER_PORT_AKKA = "controller.port.akka"; - static final String CONTROLLER_CREDENTIALS = "controller.credentials"; - static final String AKKA_CONF_LOCATION = "akka.conf.location"; - static final String MBEAN_CLUSTER = "mbean.cluster"; - static final String MBEAN_SHARD_MANAGER = "mbean.shardManager"; - static final String MBEAN_SHARD_CONFIG = "mbean.shard.config"; - static final String ADM_USE_SSL = "adm.useSsl"; - static final String ADM_PORT_SSL = "adm.port.ssl"; - static final String ADM_PORT_HTTP = "adm.port.http"; - static final String ADM_FQDN = "adm.fqdn"; - static final String ADM_HEALTHCHECK= "adm.healthcheck"; - } } \ No newline at end of file diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/connection/ConnectionManager.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/connection/ConnectionManager.java new file mode 100644 index 000000000..99fcd3e04 --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/connection/ConnectionManager.java @@ -0,0 +1,157 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.connection; + +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.charset.StandardCharsets; + +/** + * Handles the process for getting HTTP connections to resources. Has the + * ability to send JSON payloads. Only supports basic authorization when + * sending credentials. + * + * @author Anthony Haddox + * @see ConnectionResponse + */ +public interface ConnectionManager { + Logger log = LoggerFactory.getLogger(ConnectionManager.class); + int CONNECTION_TIMEOUT = 5000; // 5 second timeout + enum HttpMethod { + GET("GET"), + POST("POST"); + + private final String method; + HttpMethod(String method) { + this.method = method; + } + String getMethod() { + return method; + } + } + + /** + * Writes a JSON payload to an {@code HTTPURLConnection OutputStream}. + * + * @param input the JSON payload to send + * @param connection the {@code HTTPURLConnection} to write to + * @throws IOException if there is a problem writing to the output stream + */ + static void sendPayload(String input, HttpURLConnection connection) throws IOException { + byte[] out = input.getBytes(StandardCharsets.UTF_8); + int length = out.length; + + connection.setFixedLengthStreamingMode(length); + connection.setRequestProperty("Content-Type", "application/json"); + connection.setDoOutput(true); + connection.connect(); + try(OutputStream os = connection.getOutputStream()) { + os.write(out); + } + } + + /** + * Gets an {@code HTTPURLConnection} to a {@code host}. + * + * @param host the host to connect to + * @return an {@code HTTPURLConnection} + * @throws IOException if a connection cannot be opened + */ + static HttpURLConnection getConnection(String host) throws IOException { + log.info("getConnection(): Getting connection to: {}", host); + URL url = new URL(host); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestProperty("Connection", "keep-alive"); + connection.setRequestProperty("Proxy-Connection", "keep-alive"); + connection.setConnectTimeout(CONNECTION_TIMEOUT); + connection.setReadTimeout(CONNECTION_TIMEOUT); + return connection; + } + + /** + * Gets an {@code HTTPURLConnection} to a {@code host} and sets the + * Authorization header with the supplied credentials. Only supports basic + * authentication. + * + * @param host the host to connect to + * @param credentials the authorization credentials + * @return an {@code HTTPURLConnection} with Authorization header set + * @throws IOException if a connection cannot be opened + */ + static HttpURLConnection getConnection(String host, String credentials) throws IOException { + String auth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(credentials.getBytes()); + HttpURLConnection connection = getConnection(host); + connection.addRequestProperty("Authorization", auth); + credentials = null; + auth = null; + return connection; + } + + /** + * Opens a connection to a path, sends a payload (if supplied with one), + * and returns the response. + * @param path the host to connect to + * @param method the {@code HttpMethod} to use + * @param input the payload to send + * @param credentials the credentials to use + * @return a {@code ConnectionResponse} containing the response body and + * status code of the operation + * @throws IOException if a connection cannot be opened or if the payload + * cannot be sent + * @see HttpMethod + */ + static ConnectionResponse getConnectionResponse(String path, HttpMethod method, String input, String credentials) throws IOException { + HttpURLConnection connection = (StringUtils.isEmpty(credentials)) ? getConnection(path) : getConnection(path, credentials); + credentials = null; + connection.setRequestMethod(method.getMethod()); + connection.setDoInput(true); + + if(!StringUtils.isEmpty(input)) { + sendPayload(input, connection); + } + + StringBuilder content = new StringBuilder(); + try(BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { + String inputLine; + while((inputLine = bufferedReader.readLine()) != null) { + content.append(inputLine); + } + } finally { + connection.disconnect(); + } + + ConnectionResponse connectionResponse = new ConnectionResponse(); + connectionResponse.content = content.toString(); + connectionResponse.statusCode = connection.getResponseCode(); + log.info("getConnectionResponse(): {} response code from {}", connectionResponse.statusCode, path); + log.debug("getConnectionResponse(): Response:\n{}", connectionResponse.content); + return connectionResponse; + } +} diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/connection/ConnectionResponse.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/connection/ConnectionResponse.java new file mode 100644 index 000000000..fb16d2a12 --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/connection/ConnectionResponse.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.connection; + +/** + * A data container for HTTP connection requests. + * + * @author Anthony Haddox + * @see ConnectionManager + */ +public class ConnectionResponse { + public int statusCode; + public String content; + + public ConnectionResponse withStatusCode(int statusCode) { + this.statusCode = statusCode; + return this; + } + + @Override + public String toString() { + return "Status: " + statusCode + "\nContent: " + content; + } +} diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/AdminHealth.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/AdminHealth.java new file mode 100644 index 000000000..0e88df55e --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/AdminHealth.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.data; + +/** + * A data container for Admin health. + * + * @author Anthony Haddox + * @see org.onap.ccsdk.sli.plugins.grtoolkit.resolver.HealthResolver + */ +public class AdminHealth { + private Health health; + private int statusCode; + + public AdminHealth(Health health) { + this.health = health; + } + + public AdminHealth(Health health, int statusCode) { + this.health = health; + this.statusCode = statusCode; + } + + public Health getHealth() { + return health; + } + + public void setHealth(Health health) { + this.health = health; + } + + public int getStatusCode() { + return statusCode; + } + + public void setStatusCode(int statusCode) { + this.statusCode = statusCode; + } +} diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/ClusterActor.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/ClusterActor.java old mode 100755 new mode 100644 index 7cd503a95..d039c865e --- a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/ClusterActor.java +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/ClusterActor.java @@ -26,6 +26,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +/** + * A data container with information about an actor in the Akka cluster. + * + * @author Anthony Haddox + */ public class ClusterActor { private String node; private String member; @@ -165,8 +170,10 @@ public class ClusterActor { builder.append(" Up"); else builder.append(" Down"); - if(unreachable) + if(unreachable) { builder.append(" [ UNREACHABLE ]"); + return builder.toString(); + } if(voting) builder.append(" (Voting)"); diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/ClusterHealth.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/ClusterHealth.java new file mode 100644 index 000000000..52198225d --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/ClusterHealth.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.data; + +/** + * A data container for Akka Cluster health. + * + * @author Anthony Haddox + * @see org.onap.ccsdk.sli.plugins.grtoolkit.resolver.HealthResolver + */ +public class ClusterHealth { + private Health health; + + public ClusterHealth() { + health = Health.FAULTY; + } + + public ClusterHealth withHealth(Health h) { + this.health = h; + return this; + } + + public Health getHealth() { + return health; + } + + public void setHealth(Health health) { + this.health = health; + } +} diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/DatabaseHealth.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/DatabaseHealth.java new file mode 100644 index 000000000..14c11b51a --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/DatabaseHealth.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.data; + +/** + * A data container for Database health. + * + * @author Anthony Haddox + * @see org.onap.ccsdk.sli.plugins.grtoolkit.resolver.HealthResolver + */ +public class DatabaseHealth { + private Health health; + + public DatabaseHealth(Health health) { + this.health = health; + } + + public Health getHealth() { + return health; + } + + public void setHealth(Health health) { + this.health = health; + } +} diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/FailoverStatus.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/FailoverStatus.java new file mode 100644 index 000000000..7366ede43 --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/FailoverStatus.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.data; + +/** + * A data container for the status of a controller-level failover. + * + * @author Anthony Haddox + * @see org.onap.ccsdk.sli.plugins.grtoolkit.resolver.HealthResolver + */ +public class FailoverStatus { + private int statusCode; + private String message; + + public FailoverStatus() { + this.statusCode = 200; + this.message = "Failover complete."; + } + + public FailoverStatus withStatusCode(int code) { + this.statusCode = code; + return this; + } + + public FailoverStatus withMessage(String message) { + this.message = message; + return this; + } + + public int getStatusCode() { + return statusCode; + } + + public void setStatusCode(int statusCode) { + this.statusCode = statusCode; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/Health.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/Health.java new file mode 100644 index 000000000..deb5cb444 --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/Health.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.data; + +/** + * Potential health values. + * + * @author Anthony Haddox + */ +public enum Health { + HEALTHY("HEALTHY"), + FAULTY("FAULTY"); + + private final String health; + Health(String health) { + this.health = health; + } + public String getHealth() { + return health; + } +} diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/MemberBuilder.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/MemberBuilder.java old mode 100755 new mode 100644 index 8bbf574d6..863b56674 --- a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/MemberBuilder.java +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/MemberBuilder.java @@ -30,6 +30,14 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +/** + * Extends the {@code MembersBuilder} generated from the gr-toolkit.yang model. + * Uses information from a {@code ClusterActor} to populate the builder fields. + * + * @author Anthony Haddox + * @see ClusterActor + * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.cluster.health.output.MembersBuilder + */ public class MemberBuilder extends MembersBuilder { public MemberBuilder(ClusterActor actor) { super(); diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/PropertyKeys.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/PropertyKeys.java new file mode 100644 index 000000000..f2ad90a7f --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/PropertyKeys.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.data; + +public interface PropertyKeys { + String RESOLVER = "resolver"; + String SITE_IDENTIFIER = "site.identifier"; + String CONTROLLER_USE_SSL = "controller.useSsl"; + String CONTROLLER_PORT_SSL = "controller.port.ssl"; + String CONTROLLER_PORT_HTTP = "controller.port.http"; + String CONTROLLER_PORT_AKKA = "controller.port.akka"; + String CONTROLLER_CREDENTIALS = "controller.credentials"; + String AKKA_CONF_LOCATION = "akka.conf.location"; + String MBEAN_CLUSTER = "mbean.cluster"; + String MBEAN_SHARD_MANAGER = "mbean.shardManager"; + String MBEAN_SHARD_CONFIG = "mbean.shard.config"; + String ADM_USE_SSL = "adm.useSsl"; + String ADM_PORT_SSL = "adm.port.ssl"; + String ADM_PORT_HTTP = "adm.port.http"; + String ADM_FQDN = "adm.fqdn"; + String ADM_HEALTHCHECK= "adm.healthcheck"; +} diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/SiteHealth.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/SiteHealth.java new file mode 100644 index 000000000..8407032d5 --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/SiteHealth.java @@ -0,0 +1,125 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.data; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + + +/** + * A data container for Site health. + * + * @author Anthony Haddox + * @see org.onap.ccsdk.sli.plugins.grtoolkit.resolver.HealthResolver + */ +public class SiteHealth { + private List adminHealth; + private List databaseHealth; + private List clusterHealth; + + private Health health; + private String id; + private String role; + + public SiteHealth() { + adminHealth = new ArrayList<>(); + databaseHealth = new ArrayList<>(); + clusterHealth = new ArrayList<>(); + + // Faulty by default, it's up to the health check to affirm the health + health = Health.FAULTY; + } + + public SiteHealth withAdminHealth(AdminHealth... health) { + Collections.addAll(adminHealth, health); + return this; + } + + public SiteHealth withDatabaseHealth(DatabaseHealth... health) { + Collections.addAll(databaseHealth, health); + return this; + } + + public SiteHealth withClusterHealth(ClusterHealth... health) { + Collections.addAll(clusterHealth, health); + return this; + } + + public SiteHealth withId(String id) { + this.id = id; + return this; + } + + public SiteHealth withRole(String role) { + this.role = role; + return this; + } + + public Health getHealth() { + return health; + } + + public void setHealth(Health health) { + this.health = health; + } + + public List getAdminHealth() { + return adminHealth; + } + + public void setAdminHealth(List adminHealth) { + this.adminHealth = adminHealth; + } + + public List getDatabaseHealth() { + return databaseHealth; + } + + public void setDatabaseHealth(List databaseHealth) { + this.databaseHealth = databaseHealth; + } + + public List getClusterHealth() { + return clusterHealth; + } + + public void setClusterHealth(List clusterHealth) { + this.clusterHealth = clusterHealth; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } +} diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/HealthResolver.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/HealthResolver.java new file mode 100644 index 000000000..5c4ed13d7 --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/HealthResolver.java @@ -0,0 +1,212 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.resolver; + +import org.json.JSONException; +import org.json.JSONObject; + +import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.onap.ccsdk.sli.plugins.grtoolkit.connection.ConnectionManager; +import org.onap.ccsdk.sli.plugins.grtoolkit.connection.ConnectionResponse; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.AdminHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterActor; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.DatabaseHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.FailoverStatus; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.Health; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.PropertyKeys; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.SiteHealth; + +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverInput; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import static org.onap.ccsdk.sli.plugins.grtoolkit.data.Health.HEALTHY; + +/** + * Abstract class for the Health Resolver system, which allows for custom logic + * to be implemented, while leaving inputs/outputs generic and architecture + * agnostic. This class provides some simple implementations of both Admin and + * Database health checking, but leaves cluster and site health determinations + * up to the implementer. Useful implementation examples can be found in the + * {@code SingleNodeHealthResolver}, {@code ThreeNodeHealthResolver}, and + * {@code SixNodeHealthResolver} classes. + * + * @author Anthony Haddox + * @see org.onap.ccsdk.sli.plugins.grtoolkit.GrToolkitProvider + * @see SingleNodeHealthResolver + * @see ThreeNodeHealthResolver + * @see SixNodeHealthResolver + */ +public abstract class HealthResolver { + private final Logger log = LoggerFactory.getLogger(HealthResolver.class); + static final String OUTPUT = "output"; + final String httpProtocol; + final String controllerPort; + final String credentials; + final Map memberMap; + private DbLibService dbLib; + final ShardResolver shardResolver; + private String adminPath; + private String siteIdentifier; + + /** + * Constructs the health resolver used by the {@code GrToolkitProvider} to + * determine the health of the application components. + * + * @param map a HashMap containing all of the nodes in the akka cluster + * @param properties the properties passed ino the provider + * @param dbLib a reference to the {@code DbLibService} of the provider + * @see org.onap.ccsdk.sli.plugins.grtoolkit.GrToolkitProvider + */ + HealthResolver(Map map, Properties properties, DbLibService dbLib) { + log.info("Creating {}", this.getClass().getCanonicalName()); + this.memberMap = map; + this.dbLib = dbLib; + shardResolver = ShardResolver.getInstance(properties); + + String adminProtocol = "true".equals(properties.getProperty(PropertyKeys.ADM_USE_SSL)) ? "https://" : "http://"; + String adminPort = "true".equals(properties.getProperty(PropertyKeys.ADM_USE_SSL)) ? properties.getProperty(PropertyKeys.ADM_PORT_SSL) : properties.getProperty(PropertyKeys.ADM_PORT_HTTP); + adminPath = adminProtocol + properties.getProperty(PropertyKeys.ADM_FQDN) + ":" + adminPort + properties.getProperty(PropertyKeys.ADM_HEALTHCHECK); + siteIdentifier = properties.getProperty(PropertyKeys.SITE_IDENTIFIER).trim(); + + controllerPort = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL).trim()) ? properties.getProperty(PropertyKeys.CONTROLLER_PORT_SSL).trim() : properties.getProperty(PropertyKeys.CONTROLLER_PORT_HTTP).trim(); + httpProtocol = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL).trim()) ? "https://" : "http://"; + if(siteIdentifier == null || siteIdentifier.isEmpty()) { + siteIdentifier = properties.getProperty(PropertyKeys.SITE_IDENTIFIER).trim(); + } + credentials = properties.getProperty(PropertyKeys.CONTROLLER_CREDENTIALS).trim(); + } + + public abstract ClusterHealth getClusterHealth(); + public abstract List getSiteHealth(); + public abstract FailoverStatus tryFailover(FailoverInput input); + public abstract void resolveSites(); + + /** + * Gets a connection to the admin portal. If the status code is 200, the + * admin portal is assumed to be healthy. + * + * @return an {@code AdminHealth} object with health of the admin portal + * @see org.onap.ccsdk.sli.plugins.grtoolkit.GrToolkitProvider + * @see AdminHealth + */ + public AdminHealth getAdminHealth() { + log.info("getAdminHealth(): Requesting health check from {}", adminPath); + try { + ConnectionResponse response = ConnectionManager.getConnectionResponse(adminPath, ConnectionManager.HttpMethod.GET, null, null); + Health health = (response.statusCode == 200) ? HEALTHY : Health.FAULTY; + AdminHealth adminHealth = new AdminHealth(health, response.statusCode); + log.info("getAdminHealth(): Response: {}", response); + return adminHealth; + } catch(IOException e) { + log.error("getAdminHealth(): Problem getting ADM health.", e); + return new AdminHealth(Health.FAULTY, 500); + } + } + + /** + * Uses {@code DbLibService} to get a connection to the database. If + * {@code DbLibService} is active and the connection it returns is not read + * only, the database(s) is assumed to be healthy. + * + * @return an {@code DatabaseHealth} object with health of the database + * @see org.onap.ccsdk.sli.plugins.grtoolkit.GrToolkitProvider + * @see DatabaseHealth + */ + public DatabaseHealth getDatabaseHealth() { + log.info("getDatabaseHealth(): Determining database health..."); + try (Connection connection = dbLib.getConnection()){ + log.debug("getDatabaseHealth(): DBLib isActive(): {}", dbLib.isActive()); + log.debug("getDatabaseHealth(): DBLib isReadOnly(): {}", connection.isReadOnly()); + log.debug("getDatabaseHealth(): DBLib isClosed(): {}", connection.isClosed()); + if(!dbLib.isActive() || connection.isClosed() || connection.isReadOnly()) { + log.warn("getDatabaseHealth(): Database is FAULTY"); + return new DatabaseHealth(Health.FAULTY); + } + log.info("getDatabaseHealth(): Database is HEALTHY"); + } catch(SQLException e) { + log.error("getDatabaseHealth(): Database is FAULTY"); + log.error("getDatabaseHealth(): Error", e); + return new DatabaseHealth(Health.FAULTY); + } + + return new DatabaseHealth(HEALTHY); + } + + /** + * Utility method to see if an input is healthy. + * + * @return true if the input is healthy + * @see Health + */ + boolean isHealthy(Health h) { + return HEALTHY == h; + } + + public String getSiteIdentifier() { + return siteIdentifier; + } + + public void setSiteIdentifier(String siteIdentifier) { + this.siteIdentifier = siteIdentifier; + } + + /** + * Used to invoke the admin-health or database-health RPC to check if that + * component is healthy. + * + * @param path the path to the admin-health or database-health RPCs + * @return true if the component is healthy + * @throws IOException if a connection cannot be obtained + */ + boolean isRemoteComponentHealthy(String path) throws IOException { + String content = ConnectionManager.getConnectionResponse(path, ConnectionManager.HttpMethod.POST, null, credentials).content; + try { + JSONObject responseJson = new JSONObject(content); + JSONObject responseValue = responseJson.getJSONObject(OUTPUT); + return HEALTHY.toString().equals(responseValue.getString("health")); + } catch(JSONException e) { + log.error("Error parsing JSON", e); + throw new IOException(); + } + } + + /** + * Checks a {@code ClusterActor} object to see if the node is healthy. + * + * @param controller the controller to check + * @return true if the controller is up and reachable + * @see ClusterActor + */ + public boolean isControllerHealthy(ClusterActor controller) { + return (controller.isUp() && ! controller.isUnreachable()); + } +} diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/ShardResolver.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/ShardResolver.java new file mode 100644 index 000000000..8e96bff0c --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/ShardResolver.java @@ -0,0 +1,177 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.resolver; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import org.onap.ccsdk.sli.plugins.grtoolkit.connection.ConnectionManager; +import org.onap.ccsdk.sli.plugins.grtoolkit.connection.ConnectionResponse; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterActor; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.PropertyKeys; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Used to perform operations on the data shard information returned as JSON + * from Jolokia. + * + * @author Anthony Haddox + * @see org.onap.ccsdk.sli.plugins.grtoolkit.GrToolkitProvider + * @see HealthResolver + */ +public class ShardResolver { + private final Logger log = LoggerFactory.getLogger(ShardResolver.class); + private static ShardResolver _shardResolver; + + private String jolokiaClusterPath; + private String shardManagerPath; + private String shardPathTemplate; + private String credentials; + private String httpProtocol; + + private static final String VALUE = "value"; + + private ShardResolver(Properties properties) { + String port = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL).trim()) ? properties.getProperty(PropertyKeys.CONTROLLER_PORT_SSL).trim() : properties.getProperty(PropertyKeys.CONTROLLER_PORT_HTTP).trim(); + httpProtocol = "true".equals(properties.getProperty(PropertyKeys.CONTROLLER_USE_SSL).trim()) ? "https://" : "http://"; + jolokiaClusterPath = ":" + port + properties.getProperty(PropertyKeys.MBEAN_CLUSTER).trim(); + shardManagerPath = ":" + port + properties.getProperty(PropertyKeys.MBEAN_SHARD_MANAGER).trim(); + shardPathTemplate = ":" + port + properties.getProperty(PropertyKeys.MBEAN_SHARD_CONFIG).trim(); + credentials = properties.getProperty(PropertyKeys.CONTROLLER_CREDENTIALS).trim(); + } + + public static ShardResolver getInstance(Properties properties) { + if (_shardResolver == null) { + _shardResolver = new ShardResolver(properties); + } + return _shardResolver; + } + + private void getMemberStatus(ClusterActor clusterActor) throws IOException { + log.info("getMemberStatus(): Getting member status for {}", clusterActor.getNode()); + ConnectionResponse response = ConnectionManager.getConnectionResponse(httpProtocol + clusterActor.getNode() + jolokiaClusterPath, ConnectionManager.HttpMethod.GET, null, credentials); + try { + JSONObject responseJson = new JSONObject(response.content); + JSONObject responseValue = responseJson.getJSONObject(VALUE); + clusterActor.setUp("Up".equals(responseValue.getString("MemberStatus"))); + clusterActor.setUnreachable(false); + } catch(JSONException e) { + log.error("getMemberStatus(): Error parsing response from {}", clusterActor.getNode(), e); + clusterActor.setUp(false); + clusterActor.setUnreachable(true); + } + } + + private void getShardStatus(ClusterActor clusterActor) throws IOException { + log.info("getShardStatus(): Getting shard status for {}", clusterActor.getNode()); + ConnectionResponse response = ConnectionManager.getConnectionResponse(httpProtocol + clusterActor.getNode() + shardManagerPath, ConnectionManager.HttpMethod.GET, null, credentials); + try { + JSONObject responseValue = new JSONObject(response.content).getJSONObject(VALUE); + JSONArray shardList = responseValue.getJSONArray("LocalShards"); + + String pattern = "-config$"; + Pattern r = Pattern.compile(pattern); + List shards = new ArrayList<>(); + for(int ndx = 0; ndx < shardList.length(); ndx++) { + shards.add(shardList.getString(ndx)); + } + shards.parallelStream().forEach(shard -> { + Matcher m = r.matcher(shard); + String operationalShardName = m.replaceFirst("-operational"); + String shardConfigPath = String.format(shardPathTemplate, shard); + String shardOperationalPath = String.format(shardPathTemplate, operationalShardName).replace("Config", "Operational"); + try { + extractShardInfo(clusterActor, shard, shardConfigPath); + extractShardInfo(clusterActor, operationalShardName, shardOperationalPath); + } catch(IOException e) { + log.error("getShardStatus(): Error extracting shard info for {}", shard); + } + }); + } catch(JSONException e) { + log.error("getShardStatus(): Error parsing response from " + clusterActor.getNode(), e); + } + } + + private void extractShardInfo(ClusterActor clusterActor, String shardName, String shardPath) throws IOException { + log.info("extractShardInfo(): Extracting shard info for {}", shardName); + String shardPrefix = ""; +// String shardPrefix = clusterActor.getMember() + "-shard-"; + log.debug("extractShardInfo(): Pulling config info for {} from: {}", shardName, shardPath); + ConnectionResponse response = ConnectionManager.getConnectionResponse(httpProtocol + clusterActor.getNode() + shardPath, ConnectionManager.HttpMethod.GET, null, credentials); + log.debug("extractShardInfo(): Response: {}", response.content); + + try { + JSONObject shardValue = new JSONObject(response.content).getJSONObject(VALUE); + clusterActor.setVoting(shardValue.getBoolean("Voting")); + if(shardValue.getString("PeerAddresses").length() > 0) { + clusterActor.getReplicaShards().add(shardName.replace(shardPrefix, "")); + if(shardValue.getString("Leader").startsWith(clusterActor.getMember())) { + clusterActor.getShardLeader().add(shardName.replace(shardPrefix, "")); + } + } else { + clusterActor.getNonReplicaShards().add(shardName.replace(shardPrefix, "")); + } + JSONArray followerInfo = shardValue.getJSONArray("FollowerInfo"); + for(int followerNdx = 0; followerNdx < followerInfo.length(); followerNdx++) { + int commitIndex = shardValue.getInt("CommitIndex"); + int matchIndex = followerInfo.getJSONObject(followerNdx).getInt("matchIndex"); + if(commitIndex != -1 && matchIndex != -1) { + int commitsBehind = commitIndex - matchIndex; + clusterActor.getCommits().put(followerInfo.getJSONObject(followerNdx).getString("id"), commitsBehind); + } + } + } catch(JSONException e) { + log.error("extractShardInfo(): Error parsing response from " + clusterActor.getNode(), e); + } + } + + public void getControllerHealth(Map memberMap) { + memberMap.values().parallelStream().forEach(this::getControllerHealth); + } + + // Seen ConcurrentAccess issues, probably related to getting the controller health + private synchronized void getControllerHealth(ClusterActor clusterActor) { + clusterActor.flush(); + log.info("getControllerHealth(): Gathering info for {}", clusterActor.getNode()); + try { + // First flush out the old values + getMemberStatus(clusterActor); + getShardStatus(clusterActor); + } catch(IOException e) { + log.error("getControllerHealth(): Connection Error", e); + clusterActor.setUnreachable(true); + clusterActor.setUp(false); + } + log.info("getControllerHealth(): MemberInfo:\n{}", clusterActor); + } +} diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/SingleNodeHealthResolver.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/SingleNodeHealthResolver.java new file mode 100644 index 000000000..2799df1b0 --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/SingleNodeHealthResolver.java @@ -0,0 +1,160 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.resolver; + +import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.AdminHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterActor; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.DatabaseHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.FailoverStatus; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.Health; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.SiteHealth; + +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverInput; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +/** + * Implementation of {@code HealthResolver} for a single node controller + * architecture. + * + * @author Anthony Haddox + * @see HealthResolver + */ +public class SingleNodeHealthResolver extends HealthResolver { + private final Logger log = LoggerFactory.getLogger(SingleNodeHealthResolver.class); + + /** + * Constructs the health resolver used by the {@code GrToolkitProvider} to + * determine the health of the application components. + * + * @param map a HashMap containing all of the nodes in the akka cluster + * @param properties the properties passed ino the provider + * @param dbLib a reference to the {@code DbLibService} of the provider + * @see HealthResolver + * @see org.onap.ccsdk.sli.plugins.grtoolkit.GrToolkitProvider + */ + public SingleNodeHealthResolver(Map map, Properties properties, DbLibService dbLib) { + super(map, properties, dbLib); + resolveSites(); + } + + /** + * Implementation of {@code getClusterHealth()}. Uses the + * {@code ShardResolver} to gather health information about the controller. + * This method assumes the cluster is always healthy since it is a single + * node. + * + * @return an {@code ClusterHealth} object with health of the akka cluster + * @see org.onap.ccsdk.sli.plugins.grtoolkit.GrToolkitProvider + * @see HealthResolver + * @see ClusterHealth + * @see ShardResolver + */ + @Override + public ClusterHealth getClusterHealth() { + log.info("getClusterHealth(): Getting cluster health..."); + shardResolver.getControllerHealth(memberMap); + return new ClusterHealth().withHealth(Health.HEALTHY); + } + + /** + * Implementation of {@code getSiteHealth()}. Uses the results from + * {@code getAdminHealth}, {@code getDatabaseHealth}, and + * {@code getClusterHealth} to determine the health of the site. If all + * components are healthy, the site is healthy. + * + * @return a List of {@code SiteHealth} objects with health of the site + * @see org.onap.ccsdk.sli.plugins.grtoolkit.GrToolkitProvider + * @see HealthResolver + * @see SiteHealth + * @see ShardResolver + */ + @Override + public List getSiteHealth() { + log.info("getSiteHealth(): Getting site health..."); + AdminHealth adminHealth = getAdminHealth(); + DatabaseHealth databaseHealth = getDatabaseHealth(); + ClusterHealth clusterHealth = getClusterHealth(); + SiteHealth siteHealth = new SiteHealth() + .withAdminHealth(adminHealth) + .withDatabaseHealth(databaseHealth) + .withClusterHealth(clusterHealth) + .withRole("ACTIVE") + .withId(getSiteIdentifier()); + log.info("getSiteHealth(): Admin Health: {}", adminHealth.getHealth().toString()); + log.info("getSiteHealth(): Database Health: {}", databaseHealth.getHealth().toString()); + log.info("getSiteHealth(): Cluster Health: {}", clusterHealth.getHealth().toString()); + if(isHealthy(adminHealth.getHealth()) && isHealthy(databaseHealth.getHealth()) && isHealthy(clusterHealth.getHealth())) { + siteHealth.setHealth(Health.HEALTHY); + } + + return Collections.singletonList(siteHealth); + } + + /** + * Implementation of {@code tryFailover()}. No controller-level failover + * options are available in a single node architecture, so 400 Bad Request + * is returned, and no action is taken. + * + * @return an {@code SiteHealth} object with health of the site + * @see org.onap.ccsdk.sli.plugins.grtoolkit.GrToolkitProvider + * @see HealthResolver + * @see FailoverStatus + * @see FailoverInput + */ + @Override + public FailoverStatus tryFailover(FailoverInput input) { + log.info("tryFailover(): Failover not supported in the current configuration."); + return new FailoverStatus().withStatusCode(400).withMessage("Failover not supported in current configuration."); + } + + /** + * Implementation of {@code resolveSites()}. Calls + * {@code resolveSiteForMember()} to resolve which site a member belongs to. + * + * @see HealthResolver + */ + @Override + public void resolveSites() { + log.info("Map contains {} entries", memberMap.size()); + memberMap.forEach((key, value) -> resolveSiteForMember(value)); + } + + /** + * Resolves which site a member belongs to. Since this is a Single node + * architecture, it is defaulted to Site 1. + * + * @see HealthResolver + */ + private void resolveSiteForMember(ClusterActor actor) { + actor.setSite("Site 1"); + log.info("resolveSiteForMember(): {} belongs to {}", actor.getNode(), actor.getSite()); + } +} diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/SixNodeHealthResolver.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/SixNodeHealthResolver.java new file mode 100644 index 000000000..e79262cf3 --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/SixNodeHealthResolver.java @@ -0,0 +1,316 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.resolver; + +import org.json.JSONArray; +import org.json.JSONObject; + +import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.onap.ccsdk.sli.plugins.grtoolkit.connection.ConnectionManager; +import org.onap.ccsdk.sli.plugins.grtoolkit.connection.ConnectionResponse; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.AdminHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterActor; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.DatabaseHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.FailoverStatus; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.Health; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.SiteHealth; + +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverInput; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Properties; +import java.util.stream.Collectors; + +/** + * Implementation of {@code HealthResolver} for a six node controller + * architecture, where three nodes are located in one data center, and the + * other three nodes are located in another. The sites are assumed to be in an + * Active/Standby configuration, with the Active site nodes voting and the + * Standby site notes non-voting. + * + * @author Anthony Haddox + * @see HealthResolver + */ +public class SixNodeHealthResolver extends HealthResolver { + private final Logger log = LoggerFactory.getLogger(SixNodeHealthResolver.class); + + /** + * Constructs the health resolver used by the {@code GrToolkitProvider} to + * determine the health of the application components. + * + * @param map a HashMap containing all of the nodes in the akka cluster + * @param properties the properties passed ino the provider + * @param dbLib a reference to the {@code DbLibService} of the provider + * @see HealthResolver + * @see org.onap.ccsdk.sli.plugins.grtoolkit.GrToolkitProvider + */ + public SixNodeHealthResolver(Map map, Properties properties, DbLibService dbLib) { + super(map, properties, dbLib); + resolveSites(); + } + + /** + * Implementation of {@code getClusterHealth()}. Uses the + * {@code ShardResolver} to gather health information about the controller. + * If 4 of 6 members are healthy, the cluster is deemed healthy. + * + * @return an {@code ClusterHealth} object with health of the akka cluster + * @see org.onap.ccsdk.sli.plugins.grtoolkit.GrToolkitProvider + * @see HealthResolver + * @see ClusterHealth + * @see ShardResolver + */ + @Override + public ClusterHealth getClusterHealth() { + log.info("getClusterHealth(): Getting cluster health..."); + shardResolver.getControllerHealth(memberMap); + long healthyMembers = memberMap.values().stream().filter(member -> member.isUp() && ! member.isUnreachable()).count(); + return (healthyMembers > 4) ? new ClusterHealth().withHealth(Health.HEALTHY) : new ClusterHealth().withHealth(Health.FAULTY); + } + + /** + * Implementation of {@code getSiteHealth()}. Gathers health information on + * all of the contollers, then separates the nodes into voting and + * non-voting sites. Each site is then checked for its health and the + * result is returned as a List. + * + * @return a List of {@code SiteHealth} objects with health of the site + * @see org.onap.ccsdk.sli.plugins.grtoolkit.GrToolkitProvider + * @see HealthResolver + * @see SiteHealth + * @see ShardResolver + */ + @Override + public List getSiteHealth() { + log.info("getSiteHealth(): Getting site health..."); + + // Get cluster health to populate memberMap with necessary values + getClusterHealth(); + List votingActors = memberMap.values().stream().filter(ClusterActor::isVoting).collect(Collectors.toList()); + List nonVotingActors = memberMap.values().stream().filter(member -> !member.isVoting()).collect(Collectors.toList()); + + SiteHealth votingSiteHealth = getSiteHealth(votingActors).withRole("ACTIVE"); + SiteHealth nonVotingSiteHealth = getSiteHealth(nonVotingActors).withRole("STANDBY"); + return Arrays.asList(votingSiteHealth, nonVotingSiteHealth); + } + + /** + * Gathers the site identifier, admin health, and database health of a + * site. + * + * @return a {@code SiteHealth} object with health of the site + * @see org.onap.ccsdk.sli.plugins.grtoolkit.GrToolkitProvider + * @see ClusterActor + * @see SiteHealth + * @see ConnectionManager + */ + public SiteHealth getSiteHealth(List actorList) { + AdminHealth adminHealth = null; + DatabaseHealth databaseHealth = null; + String siteId = null; + int healthyMembers = 0; + + for(ClusterActor actor : actorList) { + if(actor.isUp() && !actor.isUnreachable()) { + healthyMembers++; + } + if(siteId == null) { + try { + String content = ConnectionManager.getConnectionResponse(httpProtocol + actor.getNode() + ":" + controllerPort + "/restconf/operations/gr-toolkit:site-identifier", ConnectionManager.HttpMethod.POST, null, credentials).content; + siteId = new JSONObject(content).getJSONObject(OUTPUT).getString("id"); + } catch(IOException e) { + log.error("getSiteHealth(): Error getting site identifier from {}", actor.getNode()); + log.error("getSiteHealth(): IOException", e); + } + } + if(adminHealth == null) { + try { + boolean isAdminHealthy = isRemoteComponentHealthy(httpProtocol + actor.getNode() + ":" + controllerPort + "/restconf/operations/gr-toolkit:admin-health"); + if(isAdminHealthy) { + adminHealth = new AdminHealth(Health.HEALTHY, 200); + } + } catch(IOException e) { + log.error("getSiteHealth(): Error getting admin health from {}", actor.getNode()); + log.error("getSiteHealth(): IOException", e); + } + } + if(databaseHealth == null) { + try { + boolean isDatabaseHealthy = isRemoteComponentHealthy(httpProtocol + actor.getNode() + ":" + controllerPort + "/restconf/operations/gr-toolkit:database-health"); + if(isDatabaseHealthy) { + databaseHealth = new DatabaseHealth(Health.HEALTHY); + } + } catch(IOException e) { + log.error("getSiteHealth(): Error getting database health from {}", actor.getNode()); + log.error("getSiteHealth(): IOException", e); + } + } + } + + if(siteId == null) { + siteId = "UNKNOWN SITE"; + } + if(adminHealth == null) { + adminHealth = new AdminHealth(Health.FAULTY, 500); + } + if(databaseHealth == null) { + databaseHealth = new DatabaseHealth(Health.FAULTY); + } + SiteHealth health = new SiteHealth() + .withAdminHealth(adminHealth) + .withDatabaseHealth(databaseHealth) + .withId(siteId); + if(isHealthy(adminHealth.getHealth()) && isHealthy(databaseHealth.getHealth()) && healthyMembers > 1) { + health.setHealth(Health.HEALTHY); + } + + return health; + } + + /** + * Implementation of {@code tryFailover()}. Performs a preliminary call to + * {@code getClusterHealth} to populate information about the cluster. If + * no voting members can be found, the method terminates immediately. The + * nodes are separated into voting and non-voting sites, and a driving + * operator is selected from the non-voting nodes to perform requests + * against. A payload to swap voting between sites is sent to the operator + * to perform a controller-level failover. + * + * @return an {@code SiteHealth} object with health of the site + * @see org.onap.ccsdk.sli.plugins.grtoolkit.GrToolkitProvider + * @see HealthResolver + * @see FailoverStatus + * @see FailoverInput + */ + @Override + public FailoverStatus tryFailover(FailoverInput input) { + // Get Cluster Health to populate the memberMap with the necessary values + log.info("tryFailover(): Performing preliminary health check..."); + getClusterHealth(); + FailoverStatus status = new FailoverStatus(); + ConnectionResponse votingResponse = null; + List votingActors = memberMap.values().stream().filter(ClusterActor::isVoting).collect(Collectors.toList()); + List nonVotingActors = memberMap.values().stream().filter(member -> !member.isVoting()).collect(Collectors.toList()); + + if(nonVotingActors.size() == 0) { + status.setStatusCode(500); + status.setMessage("No nonvoting members found. Cannot perform voting switch."); + return status; + } + + ClusterActor operator; + try { + operator = nonVotingActors.stream().filter(this::isControllerHealthy).findFirst().get(); + } catch(NoSuchElementException e) { + log.error("tryFailover(): Could not find any healthy members.", e); + status.setStatusCode(500); + status.setMessage("Could not find any healthy members."); + return status; + } + + // Assuming two 3 node sites, 3 voting and 3 non voting + if(votingActors.size() < 3 || nonVotingActors.size() < 3) { + log.warn("tryFailover(): Sites do not contain an equal amount of voting and nonvoting members: Voting: {} | NonVoting: {}", votingActors.size(), nonVotingActors.size()); + } + log.info("tryFailover(): Swapping voting..."); + try { + JSONObject votingInput = new JSONObject(); + JSONObject inputBlock = new JSONObject(); + JSONArray votingStateArray = new JSONArray(); + JSONObject memberVotingState; + for(ClusterActor actor : votingActors) { + memberVotingState = new JSONObject(); + memberVotingState.put("member-name", actor.getMember()); + memberVotingState.put("voting", false); + votingStateArray.put(memberVotingState); + } + for(ClusterActor actor : nonVotingActors) { + memberVotingState = new JSONObject(); + memberVotingState.put("member-name", actor.getMember()); + memberVotingState.put("voting", true); + votingStateArray.put(memberVotingState); + } + inputBlock.put("member-voting-state", votingStateArray); + votingInput.put("input", inputBlock); + log.debug("tryFailover(): {}", votingInput); + // Change voting all shards + votingResponse = ConnectionManager.getConnectionResponse(httpProtocol + operator.getNode() + ":" + controllerPort + "/restconf/operations/cluster-admin:change-member-voting-states-for-all-shards", ConnectionManager.HttpMethod.POST, votingInput.toString(), credentials); + } catch(IOException e) { + log.error("tryFailover(): Failure changing voting", e); + } + if(votingResponse != null) { + if(votingResponse.statusCode != 200) { + status.setStatusCode(votingResponse.statusCode); + status.setMessage("Failed to swap voting."); + } else { + status.setStatusCode(200); + status.setMessage("Failover complete."); + } + } else { + status.setStatusCode(500); + status.setMessage("Failed to swap voting."); + } + + return status; + } + + /** + * Implementation of {@code resolveSites()}. Calls + * {@code resolveSiteForMember()} to resolve which site a member belongs to. + * + * @see HealthResolver + */ + @Override + public void resolveSites() { + log.info("Map contains {} entries", memberMap.size()); + memberMap.forEach((key, value) -> resolveSiteForMember(value)); + } + + /** + * Resolves which site a member belongs to. Members 1-3 are assumed to be + * Site 1 while members 4-6 are assumed to be Site 2. + * + * @see HealthResolver + */ + private void resolveSiteForMember(ClusterActor actor) { + try { + int memberNumber = Integer.parseInt(actor.getMember().split("-")[1]); + if(memberNumber < 4) { + actor.setSite("Site 1"); + } else { + actor.setSite("Site 2"); + } + log.info("resolveSiteForMember(): {} belongs to {}", actor.getNode(), actor.getSite()); + } catch (NumberFormatException e) { + log.error("resolveSiteForMember(): Could not parse member number for {}. Defaulting to Site 1.", actor.getNode()); + actor.setSite("resolveSiteForMember(): Site 1"); + } + } +} \ No newline at end of file diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/ThreeNodeHealthResolver.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/ThreeNodeHealthResolver.java new file mode 100644 index 000000000..2180b2bf8 --- /dev/null +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/ThreeNodeHealthResolver.java @@ -0,0 +1,162 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.resolver; + +import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.AdminHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterActor; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.DatabaseHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.FailoverStatus; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.Health; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.SiteHealth; + +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverInput; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +/** + * Implementation of {@code HealthResolver} for a three node controller + * architecture, where all nodes are located within the same data center or + * geographic region. The nodes are assumed to be in an Active/Active/Active + * voting configuration. + * + * @author Anthony Haddox + * @see HealthResolver + */ +public class ThreeNodeHealthResolver extends HealthResolver { + private final Logger log = LoggerFactory.getLogger(ThreeNodeHealthResolver.class); + + /** + * Constructs the health resolver used by the {@code GrToolkitProvider} to + * determine the health of the application components. + * + * @param map a HashMap containing all of the nodes in the akka cluster + * @param properties the properties passed ino the provider + * @param dbLib a reference to the {@code DbLibService} of the provider + * @see HealthResolver + * @see org.onap.ccsdk.sli.plugins.grtoolkit.GrToolkitProvider + */ + public ThreeNodeHealthResolver(Map map, Properties properties, DbLibService dbLib) { + super(map, properties, dbLib); + resolveSites(); + } + + /** + * Implementation of {@code getClusterHealth()}. Uses the + * {@code ShardResolver} to gather health information about the controller. + * If 2 of 3 members are healthy, the cluster is deemed healthy. + * + * @return an {@code ClusterHealth} object with health of the akka cluster + * @see org.onap.ccsdk.sli.plugins.grtoolkit.GrToolkitProvider + * @see HealthResolver + * @see ClusterHealth + * @see ShardResolver + */ + @Override + public ClusterHealth getClusterHealth() { + log.info("getClusterHealth(): Getting cluster health..."); + shardResolver.getControllerHealth(memberMap); + long healthyMembers = memberMap.values().stream().filter(member -> member.isUp() && ! member.isUnreachable()).count(); + return (healthyMembers > 1) ? new ClusterHealth().withHealth(Health.HEALTHY) : new ClusterHealth().withHealth(Health.FAULTY); + } + + /** + * Implementation of {@code getSiteHealth()}. Uses the results from + * {@code getAdminHealth}, {@code getDatabaseHealth}, and + * {@code getClusterHealth} to determine the health of the site. If all + * components are healthy, the site is healthy. + * + * @return a List of {@code SiteHealth} objects with health of the site + * @see org.onap.ccsdk.sli.plugins.grtoolkit.GrToolkitProvider + * @see HealthResolver + * @see SiteHealth + * @see ShardResolver + */ + @Override + public List getSiteHealth() { + log.info("getSiteHealth(): Getting site health..."); + AdminHealth adminHealth = getAdminHealth(); + DatabaseHealth databaseHealth = getDatabaseHealth(); + ClusterHealth clusterHealth = getClusterHealth(); + SiteHealth siteHealth = new SiteHealth() + .withAdminHealth(adminHealth) + .withDatabaseHealth(databaseHealth) + .withClusterHealth(clusterHealth) + .withRole("ACTIVE") + .withId(getSiteIdentifier()); + log.info("getSiteHealth(): Admin Health: {}", adminHealth.getHealth().toString()); + log.info("getSiteHealth(): Database Health: {}", databaseHealth.getHealth().toString()); + log.info("getSiteHealth(): Cluster Health: {}", clusterHealth.getHealth().toString()); + if(isHealthy(adminHealth.getHealth()) && isHealthy(databaseHealth.getHealth()) && isHealthy(clusterHealth.getHealth())) { + siteHealth.setHealth(Health.HEALTHY); + } + + return Collections.singletonList(siteHealth); + } + + /** + * Implementation of {@code tryFailover()}. No controller-level failover + * options are available in a three node architecture, so 400 Bad Request + * is returned, and no action is taken. + * + * @return an {@code SiteHealth} object with health of the site + * @see org.onap.ccsdk.sli.plugins.grtoolkit.GrToolkitProvider + * @see HealthResolver + * @see FailoverStatus + * @see FailoverInput + */ + @Override + public FailoverStatus tryFailover(FailoverInput input) { + log.info("tryFailover(): Failover not supported in the current configuration."); + return new FailoverStatus().withStatusCode(400).withMessage("Failover not supported in current configuration."); + } + + /** + * Implementation of {@code resolveSites()}. Calls + * {@code resolveSiteForMember()} to resolve which site a member belongs to. + * + * @see HealthResolver + */ + @Override + public void resolveSites() { + log.info("Map contains {} entries", memberMap.size()); + memberMap.forEach((key, value) -> resolveSiteForMember(value)); + } + + /** + * Resolves which site a member belongs to. Since this is a three node + * co-located architecture, it is defaulted to Site 1. + * + * @see HealthResolver + */ + private void resolveSiteForMember(ClusterActor actor) { + actor.setSite("Site 1"); + log.info("resolveSiteForMember(): {} belongs to {}", actor.getNode(), actor.getSite()); + } +} diff --git a/grToolkit/provider/src/main/resources/OSGI-INF/blueprint/GrToolkit.xml b/grToolkit/provider/src/main/resources/OSGI-INF/blueprint/GrToolkit.xml deleted file mode 100755 index 5a4492c56..000000000 --- a/grToolkit/provider/src/main/resources/OSGI-INF/blueprint/GrToolkit.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/grToolkit/provider/src/main/resources/gr-toolkit.properties b/grToolkit/provider/src/main/resources/gr-toolkit.properties index c008eea98..e3463df08 100755 --- a/grToolkit/provider/src/main/resources/gr-toolkit.properties +++ b/grToolkit/provider/src/main/resources/gr-toolkit.properties @@ -17,6 +17,7 @@ # limitations under the License. # ============LICENSE_END========================================================= +resolver=org.onap.ccsdk.sli.plugins.grtoolkit.resolver.SingleNodeHealthResolver akka.conf.location=/opt/opendaylight/current/controller/configuration/initial/akka.conf adm.useSsl=true adm.fqdn= @@ -31,4 +32,4 @@ controller.port.akka=2550 mbean.cluster=/jolokia/read/akka:type=Cluster mbean.shardManager=/jolokia/read/org.opendaylight.controller:Category=ShardManager,name=shard-manager-config,type=DistributedConfigDatastore mbean.shard.config=/jolokia/read/org.opendaylight.controller:Category=Shards,name=%s,type=DistributedConfigDatastore -site.identifier=UniqueSiteNamehere +site.identifier=UniqueSiteNameHere diff --git a/grToolkit/provider/src/main/resources/org/opendaylight/blueprint/GrToolkit.xml b/grToolkit/provider/src/main/resources/org/opendaylight/blueprint/GrToolkit.xml old mode 100755 new mode 100644 diff --git a/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProviderTest.java b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProviderTest.java index dabdf2065..3be159598 100644 --- a/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProviderTest.java +++ b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProviderTest.java @@ -20,14 +20,19 @@ */ package org.onap.ccsdk.sli.plugins.grtoolkit; +import com.github.tomakehurst.wiremock.junit.WireMockRule; + import com.google.common.util.concurrent.ListenableFuture; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.contrib.java.lang.system.EnvironmentVariables; + import org.onap.ccsdk.sli.core.dblib.DBLibConnection; import org.onap.ccsdk.sli.core.dblib.DbLibService; import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterActor; + import org.opendaylight.controller.cluster.access.concepts.MemberName; import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface; import org.opendaylight.controller.cluster.datastore.utils.ActorContext; @@ -38,22 +43,34 @@ import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ClusterHealthOutput; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.DatabaseHealthOutput; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverOutput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.FailoverOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.HaltAkkaTrafficInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.HaltAkkaTrafficOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ResumeAkkaTrafficInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.ResumeAkkaTrafficOutput; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteHealthOutput; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.plugins.gr.toolkit.rev180926.SiteIdentifierOutput; import org.opendaylight.yangtools.yang.common.RpcResult; -import java.lang.reflect.Field; +import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.nio.file.Files; +import java.nio.file.Paths; import java.sql.SQLException; import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; +import java.util.Properties; import java.util.concurrent.ExecutionException; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; + import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; @@ -67,13 +84,16 @@ public class GrToolkitProviderTest { DistributedDataStoreInterface configDatastore; DbLibService dbLibService; DBLibConnection connection; + Properties properties; @Rule public final EnvironmentVariables environmentVariables = new EnvironmentVariables(); + @Rule + public WireMockRule wireMockRule = new WireMockRule(9999); @Before public void setup() { - environmentVariables.set("SDNC_CONFIG_DIR","src/test/resources/"); + environmentVariables.set("SDNC_CONFIG_DIR","src/test/resources"); dataBroker = mock(DataBroker.class); notificationProviderService = mock(NotificationPublishService.class); rpcProviderRegistry = mock(RpcProviderRegistry.class); @@ -99,14 +119,14 @@ public class GrToolkitProviderTest { provider = new GrToolkitProvider(dataBroker, notificationProviderService, rpcProviderRegistry, configDatastore, dbLibService); providerSpy = spy(provider); + stubController(); } @Test public void closeTest() { try { provider.close(); - } - catch(Exception e) { + } catch(Exception e) { // Exception expected } } @@ -117,63 +137,54 @@ public class GrToolkitProviderTest { // onDataTreeChanged is an empty stub } - @Test - public void clusterHealthTest() { - ListenableFuture> result = provider.clusterHealth(null); - try { - assertEquals("200", result.get().getResult().getStatus()); - } catch(InterruptedException | ExecutionException e) { + private void stubController() { + String clusterBody = null; + String shardManagerBody = null; + String shardDefaultBody = null; + String shardOperationalBody = null; + try(Stream stream = Files.lines(Paths.get("src/test/resources/three/cluster.json"))) { + clusterBody = stream.collect(Collectors.joining()); + } catch(IOException e) { + fail(); + } + try(Stream stream = Files.lines(Paths.get("src/test/resources/three/shard-manager.json"))) { + shardManagerBody = stream.collect(Collectors.joining()); + } catch(IOException e) { + fail(); + } + try(Stream stream = Files.lines(Paths.get("src/test/resources/three/default-config.json"))) { + shardDefaultBody = stream.collect(Collectors.joining()); + } catch(IOException e) { + fail(); + } + try(Stream stream = Files.lines(Paths.get("src/test/resources/three/default-operational.json"))) { + shardOperationalBody = stream.collect(Collectors.joining()); + } catch(IOException e) { fail(); } - } - @Test - public void siteHealthTest() { - ListenableFuture> result = provider.siteHealth(null); - try { - assertEquals("200", result.get().getResult().getStatus()); - } catch(InterruptedException | ExecutionException e) { + if(clusterBody == null || shardManagerBody == null || shardDefaultBody == null || shardOperationalBody == null) { fail(); } + stubFor(get(urlEqualTo("/adm/healthcheck")).willReturn(aResponse().withStatus(200))); + stubFor(get(urlEqualTo("/jolokia/read/akka:type=Cluster")).willReturn(aResponse().withStatus(200).withBody(clusterBody))); + stubFor(get(urlEqualTo("/jolokia/read/org.opendaylight.controller:Category=ShardManager,name=shard-manager-config,type=DistributedConfigDatastore")).inScenario("testing").willReturn(aResponse().withStatus(200).withBody(shardManagerBody)).willSetStateTo("next")); + stubFor(get(urlEqualTo("/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-1-shard-default-config,type=DistributedConfigDatastore")).inScenario("testing").willReturn(aResponse().withStatus(200).withBody(shardDefaultBody)).willSetStateTo("next")); + stubFor(get(urlEqualTo("/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-1-shard-default-operational,type=DistributedOperationalDatastore")).willReturn(aResponse().withStatus(200).withBody(shardOperationalBody))); } @Test - public void siteHealth6NodeTest() { - Map memberMap = new HashMap<>(); - ClusterActor actor; - for(int ndx = 0; ndx < 6; ndx++) { - actor = new ClusterActor(); - actor.setNode("member-" + (ndx + 1)); - actor.setUp(true); - actor.setUnreachable(false); - - memberMap.put(actor.getNode(), actor); - } - + public void clusterHealthTest() { + ListenableFuture> result = provider.clusterHealth(null); try { - Field field = provider.getClass().getDeclaredField("siteConfiguration"); - field.setAccessible(true); - field.set(provider, GrToolkitProvider.SiteConfiguration.GEO); - - field = provider.getClass().getDeclaredField("memberMap"); - field.setAccessible(true); - field.set(provider, memberMap); - - - actor = new ClusterActor(); - actor.setNode("member-1"); - field = provider.getClass().getDeclaredField("self"); - field.setAccessible(true); - field.set(provider, actor); - - field = provider.getClass().getDeclaredField("member"); - field.setAccessible(true); - field.set(provider, actor.getNode()); - } - catch(IllegalAccessException | NoSuchFieldException e) { + assertEquals("0", result.get().getResult().getStatus()); + } catch(InterruptedException | ExecutionException e) { fail(); } + } + @Test + public void siteHealthTest() { ListenableFuture> result = provider.siteHealth(null); try { assertEquals("200", result.get().getResult().getStatus()); @@ -201,7 +212,7 @@ public class GrToolkitProviderTest { } ListenableFuture> result = provider.databaseHealth(null); try { - assertEquals("200", result.get().getResult().getStatus()); + assertEquals("500", result.get().getResult().getStatus()); } catch(InterruptedException | ExecutionException e) { fail(); } @@ -216,7 +227,7 @@ public class GrToolkitProviderTest { } ListenableFuture> result = provider.databaseHealth(null); try { - assertEquals("200", result.get().getResult().getStatus()); + assertEquals("500", result.get().getResult().getStatus()); } catch(InterruptedException | ExecutionException e) { fail(); } @@ -252,14 +263,37 @@ public class GrToolkitProviderTest { } } + @Test + public void haltTrafficTest() { + HaltAkkaTrafficInputBuilder builder = new HaltAkkaTrafficInputBuilder(); + builder.setNodeInfo(new ArrayList<>()); + ListenableFuture> result = provider.haltAkkaTraffic(builder.build()); + try { + assertEquals("200", result.get().getResult().getStatus()); + } catch(InterruptedException | ExecutionException e) { + fail(); + } + } + + @Test + public void resumeTrafficTest() { + ResumeAkkaTrafficInputBuilder builder = new ResumeAkkaTrafficInputBuilder(); + builder.setNodeInfo(new ArrayList<>()); + ListenableFuture> result = provider.resumeAkkaTraffic(builder.build()); + try { + assertEquals("200", result.get().getResult().getStatus()); + } catch(InterruptedException | ExecutionException e) { + fail(); + } + } + @Test public void executeCommandTest() { try { Method method = provider.getClass().getDeclaredMethod("executeCommand", String.class); method.setAccessible(true); method.invoke(provider, "ls"); - } - catch(NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + } catch(NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { fail(); } } @@ -277,8 +311,7 @@ public class GrToolkitProviderTest { Method method = provider.getClass().getDeclaredMethod("isolateSiteFromCluster", ArrayList.class, ArrayList.class, String.class); method.setAccessible(true); method.invoke(provider, activeList, standbyList, "80"); - } - catch(NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + } catch(NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { fail(); } } @@ -296,30 +329,7 @@ public class GrToolkitProviderTest { Method method = provider.getClass().getDeclaredMethod("downUnreachableNodes", ArrayList.class, ArrayList.class, String.class); method.setAccessible(true); method.invoke(provider, activeList, standbyList, "80"); - } - catch(NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { - fail(); - } - } - - @Test - public void changeClusterVotingTest() { - try { - ClusterActor actor = new ClusterActor(); - actor.setMember("some-member"); - actor.setNode("some-Node"); - ArrayList activeList = new ArrayList<>(); - activeList.add(actor); - ArrayList standbyList = new ArrayList<>(); - standbyList.add(actor); - Field field = provider.getClass().getDeclaredField("self"); - field.setAccessible(true); - field.set(provider, actor); - Method method = provider.getClass().getDeclaredMethod("changeClusterVoting", FailoverOutputBuilder.class, ArrayList.class, ArrayList.class, String.class); - method.setAccessible(true); - method.invoke(provider, new FailoverOutputBuilder(), activeList, standbyList, "80"); - } - catch(NoSuchMethodException | IllegalAccessException | InvocationTargetException | NoSuchFieldException e) { + } catch(NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { fail(); } } @@ -335,10 +345,8 @@ public class GrToolkitProviderTest { Method method = provider.getClass().getDeclaredMethod("backupMdSal", ArrayList.class, String.class); method.setAccessible(true); method.invoke(provider, activeList, "80"); - } - catch(NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + } catch(NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { fail(); } } - } diff --git a/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/connection/ConnectionManagerTest.java b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/connection/ConnectionManagerTest.java new file mode 100644 index 000000000..f749688d9 --- /dev/null +++ b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/connection/ConnectionManagerTest.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.connection; + +import com.github.tomakehurst.wiremock.junit.WireMockRule; + +import org.junit.Rule; +import org.junit.Test; + +import static org.junit.Assert.*; + +import static com.github.tomakehurst.wiremock.client.WireMock.*; + +public class ConnectionManagerTest { + @Rule + public WireMockRule wireMockRule = new WireMockRule(9999); + + @Test + public void getConnectionResponseWithInput() throws Exception { + stubFor(post(urlEqualTo("/post")) + .willReturn(aResponse().withStatus(200))); + ConnectionResponse response = ConnectionManager.getConnectionResponse("http://localhost:9999/post", ConnectionManager.HttpMethod.POST, "", "creds:creds"); + assertNotNull(response); + assertEquals(200, response.statusCode); + } + + @Test + public void getConnectionResponseWithCredentials() throws Exception { + stubFor(post(urlEqualTo("/post")) + .willReturn(aResponse().withStatus(200))); + ConnectionResponse response = ConnectionManager.getConnectionResponse("http://localhost:9999/post", ConnectionManager.HttpMethod.POST, "", "creds:creds"); + assertNotNull(response); + assertEquals(200, response.statusCode); + } + + @Test + public void getConnectionResponse() throws Exception { + stubFor(get(urlEqualTo("/get")) + .willReturn(aResponse().withStatus(200) + .withBody("Multi\nLine\nResponse"))); + ConnectionResponse response = ConnectionManager.getConnectionResponse("http://localhost:9999/get", ConnectionManager.HttpMethod.GET, null, null); + assertNotNull(response); + assertEquals(200, response.statusCode); + assertEquals("MultiLineResponse", response.content); + } +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/connection/ConnectionResponseTest.java b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/connection/ConnectionResponseTest.java new file mode 100644 index 000000000..a9f0edc30 --- /dev/null +++ b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/connection/ConnectionResponseTest.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.connection; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class ConnectionResponseTest { + @Test + public void constructorTest() { + ConnectionResponse response = new ConnectionResponse(); + assertNotNull(response); + assertEquals(0, response.statusCode); + assertNull(response.content); + assertTrue(response.toString().length() > 0); + } + @Test + public void withStatusCode() { + ConnectionResponse response = new ConnectionResponse().withStatusCode(123); + assertEquals(123, response.statusCode); + } +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/AdminHealthTest.java b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/AdminHealthTest.java new file mode 100644 index 000000000..fa56a4d49 --- /dev/null +++ b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/AdminHealthTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.data; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class AdminHealthTest { + @Test + public void constructorTest() { + AdminHealth health = new AdminHealth(Health.HEALTHY); + assertEquals(Health.HEALTHY, health.getHealth()); + } + + @Test + public void constructor2Test() { + AdminHealth health = new AdminHealth(Health.FAULTY, 500); + assertEquals(Health.FAULTY, health.getHealth()); + assertEquals(500, health.getStatusCode()); + } + + @Test + public void setHealth() { + AdminHealth health = new AdminHealth(Health.HEALTHY, 201); + assertEquals(Health.HEALTHY, health.getHealth()); + assertEquals(201, health.getStatusCode()); + health.setHealth(Health.FAULTY); + assertEquals(Health.FAULTY, health.getHealth()); + } + + @Test + public void setStatusCode() { + AdminHealth health = new AdminHealth(Health.HEALTHY, 200); + assertEquals(Health.HEALTHY, health.getHealth()); + assertEquals(200, health.getStatusCode()); + health.setStatusCode(409); + assertEquals(409, health.getStatusCode()); + } +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/ClusterHealthTest.java b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/ClusterHealthTest.java new file mode 100644 index 000000000..2e2ab3fd7 --- /dev/null +++ b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/ClusterHealthTest.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.data; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class ClusterHealthTest { + @Test + public void constructorTest() { + ClusterHealth health = new ClusterHealth(); + assertEquals(Health.FAULTY, health.getHealth()); + } + + @Test + public void withHealth() { + ClusterHealth health = new ClusterHealth().withHealth(Health.HEALTHY); + assertEquals(Health.HEALTHY, health.getHealth()); + } + + @Test + public void setHealth() { + ClusterHealth health = new ClusterHealth(); + health.setHealth(Health.HEALTHY); + assertEquals(Health.HEALTHY, health.getHealth()); + } +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/DatabaseHealthTest.java b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/DatabaseHealthTest.java new file mode 100644 index 000000000..05621a503 --- /dev/null +++ b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/DatabaseHealthTest.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.data; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class DatabaseHealthTest { + @Test + public void constructorTest() { + DatabaseHealth health = new DatabaseHealth(Health.FAULTY); + assertEquals(Health.FAULTY, health.getHealth()); + } + + @Test + public void setHealth() { + DatabaseHealth health = new DatabaseHealth(Health.FAULTY); + assertEquals(Health.FAULTY, health.getHealth()); + health.setHealth(Health.HEALTHY); + assertEquals(Health.HEALTHY, health.getHealth()); + } +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/FailoverStatusTest.java b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/FailoverStatusTest.java new file mode 100644 index 000000000..b5b3d00d2 --- /dev/null +++ b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/FailoverStatusTest.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.data; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class FailoverStatusTest { + @Test + public void constructorTest() { + FailoverStatus status = new FailoverStatus(); + assertEquals(200, status.getStatusCode()); + assertEquals("Failover complete.", status.getMessage()); + } + @Test + public void withStatusCode() { + FailoverStatus status = new FailoverStatus().withStatusCode(500); + assertEquals(500, status.getStatusCode()); + } + + @Test + public void withMessage() { + FailoverStatus status = new FailoverStatus().withMessage("Test"); + assertEquals("Test", status.getMessage()); + } + + @Test + public void setStatusCode() { + FailoverStatus status = new FailoverStatus(); + status.setStatusCode(500); + assertEquals(500, status.getStatusCode()); + } + + @Test + public void setMessage() { + FailoverStatus status = new FailoverStatus(); + status.setMessage("Test"); + assertEquals("Test", status.getMessage()); + } +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/HealthTest.java b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/HealthTest.java new file mode 100644 index 000000000..1115d2084 --- /dev/null +++ b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/HealthTest.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.data; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class HealthTest { + @Test + public void getHealth() { + assertEquals("HEALTHY", Health.HEALTHY.getHealth()); + assertEquals("FAULTY", Health.FAULTY.getHealth()); + } +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/MemberBuilderTest.java b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/MemberBuilderTest.java index 4b657cf0a..7ed0135a6 100644 --- a/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/MemberBuilderTest.java +++ b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/MemberBuilderTest.java @@ -1,3 +1,24 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2018 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.grtoolkit.data; import org.junit.Before; diff --git a/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/SiteHealthTest.java b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/SiteHealthTest.java new file mode 100644 index 000000000..7b74991e7 --- /dev/null +++ b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/data/SiteHealthTest.java @@ -0,0 +1,108 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.data; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class SiteHealthTest { + @Test + public void constructorTest() { + SiteHealth health = new SiteHealth(); + assertNotNull(health.getAdminHealth()); + assertNotNull(health.getDatabaseHealth()); + assertNotNull(health.getClusterHealth()); + assertEquals(Health.FAULTY, health.getHealth()); + } + @Test + public void withAdminHealth() { + SiteHealth health = new SiteHealth().withAdminHealth(new AdminHealth(Health.HEALTHY)); + assertEquals(Health.HEALTHY, health.getAdminHealth().get(0).getHealth()); + } + + @Test + public void withDatabaseHealth() { + SiteHealth health = new SiteHealth().withDatabaseHealth(new DatabaseHealth(Health.HEALTHY)); + assertEquals(Health.HEALTHY, health.getDatabaseHealth().get(0).getHealth()); + } + + @Test + public void withClusterHealth() { + SiteHealth health = new SiteHealth().withClusterHealth(new ClusterHealth()); + assertEquals(Health.FAULTY, health.getClusterHealth().get(0).getHealth()); + } + + @Test + public void withId() { + SiteHealth health = new SiteHealth().withId("My_ID"); + assertEquals("My_ID", health.getId()); + } + + @Test + public void withRole() { + SiteHealth health = new SiteHealth().withRole("My_role"); + assertEquals("My_role", health.getRole()); + } + + @Test + public void setHealth() { + SiteHealth health = new SiteHealth(); + health.setHealth(Health.HEALTHY); + assertEquals(Health.HEALTHY, health.getHealth()); + } + + @Test + public void setAdminHealth() { + SiteHealth health = new SiteHealth().withAdminHealth(new AdminHealth(Health.HEALTHY)); + health.setAdminHealth(null); + assertNull(health.getAdminHealth()); + } + + @Test + public void setDatabaseHealth() { + SiteHealth health = new SiteHealth().withDatabaseHealth(new DatabaseHealth(Health.HEALTHY)); + health.setDatabaseHealth(null); + assertNull(health.getDatabaseHealth()); + } + + @Test + public void setClusterHealth() { + SiteHealth health = new SiteHealth().withClusterHealth(new ClusterHealth()); + health.setClusterHealth(null); + assertNull(health.getClusterHealth()); + } + + @Test + public void setId() { + SiteHealth health = new SiteHealth().withId("My_ID"); + health.setId("My_new_ID"); + assertEquals("My_new_ID", health.getId()); + } + + @Test + public void setRole() { + SiteHealth health = new SiteHealth().withRole("My_role"); + health.setRole("My_new_role"); + assertEquals("My_new_role", health.getRole()); + } +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/SingleNodeHealthResolverTest.java b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/SingleNodeHealthResolverTest.java new file mode 100644 index 000000000..2827b4055 --- /dev/null +++ b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/SingleNodeHealthResolverTest.java @@ -0,0 +1,235 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.resolver; + +import com.github.tomakehurst.wiremock.junit.WireMockRule; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import org.onap.ccsdk.sli.core.dblib.DBLibConnection; +import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.AdminHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterActor; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.DatabaseHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.FailoverStatus; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.Health; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.SiteHealth; + +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; + +import static org.junit.Assert.*; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class SingleNodeHealthResolverTest { + private Map memberMap; + private DbLibService dbLibService; + private DBLibConnection connection; + private SingleNodeHealthResolver resolver; + + @Rule + public WireMockRule wireMockRule = new WireMockRule(9999); + + @Before + public void setUp() { + memberMap = generateMemberMap(1); + Properties properties = new Properties(); + try(FileInputStream fileInputStream = new FileInputStream("src/test/resources/single/gr-toolkit.properties")) { + properties.load(fileInputStream); + } catch(IOException e) { + fail(); + } + + dbLibService = mock(DbLibService.class); + connection = mock(DBLibConnection.class); + resolver = new SingleNodeHealthResolver(memberMap, properties, dbLibService); + } + + private Map generateMemberMap(int memberCount) { + Map map = new HashMap<>(); + ClusterActor actor; + for(int ndx = 0; ndx < memberCount; ndx++) { + actor = new ClusterActor(); + actor.setNode("localhost"); + actor.setAkkaPort("2550"); + actor.setMember("member-" + (ndx + 1)); + actor.setUp(true); + actor.setUnreachable(false); + + map.put(actor.getNode(), actor); + } + return map; + } + + @Test + public void getAdminHealthFaulty() { + stubFor(get(urlEqualTo("/adm/healthcheck")).willReturn(aResponse().withStatus(500))); + AdminHealth health = resolver.getAdminHealth(); + assertNotNull(health); + assertEquals(500, health.getStatusCode()); + assertEquals(Health.FAULTY, health.getHealth()); + } + + @Test + public void getAdminHealthHealthy() { + stubFor(get(urlEqualTo("/adm/healthcheck")).willReturn(aResponse().withStatus(200))); + AdminHealth health = resolver.getAdminHealth(); + assertNotNull(health); + assertEquals(200, health.getStatusCode()); + assertEquals(Health.HEALTHY, health.getHealth()); + } + + @Test + public void getDatabaseHealth() { + try { + when(connection.isReadOnly()).thenReturn(false); + when(connection.isClosed()).thenReturn(false); + when(dbLibService.isActive()).thenReturn(true); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + DatabaseHealth health = resolver.getDatabaseHealth(); + assertEquals(Health.HEALTHY, health.getHealth()); + } + + @Test + public void getDatabaseHealthFaulty() { + try { + when(connection.isReadOnly()).thenReturn(true); + when(connection.isClosed()).thenReturn(true); + when(dbLibService.isActive()).thenReturn(false); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + DatabaseHealth health = resolver.getDatabaseHealth(); + assertEquals(Health.FAULTY, health.getHealth()); + } + + @Test + public void getDatabaseHealthException() { + try { + when(connection.isReadOnly()).thenThrow(new SQLException()); + when(connection.isClosed()).thenReturn(true); + when(dbLibService.isActive()).thenReturn(false); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + DatabaseHealth health = resolver.getDatabaseHealth(); + assertEquals(Health.FAULTY, health.getHealth()); + } + + @Test + public void siteIdentifier() { + assertEquals("TestODL", resolver.getSiteIdentifier()); + resolver.setSiteIdentifier("NewTestODL"); + assertEquals("NewTestODL", resolver.getSiteIdentifier()); + } + + @Test + public void getClusterHealth() { + stubController(); + ClusterHealth health = resolver.getClusterHealth(); + assertEquals(Health.HEALTHY, health.getHealth()); + } + + private void stubController() { + String clusterBody = null; + String shardManagerBody = null; + String shardDefaultBody = null; + String shardOperationalBody = null; + try(Stream stream = Files.lines(Paths.get("src/test/resources/single/cluster.json"))) { + clusterBody = stream.collect(Collectors.joining()); + } catch(IOException e) { + fail(); + } + try(Stream stream = Files.lines(Paths.get("src/test/resources/single/shard-manager.json"))) { + shardManagerBody = stream.collect(Collectors.joining()); + } catch(IOException e) { + fail(); + } + try(Stream stream = Files.lines(Paths.get("src/test/resources/single/default-config.json"))) { + shardDefaultBody = stream.collect(Collectors.joining()); + } catch(IOException e) { + fail(); + } + try(Stream stream = Files.lines(Paths.get("src/test/resources/single/default-operational.json"))) { + shardOperationalBody = stream.collect(Collectors.joining()); + } catch(IOException e) { + fail(); + } + + if(clusterBody == null || shardManagerBody == null || shardDefaultBody == null || shardOperationalBody == null) { + fail(); + } + stubFor(get(urlEqualTo("/jolokia/read/akka:type=Cluster")).willReturn(aResponse().withStatus(200).withBody(clusterBody))); + stubFor(get(urlEqualTo("/jolokia/read/org.opendaylight.controller:Category=ShardManager,name=shard-manager-config,type=DistributedConfigDatastore")).willReturn(aResponse().withStatus(200).withBody(shardManagerBody))); + stubFor(get(urlEqualTo("/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-1-shard-default-config,type=DistributedConfigDatastore")).willReturn(aResponse().withStatus(200).withBody(shardDefaultBody))); + stubFor(get(urlEqualTo("/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-1-shard-default-operational,type=DistributedOperationalDatastore")).willReturn(aResponse().withStatus(200).withBody(shardOperationalBody))); + } + + @Test + public void getSiteHealth() { + stubController(); + stubFor(get(urlEqualTo("/adm/healthcheck")).willReturn(aResponse().withStatus(200))); + try { + when(connection.isReadOnly()).thenReturn(false); + when(connection.isClosed()).thenReturn(false); + when(dbLibService.isActive()).thenReturn(true); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + List health = resolver.getSiteHealth(); + assertNotNull(health); + assertNotEquals(0, health.size()); + assertEquals(1, health.size()); + assertEquals(Health.HEALTHY, health.get(0).getHealth()); + } + + @Test + public void tryFailover() { + FailoverStatus status = resolver.tryFailover(null); + assertEquals(400, status.getStatusCode()); + } +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/SixNodeHealthResolverTest.java b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/SixNodeHealthResolverTest.java new file mode 100644 index 000000000..cbab450e1 --- /dev/null +++ b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/SixNodeHealthResolverTest.java @@ -0,0 +1,335 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.resolver; + +import com.github.tomakehurst.wiremock.junit.WireMockRule; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import org.onap.ccsdk.sli.core.dblib.DBLibConnection; +import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.AdminHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterActor; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.DatabaseHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.FailoverStatus; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.Health; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.SiteHealth; + +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; + +import static org.junit.Assert.*; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class SixNodeHealthResolverTest { + private Map memberMap; + private DbLibService dbLibService; + private DBLibConnection connection; + private SixNodeHealthResolver resolver; + + @Rule + public WireMockRule wireMockRule = new WireMockRule(9999); + + @Before + public void setUp() { + memberMap = generateMemberMap(6); + Properties properties = new Properties(); + try(FileInputStream fileInputStream = new FileInputStream("src/test/resources/six/gr-toolkit.properties")) { + properties.load(fileInputStream); + } catch(IOException e) { + fail(); + } + + dbLibService = mock(DbLibService.class); + connection = mock(DBLibConnection.class); + resolver = new SixNodeHealthResolver(memberMap, properties, dbLibService); + } + + private Map generateMemberMap(int memberCount) { + Map map = new HashMap<>(); + ClusterActor actor; + for(int ndx = 0; ndx < memberCount; ndx++) { + actor = new ClusterActor(); + actor.setNode("127.0.1." + (ndx + 1)); + actor.setAkkaPort("2550"); + actor.setMember("member-" + (ndx + 1)); + actor.setUp(true); + actor.setUnreachable(false); + + map.put(actor.getNode(), actor); + } + return map; + } + + @Test + public void getAdminHealthFaulty() { + stubFor(get(urlEqualTo("/adm/healthcheck")).willReturn(aResponse().withStatus(500))); + AdminHealth health = resolver.getAdminHealth(); + assertNotNull(health); + assertEquals(500, health.getStatusCode()); + assertEquals(Health.FAULTY, health.getHealth()); + } + + @Test + public void getAdminHealthHealthy() { + stubFor(get(urlEqualTo("/adm/healthcheck")).willReturn(aResponse().withStatus(200))); + AdminHealth health = resolver.getAdminHealth(); + assertNotNull(health); + assertEquals(200, health.getStatusCode()); + assertEquals(Health.HEALTHY, health.getHealth()); + } + + @Test + public void getDatabaseHealth() { + try { + when(connection.isReadOnly()).thenReturn(false); + when(connection.isClosed()).thenReturn(false); + when(dbLibService.isActive()).thenReturn(true); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + DatabaseHealth health = resolver.getDatabaseHealth(); + assertEquals(Health.HEALTHY, health.getHealth()); + } + + @Test + public void getDatabaseHealthFaulty() { + try { + when(connection.isReadOnly()).thenReturn(true); + when(connection.isClosed()).thenReturn(true); + when(dbLibService.isActive()).thenReturn(false); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + DatabaseHealth health = resolver.getDatabaseHealth(); + assertEquals(Health.FAULTY, health.getHealth()); + } + + @Test + public void getDatabaseHealthException() { + try { + when(connection.isReadOnly()).thenThrow(new SQLException()); + when(connection.isClosed()).thenReturn(true); + when(dbLibService.isActive()).thenReturn(false); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + DatabaseHealth health = resolver.getDatabaseHealth(); + assertEquals(Health.FAULTY, health.getHealth()); + } + + @Test + public void siteIdentifier() { + assertEquals("TestODL", resolver.getSiteIdentifier()); + resolver.setSiteIdentifier("NewTestODL"); + assertEquals("NewTestODL", resolver.getSiteIdentifier()); + } + + @Test + public void getClusterHealth() { + stubController(); + ClusterHealth health = resolver.getClusterHealth(); + assertEquals(Health.HEALTHY, health.getHealth()); + } + + private void stubController() { + String clusterBody = null; + String shardManagerBody = null; + String shardDefaultBody = null; + String shardOperationalBody = null; + String componentBody = null; + String identifierBody = null; + try(Stream stream = Files.lines(Paths.get("src/test/resources/six/cluster.json"))) { + clusterBody = stream.collect(Collectors.joining()); + } catch(IOException e) { + fail(); + } + try(Stream stream = Files.lines(Paths.get("src/test/resources/six/shard-manager.json"))) { + shardManagerBody = stream.collect(Collectors.joining()); + } catch(IOException e) { + fail(); + } + try(Stream stream = Files.lines(Paths.get("src/test/resources/six/default-config.json"))) { + shardDefaultBody = stream.collect(Collectors.joining()); + } catch(IOException e) { + fail(); + } + try(Stream stream = Files.lines(Paths.get("src/test/resources/six/default-operational.json"))) { + shardOperationalBody = stream.collect(Collectors.joining()); + } catch(IOException e) { + fail(); + } + try(Stream stream = Files.lines(Paths.get("src/test/resources/six/component-health.json"))) { + componentBody = stream.collect(Collectors.joining()); + } catch(IOException e) { + fail(); + } + try(Stream stream = Files.lines(Paths.get("src/test/resources/six/site-identifier.json"))) { + identifierBody = stream.collect(Collectors.joining()); + } catch(IOException e) { + fail(); + } + + if(clusterBody == null || shardManagerBody == null || shardDefaultBody == null || shardOperationalBody == null + || componentBody == null || identifierBody == null) { + fail(); + } + stubFor(get(urlEqualTo("/jolokia/read/akka:type=Cluster")).willReturn(aResponse().withStatus(200).withBody(clusterBody))); + stubFor(get(urlEqualTo("/jolokia/read/org.opendaylight.controller:Category=ShardManager,name=shard-manager-config,type=DistributedConfigDatastore")).inScenario("testing").willReturn(aResponse().withStatus(200).withBody(shardManagerBody)).willSetStateTo("next")); + stubFor(get(urlEqualTo("/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-1-shard-default-config,type=DistributedConfigDatastore")).inScenario("testing").willReturn(aResponse().withStatus(200).withBody(shardDefaultBody)).willSetStateTo("next")); + stubFor(get(urlEqualTo("/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-1-shard-default-operational,type=DistributedOperationalDatastore")).willReturn(aResponse().withStatus(200).withBody(shardOperationalBody))); + stubFor(post(urlEqualTo("/restconf/operations/gr-toolkit:site-identifier")).willReturn(aResponse().withStatus(200).withBody(identifierBody))); + stubFor(post(urlEqualTo("/restconf/operations/gr-toolkit:admin-health")).inScenario("testing").willReturn(aResponse().withStatus(200).withBody(componentBody)).willSetStateTo("next")); + stubFor(post(urlEqualTo("/restconf/operations/gr-toolkit:database-health")).willReturn(aResponse().withStatus(200).withBody(componentBody))); + } + + @Test + public void getSiteHealth() { + stubController(); + stubFor(get(urlEqualTo("/adm/healthcheck")).willReturn(aResponse().withStatus(200))); + try { + when(connection.isReadOnly()).thenReturn(false); + when(connection.isClosed()).thenReturn(false); + when(dbLibService.isActive()).thenReturn(true); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + List health = resolver.getSiteHealth(); + assertNotNull(health); + assertNotEquals(0, health.size()); + assertEquals(2, health.size()); + assertEquals(Health.HEALTHY, health.get(0).getHealth()); + } + + @Test + public void getSiteHealthFaulty() { + stubController(); + stubFor(get(urlEqualTo("/adm/healthcheck")).willReturn(aResponse().withStatus(200))); + try { + when(connection.isReadOnly()).thenReturn(false); + when(connection.isClosed()).thenReturn(false); + when(dbLibService.isActive()).thenReturn(true); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + stubFor(get(urlEqualTo("/jolokia/read/org.opendaylight.controller:Category=ShardManager,name=shard-manager-config,type=DistributedConfigDatastore")).inScenario("testing").whenScenarioStateIs("next").willReturn(aResponse().withBodyFile("nonexistent"))); + List health = resolver.getSiteHealth(); + assertNotNull(health); + assertNotEquals(0, health.size()); + assertEquals(2, health.size()); + assertEquals(Health.FAULTY, health.get(0).getHealth()); + } + + @Test + public void getSiteHealthFaultyShard() { + stubController(); + stubFor(get(urlEqualTo("/adm/healthcheck")).willReturn(aResponse().withStatus(200))); + try { + when(connection.isReadOnly()).thenReturn(false); + when(connection.isClosed()).thenReturn(false); + when(dbLibService.isActive()).thenReturn(true); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + stubFor(get(urlEqualTo("/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-1-shard-default-config,type=DistributedConfigDatastore")).inScenario("testing").willReturn(aResponse().withBodyFile("nonexistent")).willSetStateTo("next")); + List health = resolver.getSiteHealth(); + assertNotNull(health); + assertNotEquals(0, health.size()); + assertEquals(2, health.size()); + assertEquals(Health.FAULTY, health.get(0).getHealth()); + } + + @Test + public void getSiteHealthFaultyCluster() { + stubController(); + stubFor(get(urlEqualTo("/adm/healthcheck")).willReturn(aResponse().withStatus(200))); + try { + when(connection.isReadOnly()).thenReturn(false); + when(connection.isClosed()).thenReturn(false); + when(dbLibService.isActive()).thenReturn(true); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + stubFor(get(urlEqualTo("/jolokia/read/akka:type=Cluster")).willReturn(aResponse().withStatus(200).withBodyFile("nonexistent"))); + List health = resolver.getSiteHealth(); + assertNotNull(health); + assertNotEquals(0, health.size()); + assertEquals(2, health.size()); + assertEquals(Health.FAULTY, health.get(0).getHealth()); + } + + @Test + public void getSiteHealthFaultyAdmin() { + stubController(); + stubFor(post(urlEqualTo("/restconf/operations/gr-toolkit:admin-health")).inScenario("testing").willReturn(aResponse().withBodyFile("nonexistent")).willSetStateTo("next")); + stubFor(get(urlEqualTo("/restconf/operations/gr-toolkit:admin-health")).inScenario("testing").whenScenarioStateIs("next").willReturn(aResponse().withBodyFile("nonexistent"))); + try { + when(connection.isReadOnly()).thenReturn(false); + when(connection.isClosed()).thenReturn(false); + when(dbLibService.isActive()).thenReturn(true); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + List health = resolver.getSiteHealth(); + assertNotNull(health); + assertNotEquals(0, health.size()); + assertEquals(2, health.size()); + assertEquals(Health.FAULTY, health.get(0).getHealth()); + assertEquals(Health.FAULTY, health.get(1).getHealth()); + } + + @Test + public void tryFailover() { + stubController(); + stubFor(get(urlEqualTo("/restconf/operations/cluster-admin:change-member-voting-states-for-all-shards")).willReturn(aResponse().withStatus(200))); + FailoverStatus status = resolver.tryFailover(null); + assertEquals(500, status.getStatusCode()); + } +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/ThreeNodeHealthResolverTest.java b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/ThreeNodeHealthResolverTest.java new file mode 100644 index 000000000..4ea07be43 --- /dev/null +++ b/grToolkit/provider/src/test/java/org/onap/ccsdk/sli/plugins/grtoolkit/resolver/ThreeNodeHealthResolverTest.java @@ -0,0 +1,314 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2019 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.grtoolkit.resolver; + +import com.github.tomakehurst.wiremock.junit.WireMockRule; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import org.onap.ccsdk.sli.core.dblib.DBLibConnection; +import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.AdminHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterActor; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.DatabaseHealth; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.FailoverStatus; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.Health; +import org.onap.ccsdk.sli.plugins.grtoolkit.data.SiteHealth; + +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; + +import static org.junit.Assert.*; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class ThreeNodeHealthResolverTest { + private Map memberMap; + private DbLibService dbLibService; + private DBLibConnection connection; + private ThreeNodeHealthResolver resolver; + + @Rule + public WireMockRule wireMockRule = new WireMockRule(9999); + + @Before + public void setUp() { + memberMap = generateMemberMap(3); + Properties properties = new Properties(); + try(FileInputStream fileInputStream = new FileInputStream("src/test/resources/three/gr-toolkit.properties")) { + properties.load(fileInputStream); + } catch(IOException e) { + fail(); + } + + dbLibService = mock(DbLibService.class); + connection = mock(DBLibConnection.class); + resolver = new ThreeNodeHealthResolver(memberMap, properties, dbLibService); + } + + private Map generateMemberMap(int memberCount) { + Map map = new HashMap<>(); + ClusterActor actor; + for(int ndx = 0; ndx < memberCount; ndx++) { + actor = new ClusterActor(); + actor.setNode("127.0.1." + (ndx + 1)); + actor.setAkkaPort("2550"); + actor.setMember("member-" + (ndx + 1)); + actor.setUp(true); + actor.setUnreachable(false); + + map.put(actor.getNode(), actor); + } + return map; + } + + @Test + public void getAdminHealthFaulty() { + stubFor(get(urlEqualTo("/adm/healthcheck")).willReturn(aResponse().withStatus(500))); + AdminHealth health = resolver.getAdminHealth(); + assertNotNull(health); + assertEquals(500, health.getStatusCode()); + assertEquals(Health.FAULTY, health.getHealth()); + } + + @Test + public void getAdminHealthHealthy() { + stubFor(get(urlEqualTo("/adm/healthcheck")).willReturn(aResponse().withStatus(200))); + AdminHealth health = resolver.getAdminHealth(); + assertNotNull(health); + assertEquals(200, health.getStatusCode()); + assertEquals(Health.HEALTHY, health.getHealth()); + } + + @Test + public void getDatabaseHealth() { + try { + when(connection.isReadOnly()).thenReturn(false); + when(connection.isClosed()).thenReturn(false); + when(dbLibService.isActive()).thenReturn(true); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + DatabaseHealth health = resolver.getDatabaseHealth(); + assertEquals(Health.HEALTHY, health.getHealth()); + } + + @Test + public void getDatabaseHealthFaulty() { + try { + when(connection.isReadOnly()).thenReturn(true); + when(connection.isClosed()).thenReturn(true); + when(dbLibService.isActive()).thenReturn(false); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + DatabaseHealth health = resolver.getDatabaseHealth(); + assertEquals(Health.FAULTY, health.getHealth()); + } + + @Test + public void getDatabaseHealthException() { + try { + when(connection.isReadOnly()).thenThrow(new SQLException()); + when(connection.isClosed()).thenReturn(true); + when(dbLibService.isActive()).thenReturn(false); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + DatabaseHealth health = resolver.getDatabaseHealth(); + assertEquals(Health.FAULTY, health.getHealth()); + } + + @Test + public void siteIdentifier() { + assertEquals("TestODL", resolver.getSiteIdentifier()); + resolver.setSiteIdentifier("NewTestODL"); + assertEquals("NewTestODL", resolver.getSiteIdentifier()); + } + + @Test + public void getClusterHealth() { + stubController(); + ClusterHealth health = resolver.getClusterHealth(); + assertEquals(Health.HEALTHY, health.getHealth()); + } + + private void stubController() { + String clusterBody = null; + String shardManagerBody = null; + String shardDefaultBody = null; + String shardOperationalBody = null; + try(Stream stream = Files.lines(Paths.get("src/test/resources/three/cluster.json"))) { + clusterBody = stream.collect(Collectors.joining()); + } catch(IOException e) { + fail(); + } + try(Stream stream = Files.lines(Paths.get("src/test/resources/three/shard-manager.json"))) { + shardManagerBody = stream.collect(Collectors.joining()); + } catch(IOException e) { + fail(); + } + try(Stream stream = Files.lines(Paths.get("src/test/resources/three/default-config.json"))) { + shardDefaultBody = stream.collect(Collectors.joining()); + } catch(IOException e) { + fail(); + } + try(Stream stream = Files.lines(Paths.get("src/test/resources/three/default-operational.json"))) { + shardOperationalBody = stream.collect(Collectors.joining()); + } catch(IOException e) { + fail(); + } + + if(clusterBody == null || shardManagerBody == null || shardDefaultBody == null || shardOperationalBody == null) { + fail(); + } + stubFor(get(urlEqualTo("/jolokia/read/akka:type=Cluster")).willReturn(aResponse().withStatus(200).withBody(clusterBody))); + stubFor(get(urlEqualTo("/jolokia/read/org.opendaylight.controller:Category=ShardManager,name=shard-manager-config,type=DistributedConfigDatastore")).inScenario("testing").willReturn(aResponse().withStatus(200).withBody(shardManagerBody)).willSetStateTo("next")); + stubFor(get(urlEqualTo("/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-1-shard-default-config,type=DistributedConfigDatastore")).inScenario("testing").willReturn(aResponse().withStatus(200).withBody(shardDefaultBody)).willSetStateTo("next")); + stubFor(get(urlEqualTo("/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-1-shard-default-operational,type=DistributedOperationalDatastore")).willReturn(aResponse().withStatus(200).withBody(shardOperationalBody))); + } + + @Test + public void getSiteHealth() { + stubController(); + stubFor(get(urlEqualTo("/adm/healthcheck")).willReturn(aResponse().withStatus(200))); + try { + when(connection.isReadOnly()).thenReturn(false); + when(connection.isClosed()).thenReturn(false); + when(dbLibService.isActive()).thenReturn(true); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + List health = resolver.getSiteHealth(); + assertNotNull(health); + assertNotEquals(0, health.size()); + assertEquals(1, health.size()); + assertEquals(Health.HEALTHY, health.get(0).getHealth()); + } + + @Test + public void getSiteHealthFaulty() { + stubController(); + stubFor(get(urlEqualTo("/adm/healthcheck")).willReturn(aResponse().withStatus(200))); + try { + when(connection.isReadOnly()).thenReturn(false); + when(connection.isClosed()).thenReturn(false); + when(dbLibService.isActive()).thenReturn(true); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + stubFor(get(urlEqualTo("/jolokia/read/org.opendaylight.controller:Category=ShardManager,name=shard-manager-config,type=DistributedConfigDatastore")).inScenario("testing").whenScenarioStateIs("next").willReturn(aResponse().withBodyFile("nonexistent"))); + List health = resolver.getSiteHealth(); + assertNotNull(health); + assertNotEquals(0, health.size()); + assertEquals(1, health.size()); + assertEquals(Health.FAULTY, health.get(0).getHealth()); + } + + @Test + public void getSiteHealthFaultyShard() { + stubController(); + stubFor(get(urlEqualTo("/adm/healthcheck")).willReturn(aResponse().withStatus(200))); + try { + when(connection.isReadOnly()).thenReturn(false); + when(connection.isClosed()).thenReturn(false); + when(dbLibService.isActive()).thenReturn(true); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + stubFor(get(urlEqualTo("/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-1-shard-default-config,type=DistributedConfigDatastore")).inScenario("testing").willReturn(aResponse().withBodyFile("nonexistent")).willSetStateTo("next")); + List health = resolver.getSiteHealth(); + assertNotNull(health); + assertNotEquals(0, health.size()); + assertEquals(1, health.size()); + assertEquals(Health.HEALTHY, health.get(0).getHealth()); + } + + @Test + public void getSiteHealthFaultyCluster() { + stubController(); + stubFor(get(urlEqualTo("/adm/healthcheck")).willReturn(aResponse().withStatus(200))); + try { + when(connection.isReadOnly()).thenReturn(false); + when(connection.isClosed()).thenReturn(false); + when(dbLibService.isActive()).thenReturn(true); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + stubFor(get(urlEqualTo("/jolokia/read/akka:type=Cluster")).willReturn(aResponse().withStatus(200).withBodyFile("nonexistent"))); + List health = resolver.getSiteHealth(); + assertNotNull(health); + assertNotEquals(0, health.size()); + assertEquals(1, health.size()); + assertEquals(Health.FAULTY, health.get(0).getHealth()); + } + + @Test + public void getSiteHealthFaultyAdmin() { + stubController(); + stubFor(get(urlEqualTo("/adm/healthcheck")).willReturn(aResponse().withStatus(400))); + try { + when(connection.isReadOnly()).thenReturn(false); + when(connection.isClosed()).thenReturn(false); + when(dbLibService.isActive()).thenReturn(true); + when(dbLibService.getConnection()).thenReturn(connection); + } catch(SQLException e) { + fail(); + } + List health = resolver.getSiteHealth(); + assertNotNull(health); + assertNotEquals(0, health.size()); + assertEquals(1, health.size()); + assertEquals(Health.FAULTY, health.get(0).getHealth()); + } + + @Test + public void tryFailover() { + FailoverStatus status = resolver.tryFailover(null); + assertEquals(400, status.getStatusCode()); + } +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/resources/akka.conf b/grToolkit/provider/src/test/resources/akka.conf index cbb73d548..ce46748ec 100644 --- a/grToolkit/provider/src/test/resources/akka.conf +++ b/grToolkit/provider/src/test/resources/akka.conf @@ -1,3 +1,21 @@ +# ============LICENSE_START======================================================= +# openECOMP : SDN-C +# ================================================================================ +# Copyright (C) 2019 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========================================================= odl-cluster-data { akka { @@ -20,7 +38,7 @@ odl-cluster-data { cluster { # Remove ".tcp" when using artery. - seed-nodes = ["akka.tcp://opendaylight-cluster-data@127.0.0.1:2550"] + seed-nodes = ["akka.tcp://opendaylight-cluster-data@127.0.1.1:2550"] roles = [ "member-1" diff --git a/grToolkit/provider/src/test/resources/akka6.conf b/grToolkit/provider/src/test/resources/akka6.conf deleted file mode 100644 index 358218d9c..000000000 --- a/grToolkit/provider/src/test/resources/akka6.conf +++ /dev/null @@ -1,49 +0,0 @@ - -odl-cluster-data { - akka { - remote { - artery { - enabled = off - canonical.hostname = "127.0.0.1" - canonical.port = 2550 - } - netty.tcp { - hostname = "127.0.0.1" - port = 2550 - } - # when under load we might trip a false positive on the failure detector - # transport-failure-detector { - # heartbeat-interval = 4 s - # acceptable-heartbeat-pause = 16s - # } - } - - cluster { - # Remove ".tcp" when using artery. - seed-nodes = ["akka.tcp://opendaylight-cluster-data@127.0.0.1:2550", "akka.tcp://opendaylight-cluster-data@127.0.0.2:2550", "akka.tcp://opendaylight-cluster-data@127.0.0.3:2550", "akka.tcp://opendaylight-cluster-data@127.0.0.4:2550", "akka.tcp://opendaylight-cluster-data@127.0.0.5:2550", "akka.tcp://opendaylight-cluster-data@127.0.0.6:2550"] - - roles = [ - "member-1" - ] - - } - - persistence { - # By default the snapshots/journal directories live in KARAF_HOME. You can choose to put it somewhere else by - # modifying the following two properties. The directory location specified may be a relative or absolute path. - # The relative path is always relative to KARAF_HOME. - - # snapshot-store.local.dir = "target/snapshots" - # journal.leveldb.dir = "target/journal" - - journal { - leveldb { - # Set native = off to use a Java-only implementation of leveldb. - # Note that the Java-only version is not currently considered by Akka to be production quality. - - # native = off - } - } - } - } -} diff --git a/grToolkit/provider/src/test/resources/gr-toolkit.properties b/grToolkit/provider/src/test/resources/gr-toolkit.properties index d9bc66dcd..52b19bf51 100755 --- a/grToolkit/provider/src/test/resources/gr-toolkit.properties +++ b/grToolkit/provider/src/test/resources/gr-toolkit.properties @@ -17,18 +17,19 @@ # limitations under the License. # ============LICENSE_END========================================================= +resolver=org.onap.ccsdk.sli.plugins.grtoolkit.resolver.SingleNodeHealthResolver akka.conf.location=src/test/resources/akka.conf adm.useSsl=false -adm.fqdn=wiki.onap.org -adm.healthcheck= -adm.port.http=80 -adm.port.ssl=443 +adm.fqdn=localhost +adm.healthcheck=/adm/healthcheck +adm.port.http=9999 +adm.port.ssl=19999 controller.credentials=admin:admin controller.useSsl=false -controller.port.http=8181 -controller.port.ssl=8443 +controller.port.http=9999 +controller.port.ssl=19999 controller.port.akka=2550 mbean.cluster=/jolokia/read/akka:type=Cluster mbean.shardManager=/jolokia/read/org.opendaylight.controller:Category=ShardManager,name=shard-manager-config,type=DistributedConfigDatastore mbean.shard.config=/jolokia/read/org.opendaylight.controller:Category=Shards,name=%s,type=DistributedConfigDatastore -site.identifier=TestODL +#site.identifier=TestODL diff --git a/grToolkit/provider/src/test/resources/single/akka.conf b/grToolkit/provider/src/test/resources/single/akka.conf new file mode 100644 index 000000000..ce46748ec --- /dev/null +++ b/grToolkit/provider/src/test/resources/single/akka.conf @@ -0,0 +1,67 @@ +# ============LICENSE_START======================================================= +# openECOMP : SDN-C +# ================================================================================ +# Copyright (C) 2019 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========================================================= + +odl-cluster-data { + akka { + remote { + artery { + enabled = off + canonical.hostname = "127.0.0.1" + canonical.port = 2550 + } + netty.tcp { + hostname = "127.0.0.1" + port = 2550 + } + # when under load we might trip a false positive on the failure detector + # transport-failure-detector { + # heartbeat-interval = 4 s + # acceptable-heartbeat-pause = 16s + # } + } + + cluster { + # Remove ".tcp" when using artery. + seed-nodes = ["akka.tcp://opendaylight-cluster-data@127.0.1.1:2550"] + + roles = [ + "member-1" + ] + + } + + persistence { + # By default the snapshots/journal directories live in KARAF_HOME. You can choose to put it somewhere else by + # modifying the following two properties. The directory location specified may be a relative or absolute path. + # The relative path is always relative to KARAF_HOME. + + # snapshot-store.local.dir = "target/snapshots" + # journal.leveldb.dir = "target/journal" + + journal { + leveldb { + # Set native = off to use a Java-only implementation of leveldb. + # Note that the Java-only version is not currently considered by Akka to be production quality. + + # native = off + } + } + } + } +} diff --git a/grToolkit/provider/src/test/resources/single/cluster.json b/grToolkit/provider/src/test/resources/single/cluster.json new file mode 100644 index 000000000..93360845f --- /dev/null +++ b/grToolkit/provider/src/test/resources/single/cluster.json @@ -0,0 +1,17 @@ +{ + "request": { + "mbean": "akka:type=Cluster", + "type": "read" + }, + "value": { + "Leader": "akka.tcp://opendaylight-cluster-data@localhost:2550", + "Unreachable": "", + "Singleton": true, + "Available": true, + "MemberStatus": "Up", + "ClusterStatus": "{\n \"members\": [\n {\n \"address\": \"akka.tcp://opendaylight-cluster-data@localhost:2550\",\n \"roles\": [\n \"dc-default\",\n \"member-1\"\n ],\n \"status\": \"Up\"\n }\n ],\n \"self-address\": \"akka.tcp://opendaylight-cluster-data@localhost:2550\",\n \"unreachable\": []\n}\n", + "Members": "akka.tcp://opendaylight-cluster-data@localhost:2550" + }, + "timestamp": 1575393881, + "status": 200 +} diff --git a/grToolkit/provider/src/test/resources/single/default-config.json b/grToolkit/provider/src/test/resources/single/default-config.json new file mode 100644 index 000000000..d75998e5d --- /dev/null +++ b/grToolkit/provider/src/test/resources/single/default-config.json @@ -0,0 +1,46 @@ +{ + "request": { + "mbean": "org.opendaylight.controller:Category=Shards,name=member-1-shard-default-config,type=DistributedConfigDatastore", + "type": "read" + }, + "value": { + "ReadWriteTransactionCount": 0, + "SnapshotIndex": 22, + "InMemoryJournalLogSize": 1, + "ReplicatedToAllIndex": -1, + "Leader": "member-1-shard-default-config", + "LastIndex": 23, + "RaftState": "Leader", + "LastCommittedTransactionTime": "2019-12-03 16:36:39.413", + "LastApplied": 23, + "PeerAddresses": "", + "LastLogIndex": 23, + "LastLeadershipChangeTime": "2019-12-03 16:36:33.460", + "WriteOnlyTransactionCount": 0, + "FollowerInitialSyncStatus": false, + "FollowerInfo": [], + "FailedReadTransactionsCount": 0, + "Voting": true, + "StatRetrievalTime": "454.8 μs", + "CurrentTerm": 4, + "LastTerm": 4, + "FailedTransactionsCount": 0, + "PendingTxCommitQueueSize": 0, + "VotedFor": "member-1-shard-default-config", + "SnapshotCaptureInitiated": false, + "CommittedTransactionsCount": 5, + "TxCohortCacheSize": 0, + "PeerVotingStates": "", + "LastLogTerm": 4, + "StatRetrievalError": null, + "CommitIndex": 23, + "SnapshotTerm": 4, + "AbortTransactionsCount": 0, + "ReadOnlyTransactionCount": 0, + "ShardName": "member-1-shard-default-config", + "LeadershipChangeCount": 1, + "InMemoryJournalDataSize": 37 + }, + "timestamp": 1575393787, + "status": 200 +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/resources/single/default-operational.json b/grToolkit/provider/src/test/resources/single/default-operational.json new file mode 100644 index 000000000..88a5d2c96 --- /dev/null +++ b/grToolkit/provider/src/test/resources/single/default-operational.json @@ -0,0 +1,46 @@ +{ + "request": { + "mbean": "org.opendaylight.controller:Category=Shards,name=member-1-shard-default-operational,type=DistributedOperationalDatastore", + "type": "read" + }, + "value": { + "ReadWriteTransactionCount": 0, + "SnapshotIndex": 22, + "InMemoryJournalLogSize": 1, + "ReplicatedToAllIndex": -1, + "Leader": "member-1-shard-default-operational", + "LastIndex": 23, + "RaftState": "Leader", + "LastCommittedTransactionTime": "2019-12-03 16:36:39.413", + "LastApplied": 23, + "PeerAddresses": "", + "LastLogIndex": 23, + "LastLeadershipChangeTime": "2019-12-03 16:36:33.460", + "WriteOnlyTransactionCount": 0, + "FollowerInitialSyncStatus": false, + "FollowerInfo": [], + "FailedReadTransactionsCount": 0, + "Voting": true, + "StatRetrievalTime": "454.8 μs", + "CurrentTerm": 4, + "LastTerm": 4, + "FailedTransactionsCount": 0, + "PendingTxCommitQueueSize": 0, + "VotedFor": "member-1-shard-default-operational", + "SnapshotCaptureInitiated": false, + "CommittedTransactionsCount": 5, + "TxCohortCacheSize": 0, + "PeerVotingStates": "", + "LastLogTerm": 4, + "StatRetrievalError": null, + "CommitIndex": 23, + "SnapshotTerm": 4, + "AbortTransactionsCount": 0, + "ReadOnlyTransactionCount": 0, + "ShardName": "member-1-shard-default-operational", + "LeadershipChangeCount": 1, + "InMemoryJournalDataSize": 37 + }, + "timestamp": 1575393787, + "status": 200 +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/resources/single/gr-toolkit.properties b/grToolkit/provider/src/test/resources/single/gr-toolkit.properties new file mode 100755 index 000000000..cc7820e90 --- /dev/null +++ b/grToolkit/provider/src/test/resources/single/gr-toolkit.properties @@ -0,0 +1,34 @@ +# ============LICENSE_START======================================================= +# openECOMP : SDN-C +# ================================================================================ +# Copyright (C) 2019 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========================================================= + +akka.conf.location=src/test/resources/single/akka.conf +adm.useSsl=false +adm.fqdn=localhost +adm.healthcheck=/adm/healthcheck +adm.port.http=9999 +adm.port.ssl=19999 +controller.credentials=admin:admin +controller.useSsl=false +controller.port.http=9999 +controller.port.ssl=19999 +controller.port.akka=2550 +mbean.cluster=/jolokia/read/akka:type=Cluster +mbean.shardManager=/jolokia/read/org.opendaylight.controller:Category=ShardManager,name=shard-manager-config,type=DistributedConfigDatastore +mbean.shard.config=/jolokia/read/org.opendaylight.controller:Category=Shards,name=%s,type=DistributedConfigDatastore +site.identifier=TestODL diff --git a/grToolkit/provider/src/test/resources/single/shard-manager.json b/grToolkit/provider/src/test/resources/single/shard-manager.json new file mode 100644 index 000000000..301184ef8 --- /dev/null +++ b/grToolkit/provider/src/test/resources/single/shard-manager.json @@ -0,0 +1,15 @@ +{ + "request": { + "mbean": "org.opendaylight.controller:Category=ShardManager,name=shard-manager-config,type=DistributedConfigDatastore", + "type": "read" + }, + "value": { + "LocalShards": [ + "member-1-shard-default-config" + ], + "SyncStatus": true, + "MemberName": "member-1" + }, + "timestamp": 1575393918, + "status": 200 +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/resources/six/akka.conf b/grToolkit/provider/src/test/resources/six/akka.conf new file mode 100644 index 000000000..9bda35d68 --- /dev/null +++ b/grToolkit/provider/src/test/resources/six/akka.conf @@ -0,0 +1,67 @@ +# ============LICENSE_START======================================================= +# openECOMP : SDN-C +# ================================================================================ +# Copyright (C) 2019 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========================================================= + +odl-cluster-data { + akka { + remote { + artery { + enabled = off + canonical.hostname = "127.0.0.1" + canonical.port = 2550 + } + netty.tcp { + hostname = "127.0.0.1" + port = 2550 + } + # when under load we might trip a false positive on the failure detector + # transport-failure-detector { + # heartbeat-interval = 4 s + # acceptable-heartbeat-pause = 16s + # } + } + + cluster { + # Remove ".tcp" when using artery. + seed-nodes = ["akka.tcp://opendaylight-cluster-data@127.0.0.1:2550", "akka.tcp://opendaylight-cluster-data@127.0.0.2:2550", "akka.tcp://opendaylight-cluster-data@127.0.0.3:2550", "akka.tcp://opendaylight-cluster-data@127.0.0.4:2550", "akka.tcp://opendaylight-cluster-data@127.0.0.5:2550", "akka.tcp://opendaylight-cluster-data@127.0.0.6:2550"] + + roles = [ + "member-1" + ] + + } + + persistence { + # By default the snapshots/journal directories live in KARAF_HOME. You can choose to put it somewhere else by + # modifying the following two properties. The directory location specified may be a relative or absolute path. + # The relative path is always relative to KARAF_HOME. + + # snapshot-store.local.dir = "target/snapshots" + # journal.leveldb.dir = "target/journal" + + journal { + leveldb { + # Set native = off to use a Java-only implementation of leveldb. + # Note that the Java-only version is not currently considered by Akka to be production quality. + + # native = off + } + } + } + } +} diff --git a/grToolkit/provider/src/test/resources/six/cluster.json b/grToolkit/provider/src/test/resources/six/cluster.json new file mode 100644 index 000000000..d6a54c8c8 --- /dev/null +++ b/grToolkit/provider/src/test/resources/six/cluster.json @@ -0,0 +1,17 @@ +{ + "request": { + "mbean": "akka:type=Cluster", + "type": "read" + }, + "value": { + "Leader": "akka.tcp://opendaylight-cluster-data@localhost:2550", + "Unreachable": "", + "Singleton": true, + "Available": true, + "MemberStatus": "Up", + "ClusterStatus": "{\n \"members\": [\n {\n \"address\": \"akka.tcp://opendaylight-cluster-data@localhost:2550\",\n \"roles\": [\n \"dc-default\",\n \"member-1\"\n ],\n \"status\": \"Up\"\n },\n {\n \"address\": \"akka.tcp://opendaylight-cluster-data@localhost:2550\",\n \"roles\": [\n \"dc-default\",\n \"member-2\"\n ],\n \"status\": \"Up\"\n },\n {\n \"address\": \"akka.tcp://opendaylight-cluster-data@localhost:2550\",\n \"roles\": [\n \"dc-default\",\n \"member-3\"\n ],\n \"status\": \"Up\"\n }\n ],\n \"self-address\": \"akka.tcp://opendaylight-cluster-data@localhost:2550\",\n \"unreachable\": []\n}\n", + "Members": "akka.tcp://opendaylight-cluster-data@localhost:2550" + }, + "timestamp": 1575393881, + "status": 200 +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/resources/six/component-health.json b/grToolkit/provider/src/test/resources/six/component-health.json new file mode 100644 index 000000000..1ca01da42 --- /dev/null +++ b/grToolkit/provider/src/test/resources/six/component-health.json @@ -0,0 +1,7 @@ +{ + "output": { + "status": "200", + "served-by": "member-2", + "health": "HEALTHY" + } +} diff --git a/grToolkit/provider/src/test/resources/six/default-config.json b/grToolkit/provider/src/test/resources/six/default-config.json new file mode 100644 index 000000000..d75998e5d --- /dev/null +++ b/grToolkit/provider/src/test/resources/six/default-config.json @@ -0,0 +1,46 @@ +{ + "request": { + "mbean": "org.opendaylight.controller:Category=Shards,name=member-1-shard-default-config,type=DistributedConfigDatastore", + "type": "read" + }, + "value": { + "ReadWriteTransactionCount": 0, + "SnapshotIndex": 22, + "InMemoryJournalLogSize": 1, + "ReplicatedToAllIndex": -1, + "Leader": "member-1-shard-default-config", + "LastIndex": 23, + "RaftState": "Leader", + "LastCommittedTransactionTime": "2019-12-03 16:36:39.413", + "LastApplied": 23, + "PeerAddresses": "", + "LastLogIndex": 23, + "LastLeadershipChangeTime": "2019-12-03 16:36:33.460", + "WriteOnlyTransactionCount": 0, + "FollowerInitialSyncStatus": false, + "FollowerInfo": [], + "FailedReadTransactionsCount": 0, + "Voting": true, + "StatRetrievalTime": "454.8 μs", + "CurrentTerm": 4, + "LastTerm": 4, + "FailedTransactionsCount": 0, + "PendingTxCommitQueueSize": 0, + "VotedFor": "member-1-shard-default-config", + "SnapshotCaptureInitiated": false, + "CommittedTransactionsCount": 5, + "TxCohortCacheSize": 0, + "PeerVotingStates": "", + "LastLogTerm": 4, + "StatRetrievalError": null, + "CommitIndex": 23, + "SnapshotTerm": 4, + "AbortTransactionsCount": 0, + "ReadOnlyTransactionCount": 0, + "ShardName": "member-1-shard-default-config", + "LeadershipChangeCount": 1, + "InMemoryJournalDataSize": 37 + }, + "timestamp": 1575393787, + "status": 200 +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/resources/six/default-operational.json b/grToolkit/provider/src/test/resources/six/default-operational.json new file mode 100644 index 000000000..88a5d2c96 --- /dev/null +++ b/grToolkit/provider/src/test/resources/six/default-operational.json @@ -0,0 +1,46 @@ +{ + "request": { + "mbean": "org.opendaylight.controller:Category=Shards,name=member-1-shard-default-operational,type=DistributedOperationalDatastore", + "type": "read" + }, + "value": { + "ReadWriteTransactionCount": 0, + "SnapshotIndex": 22, + "InMemoryJournalLogSize": 1, + "ReplicatedToAllIndex": -1, + "Leader": "member-1-shard-default-operational", + "LastIndex": 23, + "RaftState": "Leader", + "LastCommittedTransactionTime": "2019-12-03 16:36:39.413", + "LastApplied": 23, + "PeerAddresses": "", + "LastLogIndex": 23, + "LastLeadershipChangeTime": "2019-12-03 16:36:33.460", + "WriteOnlyTransactionCount": 0, + "FollowerInitialSyncStatus": false, + "FollowerInfo": [], + "FailedReadTransactionsCount": 0, + "Voting": true, + "StatRetrievalTime": "454.8 μs", + "CurrentTerm": 4, + "LastTerm": 4, + "FailedTransactionsCount": 0, + "PendingTxCommitQueueSize": 0, + "VotedFor": "member-1-shard-default-operational", + "SnapshotCaptureInitiated": false, + "CommittedTransactionsCount": 5, + "TxCohortCacheSize": 0, + "PeerVotingStates": "", + "LastLogTerm": 4, + "StatRetrievalError": null, + "CommitIndex": 23, + "SnapshotTerm": 4, + "AbortTransactionsCount": 0, + "ReadOnlyTransactionCount": 0, + "ShardName": "member-1-shard-default-operational", + "LeadershipChangeCount": 1, + "InMemoryJournalDataSize": 37 + }, + "timestamp": 1575393787, + "status": 200 +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/resources/six/gr-toolkit.properties b/grToolkit/provider/src/test/resources/six/gr-toolkit.properties new file mode 100755 index 000000000..54c9af742 --- /dev/null +++ b/grToolkit/provider/src/test/resources/six/gr-toolkit.properties @@ -0,0 +1,34 @@ +# ============LICENSE_START======================================================= +# openECOMP : SDN-C +# ================================================================================ +# Copyright (C) 2019 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========================================================= + +akka.conf.location=src/test/resources/six/akka.conf +adm.useSsl=false +adm.fqdn=localhost +adm.healthcheck=/adm/healthcheck +adm.port.http=9999 +adm.port.ssl=19999 +controller.credentials=admin:admin +controller.useSsl=false +controller.port.http=9999 +controller.port.ssl=19999 +controller.port.akka=2550 +mbean.cluster=/jolokia/read/akka:type=Cluster +mbean.shardManager=/jolokia/read/org.opendaylight.controller:Category=ShardManager,name=shard-manager-config,type=DistributedConfigDatastore +mbean.shard.config=/jolokia/read/org.opendaylight.controller:Category=Shards,name=%s,type=DistributedConfigDatastore +site.identifier=TestODL diff --git a/grToolkit/provider/src/test/resources/six/shard-manager.json b/grToolkit/provider/src/test/resources/six/shard-manager.json new file mode 100644 index 000000000..301184ef8 --- /dev/null +++ b/grToolkit/provider/src/test/resources/six/shard-manager.json @@ -0,0 +1,15 @@ +{ + "request": { + "mbean": "org.opendaylight.controller:Category=ShardManager,name=shard-manager-config,type=DistributedConfigDatastore", + "type": "read" + }, + "value": { + "LocalShards": [ + "member-1-shard-default-config" + ], + "SyncStatus": true, + "MemberName": "member-1" + }, + "timestamp": 1575393918, + "status": 200 +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/resources/six/site-identifier.json b/grToolkit/provider/src/test/resources/six/site-identifier.json new file mode 100644 index 000000000..7599ceb15 --- /dev/null +++ b/grToolkit/provider/src/test/resources/six/site-identifier.json @@ -0,0 +1,7 @@ +{ + "output": { + "status": "200", + "id": "test-site", + "served-by": "member-1" + } +} diff --git a/grToolkit/provider/src/test/resources/three/akka.conf b/grToolkit/provider/src/test/resources/three/akka.conf new file mode 100644 index 000000000..a6c151dd1 --- /dev/null +++ b/grToolkit/provider/src/test/resources/three/akka.conf @@ -0,0 +1,67 @@ +# ============LICENSE_START======================================================= +# openECOMP : SDN-C +# ================================================================================ +# Copyright (C) 2019 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========================================================= + +odl-cluster-data { + akka { + remote { + artery { + enabled = off + canonical.hostname = "127.0.0.1" + canonical.port = 2550 + } + netty.tcp { + hostname = "127.0.0.1" + port = 2550 + } + # when under load we might trip a false positive on the failure detector + # transport-failure-detector { + # heartbeat-interval = 4 s + # acceptable-heartbeat-pause = 16s + # } + } + + cluster { + # Remove ".tcp" when using artery. + seed-nodes = ["akka.tcp://opendaylight-cluster-data@127.0.0.1:2550", "akka.tcp://opendaylight-cluster-data@127.0.0.2:2550", "akka.tcp://opendaylight-cluster-data@127.0.0.3:2550"] + + roles = [ + "member-1" + ] + + } + + persistence { + # By default the snapshots/journal directories live in KARAF_HOME. You can choose to put it somewhere else by + # modifying the following two properties. The directory location specified may be a relative or absolute path. + # The relative path is always relative to KARAF_HOME. + + # snapshot-store.local.dir = "target/snapshots" + # journal.leveldb.dir = "target/journal" + + journal { + leveldb { + # Set native = off to use a Java-only implementation of leveldb. + # Note that the Java-only version is not currently considered by Akka to be production quality. + + # native = off + } + } + } + } +} diff --git a/grToolkit/provider/src/test/resources/three/cluster.json b/grToolkit/provider/src/test/resources/three/cluster.json new file mode 100644 index 000000000..d6a54c8c8 --- /dev/null +++ b/grToolkit/provider/src/test/resources/three/cluster.json @@ -0,0 +1,17 @@ +{ + "request": { + "mbean": "akka:type=Cluster", + "type": "read" + }, + "value": { + "Leader": "akka.tcp://opendaylight-cluster-data@localhost:2550", + "Unreachable": "", + "Singleton": true, + "Available": true, + "MemberStatus": "Up", + "ClusterStatus": "{\n \"members\": [\n {\n \"address\": \"akka.tcp://opendaylight-cluster-data@localhost:2550\",\n \"roles\": [\n \"dc-default\",\n \"member-1\"\n ],\n \"status\": \"Up\"\n },\n {\n \"address\": \"akka.tcp://opendaylight-cluster-data@localhost:2550\",\n \"roles\": [\n \"dc-default\",\n \"member-2\"\n ],\n \"status\": \"Up\"\n },\n {\n \"address\": \"akka.tcp://opendaylight-cluster-data@localhost:2550\",\n \"roles\": [\n \"dc-default\",\n \"member-3\"\n ],\n \"status\": \"Up\"\n }\n ],\n \"self-address\": \"akka.tcp://opendaylight-cluster-data@localhost:2550\",\n \"unreachable\": []\n}\n", + "Members": "akka.tcp://opendaylight-cluster-data@localhost:2550" + }, + "timestamp": 1575393881, + "status": 200 +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/resources/three/default-config.json b/grToolkit/provider/src/test/resources/three/default-config.json new file mode 100644 index 000000000..d75998e5d --- /dev/null +++ b/grToolkit/provider/src/test/resources/three/default-config.json @@ -0,0 +1,46 @@ +{ + "request": { + "mbean": "org.opendaylight.controller:Category=Shards,name=member-1-shard-default-config,type=DistributedConfigDatastore", + "type": "read" + }, + "value": { + "ReadWriteTransactionCount": 0, + "SnapshotIndex": 22, + "InMemoryJournalLogSize": 1, + "ReplicatedToAllIndex": -1, + "Leader": "member-1-shard-default-config", + "LastIndex": 23, + "RaftState": "Leader", + "LastCommittedTransactionTime": "2019-12-03 16:36:39.413", + "LastApplied": 23, + "PeerAddresses": "", + "LastLogIndex": 23, + "LastLeadershipChangeTime": "2019-12-03 16:36:33.460", + "WriteOnlyTransactionCount": 0, + "FollowerInitialSyncStatus": false, + "FollowerInfo": [], + "FailedReadTransactionsCount": 0, + "Voting": true, + "StatRetrievalTime": "454.8 μs", + "CurrentTerm": 4, + "LastTerm": 4, + "FailedTransactionsCount": 0, + "PendingTxCommitQueueSize": 0, + "VotedFor": "member-1-shard-default-config", + "SnapshotCaptureInitiated": false, + "CommittedTransactionsCount": 5, + "TxCohortCacheSize": 0, + "PeerVotingStates": "", + "LastLogTerm": 4, + "StatRetrievalError": null, + "CommitIndex": 23, + "SnapshotTerm": 4, + "AbortTransactionsCount": 0, + "ReadOnlyTransactionCount": 0, + "ShardName": "member-1-shard-default-config", + "LeadershipChangeCount": 1, + "InMemoryJournalDataSize": 37 + }, + "timestamp": 1575393787, + "status": 200 +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/resources/three/default-operational.json b/grToolkit/provider/src/test/resources/three/default-operational.json new file mode 100644 index 000000000..88a5d2c96 --- /dev/null +++ b/grToolkit/provider/src/test/resources/three/default-operational.json @@ -0,0 +1,46 @@ +{ + "request": { + "mbean": "org.opendaylight.controller:Category=Shards,name=member-1-shard-default-operational,type=DistributedOperationalDatastore", + "type": "read" + }, + "value": { + "ReadWriteTransactionCount": 0, + "SnapshotIndex": 22, + "InMemoryJournalLogSize": 1, + "ReplicatedToAllIndex": -1, + "Leader": "member-1-shard-default-operational", + "LastIndex": 23, + "RaftState": "Leader", + "LastCommittedTransactionTime": "2019-12-03 16:36:39.413", + "LastApplied": 23, + "PeerAddresses": "", + "LastLogIndex": 23, + "LastLeadershipChangeTime": "2019-12-03 16:36:33.460", + "WriteOnlyTransactionCount": 0, + "FollowerInitialSyncStatus": false, + "FollowerInfo": [], + "FailedReadTransactionsCount": 0, + "Voting": true, + "StatRetrievalTime": "454.8 μs", + "CurrentTerm": 4, + "LastTerm": 4, + "FailedTransactionsCount": 0, + "PendingTxCommitQueueSize": 0, + "VotedFor": "member-1-shard-default-operational", + "SnapshotCaptureInitiated": false, + "CommittedTransactionsCount": 5, + "TxCohortCacheSize": 0, + "PeerVotingStates": "", + "LastLogTerm": 4, + "StatRetrievalError": null, + "CommitIndex": 23, + "SnapshotTerm": 4, + "AbortTransactionsCount": 0, + "ReadOnlyTransactionCount": 0, + "ShardName": "member-1-shard-default-operational", + "LeadershipChangeCount": 1, + "InMemoryJournalDataSize": 37 + }, + "timestamp": 1575393787, + "status": 200 +} \ No newline at end of file diff --git a/grToolkit/provider/src/test/resources/three/gr-toolkit.properties b/grToolkit/provider/src/test/resources/three/gr-toolkit.properties new file mode 100755 index 000000000..cc7820e90 --- /dev/null +++ b/grToolkit/provider/src/test/resources/three/gr-toolkit.properties @@ -0,0 +1,34 @@ +# ============LICENSE_START======================================================= +# openECOMP : SDN-C +# ================================================================================ +# Copyright (C) 2019 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========================================================= + +akka.conf.location=src/test/resources/single/akka.conf +adm.useSsl=false +adm.fqdn=localhost +adm.healthcheck=/adm/healthcheck +adm.port.http=9999 +adm.port.ssl=19999 +controller.credentials=admin:admin +controller.useSsl=false +controller.port.http=9999 +controller.port.ssl=19999 +controller.port.akka=2550 +mbean.cluster=/jolokia/read/akka:type=Cluster +mbean.shardManager=/jolokia/read/org.opendaylight.controller:Category=ShardManager,name=shard-manager-config,type=DistributedConfigDatastore +mbean.shard.config=/jolokia/read/org.opendaylight.controller:Category=Shards,name=%s,type=DistributedConfigDatastore +site.identifier=TestODL diff --git a/grToolkit/provider/src/test/resources/three/shard-manager.json b/grToolkit/provider/src/test/resources/three/shard-manager.json new file mode 100644 index 000000000..301184ef8 --- /dev/null +++ b/grToolkit/provider/src/test/resources/three/shard-manager.json @@ -0,0 +1,15 @@ +{ + "request": { + "mbean": "org.opendaylight.controller:Category=ShardManager,name=shard-manager-config,type=DistributedConfigDatastore", + "type": "read" + }, + "value": { + "LocalShards": [ + "member-1-shard-default-config" + ], + "SyncStatus": true, + "MemberName": "member-1" + }, + "timestamp": 1575393918, + "status": 200 +} \ No newline at end of file -- cgit From 3e8b55b9d3841c175776d84d54edf2a284f1f4b5 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 11 Dec 2019 09:52:18 -0500 Subject: Generate dependency list Generate list of direct dependencies for repository and publish to Nexus. Change-Id: I05820144bab2820cb00d8796f361d16172069eaa Issue-ID: CCSDK-1986 Signed-off-by: Timoney, Dan (dt5972) --- .gitignore | 3 +++ pom.xml | 47 +++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index fabe495f5..405446e78 100755 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,6 @@ provider/src/main/java/inventory/ sdnc-plugins_bdio.jsonld blackDuckHubProjectName.txt blackDuckHubProjectVersionName.txt + +#Generated dependencies list +direct-dependencies.txt diff --git a/pom.xml b/pom.xml index abdba44b2..08d7ea2d6 100755 --- a/pom.xml +++ b/pom.xml @@ -95,11 +95,50 @@ - - - - + + dependency-list + + + + com.github.ferstl + depgraph-maven-plugin + + + validate + false + + aggregate + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + package + false + + attach-artifact + + + + + ${dependency-list.file} + txt + dependencies + + + + + + + + + -- cgit From dffc1fd635470b0fc0e940f78e69d8f0ab0d14f0 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 12 Dec 2019 14:08:33 -0500 Subject: Refactor karaf features into single module Refactor karaf features installation into a single installation bundle instead of embedding in each module's installer. Change-Id: I281973c5d6fda5eeb0483cf9e6d058b8a4992ed3 Issue-ID: CCSDK-1754 Signed-off-by: Timoney, Dan (dt5972) --- features/ccsdk-gr-toolkit/pom.xml | 37 ++++++++++ features/ccsdk-properties-node/pom.xml | 30 ++++++++ features/ccsdk-restapi-call-node/pom.xml | 39 +++++++++++ features/ccsdk-restconf-client/pom.xml | 35 ++++++++++ features/ccsdk-sshapi-call-node/pom.xml | 42 ++++++++++++ features/ccsdk-template-node/pom.xml | 27 ++++++++ features/features-sli-plugins/pom.xml | 39 +++++++++++ features/installer/pom.xml | 79 +++++++++++++++++++++- features/pom.xml | 6 ++ grToolkit/features/.gitignore | 2 - grToolkit/features/ccsdk-gr-toolkit/pom.xml | 37 ---------- grToolkit/features/features-gr-toolkit/pom.xml | 29 -------- grToolkit/features/pom.xml | 21 ------ grToolkit/installer/pom.xml | 13 ---- grToolkit/pom.xml | 8 --- .../features/ccsdk-properties-node/pom.xml | 30 -------- .../features/features-properties-node/pom.xml | 29 -------- properties-node/features/pom.xml | 22 ------ properties-node/installer/pom.xml | 14 ---- properties-node/pom.xml | 1 - .../features/ccsdk-restapi-call-node/pom.xml | 39 ----------- .../features/features-restapi-call-node/pom.xml | 29 -------- restapi-call-node/features/pom.xml | 22 ------ restapi-call-node/installer/pom.xml | 15 ---- restapi-call-node/pom.xml | 1 - .../features/ccsdk-restconf-client/pom.xml | 35 ---------- .../features/features-restconf-client/pom.xml | 29 -------- restconf-client/features/pom.xml | 22 ------ restconf-client/installer/pom.xml | 14 ---- restconf-client/pom.xml | 1 - .../features/ccsdk-sshapi-call-node/pom.xml | 42 ------------ .../features/features-sshapi-call-node/pom.xml | 29 -------- sshapi-call-node/features/pom.xml | 22 ------ sshapi-call-node/installer/pom.xml | 14 ---- sshapi-call-node/pom.xml | 1 - template-node/features/ccsdk-template-node/pom.xml | 27 -------- .../features/features-template-node/pom.xml | 27 -------- template-node/features/pom.xml | 20 ------ template-node/installer/pom.xml | 13 ---- template-node/pom.xml | 1 - 40 files changed, 333 insertions(+), 610 deletions(-) create mode 100644 features/ccsdk-gr-toolkit/pom.xml create mode 100644 features/ccsdk-properties-node/pom.xml create mode 100644 features/ccsdk-restapi-call-node/pom.xml create mode 100644 features/ccsdk-restconf-client/pom.xml create mode 100644 features/ccsdk-sshapi-call-node/pom.xml create mode 100644 features/ccsdk-template-node/pom.xml delete mode 100755 grToolkit/features/.gitignore delete mode 100644 grToolkit/features/ccsdk-gr-toolkit/pom.xml delete mode 100755 grToolkit/features/features-gr-toolkit/pom.xml delete mode 100755 grToolkit/features/pom.xml delete mode 100644 properties-node/features/ccsdk-properties-node/pom.xml delete mode 100644 properties-node/features/features-properties-node/pom.xml delete mode 100755 properties-node/features/pom.xml delete mode 100644 restapi-call-node/features/ccsdk-restapi-call-node/pom.xml delete mode 100644 restapi-call-node/features/features-restapi-call-node/pom.xml delete mode 100755 restapi-call-node/features/pom.xml delete mode 100644 restconf-client/features/ccsdk-restconf-client/pom.xml delete mode 100644 restconf-client/features/features-restconf-client/pom.xml delete mode 100755 restconf-client/features/pom.xml delete mode 100644 sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml delete mode 100644 sshapi-call-node/features/features-sshapi-call-node/pom.xml delete mode 100755 sshapi-call-node/features/pom.xml delete mode 100644 template-node/features/ccsdk-template-node/pom.xml delete mode 100644 template-node/features/features-template-node/pom.xml delete mode 100644 template-node/features/pom.xml diff --git a/features/ccsdk-gr-toolkit/pom.xml b/features/ccsdk-gr-toolkit/pom.xml new file mode 100644 index 000000000..1ac3f96b3 --- /dev/null +++ b/features/ccsdk-gr-toolkit/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.5.1-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + ccsdk-gr-toolkit + 0.7.0-SNAPSHOT + feature + + ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} + + + + org.opendaylight.controller + odl-mdsal-broker + xml + features + + + ${project.groupId} + gr-toolkit-model + ${project.version} + + + ${project.groupId} + gr-toolkit-provider + ${project.version} + + + diff --git a/features/ccsdk-properties-node/pom.xml b/features/ccsdk-properties-node/pom.xml new file mode 100644 index 000000000..9cdee255b --- /dev/null +++ b/features/ccsdk-properties-node/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.5.1-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + ccsdk-properties-node + 0.7.0-SNAPSHOT + feature + + ccsdk-sli-plugins :: properties-node :: ${project.artifactId} + + + + + + + ${project.groupId} + properties-node-provider + ${project.version} + + + + diff --git a/features/ccsdk-restapi-call-node/pom.xml b/features/ccsdk-restapi-call-node/pom.xml new file mode 100644 index 000000000..1347c7a99 --- /dev/null +++ b/features/ccsdk-restapi-call-node/pom.xml @@ -0,0 +1,39 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.5.1-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + ccsdk-restapi-call-node + 0.7.0-SNAPSHOT + feature + + ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} + + + + + javax.ws.rs + javax.ws.rs-api + + + + ${project.groupId} + restapi-call-node-provider + ${project.version} + + + + org.onap.logging-analytics + logging-filter-base + + + + + diff --git a/features/ccsdk-restconf-client/pom.xml b/features/ccsdk-restconf-client/pom.xml new file mode 100644 index 000000000..70c75b92e --- /dev/null +++ b/features/ccsdk-restconf-client/pom.xml @@ -0,0 +1,35 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.5.1-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + ccsdk-restconf-client + 0.7.0-SNAPSHOT + feature + + + true + + + ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} + + + + + + + + + ${project.groupId} + restconf-client-provider + ${project.version} + + + diff --git a/features/ccsdk-sshapi-call-node/pom.xml b/features/ccsdk-sshapi-call-node/pom.xml new file mode 100644 index 000000000..838405be6 --- /dev/null +++ b/features/ccsdk-sshapi-call-node/pom.xml @@ -0,0 +1,42 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.5.1-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + ccsdk-sshapi-call-node + 0.7.0-SNAPSHOT + feature + + ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} + + + + + diff --git a/features/ccsdk-template-node/pom.xml b/features/ccsdk-template-node/pom.xml new file mode 100644 index 000000000..7f4c16925 --- /dev/null +++ b/features/ccsdk-template-node/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.5.1-SNAPSHOT + + + + org.onap.ccsdk.sli.plugins + ccsdk-template-node + 0.7.0-SNAPSHOT + feature + + ccsdk-sli-plugins :: template-node :: ${project.artifactId} + + + + + ${project.groupId} + template-node-provider + ${project.version} + + + diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index 1e82332bd..4f8cd5c19 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -17,6 +17,45 @@ ccsdk-sli-plugins :: features :: ${project.artifactId} + + org.onap.ccsdk.sli.plugins + ccsdk-gr-toolkit + ${project.version} + xml + features + + + * + * + + + + + org.onap.ccsdk.sli.plugins + ccsdk-properties-node + ${project.version} + xml + features + + + * + * + + + + + org.onap.ccsdk.sli.plugins + ccsdk-restapi-call-node + ${project.version} + xml + features + + + * + * + + + ${project.groupId} ccsdk-sli-plugins-all diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 70393eb81..686eb812c 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -24,7 +24,84 @@ - + + org.onap.ccsdk.sli.plugins + ccsdk-gr-toolkit + ${project.version} + xml + features + + + * + * + + + + + org.onap.ccsdk.sli.plugins + ccsdk-properties-node + ${project.version} + xml + features + + + * + * + + + + + org.onap.ccsdk.sli.plugins + ccsdk-restapi-call-node + ${project.version} + xml + features + + + * + * + + + + + org.onap.ccsdk.sli.plugins + ccsdk-restconf-client + ${project.version} + xml + features + + + * + * + + + + + org.onap.ccsdk.sli.plugins + ccsdk-sshapi-call-node + ${project.version} + xml + features + + + * + * + + + + + org.onap.ccsdk.sli.plugins + ccsdk-template-node + ${project.version} + xml + features + + + * + * + + + org.onap.ccsdk.sli.plugins ${application.name} diff --git a/features/pom.xml b/features/pom.xml index 59f2e3299..7f8bb9122 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -17,6 +17,12 @@ ccsdk-sli-plugins :: features + ccsdk-gr-toolkit + ccsdk-properties-node + ccsdk-restapi-call-node + ccsdk-restconf-client + ccsdk-sshapi-call-node + ccsdk-template-node ccsdk-sli-plugins-all features-sli-plugins installer diff --git a/grToolkit/features/.gitignore b/grToolkit/features/.gitignore deleted file mode 100755 index 05a0d25f8..000000000 --- a/grToolkit/features/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target-ide/ -/bin/ diff --git a/grToolkit/features/ccsdk-gr-toolkit/pom.xml b/grToolkit/features/ccsdk-gr-toolkit/pom.xml deleted file mode 100644 index 1ac3f96b3..000000000 --- a/grToolkit/features/ccsdk-gr-toolkit/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - ccsdk-gr-toolkit - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} - - - - org.opendaylight.controller - odl-mdsal-broker - xml - features - - - ${project.groupId} - gr-toolkit-model - ${project.version} - - - ${project.groupId} - gr-toolkit-provider - ${project.version} - - - diff --git a/grToolkit/features/features-gr-toolkit/pom.xml b/grToolkit/features/features-gr-toolkit/pom.xml deleted file mode 100755 index f19e2d8e1..000000000 --- a/grToolkit/features/features-gr-toolkit/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - feature-repo-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - features-gr-toolkit - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} - - - - ${project.groupId} - ccsdk-gr-toolkit - ${project.version} - xml - features - - - - diff --git a/grToolkit/features/pom.xml b/grToolkit/features/pom.xml deleted file mode 100755 index 8a351ca90..000000000 --- a/grToolkit/features/pom.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - 4.0.0 - - org.onap.ccsdk.parent - odlparent-lite - 1.5.1-SNAPSHOT - - - - ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} - gr-toolkit-features - org.onap.ccsdk.sli.plugins - 0.7.0-SNAPSHOT - pom - - - ccsdk-gr-toolkit - features-gr-toolkit - - diff --git a/grToolkit/installer/pom.xml b/grToolkit/installer/pom.xml index 8830fdc4b..6350e2653 100755 --- a/grToolkit/installer/pom.xml +++ b/grToolkit/installer/pom.xml @@ -20,19 +20,6 @@ false - - org.onap.ccsdk.sli.plugins - ${application.name} - ${project.version} - xml - features - - - * - * - - - org.onap.ccsdk.sli.plugins gr-toolkit-provider diff --git a/grToolkit/pom.xml b/grToolkit/pom.xml index 770c40b33..4102c8caa 100755 --- a/grToolkit/pom.xml +++ b/grToolkit/pom.xml @@ -19,20 +19,12 @@ model - features installer provider - - org.onap.ccsdk.sli.plugins - gr-toolkit-features - features - xml - ${project.version} - org.onap.ccsdk.sli.plugins gr-toolkit-model diff --git a/properties-node/features/ccsdk-properties-node/pom.xml b/properties-node/features/ccsdk-properties-node/pom.xml deleted file mode 100644 index 9cdee255b..000000000 --- a/properties-node/features/ccsdk-properties-node/pom.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - ccsdk-properties-node - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-plugins :: properties-node :: ${project.artifactId} - - - - - - - ${project.groupId} - properties-node-provider - ${project.version} - - - - diff --git a/properties-node/features/features-properties-node/pom.xml b/properties-node/features/features-properties-node/pom.xml deleted file mode 100644 index 93d4b85b4..000000000 --- a/properties-node/features/features-properties-node/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - feature-repo-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - features-properties-node - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-plugins :: properties-node :: ${project.artifactId} - - - - ${project.groupId} - ccsdk-properties-node - ${project.version} - xml - features - - - - diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml deleted file mode 100755 index 06dec869c..000000000 --- a/properties-node/features/pom.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.5.1-SNAPSHOT - - - org.onap.ccsdk.sli.plugins - properties-node-features - 0.7.0-SNAPSHOT - pom - - ccsdk-sli-plugins :: properties-node :: ${project.artifactId} - - - ccsdk-properties-node - features-properties-node - - diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 88ce8aa2a..8af50203d 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -24,20 +24,6 @@ - - org.onap.ccsdk.sli.plugins - ${application.name} - ${project.version} - xml - features - - - * - * - - - - org.onap.ccsdk.sli.plugins properties-node-provider diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 8b2811a9a..7dd655ac8 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -19,7 +19,6 @@ provider - features installer diff --git a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml b/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml deleted file mode 100644 index 1347c7a99..000000000 --- a/restapi-call-node/features/ccsdk-restapi-call-node/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - ccsdk-restapi-call-node - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} - - - - - javax.ws.rs - javax.ws.rs-api - - - - ${project.groupId} - restapi-call-node-provider - ${project.version} - - - - org.onap.logging-analytics - logging-filter-base - - - - - diff --git a/restapi-call-node/features/features-restapi-call-node/pom.xml b/restapi-call-node/features/features-restapi-call-node/pom.xml deleted file mode 100644 index a2a2c9243..000000000 --- a/restapi-call-node/features/features-restapi-call-node/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - feature-repo-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - features-restapi-call-node - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} - - - - ${project.groupId} - ccsdk-restapi-call-node - ${project.version} - xml - features - - - - diff --git a/restapi-call-node/features/pom.xml b/restapi-call-node/features/pom.xml deleted file mode 100755 index 10646edee..000000000 --- a/restapi-call-node/features/pom.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.5.1-SNAPSHOT - - - org.onap.ccsdk.sli.plugins - restapi-call-node-features - 0.7.0-SNAPSHOT - pom - - ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} - - - ccsdk-restapi-call-node - features-restapi-call-node - - diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 1e1361002..f4db07b59 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -23,21 +23,6 @@ - - - org.onap.ccsdk.sli.plugins - ${application.name} - ${project.version} - xml - features - - - * - * - - - - org.onap.ccsdk.sli.plugins restapi-call-node-provider diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 39a0a70f9..1c3b8ddf3 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -18,7 +18,6 @@ provider - features installer diff --git a/restconf-client/features/ccsdk-restconf-client/pom.xml b/restconf-client/features/ccsdk-restconf-client/pom.xml deleted file mode 100644 index 70c75b92e..000000000 --- a/restconf-client/features/ccsdk-restconf-client/pom.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - ccsdk-restconf-client - 0.7.0-SNAPSHOT - feature - - - true - - - ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} - - - - - - - - - ${project.groupId} - restconf-client-provider - ${project.version} - - - diff --git a/restconf-client/features/features-restconf-client/pom.xml b/restconf-client/features/features-restconf-client/pom.xml deleted file mode 100644 index 5849dc03d..000000000 --- a/restconf-client/features/features-restconf-client/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - feature-repo-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - features-restconf-client - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} - - - - ${project.groupId} - ccsdk-restconf-client - ${project.version} - xml - features - - - - diff --git a/restconf-client/features/pom.xml b/restconf-client/features/pom.xml deleted file mode 100755 index b39f987b3..000000000 --- a/restconf-client/features/pom.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.5.1-SNAPSHOT - - - org.onap.ccsdk.sli.plugins - restconf-client-features - 0.7.0-SNAPSHOT - pom - - ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} - - - ccsdk-restconf-client - features-restconf-client - - diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index db75310be..f7704298e 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -25,20 +25,6 @@ - - org.onap.ccsdk.sli.plugins - ${application.name} - ${project.version} - xml - features - - - * - * - - - - org.onap.ccsdk.sli.plugins restconf-client-provider diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index 0f04513a5..76fb65c60 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -18,7 +18,6 @@ provider - features installer diff --git a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml b/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml deleted file mode 100644 index 838405be6..000000000 --- a/sshapi-call-node/features/ccsdk-sshapi-call-node/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - ccsdk-sshapi-call-node - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} - - - - - diff --git a/sshapi-call-node/features/features-sshapi-call-node/pom.xml b/sshapi-call-node/features/features-sshapi-call-node/pom.xml deleted file mode 100644 index 26ab0ca31..000000000 --- a/sshapi-call-node/features/features-sshapi-call-node/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - feature-repo-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - features-sshapi-call-node - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} - - - - ${project.groupId} - ccsdk-sshapi-call-node - ${project.version} - xml - features - - - - diff --git a/sshapi-call-node/features/pom.xml b/sshapi-call-node/features/pom.xml deleted file mode 100755 index 2c2d4ee95..000000000 --- a/sshapi-call-node/features/pom.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.5.1-SNAPSHOT - - - org.onap.ccsdk.sli.plugins - sshapi-call-node-features - 0.7.0-SNAPSHOT - pom - - ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} - - - ccsdk-sshapi-call-node - features-sshapi-call-node - - diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index b2f5cb02d..d99170b3c 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -24,20 +24,6 @@ - - org.onap.ccsdk.sli.plugins - ${application.name} - ${project.version} - xml - features - - - * - * - - - - org.onap.ccsdk.sli.plugins sshapi-call-node-provider diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index 0860c78b8..caa0a4cde 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -18,7 +18,6 @@ provider - features installer diff --git a/template-node/features/ccsdk-template-node/pom.xml b/template-node/features/ccsdk-template-node/pom.xml deleted file mode 100644 index 7f4c16925..000000000 --- a/template-node/features/ccsdk-template-node/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - ccsdk-template-node - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-plugins :: template-node :: ${project.artifactId} - - - - - ${project.groupId} - template-node-provider - ${project.version} - - - diff --git a/template-node/features/features-template-node/pom.xml b/template-node/features/features-template-node/pom.xml deleted file mode 100644 index 3baba62a9..000000000 --- a/template-node/features/features-template-node/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - feature-repo-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.plugins - features-template-node - 0.7.0-SNAPSHOT - feature - - - - ${project.groupId} - ccsdk-template-node - ${project.version} - xml - features - - - - diff --git a/template-node/features/pom.xml b/template-node/features/pom.xml deleted file mode 100644 index 9d2af0f46..000000000 --- a/template-node/features/pom.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.5.1-SNAPSHOT - - - org.onap.ccsdk.sli.plugins - template-node-features - 0.7.0-SNAPSHOT - pom - - - ccsdk-template-node - features-template-node - - diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index 99ef46fff..9e2b15e16 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -23,19 +23,6 @@ - - org.onap.ccsdk.sli.plugins - ${application.name} - ${project.version} - xml - features - - - * - * - - - org.onap.ccsdk.sli.plugins template-node-provider diff --git a/template-node/pom.xml b/template-node/pom.xml index f1200b32d..781a798cd 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -15,7 +15,6 @@ provider - features installer -- cgit From 767b8eac24dba80a8aa815879c13b721015b7ab4 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 18 Dec 2019 21:29:24 +0000 Subject: RestapiCallNode unit tests Validate JsonParser in RestapiCallNode Issue-ID: CCSDK-2008 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: Idd062d9614b89b1c0142591af600ea8ff61c019a --- .../sli/plugins/restapicall/TestJsonParser.java | 220 ++++++++++++++++++--- .../sli/plugins/restapicall/TestXmlParser.java | 124 ++++++------ .../provider/src/test/resources/2dArray.json | 4 + .../provider/src/test/resources/3dArray.json | 4 + .../provider/src/test/resources/ArrayMenu.json | 41 ++++ .../src/test/resources/EmbeddedEscapedJson.json | 16 ++ .../provider/src/test/resources/EscapedJson.json | 1 + .../provider/src/test/resources/ObjectMenu.json | 43 ++++ .../provider/src/test/resources/Widget.json | 27 +++ 9 files changed, 386 insertions(+), 94 deletions(-) create mode 100644 restapi-call-node/provider/src/test/resources/2dArray.json create mode 100644 restapi-call-node/provider/src/test/resources/3dArray.json create mode 100644 restapi-call-node/provider/src/test/resources/ArrayMenu.json create mode 100644 restapi-call-node/provider/src/test/resources/EmbeddedEscapedJson.json create mode 100644 restapi-call-node/provider/src/test/resources/EscapedJson.json create mode 100644 restapi-call-node/provider/src/test/resources/ObjectMenu.json create mode 100644 restapi-call-node/provider/src/test/resources/Widget.json diff --git a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java index e4ec9147c..21b66b221 100644 --- a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java +++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java @@ -21,39 +21,41 @@ package org.onap.ccsdk.sli.plugins.restapicall; -import java.io.BufferedReader; +import static org.junit.Assert.assertEquals; import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Map; - import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.plugins.restapicall.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 mm = JsonParser.convertToProperties(b.toString()); - - logProperties(mm); - - in.close(); + String path = "src/test/resources/test.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + Map mm = JsonParser.convertToProperties(content); + assertEquals("Server1", mm.get("equipment-data[0].equipment-id")); + assertEquals("1600000", mm.get("equipment-data[0].max-server-speed")); + assertEquals("2", mm.get("equipment-data[0].number-primary-servers")); + assertEquals("4", mm.get("equipment-data[0].server-count")); + assertEquals("Server1", mm.get("equipment-data[0].server-id")); + assertEquals("Unknown", mm.get("equipment-data[0].server-model")); + assertEquals("Test-Value", mm.get("equipment-data[0].test-node.test-inner-node")); + assertEquals("1", mm.get("equipment-data_length")); + assertEquals("The provisioned access bandwidth is at or exceeds 50% of the total server capacity.", + mm.get("message")); + assertEquals("VCE-Cust", mm.get("resource-rule.endpoint-position")); + assertEquals("Server", mm.get("resource-rule.equipment-level")); + assertEquals("max-server-speed * number-primary-servers", mm.get("resource-rule.hard-limit-expression")); + assertEquals("Bandwidth", mm.get("resource-rule.resource-name")); + assertEquals("DUMMY", mm.get("resource-rule.service-model")); + assertEquals("0.6 * max-server-speed * number-primary-servers", mm.get("resource-rule.soft-limit-expression")); + assertEquals("1605000", mm.get("resource-state.last-added")); + assertEquals("1920000", mm.get("resource-state.limit-value")); + assertEquals("1600000", mm.get("resource-state.threshold-value")); + assertEquals("1605000", mm.get("resource-state.used")); } @Test(expected = NullPointerException.class) @@ -61,13 +63,167 @@ public class TestJsonParser { JsonParser.convertToProperties(null); } - private void logProperties(Map mm) { - List 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)); + @Test + public void testJsonStringToCtxToplevelArray() throws Exception { + String path = "src/test/resources/ArrayMenu.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + Map mm = JsonParser.convertToProperties(content); + assertEquals("plain", mm.get("name")); + assertEquals("true", mm.get("vegetarian")); + assertEquals("1", mm.get("id")); + assertEquals("1000", mm.get("calories")); + assertEquals("pizza", mm.get("type")); + + // The below statements are how I expected it to work, but it does not work this way +/* + assertEquals("1000", mm.get("[0].calories")); + assertEquals("1", mm.get("[0].id")); + assertEquals("plain", mm.get("[0].name")); + assertEquals("pizza", mm.get("[0].type")); + assertEquals("true", mm.get("[0].vegetarian")); + assertEquals("2000", mm.get("[1].calories")); + assertEquals("2", mm.get("[1].id")); + assertEquals("Tuesday Special", mm.get("[1].name")); + assertEquals("1", mm.get("[1].topping[0].id")); + assertEquals("onion", mm.get("[1].topping[0].name")); + assertEquals("2", mm.get("[1].topping[1].id")); + assertEquals("pepperoni", mm.get("[1].topping[1].name")); + assertEquals("2", mm.get("[1].topping_length")); + assertEquals("pizza", mm.get("[1].type")); + assertEquals("false", mm.get("[1].vegetarian")); + assertEquals("1500", mm.get("[2].calories")); + assertEquals("3", mm.get("[2].id")); + assertEquals("House Special", mm.get("[2].name")); + assertEquals("3", mm.get("[2].topping[0].id")); + assertEquals("basil", mm.get("[2].topping[0].name")); + assertEquals("4", mm.get("[2].topping[1].id")); + assertEquals("fresh mozzarella", mm.get("[2].topping[1].name")); + assertEquals("5", mm.get("[2].topping[2].id")); + assertEquals("tomato", mm.get("[2].topping[2].name")); + assertEquals("3", mm.get("[2].topping_length")); + assertEquals("pizza", mm.get("[2].type")); + assertEquals("true", mm.get("[2].vegetarian")); + assertEquals("3", mm.get("_length")); +*/ + } + + @Test + public void testJsonStringToCtx() throws Exception { + String path = "src/test/resources/ObjectMenu.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + Map mm = JsonParser.convertToProperties(content); + assertEquals("1000", mm.get("menu[0].calories")); + assertEquals("1", mm.get("menu[0].id")); + assertEquals("plain", mm.get("menu[0].name")); + assertEquals("pizza", mm.get("menu[0].type")); + assertEquals("true", mm.get("menu[0].vegetarian")); + assertEquals("2000", mm.get("menu[1].calories")); + assertEquals("2", mm.get("menu[1].id")); + assertEquals("Tuesday Special", mm.get("menu[1].name")); + assertEquals("1", mm.get("menu[1].topping[0].id")); + assertEquals("onion", mm.get("menu[1].topping[0].name")); + assertEquals("2", mm.get("menu[1].topping[1].id")); + assertEquals("pepperoni", mm.get("menu[1].topping[1].name")); + assertEquals("2", mm.get("menu[1].topping_length")); + assertEquals("pizza", mm.get("menu[1].type")); + assertEquals("false", mm.get("menu[1].vegetarian")); + assertEquals("1500", mm.get("menu[2].calories")); + assertEquals("3", mm.get("menu[2].id")); + assertEquals("House Special", mm.get("menu[2].name")); + assertEquals("3", mm.get("menu[2].topping[0].id")); + assertEquals("basil", mm.get("menu[2].topping[0].name")); + assertEquals("4", mm.get("menu[2].topping[1].id")); + assertEquals("fresh mozzarella", mm.get("menu[2].topping[1].name")); + assertEquals("5", mm.get("menu[2].topping[2].id")); + assertEquals("tomato", mm.get("menu[2].topping[2].name")); + assertEquals("3", mm.get("menu[2].topping_length")); + assertEquals("pizza", mm.get("menu[2].type")); + assertEquals("true", mm.get("menu[2].vegetarian")); + assertEquals("3", mm.get("menu_length")); + } + + @Test(expected = SvcLogicException.class) // current behavior is multidimensional arrays are not supported + public void test2dJsonStringToCtx() throws Exception { + String path = "src/test/resources/2dArray.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + Map mm = JsonParser.convertToProperties(content); + + // code will crash before these tests + assertEquals("apple", mm.get("[0][0]")); + assertEquals("orange", mm.get("[0][1]")); + assertEquals("banana", mm.get("[0][2]")); + assertEquals("3", mm.get("[0]_length")); + assertEquals("squash", mm.get("[1][0]")); + assertEquals("broccoli", mm.get("[1][1]")); + assertEquals("cauliflower", mm.get("[1][2]")); + assertEquals("3", mm.get("[1]_length")); + assertEquals("2", mm.get("_length")); + } + + @Test(expected = SvcLogicException.class) // current behavior is multidimensional arrays are not supported + public void test3dJsonStringToCtx() throws Exception { + String path = "src/test/resources/3dArray.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + Map mm = JsonParser.convertToProperties(content); + + // code will crash before these tests + assertEquals("a", mm.get("[0][0][0]")); + assertEquals("b", mm.get("[0][0][1]")); + assertEquals("c", mm.get("[0][0][2]")); + assertEquals("3", mm.get("[0][0]_length")); + assertEquals("d", mm.get("[0][1][0]")); + assertEquals("e", mm.get("[0][1][1]")); + assertEquals("f", mm.get("[0][1][2]")); + assertEquals("3", mm.get("[0][1]_length")); + assertEquals("2", mm.get("[0]_length")); + assertEquals("x", mm.get("[1][0][0]")); + assertEquals("y", mm.get("[1][0][1]")); + assertEquals("z", mm.get("[1][0][2]")); + assertEquals("3", mm.get("[1][0]_length")); + assertEquals("1", mm.get("[1]_length")); + assertEquals("2", mm.get("_length")); + } + + @Test + public void testJsonWidgetStringToCtx() throws Exception { + String path = "src/test/resources/Widget.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + Map mm = JsonParser.convertToProperties(content); + assertEquals("false", mm.get("widget.debug")); + assertEquals("center", mm.get("widget.image.alignment")); + assertEquals("150", mm.get("widget.image.hOffset")); + assertEquals("moon", mm.get("widget.image.name")); + assertEquals("images/moon.png", mm.get("widget.image.src")); + assertEquals("150", mm.get("widget.image.vOffset")); + assertEquals("center", mm.get("widget.text.alignment")); + assertEquals("Click Me", mm.get("widget.text.data")); + assertEquals("350", mm.get("widget.text.hOffset")); + assertEquals("text1", mm.get("widget.text.name")); + assertEquals("21", mm.get("widget.text.size")); + assertEquals("bold", mm.get("widget.text.style")); + assertEquals("200", mm.get("widget.text.vOffset")); + assertEquals("300", mm.get("widget.window.height")); + assertEquals("main_window", mm.get("widget.window.name")); + assertEquals("ONAP Widget", mm.get("widget.window.title")); + assertEquals("200", mm.get("widget.window.width")); + } + + @Test + public void testEmbeddedEscapedJsonJsonStringToCtx() throws Exception { + String path = "src/test/resources/EmbeddedEscapedJson.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + Map mm = JsonParser.convertToProperties(content); + assertEquals("escapedJsonObject", mm.get("input.parameters[0].name")); + assertEquals("[{\"id\":\"0.2.0.0/16\"},{\"id\":\"ge04::/64\"}]", mm.get("input.parameters[0].value")); + assertEquals("Hello/World", mm.get("input.parameters[1].value")); + assertEquals("resourceName", mm.get("input.parameters[2].name")); + assertEquals("The\t\"Best\"\tName", mm.get("input.parameters[2].value")); + assertEquals("3", mm.get("input.parameters_length")); + + // Break the embedded json object into properties + mm = JsonParser.convertToProperties(mm.get("input.parameters[0].value")); + assertEquals("0.2.0.0/16", mm.get("id")); + // assertEquals("ge04::/64", mm.get("id")); this second value gets lost } + } diff --git a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java index 326c9ca89..76f86abc0 100644 --- a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java +++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java @@ -21,38 +21,21 @@ package org.onap.ccsdk.sli.plugins.restapicall; -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 static org.junit.Assert.assertEquals; +import java.nio.file.Files; +import java.nio.file.Paths; 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.restapicall.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'); - + String path = "src/test/resources/test3.xml"; + String content = new String(Files.readAllBytes(Paths.get(path))); Set listNameList = new HashSet(); listNameList.add("project.dependencies.dependency"); listNameList.add("project.build.plugins.plugin"); @@ -61,61 +44,78 @@ public class TestXmlParser { listNameList.add("project.build.pluginManagement." + "plugins.plugin.configuration.lifecycleMappingMetadata.pluginExecutions.pluginExecution"); - Map mm = XmlParser.convertToProperties(b.toString(), listNameList); - logProperties(mm); - in.close(); + Map mm = XmlParser.convertToProperties(content, listNameList); + assertEquals("811182", mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VpnId")); + assertEquals("v6", mm.get("ApplyGroupResponse.ApplyGroupResponseData.RoutingApplyGroups.Family")); + assertEquals("SET6_BVOIP_IN", mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport")); + assertEquals("AG_MAX_MCASTROUTES", + mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.ApplyGroup.ApplyGroup")); + assertEquals("ICOREPVC-81114561", mm.get("ApplyGroupResponse.ApplyGroupResponseData.ServiceInstanceId")); + assertEquals("SET_RESET_LP", mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport")); + assertEquals("21302:811182", mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfName")); + assertEquals("BGP4_PROTOCOL", + mm.get("ApplyGroupResponse.ApplyGroupResponseData.RoutingApplyGroups.RoutingProtocol")); + assertEquals("AG6_MAX_PREFIX", + mm.get("ApplyGroupResponse.ApplyGroupResponseData.RoutingApplyGroups.ApplyGroupPeer.ApplyGroup")); + assertEquals("VPNL811182", mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.End2EndVpnKey")); + assertEquals("AG6_BFD_BGP_3000", + mm.get("ApplyGroupResponse.ApplyGroupResponseData.RoutingApplyGroups.ApplyGroupNeighbour.ApplyGroup")); + assertEquals("200", mm.get("ApplyGroupResponse.response-code")); + assertEquals("gp6_21302:811182", + mm.get("ApplyGroupResponse.ApplyGroupResponseData.RoutingApplyGroups.PeerGroupName")); + assertEquals("Y", mm.get("ApplyGroupResponse.ack-final-indicator")); + assertEquals("Success", mm.get("ApplyGroupResponse.response-message")); } @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'); - + String path = "src/test/resources/test3.xml"; + String content = new String(Files.readAllBytes(Paths.get(path))); Set listNameList = new HashSet(); listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); - Map 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(); + Map mm = XmlParser.convertToProperties(content, listNameList); + assertEquals("AG6_BFD_BGP_3000", + mm.get("ApplyGroupResponse.ApplyGroupResponseData.RoutingApplyGroups.ApplyGroupNeighbour.ApplyGroup")); + assertEquals("AG6_MAX_PREFIX", + mm.get("ApplyGroupResponse.ApplyGroupResponseData.RoutingApplyGroups.ApplyGroupPeer.ApplyGroup")); + assertEquals("v6", mm.get("ApplyGroupResponse.ApplyGroupResponseData.RoutingApplyGroups.Family")); + assertEquals("gp6_21302:811182", + mm.get("ApplyGroupResponse.ApplyGroupResponseData.RoutingApplyGroups.PeerGroupName")); + assertEquals("BGP4_PROTOCOL", + mm.get("ApplyGroupResponse.ApplyGroupResponseData.RoutingApplyGroups.RoutingProtocol")); + assertEquals("ICOREPVC-81114561", mm.get("ApplyGroupResponse.ApplyGroupResponseData.ServiceInstanceId")); + assertEquals("AG_MAX_MCASTROUTES", + mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.ApplyGroup.ApplyGroup")); + assertEquals("VPNL811182", mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.End2EndVpnKey")); + assertEquals("811182", mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VpnId")); + assertEquals("SET6_DSU", mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport[0]")); + assertEquals("SET_DSU", mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport[1]")); + assertEquals("SET6_MANAGED", mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport[2]")); + assertEquals("SET_MANAGED", mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport[3]")); + assertEquals("SET_LOVRF_COMMUNITY", + mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport[4]")); + assertEquals("SET_RESET_LP", mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport[5]")); + assertEquals("6", mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport_length")); + assertEquals("SET_BVOIP_IN", mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport[0]")); + assertEquals("SET6_BVOIP_IN", mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport[1]")); + assertEquals("2", mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport_length")); + assertEquals("21302:811182", mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfName")); + assertEquals("Y", mm.get("ApplyGroupResponse.ack-final-indicator")); + assertEquals("200", mm.get("ApplyGroupResponse.response-code")); + assertEquals("Success", mm.get("ApplyGroupResponse.response-message")); } @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'); - + String path = "src/test/resources/invalidlength.xml"; + String content = new String(Files.readAllBytes(Paths.get(path))); Set listNameList = new HashSet(); listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); - - Map mm = XmlParser.convertToProperties(b.toString(), listNameList); - logProperties(mm); - in.close(); + XmlParser.convertToProperties(content, listNameList); // throws an exception because the length in the xml is + // not a valid number } - private void logProperties(Map mm) { - List 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/restapi-call-node/provider/src/test/resources/2dArray.json b/restapi-call-node/provider/src/test/resources/2dArray.json new file mode 100644 index 000000000..b473864d8 --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/2dArray.json @@ -0,0 +1,4 @@ +[ + ["apple", "orange", "banana"], + ["squash", "broccoli", "cauliflower"] +] \ No newline at end of file diff --git a/restapi-call-node/provider/src/test/resources/3dArray.json b/restapi-call-node/provider/src/test/resources/3dArray.json new file mode 100644 index 000000000..149955596 --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/3dArray.json @@ -0,0 +1,4 @@ +[ + [["a","b","c"], ["d","e","f"]], + [["x","y","z"]] +] \ No newline at end of file diff --git a/restapi-call-node/provider/src/test/resources/ArrayMenu.json b/restapi-call-node/provider/src/test/resources/ArrayMenu.json new file mode 100644 index 000000000..b12f16315 --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/ArrayMenu.json @@ -0,0 +1,41 @@ +[{ + "id": "1", + "type": "pizza", + "name": "plain", + "calories": 1000, + "vegetarian": true + }, { + "id": "2", + "type": "pizza", + "name": "Tuesday Special", + "calories": 2000, + "vegetarian": false, + "topping": + [{ + "id": "1", + "name": "onion" + }, { + "id": "2", + "name": "pepperoni" + } + ] + }, { + "id": "3", + "type": "pizza", + "name": "House Special", + "calories": 1500, + "vegetarian": true, + "topping": + [{ + "id": "3", + "name": "basil" + }, { + "id": "4", + "name": "fresh mozzarella" + }, { + "id": "5", + "name": "tomato" + } + ] + } +] diff --git a/restapi-call-node/provider/src/test/resources/EmbeddedEscapedJson.json b/restapi-call-node/provider/src/test/resources/EmbeddedEscapedJson.json new file mode 100644 index 000000000..dbb6d8d3a --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/EmbeddedEscapedJson.json @@ -0,0 +1,16 @@ +{ + "input": { + "parameters": + [{ + "name": "escapedJsonObject", + "value": "[{\"id\":\"0.2.0.0\/16\"},{\"id\":\"ge04::\/64\"}]" + }, { + "name": "password", + "value": "Hello\/World" + }, { + "name": "resourceName", + "value": "The\t\"Best\"\tName" + } + ] + } +} \ No newline at end of file diff --git a/restapi-call-node/provider/src/test/resources/EscapedJson.json b/restapi-call-node/provider/src/test/resources/EscapedJson.json new file mode 100644 index 000000000..a7719e819 --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/EscapedJson.json @@ -0,0 +1 @@ +{\"widget\":{\"debug\":false,\"window\":{\"title\":\"ONAP Widget\",\"name\":\"main_window\",\"width\":200,\"height\":300},\"image\":{\"src\":\"images\/moon.png\",\"name\":\"moon\",\"hOffset\":150,\"vOffset\":150,\"alignment\":\"center\"},\"text\":{\"data\":\"Click Me\",\"size\":21,\"style\":\"bold\",\"name\":\"text1\",\"hOffset\":350,\"vOffset\":200,\"alignment\":\"center\"}}} \ No newline at end of file diff --git a/restapi-call-node/provider/src/test/resources/ObjectMenu.json b/restapi-call-node/provider/src/test/resources/ObjectMenu.json new file mode 100644 index 000000000..56f842d48 --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/ObjectMenu.json @@ -0,0 +1,43 @@ +{ + "menu": [{ + "id": "1", + "type": "pizza", + "name": "plain", + "calories": 1000, + "vegetarian": true + }, { + "id": "2", + "type": "pizza", + "name": "Tuesday Special", + "calories": 2000, + "vegetarian": false, + "topping": + [{ + "id": "1", + "name": "onion" + }, { + "id": "2", + "name": "pepperoni" + } + ] + }, { + "id": "3", + "type": "pizza", + "name": "House Special", + "calories": 1500, + "vegetarian": true, + "topping": + [{ + "id": "3", + "name": "basil" + }, { + "id": "4", + "name": "fresh mozzarella" + }, { + "id": "5", + "name": "tomato" + } + ] + } + ] +} diff --git a/restapi-call-node/provider/src/test/resources/Widget.json b/restapi-call-node/provider/src/test/resources/Widget.json new file mode 100644 index 000000000..1e25282c2 --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/Widget.json @@ -0,0 +1,27 @@ +{ + "widget": { + "debug": false, + "window": { + "title": "ONAP Widget", + "name": "main_window", + "width": 200, + "height": 300 + }, + "image": { + "src": "images/moon.png", + "name": "moon", + "hOffset": 150, + "vOffset": 150, + "alignment": "center" + }, + "text": { + "data": "Click Me", + "size": 21, + "style": "bold", + "name": "text1", + "hOffset": 350, + "vOffset": 200, + "alignment": "center" + } + } +} \ No newline at end of file -- cgit From c185a9bf56303dc4ad9feb4ba5b6227a038f4153 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Thu, 19 Dec 2019 11:07:59 -0500 Subject: Fixing JSONParser for JSONArray element Refactoring Related JUnit and fixing test JSON Files Change-Id: I1cd7ba04f53798e4b3f5451de6bfed24054d3ea5 Issue-ID: CCSDK-2008 Signed-off-by: Singal, Kapil (ks220y) --- .../ccsdk/sli/plugins/restapicall/JsonParser.java | 57 ++++++++++++++-------- .../src/main/resources/actokentemplate.json | 21 -------- .../src/main/resources/default-ueb-message.json | 21 -------- .../src/main/resources/get-multicast-data.json | 21 -------- .../main/resources/l2-dci-connects-template.json | 18 ------- .../main/resources/l3-dci-connects-template.json | 20 -------- .../src/main/resources/l3smsitetemplate.json | 21 -------- .../src/main/resources/l3smvpntemplate.json | 21 -------- .../src/main/resources/l3smvrftemplate.json | 21 -------- .../main/resources/northbound-api-template.json | 21 -------- ...iguration-notification-northbound-template.json | 21 -------- .../src/main/resources/sptn-l3vpn-template.json | 21 -------- .../update-vpe-data-with-apply-group.json | 21 -------- .../src/main/resources/vnf-information-update.json | 21 -------- .../src/main/resources/vpn-allocation-request.json | 21 -------- .../src/main/resources/vpn-information-update.json | 25 +--------- ...service-configuration-information-template.json | 25 +--------- .../resources/vrf-update-vlan-status-template.json | 21 -------- .../provider/src/main/resources/vrf-update.json | 25 +--------- .../sli/plugins/restapicall/TestJsonParser.java | 18 ++----- .../plugins/restapicall/TestRestapiCallNode.java | 15 +++--- .../src/test/resources/actokentemplate.json | 21 -------- .../test/resources/l2-dci-connects-template.json | 18 ------- .../test/resources/l3-dci-connects-template.json | 20 -------- .../src/test/resources/l3smsitetemplate.json | 21 -------- .../src/test/resources/l3smvpntemplate.json | 21 -------- .../src/test/resources/l3smvrftemplate.json | 21 -------- .../provider/src/test/resources/test-template.json | 21 -------- .../provider/src/test/resources/test.json | 21 -------- 29 files changed, 56 insertions(+), 584 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java index 910baf52b..4c3ba7f8e 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java @@ -10,7 +10,7 @@ * 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. @@ -21,13 +21,10 @@ package org.onap.ccsdk.sli.plugins.restapicall; -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; @@ -35,6 +32,8 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static com.google.common.base.Preconditions.checkNotNull; + public final class JsonParser { private static final Logger log = LoggerFactory.getLogger(JsonParser.class); @@ -45,34 +44,51 @@ public final class JsonParser { @SuppressWarnings("unchecked") public static Map convertToProperties(String s) - throws SvcLogicException { + throws SvcLogicException { checkNotNull(s, "Input should not be null."); try { - JSONObject json = null; + Map wm = new HashMap<>(); + String topLvlArrLength = null; + JSONObject json; + JSONArray jsonArr; //support top level list in json response if (s.startsWith("[")) { - JSONArray jsonArr = new JSONArray(s); - json = jsonArr.getJSONObject(0); + jsonArr = new JSONArray(s); + topLvlArrLength = String.valueOf(jsonArr.length()); + for (int i = 0, length = jsonArr.length(); i < length; i++) { + json = jsonArr.getJSONObject(i); + Iterator ii = json.keys(); + while (ii.hasNext()) { + String key = ii.next(); + String key1 = "[" + i + "]." + key; + String[] subKey = key1.split(":"); + if (subKey.length == 2) { + wm.put(subKey[1], json.get(key)); + } else { + wm.put(key1, json.get(key)); + } + } + } } else { json = new JSONObject(s); - } - - Map wm = new HashMap<>(); - Iterator ii = json.keys(); - while (ii.hasNext()) { - String key1 = ii.next(); - String[] subKey = key1.split(":"); - if (subKey.length == 2) { - wm.put(subKey[1], json.get(key1)); - } else { - wm.put(key1, json.get(key1)); + Iterator ii = json.keys(); + while (ii.hasNext()) { + String key1 = ii.next(); + String[] subKey = key1.split(":"); + if (subKey.length == 2) { + wm.put(subKey[1], json.get(key1)); + } else { + wm.put(key1, json.get(key1)); + } } } Map mm = new HashMap<>(); - + if (topLvlArrLength != null) { + mm.put("_length", topLvlArrLength); + } while (!wm.isEmpty()) { for (String key : new ArrayList<>(wm.keySet())) { Object o = wm.get(key); @@ -111,4 +127,5 @@ public final class JsonParser { throw new SvcLogicException("Unable to convert JSON to properties" + e.getLocalizedMessage(), e); } } + } diff --git a/restapi-call-node/provider/src/main/resources/actokentemplate.json b/restapi-call-node/provider/src/main/resources/actokentemplate.json index 31bf0ee2b..02e62400f 100644 --- a/restapi-call-node/provider/src/main/resources/actokentemplate.json +++ b/restapi-call-node/provider/src/main/resources/actokentemplate.json @@ -1,24 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : 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========================================================= - */ - { "userName": ${prop.sdncRestApi.thirdpartySdnc.user}, "password": ${prop.sdncRestApi.thirdpartySdnc.password} diff --git a/restapi-call-node/provider/src/main/resources/default-ueb-message.json b/restapi-call-node/provider/src/main/resources/default-ueb-message.json index 6ef6be7f6..484d872f5 100644 --- a/restapi-call-node/provider/src/main/resources/default-ueb-message.json +++ b/restapi-call-node/provider/src/main/resources/default-ueb-message.json @@ -1,24 +1,3 @@ -/*- - * ============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========================================================= - */ - { "event":{ "header":{ diff --git a/restapi-call-node/provider/src/main/resources/get-multicast-data.json b/restapi-call-node/provider/src/main/resources/get-multicast-data.json index f6155ee32..3b9997f64 100644 --- a/restapi-call-node/provider/src/main/resources/get-multicast-data.json +++ b/restapi-call-node/provider/src/main/resources/get-multicast-data.json @@ -1,24 +1,3 @@ -/*- - * ============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========================================================= - */ - { "input": { "sdnc-request-header": { diff --git a/restapi-call-node/provider/src/main/resources/l2-dci-connects-template.json b/restapi-call-node/provider/src/main/resources/l2-dci-connects-template.json index f18075686..e0896bbaa 100644 --- a/restapi-call-node/provider/src/main/resources/l2-dci-connects-template.json +++ b/restapi-call-node/provider/src/main/resources/l2-dci-connects-template.json @@ -1,21 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : SDN-C - * ================================================================================ - * 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========================================================= - */ - { "l2-dci-connect": { "id": ${prop.dci-connects.id}, diff --git a/restapi-call-node/provider/src/main/resources/l3-dci-connects-template.json b/restapi-call-node/provider/src/main/resources/l3-dci-connects-template.json index c011b077b..41df794fd 100644 --- a/restapi-call-node/provider/src/main/resources/l3-dci-connects-template.json +++ b/restapi-call-node/provider/src/main/resources/l3-dci-connects-template.json @@ -1,23 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : SDN-C - * ================================================================================ - * Copyright (C) 2017 Intel Corp. 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========================================================= - */ - { "l3-dci-connect": { "id": ${prop.dci-connects.id}, diff --git a/restapi-call-node/provider/src/main/resources/l3smsitetemplate.json b/restapi-call-node/provider/src/main/resources/l3smsitetemplate.json index 016879c3c..8f8156698 100644 --- a/restapi-call-node/provider/src/main/resources/l3smsitetemplate.json +++ b/restapi-call-node/provider/src/main/resources/l3smsitetemplate.json @@ -1,24 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : 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========================================================= - */ - { "site":[ { diff --git a/restapi-call-node/provider/src/main/resources/l3smvpntemplate.json b/restapi-call-node/provider/src/main/resources/l3smvpntemplate.json index 67f127ce9..30f30a24f 100644 --- a/restapi-call-node/provider/src/main/resources/l3smvpntemplate.json +++ b/restapi-call-node/provider/src/main/resources/l3smvpntemplate.json @@ -1,24 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : 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========================================================= - */ - { "vpn-service": [ { diff --git a/restapi-call-node/provider/src/main/resources/l3smvrftemplate.json b/restapi-call-node/provider/src/main/resources/l3smvrftemplate.json index 732af278c..52359a7fd 100644 --- a/restapi-call-node/provider/src/main/resources/l3smvrftemplate.json +++ b/restapi-call-node/provider/src/main/resources/l3smvrftemplate.json @@ -1,24 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : 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========================================================= - */ - { "vrf-attribute": [ { diff --git a/restapi-call-node/provider/src/main/resources/northbound-api-template.json b/restapi-call-node/provider/src/main/resources/northbound-api-template.json index 73a61b636..f185c8f5d 100644 --- a/restapi-call-node/provider/src/main/resources/northbound-api-template.json +++ b/restapi-call-node/provider/src/main/resources/northbound-api-template.json @@ -1,24 +1,3 @@ -/*- - * ============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========================================================= - */ - { "input": { diff --git a/restapi-call-node/provider/src/main/resources/service-configuration-notification-northbound-template.json b/restapi-call-node/provider/src/main/resources/service-configuration-notification-northbound-template.json index 0cb7d0b06..c64661720 100644 --- a/restapi-call-node/provider/src/main/resources/service-configuration-notification-northbound-template.json +++ b/restapi-call-node/provider/src/main/resources/service-configuration-notification-northbound-template.json @@ -1,24 +1,3 @@ -/*- - * ============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========================================================= - */ - { "input": { "svc-request-id": ${service-configuration-notification-input.svc-request-id}, diff --git a/restapi-call-node/provider/src/main/resources/sptn-l3vpn-template.json b/restapi-call-node/provider/src/main/resources/sptn-l3vpn-template.json index 9e1e92068..e850cb9a0 100644 --- a/restapi-call-node/provider/src/main/resources/sptn-l3vpn-template.json +++ b/restapi-call-node/provider/src/main/resources/sptn-l3vpn-template.json @@ -1,24 +1,3 @@ -/*- - * ============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========================================================= - */ - { "snc-l3vpn": { "-xmlns": "urn:chinamobile:l3vpn", diff --git a/restapi-call-node/provider/src/main/resources/update-vpe-data-with-apply-group.json b/restapi-call-node/provider/src/main/resources/update-vpe-data-with-apply-group.json index a82a6b4a6..979857521 100644 --- a/restapi-call-node/provider/src/main/resources/update-vpe-data-with-apply-group.json +++ b/restapi-call-node/provider/src/main/resources/update-vpe-data-with-apply-group.json @@ -1,24 +1,3 @@ -/*- - * ============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========================================================= - */ - { "vrf-export-details": [ ${repeat:restapi-result.ApplyGroupResponse.ApplyGroupResponseData[0].VrfDetails.VrfExport_length: diff --git a/restapi-call-node/provider/src/main/resources/vnf-information-update.json b/restapi-call-node/provider/src/main/resources/vnf-information-update.json index 425f0f3d7..d554624c7 100644 --- a/restapi-call-node/provider/src/main/resources/vnf-information-update.json +++ b/restapi-call-node/provider/src/main/resources/vnf-information-update.json @@ -1,24 +1,3 @@ -/*- - * ============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========================================================= - */ - { "generic-vnf-service" :${vnf-service.generic-vnf-service} } diff --git a/restapi-call-node/provider/src/main/resources/vpn-allocation-request.json b/restapi-call-node/provider/src/main/resources/vpn-allocation-request.json index 6c8427495..7a689bd5c 100644 --- a/restapi-call-node/provider/src/main/resources/vpn-allocation-request.json +++ b/restapi-call-node/provider/src/main/resources/vpn-allocation-request.json @@ -1,24 +1,3 @@ -/*- - * ============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========================================================= - */ - { "AllocateVpnResourcesRequest": { "message-id": "${service-data.oper-status.modify-timestamp}", diff --git a/restapi-call-node/provider/src/main/resources/vpn-information-update.json b/restapi-call-node/provider/src/main/resources/vpn-information-update.json index 7977066bd..3ac16e291 100644 --- a/restapi-call-node/provider/src/main/resources/vpn-information-update.json +++ b/restapi-call-node/provider/src/main/resources/vpn-information-update.json @@ -1,24 +1,3 @@ -/*- - * ============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========================================================= - */ - -{ -"vpn-information" :${vpe-vpn-service.vpn-information} +{ +"vpn-information" :${vpe-vpn-service.vpn-information} } diff --git a/restapi-call-node/provider/src/main/resources/vrf-service-configuration-information-template.json b/restapi-call-node/provider/src/main/resources/vrf-service-configuration-information-template.json index f7e843246..c6defb405 100644 --- a/restapi-call-node/provider/src/main/resources/vrf-service-configuration-information-template.json +++ b/restapi-call-node/provider/src/main/resources/vrf-service-configuration-information-template.json @@ -1,32 +1,11 @@ -/*- - * ============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========================================================= - */ - { "input": { - + "e2e-vpn-key": ${service-data.avpn-logicalchannel-information.e2e-vpn-id}, "logical-channel-id": ${service-data.service-information.service-instance-id}, "vpe-name": ${service-data.avpn-logicalchannel-information.evc-endpoint-information.vpe-name}, "rpc-action": ${tmp.rpc-action}, - + "vpn-information": ${vpe-vpn-service.vpn-information}, "vrf-details": ${vpe-vpn-service.vpn-information.vrf-details}, "vrf-vlan-resources": { diff --git a/restapi-call-node/provider/src/main/resources/vrf-update-vlan-status-template.json b/restapi-call-node/provider/src/main/resources/vrf-update-vlan-status-template.json index 7a6cab35e..f6381256f 100644 --- a/restapi-call-node/provider/src/main/resources/vrf-update-vlan-status-template.json +++ b/restapi-call-node/provider/src/main/resources/vrf-update-vlan-status-template.json @@ -1,24 +1,3 @@ -/*- - * ============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========================================================= - */ - { "input": { "e2e-vpn-key": ${service-data.avpn-logicalchannel-information.e2e-vpn-id}, diff --git a/restapi-call-node/provider/src/main/resources/vrf-update.json b/restapi-call-node/provider/src/main/resources/vrf-update.json index 778e4b294..cdaef4d82 100644 --- a/restapi-call-node/provider/src/main/resources/vrf-update.json +++ b/restapi-call-node/provider/src/main/resources/vrf-update.json @@ -1,24 +1,3 @@ -/*- - * ============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========================================================= - */ - { "vpn-vame": ${allocate-vpn-resource-notification-input.vpn-data[0].vpn-name}, "vpn-id": ${allocate-vpn-resource-notification-input.vpn-data[0].vpn-id}, @@ -63,7 +42,7 @@ "spoke-routes": { "route-target": ${allocate-vpn-resource-notification-input.vpn-data[0].spoke-route-target.route-target} }, - + "route-target-details": [ ${repeat:allocate-vpn-resource-notification-input.vpn-data[0].route-target-details_length: { @@ -72,6 +51,6 @@ } } ], - + "e2e-vpn-key": ${allocate-vpn-resource-notification-input.vpn-data[0].e2e-vpn-id} } diff --git a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java index 21b66b221..569719d6c 100644 --- a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java +++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java @@ -8,9 +8,9 @@ * 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. @@ -68,14 +68,7 @@ public class TestJsonParser { String path = "src/test/resources/ArrayMenu.json"; String content = new String(Files.readAllBytes(Paths.get(path))); Map mm = JsonParser.convertToProperties(content); - assertEquals("plain", mm.get("name")); - assertEquals("true", mm.get("vegetarian")); - assertEquals("1", mm.get("id")); - assertEquals("1000", mm.get("calories")); - assertEquals("pizza", mm.get("type")); - - // The below statements are how I expected it to work, but it does not work this way -/* + assertEquals("1000", mm.get("[0].calories")); assertEquals("1", mm.get("[0].id")); assertEquals("plain", mm.get("[0].name")); @@ -104,7 +97,6 @@ public class TestJsonParser { assertEquals("pizza", mm.get("[2].type")); assertEquals("true", mm.get("[2].vegetarian")); assertEquals("3", mm.get("_length")); -*/ } @Test @@ -222,8 +214,8 @@ public class TestJsonParser { // Break the embedded json object into properties mm = JsonParser.convertToProperties(mm.get("input.parameters[0].value")); - assertEquals("0.2.0.0/16", mm.get("id")); - // assertEquals("ge04::/64", mm.get("id")); this second value gets lost + assertEquals("0.2.0.0/16", mm.get("[0].id")); + assertEquals("ge04::/64", mm.get("[1].id")); } } diff --git a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index 0704d297a..8cabaadcf 100755 --- a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -29,15 +29,11 @@ import java.util.HashMap; import java.util.Map; import org.codehaus.jettison.json.JSONObject; -import org.glassfish.grizzly.http.server.HttpServer; -import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; -import org.glassfish.jersey.media.multipart.MultiPartFeature; -import org.glassfish.jersey.server.ResourceConfig; +import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,6 +42,11 @@ public class TestRestapiCallNode { @SuppressWarnings("unused") private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class); + @Before + public void init() { + System.setProperty("SDNC_CONFIG_DIR", "src/test/resources"); + } + @Test public void testDelete() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); @@ -476,7 +477,7 @@ public class TestRestapiCallNode { assertEquals(partnerTwoUsername,details.username); assertEquals(partnerTwoPassword,details.password); assertNull(rcn.partnerStore.get("partnerThree")); - + //In this scenario the caller expects username, password and url to be picked up from the partners json Map paramMap = new HashMap(); paramMap.put("partner", partnerTwoKey); @@ -497,7 +498,7 @@ public class TestRestapiCallNode { assertEquals(partnerTwoPassword,p.restapiPassword); assertEquals("http://localhost:7002/networking/v1/instance/3",p.restapiUrl); } - + @Test public void retryPolicyBean() throws Exception { Integer retries = 3; diff --git a/restapi-call-node/provider/src/test/resources/actokentemplate.json b/restapi-call-node/provider/src/test/resources/actokentemplate.json index 31bf0ee2b..02e62400f 100644 --- a/restapi-call-node/provider/src/test/resources/actokentemplate.json +++ b/restapi-call-node/provider/src/test/resources/actokentemplate.json @@ -1,24 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : 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========================================================= - */ - { "userName": ${prop.sdncRestApi.thirdpartySdnc.user}, "password": ${prop.sdncRestApi.thirdpartySdnc.password} diff --git a/restapi-call-node/provider/src/test/resources/l2-dci-connects-template.json b/restapi-call-node/provider/src/test/resources/l2-dci-connects-template.json index f18075686..e0896bbaa 100644 --- a/restapi-call-node/provider/src/test/resources/l2-dci-connects-template.json +++ b/restapi-call-node/provider/src/test/resources/l2-dci-connects-template.json @@ -1,21 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : SDN-C - * ================================================================================ - * 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========================================================= - */ - { "l2-dci-connect": { "id": ${prop.dci-connects.id}, diff --git a/restapi-call-node/provider/src/test/resources/l3-dci-connects-template.json b/restapi-call-node/provider/src/test/resources/l3-dci-connects-template.json index c011b077b..41df794fd 100644 --- a/restapi-call-node/provider/src/test/resources/l3-dci-connects-template.json +++ b/restapi-call-node/provider/src/test/resources/l3-dci-connects-template.json @@ -1,23 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : SDN-C - * ================================================================================ - * Copyright (C) 2017 Intel Corp. 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========================================================= - */ - { "l3-dci-connect": { "id": ${prop.dci-connects.id}, diff --git a/restapi-call-node/provider/src/test/resources/l3smsitetemplate.json b/restapi-call-node/provider/src/test/resources/l3smsitetemplate.json index 016879c3c..8f8156698 100644 --- a/restapi-call-node/provider/src/test/resources/l3smsitetemplate.json +++ b/restapi-call-node/provider/src/test/resources/l3smsitetemplate.json @@ -1,24 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : 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========================================================= - */ - { "site":[ { diff --git a/restapi-call-node/provider/src/test/resources/l3smvpntemplate.json b/restapi-call-node/provider/src/test/resources/l3smvpntemplate.json index 67f127ce9..30f30a24f 100644 --- a/restapi-call-node/provider/src/test/resources/l3smvpntemplate.json +++ b/restapi-call-node/provider/src/test/resources/l3smvpntemplate.json @@ -1,24 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : 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========================================================= - */ - { "vpn-service": [ { diff --git a/restapi-call-node/provider/src/test/resources/l3smvrftemplate.json b/restapi-call-node/provider/src/test/resources/l3smvrftemplate.json index 732af278c..52359a7fd 100644 --- a/restapi-call-node/provider/src/test/resources/l3smvrftemplate.json +++ b/restapi-call-node/provider/src/test/resources/l3smvrftemplate.json @@ -1,24 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : 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========================================================= - */ - { "vrf-attribute": [ { diff --git a/restapi-call-node/provider/src/test/resources/test-template.json b/restapi-call-node/provider/src/test/resources/test-template.json index faefef31e..ae519a731 100644 --- a/restapi-call-node/provider/src/test/resources/test-template.json +++ b/restapi-call-node/provider/src/test/resources/test-template.json @@ -1,24 +1,3 @@ -/*- - * ============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========================================================= - */ - { "sdn-circuit-request": [ ${repeat:tmp.sdn-circuit-req-row_length: diff --git a/restapi-call-node/provider/src/test/resources/test.json b/restapi-call-node/provider/src/test/resources/test.json index b48eb6b43..75155393c 100644 --- a/restapi-call-node/provider/src/test/resources/test.json +++ b/restapi-call-node/provider/src/test/resources/test.json @@ -1,24 +1,3 @@ -/*- - * ============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========================================================= - */ - { "equipment-data": [ { -- cgit From a220181cb93b27fdd02fc5a9252f22113b59cad2 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Thu, 19 Dec 2019 15:19:53 -0500 Subject: MultiDimension JSON Array Parser Adding Code to support MutiDimensional json parsing logic Change-Id: I487f25c9c7eaeb466ac6903bea80175fa4c50728 Issue-ID: CCSDK-2008 Signed-off-by: Singal, Kapil (ks220y) --- .../ccsdk/sli/plugins/restapicall/JsonParser.java | 66 +++++++++++++------- .../sli/plugins/restapicall/TestJsonParser.java | 70 +++++++++++++++++----- .../provider/src/test/resources/1dArray.json | 8 +++ .../provider/src/test/resources/3dArray.json | 5 +- 4 files changed, 109 insertions(+), 40 deletions(-) create mode 100644 restapi-call-node/provider/src/test/resources/1dArray.json diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java index 4c3ba7f8e..60d43df7a 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import org.apache.commons.lang3.StringUtils; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; @@ -42,6 +43,46 @@ public final class JsonParser { // Preventing instantiation of the same. } + + private static void handleJsonArray(String key, Map jArrayMap, JSONArray jsonArr) throws JSONException { + JSONObject jsonObj; + JSONArray subJsonArr; + boolean stripKey = false; + + for (int i = 0, length = jsonArr.length(); i < length; i++) { + if (stripKey) + key = key.substring(0, key.length()-3); + + subJsonArr = jsonArr.optJSONArray(i); + if (subJsonArr != null) { + key = StringUtils.trimToEmpty(key) + "[" + i + "]"; + jArrayMap.putIfAbsent(key + "_length", String.valueOf(subJsonArr.length())); + handleJsonArray(key, jArrayMap, subJsonArr); + stripKey = true; + continue; + } + + jsonObj = jsonArr.optJSONObject(i); + if (jsonObj != null) { + Iterator ii = jsonObj.keys(); + while (ii.hasNext()) { + String nodeKey = ii.next(); + String key1 = "[" + i + "]." + nodeKey; + String[] subKey = key1.split(":"); + if (subKey.length == 2) { + jArrayMap.putIfAbsent(subKey[1], jsonObj.get(nodeKey)); + } else { + jArrayMap.putIfAbsent(key1, jsonObj.get(nodeKey)); + } + } + } + else { + jArrayMap.putIfAbsent(StringUtils.trimToEmpty(key), jsonArr); + break; + } + } + } + @SuppressWarnings("unchecked") public static Map convertToProperties(String s) throws SvcLogicException { @@ -50,27 +91,13 @@ public final class JsonParser { try { Map wm = new HashMap<>(); - String topLvlArrLength = null; JSONObject json; JSONArray jsonArr; //support top level list in json response if (s.startsWith("[")) { jsonArr = new JSONArray(s); - topLvlArrLength = String.valueOf(jsonArr.length()); - for (int i = 0, length = jsonArr.length(); i < length; i++) { - json = jsonArr.getJSONObject(i); - Iterator ii = json.keys(); - while (ii.hasNext()) { - String key = ii.next(); - String key1 = "[" + i + "]." + key; - String[] subKey = key1.split(":"); - if (subKey.length == 2) { - wm.put(subKey[1], json.get(key)); - } else { - wm.put(key1, json.get(key)); - } - } - } + wm.put("_length", String.valueOf(jsonArr.length())); + handleJsonArray(null, wm, jsonArr); } else { json = new JSONObject(s); Iterator ii = json.keys(); @@ -86,9 +113,6 @@ public final class JsonParser { } Map mm = new HashMap<>(); - if (topLvlArrLength != null) { - mm.put("_length", topLvlArrLength); - } while (!wm.isEmpty()) { for (String key : new ArrayList<>(wm.keySet())) { Object o = wm.get(key); @@ -96,7 +120,6 @@ public final class JsonParser { 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; @@ -113,8 +136,7 @@ public final class JsonParser { } 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())); + log.info("Added property: {}_length: {}", key, ja.length()); for (int i = 0; i < ja.length(); i++) { wm.put(key + '[' + i + ']', ja.get(i)); diff --git a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java index 569719d6c..cdffd4576 100644 --- a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java +++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java @@ -134,7 +134,23 @@ public class TestJsonParser { assertEquals("3", mm.get("menu_length")); } - @Test(expected = SvcLogicException.class) // current behavior is multidimensional arrays are not supported + @Test + public void test1dJsonStringToCtx() throws Exception { + String path = "src/test/resources/1dArray.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + Map mm = JsonParser.convertToProperties(content); + + System.out.println(mm); + assertEquals("6", mm.get("_length")); + assertEquals("apple", mm.get("[0]")); + assertEquals("orange", mm.get("[1]")); + assertEquals("banana", mm.get("[2]")); + assertEquals("squash", mm.get("[3]")); + assertEquals("broccoli", mm.get("[4]")); + assertEquals("cauliflower", mm.get("[5]")); + } + + @Test public void test2dJsonStringToCtx() throws Exception { String path = "src/test/resources/2dArray.json"; String content = new String(Files.readAllBytes(Paths.get(path))); @@ -145,6 +161,7 @@ public class TestJsonParser { assertEquals("orange", mm.get("[0][1]")); assertEquals("banana", mm.get("[0][2]")); assertEquals("3", mm.get("[0]_length")); + assertEquals("squash", mm.get("[1][0]")); assertEquals("broccoli", mm.get("[1][1]")); assertEquals("cauliflower", mm.get("[1][2]")); @@ -152,28 +169,48 @@ public class TestJsonParser { assertEquals("2", mm.get("_length")); } - @Test(expected = SvcLogicException.class) // current behavior is multidimensional arrays are not supported + @Test public void test3dJsonStringToCtx() throws Exception { String path = "src/test/resources/3dArray.json"; String content = new String(Files.readAllBytes(Paths.get(path))); Map mm = JsonParser.convertToProperties(content); - // code will crash before these tests - assertEquals("a", mm.get("[0][0][0]")); - assertEquals("b", mm.get("[0][0][1]")); - assertEquals("c", mm.get("[0][0][2]")); + assertEquals("3", mm.get("_length")); + assertEquals("1", mm.get("[0]_length")); assertEquals("3", mm.get("[0][0]_length")); - assertEquals("d", mm.get("[0][1][0]")); - assertEquals("e", mm.get("[0][1][1]")); - assertEquals("f", mm.get("[0][1][2]")); - assertEquals("3", mm.get("[0][1]_length")); - assertEquals("2", mm.get("[0]_length")); - assertEquals("x", mm.get("[1][0][0]")); - assertEquals("y", mm.get("[1][0][1]")); - assertEquals("z", mm.get("[1][0][2]")); + + assertEquals("2", mm.get("[1]_length")); assertEquals("3", mm.get("[1][0]_length")); - assertEquals("1", mm.get("[1]_length")); - assertEquals("2", mm.get("_length")); + assertEquals("3", mm.get("[1][1]_length")); + + assertEquals("3", mm.get("[2]_length")); + assertEquals("3", mm.get("[2][0]_length")); + assertEquals("3", mm.get("[2][1]_length")); + assertEquals("3", mm.get("[2][2]_length")); + + assertEquals("x", mm.get("[0][0][0]")); + assertEquals("y", mm.get("[0][0][1]")); + assertEquals("z", mm.get("[0][0][2]")); + + assertEquals("abc", mm.get("[1][0][0]")); + assertEquals("def", mm.get("[1][0][1]")); + assertEquals("xyz", mm.get("[1][0][2]")); + + assertEquals("123", mm.get("[1][1][0]")); + assertEquals("456", mm.get("[1][1][1]")); + assertEquals("789", mm.get("[1][1][2]")); + + assertEquals("a", mm.get("[2][0][0]")); + assertEquals("b", mm.get("[2][0][1]")); + assertEquals("c", mm.get("[2][0][2]")); + + assertEquals("d", mm.get("[2][1][0]")); + assertEquals("e", mm.get("[2][1][1]")); + assertEquals("f", mm.get("[2][1][2]")); + + assertEquals("1", mm.get("[2][2][0]")); + assertEquals("2", mm.get("[2][2][1]")); + assertEquals("3", mm.get("[2][2][2]")); } @Test @@ -216,6 +253,7 @@ public class TestJsonParser { mm = JsonParser.convertToProperties(mm.get("input.parameters[0].value")); assertEquals("0.2.0.0/16", mm.get("[0].id")); assertEquals("ge04::/64", mm.get("[1].id")); + assertEquals("2", mm.get("_length")); } } diff --git a/restapi-call-node/provider/src/test/resources/1dArray.json b/restapi-call-node/provider/src/test/resources/1dArray.json new file mode 100644 index 000000000..208fb70a6 --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/1dArray.json @@ -0,0 +1,8 @@ +[ + "apple", + "orange", + "banana", + "squash", + "broccoli", + "cauliflower" +] \ No newline at end of file diff --git a/restapi-call-node/provider/src/test/resources/3dArray.json b/restapi-call-node/provider/src/test/resources/3dArray.json index 149955596..3f3f4fab8 100644 --- a/restapi-call-node/provider/src/test/resources/3dArray.json +++ b/restapi-call-node/provider/src/test/resources/3dArray.json @@ -1,4 +1,5 @@ [ - [["a","b","c"], ["d","e","f"]], - [["x","y","z"]] + [["x","y","z"]], + [["abc","def","xyz"], [123, 456, 789]], + [["a","b","c"], ["d","e","f"], ["1","2","3"]] ] \ No newline at end of file -- cgit From 766036fc36cf4a6dc360d6bb91df62c17bc93bfe Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 23 Jan 2020 14:41:25 -0500 Subject: Use released parent pom Use released version of ccsdk/parent poms Change-Id: I9637c4f8912f7c6583c4764928facbb706deb785 Issue-ID: CCSDK-1963 Signed-off-by: Dan Timoney --- artifacts/pom.xml | 2 +- features/ccsdk-gr-toolkit/pom.xml | 2 +- features/ccsdk-properties-node/pom.xml | 2 +- features/ccsdk-restapi-call-node/pom.xml | 2 +- features/ccsdk-restconf-client/pom.xml | 2 +- features/ccsdk-sli-plugins-all/pom.xml | 2 +- features/ccsdk-sshapi-call-node/pom.xml | 2 +- features/ccsdk-template-node/pom.xml | 2 +- features/features-sli-plugins/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- grToolkit/installer/pom.xml | 2 +- grToolkit/model/pom.xml | 2 +- grToolkit/pom.xml | 2 +- grToolkit/provider/pom.xml | 2 +- pom.xml | 2 +- properties-node/installer/pom.xml | 2 +- properties-node/pom.xml | 2 +- properties-node/provider/pom.xml | 2 +- restapi-call-node/installer/pom.xml | 2 +- restapi-call-node/pom.xml | 2 +- restapi-call-node/provider/pom.xml | 2 +- restconf-client/installer/pom.xml | 2 +- restconf-client/pom.xml | 2 +- restconf-client/provider/pom.xml | 2 +- sshapi-call-node/installer/pom.xml | 2 +- sshapi-call-node/pom.xml | 2 +- sshapi-call-node/provider/pom.xml | 2 +- template-node/installer/pom.xml | 2 +- template-node/pom.xml | 2 +- template-node/provider/pom.xml | 2 +- 31 files changed, 31 insertions(+), 31 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index ab027081a..9ac694c27 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/ccsdk-gr-toolkit/pom.xml b/features/ccsdk-gr-toolkit/pom.xml index 1ac3f96b3..352644af0 100644 --- a/features/ccsdk-gr-toolkit/pom.xml +++ b/features/ccsdk-gr-toolkit/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/ccsdk-properties-node/pom.xml b/features/ccsdk-properties-node/pom.xml index 9cdee255b..c43ee6148 100644 --- a/features/ccsdk-properties-node/pom.xml +++ b/features/ccsdk-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/ccsdk-restapi-call-node/pom.xml b/features/ccsdk-restapi-call-node/pom.xml index 1347c7a99..b93249d9c 100644 --- a/features/ccsdk-restapi-call-node/pom.xml +++ b/features/ccsdk-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/ccsdk-restconf-client/pom.xml b/features/ccsdk-restconf-client/pom.xml index 70c75b92e..75575dd1d 100644 --- a/features/ccsdk-restconf-client/pom.xml +++ b/features/ccsdk-restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index f3cb111d4..5af2e052b 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/ccsdk-sshapi-call-node/pom.xml b/features/ccsdk-sshapi-call-node/pom.xml index 838405be6..971c091d8 100644 --- a/features/ccsdk-sshapi-call-node/pom.xml +++ b/features/ccsdk-sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/ccsdk-template-node/pom.xml b/features/ccsdk-template-node/pom.xml index 7f4c16925..793d0b7f8 100644 --- a/features/ccsdk-template-node/pom.xml +++ b/features/ccsdk-template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index 4f8cd5c19..bdbd2e939 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 686eb812c..5c9eda0a4 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/pom.xml b/features/pom.xml index 7f8bb9122..e4538536e 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/grToolkit/installer/pom.xml b/grToolkit/installer/pom.xml index 6350e2653..1dd2728c1 100755 --- a/grToolkit/installer/pom.xml +++ b/grToolkit/installer/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/grToolkit/model/pom.xml b/grToolkit/model/pom.xml index 52c1c6459..d8c300a29 100755 --- a/grToolkit/model/pom.xml +++ b/grToolkit/model/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.1-SNAPSHOT + 1.5.1 ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/pom.xml b/grToolkit/pom.xml index 4102c8caa..52701e9a8 100755 --- a/grToolkit/pom.xml +++ b/grToolkit/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index 4979f206b..47be01ebe 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.1-SNAPSHOT + 1.5.1 ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index 08d7ea2d6..a9fcbeef1 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 org.onap.ccsdk.sli.plugins diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 8af50203d..98cfb5a6e 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 org.onap.ccsdk.sli.plugins diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 7dd655ac8..87f690399 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 org.onap.ccsdk.sli.plugins diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index d886f6dc2..495cafed1 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.1-SNAPSHOT + 1.5.1 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index f4db07b59..e3279ee42 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index 1c3b8ddf3..c345925aa 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 5126e60ed..17673b685 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.1-SNAPSHOT + 1.5.1 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index f7704298e..3d7213155 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index 76fb65c60..68b137c58 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 194d9a148..e6746a716 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.1-SNAPSHOT + 1.5.1 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index d99170b3c..7897d9b44 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index caa0a4cde..78b4f7766 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index f77fc8cd2..0a5e72ccb 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.1-SNAPSHOT + 1.5.1 org.onap.ccsdk.sli.plugins diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index 9e2b15e16..9bd133449 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 org.onap.ccsdk.sli.plugins diff --git a/template-node/pom.xml b/template-node/pom.xml index 781a798cd..b0fef8f4c 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 org.onap.ccsdk.sli.plugins diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index 20de353a2..6b4db7b77 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.1-SNAPSHOT + 1.5.1 org.onap.ccsdk.sli.plugins -- cgit From 256e3c5709ca341cd8f16465991ad9ae1b7be924 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Fri, 24 Jan 2020 10:52:55 -0500 Subject: Release CCSDK version 0.7.0 Release version 0.7.0 of CCSDK maven artifacts. Change-Id: I3ddddc9315ae4f188f408c48976897f83c8f56cb Issue-ID: CCSDK-1963 Signed-off-by: Dan Timoney --- releases/0.7.0.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releases/0.7.0.yaml diff --git a/releases/0.7.0.yaml b/releases/0.7.0.yaml new file mode 100644 index 000000000..e86406631 --- /dev/null +++ b/releases/0.7.0.yaml @@ -0,0 +1,5 @@ +--- +distribution_type: 'maven' +version: '0.7.0' +project: 'ccsdk-sli-plugins' +log_dir: 'ccsdk-sli-plugins-maven-stage-master/300/' -- cgit From 858ee723108ffa1c2fbcd77cf9bf0aacc83c570e Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Fri, 24 Jan 2020 16:15:16 -0500 Subject: Roll versions to next snapshot Roll CCSDK to next snapshot version Change-Id: Ic16bc8c82ac5f3daba558bfb315437505ff06475 Issue-ID: CCSDK-1963 Signed-off-by: Dan Timoney --- artifacts/pom.xml | 4 ++-- features/ccsdk-gr-toolkit/pom.xml | 4 ++-- features/ccsdk-properties-node/pom.xml | 4 ++-- features/ccsdk-restapi-call-node/pom.xml | 4 ++-- features/ccsdk-restconf-client/pom.xml | 4 ++-- features/ccsdk-sli-plugins-all/pom.xml | 4 ++-- features/ccsdk-sshapi-call-node/pom.xml | 4 ++-- features/ccsdk-template-node/pom.xml | 4 ++-- features/features-sli-plugins/pom.xml | 4 ++-- features/installer/pom.xml | 4 ++-- features/pom.xml | 4 ++-- grToolkit/installer/pom.xml | 4 ++-- grToolkit/model/pom.xml | 4 ++-- grToolkit/pom.xml | 4 ++-- grToolkit/provider/pom.xml | 4 ++-- pom.xml | 4 ++-- properties-node/installer/pom.xml | 4 ++-- properties-node/pom.xml | 4 ++-- properties-node/provider/pom.xml | 4 ++-- restapi-call-node/installer/pom.xml | 4 ++-- restapi-call-node/pom.xml | 4 ++-- restapi-call-node/provider/pom.xml | 4 ++-- restconf-client/installer/pom.xml | 4 ++-- restconf-client/pom.xml | 4 ++-- restconf-client/provider/pom.xml | 4 ++-- sshapi-call-node/installer/pom.xml | 4 ++-- sshapi-call-node/pom.xml | 4 ++-- sshapi-call-node/provider/pom.xml | 4 ++-- template-node/installer/pom.xml | 4 ++-- template-node/pom.xml | 4 ++-- template-node/provider/pom.xml | 4 ++-- version.properties | 2 +- 32 files changed, 63 insertions(+), 63 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 9ac694c27..27fe6ff2a 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.plugins sli-plugins-artifacts - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-plugins :: sli-plugins-artifacts @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.5.1 + 1.5.2-SNAPSHOT diff --git a/features/ccsdk-gr-toolkit/pom.xml b/features/ccsdk-gr-toolkit/pom.xml index 352644af0..975f163a7 100644 --- a/features/ccsdk-gr-toolkit/pom.xml +++ b/features/ccsdk-gr-toolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-gr-toolkit - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT feature ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/features/ccsdk-properties-node/pom.xml b/features/ccsdk-properties-node/pom.xml index c43ee6148..1e8b51fb8 100644 --- a/features/ccsdk-properties-node/pom.xml +++ b/features/ccsdk-properties-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-properties-node - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/features/ccsdk-restapi-call-node/pom.xml b/features/ccsdk-restapi-call-node/pom.xml index b93249d9c..f4d1e5673 100644 --- a/features/ccsdk-restapi-call-node/pom.xml +++ b/features/ccsdk-restapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restapi-call-node - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/features/ccsdk-restconf-client/pom.xml b/features/ccsdk-restconf-client/pom.xml index 75575dd1d..26e57af45 100644 --- a/features/ccsdk-restconf-client/pom.xml +++ b/features/ccsdk-restconf-client/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restconf-client - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT feature diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index 5af2e052b..31616b5f0 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins-all - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/ccsdk-sshapi-call-node/pom.xml b/features/ccsdk-sshapi-call-node/pom.xml index 971c091d8..d2e51070d 100644 --- a/features/ccsdk-sshapi-call-node/pom.xml +++ b/features/ccsdk-sshapi-call-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sshapi-call-node - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/features/ccsdk-template-node/pom.xml b/features/ccsdk-template-node/pom.xml index 793d0b7f8..dc91b544a 100644 --- a/features/ccsdk-template-node/pom.xml +++ b/features/ccsdk-template-node/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-template-node - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT feature ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index bdbd2e939..26d3944a9 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins features-sli-plugins - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 5c9eda0a4..f8d886580 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins sliplugins-features-installer - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-plugins :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index e4538536e..e4ec01a80 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins sliplugins-feature-aggregator - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-plugins :: features diff --git a/grToolkit/installer/pom.xml b/grToolkit/installer/pom.xml index 1dd2728c1..f2b67a453 100755 --- a/grToolkit/installer/pom.xml +++ b/grToolkit/installer/pom.xml @@ -4,14 +4,14 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-installer - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-gr-toolkit diff --git a/grToolkit/model/pom.xml b/grToolkit/model/pom.xml index d8c300a29..dbbea7f87 100755 --- a/grToolkit/model/pom.xml +++ b/grToolkit/model/pom.xml @@ -4,13 +4,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.1 + 1.5.2-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-model - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT bundle diff --git a/grToolkit/pom.xml b/grToolkit/pom.xml index 52701e9a8..8b76fe612 100755 --- a/grToolkit/pom.xml +++ b/grToolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins gr-toolkit - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-plugins :: gr-toolkit diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index 47be01ebe..35468f387 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -4,13 +4,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.1 + 1.5.2-SNAPSHOT ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} org.onap.ccsdk.sli.plugins gr-toolkit-provider - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT bundle diff --git a/pom.xml b/pom.xml index a9fcbeef1..e5527d4cc 100755 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-plugins diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 98cfb5a6e..4969e422e 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-installer - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 87f690399..19b2768b9 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-plugins :: properties-node diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 495cafed1..93bfd91ef 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins properties-node-provider - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT bundle ccsdk-sli-plugins :: properties-node :: ${project.artifactId} diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index e3279ee42..41306a93e 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-installer - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index c345925aa..ab138ffcc 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-plugins :: restapi-call-node diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index 17673b685..ab62e01db 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins restapi-call-node-provider - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT bundle ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index 3d7213155..8835ca665 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-installer - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index 68b137c58..75838fa4e 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-plugins :: restconf-client diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index e6746a716..22b8ecbe3 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins restconf-client-provider - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT bundle ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index 7897d9b44..1de775fa8 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-installer - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index 78b4f7766..efb1afdc7 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-plugins :: sshapi-call-node diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index 0a5e72ccb..95ca09cfe 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins sshapi-call-node-provider - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT bundle ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index 9bd133449..1efeff5ad 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-installer - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/template-node/pom.xml b/template-node/pom.xml index b0fef8f4c..261259a61 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins template-node - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index 6b4db7b77..d3df4f9e7 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent binding-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.plugins template-node-provider - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT bundle ccsdk-sli-plugins :: template-node :: ${project.artifactId} diff --git a/version.properties b/version.properties index f23ce8f9e..b9d48a2a7 100644 --- a/version.properties +++ b/version.properties @@ -7,7 +7,7 @@ release_name=0 sprint_number=7 -feature_revision=0 +feature_revision=1 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit From ab87c55476acf4e64015086e9cb200d0af181c17 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Mon, 17 Feb 2020 10:41:38 -0500 Subject: Escaping multi-line string Supporting multiline json string if embedding within Rest payload template Change-Id: I6a96f58732734fca0127d57fa5de3ba3cb7276c4 Issue-ID: CCSDK-2103 Signed-off-by: Singal, Kapil (ks220y) --- .../ccsdk/sli/plugins/restapicall/XmlJsonUtil.java | 22 ++++------------------ .../plugins/restapicall/TestRestapiCallNode.java | 22 +++++++++++++++++++++- .../resources/testMultiLineEmbeddedTemplate.json | 20 ++++++++++++++++++++ 3 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 restapi-call-node/provider/src/test/resources/testMultiLineEmbeddedTemplate.json diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java index bc6afd84c..ff3224829 100644 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.commons.text.StringEscapeUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -142,7 +143,7 @@ public final class XmlJsonUtil { } if (o instanceof String) { - return escape ? escapeXml((String) o) : (String) o; + return escape ? StringEscapeUtils.escapeXml10((String) o) : (String) o; }; if (o instanceof Map) { @@ -152,7 +153,7 @@ public final class XmlJsonUtil { Object v = entry.getValue(); String key = entry.getKey(); if (v instanceof String) { - String s = escape ? escapeXml((String) v) : (String) v; + String s = escape ? StringEscapeUtils.escapeXml10((String) v) : (String) v; ss.append(pad(indent)).append('<').append(key).append('>'); ss.append(s); ss.append("').append('\n'); @@ -190,7 +191,7 @@ public final class XmlJsonUtil { @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; + String s = escape ? StringEscapeUtils.escapeJson((String) o) : (String) o; if (padFirst) { ss.append(pad(indent)); } @@ -396,21 +397,6 @@ public final class XmlJsonUtil { return s; } - private static String escapeXml(String v) { - String s = v.replaceAll("&", "&"); - s = s.replaceAll("<", "<"); - s = s.replaceAll("'", "'"); - s = s.replaceAll("\"", """); - s = s.replaceAll(">", ">"); - 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++) { diff --git a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index 8cabaadcf..da7b80ee1 100755 --- a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -528,7 +528,27 @@ public class TestRestapiCallNode { RestapiCallNode rcn = new RestapiCallNode(); String request = rcn.buildXmlJsonRequest(ctx, rcn.readFile("src/test/resources/testEmbeddedTemplate.json"), Format.JSON); //This will throw a JSONException and fail the test case if rest api call node doesn't form valid JSON - JSONObject requestObj = new JSONObject(request); + assertNotNull(new JSONObject(request)); + } + + @Test + public void testMultiLineEmbeddedJsonTemplate() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + String complexObj = "{\n" + + " \"image_name\": \"Ubuntu 14.04\",\n" + + " \"service-instance-id\": \"1\",\n" + + " \"vnf-model-customization-uuid\": \"2f\",\n" + + " \"vnf-id\": \"3b\"\n" + + "}"; + ctx.setAttribute("reqId", "1235"); + ctx.setAttribute("subReqId", "054243"); + ctx.setAttribute("actionName", "CREATE"); + ctx.setAttribute("myPrefix", "2016-09-09 16:30:35.0"); + ctx.setAttribute("complexObj", complexObj); + RestapiCallNode rcn = new RestapiCallNode(); + String request = rcn.buildXmlJsonRequest(ctx, rcn.readFile("src/test/resources/testMultiLineEmbeddedTemplate.json"), Format.JSON); + //This will throw a JSONException and fail the test case if rest api call node doesn't form valid JSON + assertNotNull(new JSONObject(request)); } } diff --git a/restapi-call-node/provider/src/test/resources/testMultiLineEmbeddedTemplate.json b/restapi-call-node/provider/src/test/resources/testMultiLineEmbeddedTemplate.json new file mode 100644 index 000000000..84ae3a492 --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/testMultiLineEmbeddedTemplate.json @@ -0,0 +1,20 @@ +{ + "commonHeader": { + "origin": "earth", + "requestId": ${reqId}, + "subRequestId": ${subReqId} + }, + "actions": { + "actionName": ${actionName}, + "mode": "sync" + }, + "payload": { + "assignment-request": { + "prefix": [ + ${myPrefix} + ], + "assignment-properties": ${complexObj} + } + } +} + -- cgit From a0c94fb457d418da3d49ce003fcecd3f5aaee9b7 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Thu, 20 Feb 2020 19:33:15 +0000 Subject: rest api call node target entity rest api call node target entity Issue-ID: CCSDK-2109 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: Ib754a02cc64862de6518eac2a1c28b9f637616bc --- .../org/onap/ccsdk/sli/plugins/restapicall/Parameters.java | 1 + .../onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java index 8b9cdc39c..8950df4ce 100755 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/Parameters.java @@ -54,4 +54,5 @@ public class Parameters { public String accept; public boolean multipartFormData; public String multipartFile; + public String targetEntity; } diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index b4d7e1ba8..165eefde4 100755 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -73,8 +73,10 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; import org.onap.logging.filter.base.MetricLogClientFilter; +import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.slf4j.MDC; public class RestapiCallNode implements SvcLogicJavaPlugin { @@ -223,6 +225,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { p.accept = parseParam(paramMap, "accept", false, null); p.multipartFormData = valueOf(parseParam(paramMap, "multipartFormData", false, "false")); p.multipartFile = parseParam(paramMap, "multipartFile", false, null); + p.targetEntity = parseParam(paramMap, "targetEntity", false, null); return p; } @@ -463,10 +466,13 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { protected void sendRequest(Map paramMap, SvcLogicContext ctx, RetryPolicy retryPolicy) throws SvcLogicException { - HttpResponse r = new HttpResponse(); + HttpResponse r = new HttpResponse(); try { handlePartner(paramMap); Parameters p = getParameters(paramMap, new Parameters()); + if(p.targetEntity != null && !p.targetEntity.isEmpty()) { + MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY, p.targetEntity); + } if (p.restapiUrl.contains(",") && retryPolicy == null) { String[] urls = p.restapiUrl.split(","); retryPolicy = new RetryPolicy(urls, urls.length * 2); @@ -874,8 +880,6 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } } - invocationBuilder.header("X-ECOMP-RequestID", org.slf4j.MDC.get("X-ECOMP-RequestID")); - Response response; try { -- cgit From b5c10c18ce806f875e9fd2c8dcaece5628898093 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Mon, 24 Feb 2020 15:40:08 -0500 Subject: Fix dblib dependency scope Scope of dependency on dblib must be provided to avoid conflicting definition of embedded tomcat dependency in derived feature.xml Change-Id: I14ab926da13aae64bd819dbb05c66e373e1cb3ac Issue-ID: CCSDK-2117 Signed-off-by: Dan Timoney --- grToolkit/provider/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index 35468f387..201ff86ad 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -47,6 +47,7 @@ org.onap.ccsdk.sli.core dblib-provider ${ccsdk.sli.core.version} + provided org.onap.ccsdk.sli.core -- cgit From 94ca994a89607f28e38129f43c89d2402859092f Mon Sep 17 00:00:00 2001 From: sb5356 Date: Fri, 28 Feb 2020 15:25:21 -0500 Subject: Restapi-call-node: Fix sending big files to DMAAP data router Issue-ID: CCSDK-2122 Signed-off-by: Stan Bonev Change-Id: If71e6d3ee0bd649994ce4b9a23dcbd1b42a64101 --- .../sli/plugins/restapicall/RestapiCallNode.java | 142 +++++++++++++-------- .../plugins/restapicall/TestRestapiCallNode.java | 28 ++-- .../provider/src/test/resources/test_file.txt | 5 + 3 files changed, 112 insertions(+), 63 deletions(-) create mode 100644 restapi-call-node/provider/src/test/resources/test_file.txt diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 165eefde4..709774bb9 100755 --- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -25,15 +25,22 @@ package org.onap.ccsdk.sli.plugins.restapicall; import static java.lang.Boolean.valueOf; import static javax.ws.rs.client.Entity.entity; import static org.onap.ccsdk.sli.plugins.restapicall.AuthType.fromString; +import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.ProtocolException; import java.net.SocketException; import java.net.URI; +import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; import java.security.KeyStore; import java.util.ArrayList; +import java.util.Base64; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -72,7 +79,9 @@ import org.glassfish.jersey.media.multipart.file.FileDataBodyPart; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.logging.filter.base.HttpURLConnectionMetricUtil; import org.onap.logging.filter.base.MetricLogClientFilter; +import org.onap.logging.filter.base.ONAPComponents; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -128,6 +137,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { httpReadTimeout = readOptionalInteger("HTTP_READ_TIMEOUT_MS",DEFAULT_HTTP_READ_TIMEOUT_MS); } + @SuppressWarnings("unchecked") protected void loadPartners(JSONObject partners) { Iterator keys = partners.keys(); String partnerUserKey = "user"; @@ -956,6 +966,16 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { byte[] data = Files.readAllBytes(Paths.get(p.fileName)); r = sendHttpData(data, p); + + for (int i = 0; i < 10 && r.code == 301; i++) { + String newUrl = r.headers2.get("Location").get(0); + + log.info("Got response code 301. Sending same request to URL: " + newUrl); + + p.url = newUrl; + r = sendHttpData(data, p); + } + setResponseStatus(ctx, p.responsePrefix, r); } catch (SvcLogicException | IOException e) { @@ -1030,12 +1050,27 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } } - protected HttpResponse sendHttpData(byte[] data, FileParam p) throws SvcLogicException { + protected HttpResponse sendHttpData(byte[] data, FileParam p) throws IOException { + URL url = new URL(p.url); + HttpURLConnection con = (HttpURLConnection) url.openConnection(); - Client client = ClientBuilder.newBuilder().build(); - setClientTimeouts(client); - client.property(ClientProperties.FOLLOW_REDIRECTS, true); - WebTarget webTarget = addAuthType(client, p).target(p.url); + log.info("Connection: " + con.getClass().getName()); + + con.setRequestMethod(p.httpMethod.toString()); + con.setRequestProperty("Content-Type", "application/octet-stream"); + con.setRequestProperty("Accept", "*/*"); + con.setRequestProperty("Expect", "100-continue"); + con.setFixedLengthStreamingMode(data.length); + con.setInstanceFollowRedirects(false); + + if (p.user != null && p.password != null) { + String authString = p.user + ":" + p.password; + String authStringEnc = Base64.getEncoder().encodeToString(authString.getBytes()); + con.setRequestProperty("Authorization", "Basic " + authStringEnc); + } + + con.setDoInput(true); + con.setDoOutput(true); log.info("Sending file"); long t1 = System.currentTimeMillis(); @@ -1044,69 +1079,46 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { r.code = 200; if (!p.skipSending) { - String tt = "application/octet-stream"; - Invocation.Builder invocationBuilder = webTarget.request(tt).accept(tt); + HttpURLConnectionMetricUtil util = new HttpURLConnectionMetricUtil(); + util.logBefore(con, ONAPComponents.DMAAP); - Response response; + con.connect(); + boolean continue100failed = false; try { - if (p.httpMethod == HttpMethod.POST) { - response = invocationBuilder.post(Entity.entity(data, tt)); - } else if (p.httpMethod == HttpMethod.PUT) { - response = invocationBuilder.put(Entity.entity(data, tt)); - } else { - throw new SvcLogicException("Http operation" + p.httpMethod + "not supported"); - } - } catch (ProcessingException e) { - throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e); - } - - r.code = response.getStatus(); - r.headers = response.getStringHeaders(); - EntityTag etag = response.getEntityTag(); - if (etag != null) { - r.message = etag.getValue(); - } - if (response.hasEntity() && r.code != 204) { - r.body = response.readEntity(String.class); + OutputStream os = con.getOutputStream(); + os.write(data); + os.flush(); + os.close(); + } catch (ProtocolException e) { + continue100failed = true; } - if (r.code == 301) { - String newUrl = response.getStringHeaders().getFirst("Location"); + r.code = con.getResponseCode(); + r.headers2 = con.getHeaderFields(); - log.info("Got response code 301. Sending same request to URL: {}", newUrl); - - webTarget = client.target(newUrl); - invocationBuilder = webTarget.request(tt).accept(tt); - - try { - if (p.httpMethod == HttpMethod.POST) { - response = invocationBuilder.post(Entity.entity(data, tt)); - } else if (p.httpMethod == HttpMethod.PUT) { - response = invocationBuilder.put(Entity.entity(data, tt)); - } else { - throw new SvcLogicException("Http operation" + p.httpMethod + "not supported"); - } - } catch (ProcessingException e) { - throw new SvcLogicException(requestPostingException + e.getLocalizedMessage(), e); + if (r.code != 204 && !continue100failed) { + BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String inputLine; + StringBuffer response = new StringBuffer(); + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); } + in.close(); - r.code = response.getStatus(); - etag = response.getEntityTag(); - if (etag != null) { - r.message = etag.getValue(); - } - if (response.hasEntity() && r.code != 204) { - r.body = response.readEntity(String.class); - } + r.body = response.toString(); } + + util.logAfter(con); + + con.disconnect(); } long t2 = System.currentTimeMillis(); - log.info(responseReceivedMessage, t2 - t1); - log.info(responseHttpCodeMessage, r.code); + log.info("Response received. Time: {}", t2 - t1); + log.info("HTTP response code: {}", r.code); log.info("HTTP response message: {}", r.message); - logHeaders(r.headers); + logHeaders(r.headers2); log.info("HTTP response: {}", r.body); return r; @@ -1154,6 +1166,26 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } } + private void logHeaders(Map> mm) { + if (mm == null || mm.isEmpty()) { + return; + } + + List ll = new ArrayList<>(); + for (String s : mm.keySet()) { + if (s != null) { + ll.add(s); + } + } + Collections.sort(ll); + + for (String name : ll) { + List v = mm.get(name); + log.info("--- {}:{}", name, String.valueOf(mm.get(name))); + log.info("--- " + name + ": " + (v.size() == 1 ? v.get(0) : v)); + } + } + protected HttpResponse postOnUeb(String request, UebParam p) throws SvcLogicException { String[] urls = uebServers.split(" "); for (int i = 0; i < urls.length; i++) { diff --git a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index da7b80ee1..b2f75bcd1 100755 --- a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -24,12 +24,9 @@ package org.onap.ccsdk.sli.plugins.restapicall; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; - import java.util.HashMap; import java.util.Map; - import org.codehaus.jettison.json.JSONObject; - import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; @@ -80,6 +77,21 @@ public class TestRestapiCallNode { rcn.sendRequest(p, ctx); } + @Test + public void testSendFile() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + Map p = new HashMap<>(); + p.put("fileName", "src/test/resources/test_file.txt"); + p.put("url", "https://testurl.test"); + p.put("user", "user"); + p.put("password", "*******"); + p.put("skipSending", "true"); // Set real url, user, password, when testing actual sending + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendFile(p, ctx); + } + @Test public void testJsonTemplate() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); @@ -479,16 +491,16 @@ public class TestRestapiCallNode { assertNull(rcn.partnerStore.get("partnerThree")); //In this scenario the caller expects username, password and url to be picked up from the partners json - Map paramMap = new HashMap(); + Map paramMap = new HashMap<>(); paramMap.put("partner", partnerTwoKey); rcn.handlePartner(paramMap ); - assertEquals(partnerTwoUsername,paramMap.get(rcn.restapiUserKey)); - assertEquals(partnerTwoPassword,paramMap.get(rcn.restapiPasswordKey)); - assertEquals("http://localhost:7002",paramMap.get(rcn.restapiUrlString)); + assertEquals(partnerTwoUsername,paramMap.get(RestapiCallNode.restapiUserKey)); + assertEquals(partnerTwoPassword,paramMap.get(RestapiCallNode.restapiPasswordKey)); + assertEquals("http://localhost:7002",paramMap.get(RestapiCallNode.restapiUrlString)); //In this scenario the caller expects username, password and url to be picked up from the partners json //the provided suffix will be appended to the default url from the partners json - paramMap = new HashMap(); + paramMap = new HashMap<>(); paramMap.put("partner", partnerTwoKey); paramMap.put("restapiUrlSuffix", "/networking/v1/instance/3"); rcn.handlePartner(paramMap); diff --git a/restapi-call-node/provider/src/test/resources/test_file.txt b/restapi-call-node/provider/src/test/resources/test_file.txt new file mode 100644 index 000000000..038d757dc --- /dev/null +++ b/restapi-call-node/provider/src/test/resources/test_file.txt @@ -0,0 +1,5 @@ +“You think your pain and your heartbreak are unprecedented in the history of the world, but then you read. It was books that taught me that the things that tormented me most were the very things that connected me with all the people who were alive, who had ever been alive.” – James Baldwin +“When I have a little money, I buy books; and if I have any left, I buy food and clothes.” – Erasmus +“If you only read the books that everyone else is reading, you can only think what everyone else is thinking.” – Haruki Murakami +“You don’t have to burn books to destroy a culture. Just get people to stop reading them.” – Ray Bradbury +“A reader lives a thousand lives before he dies, said Jojen. The man who never reads lives only one.” – George R.R. Martin -- cgit From ccc9dffe40a1978ff129c9280b019f2dd9e52eeb Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 3 Mar 2020 13:28:31 -0500 Subject: Use released 1.5.2 CCSDK parent Update to use released version of CCSDK parent pom Change-Id: Ie2db3e1f9f8e2aa411a456cb3f29916226aa6b10 Issue-ID: CCSDK-2152 Signed-off-by: Dan Timoney --- artifacts/pom.xml | 2 +- features/ccsdk-gr-toolkit/pom.xml | 2 +- features/ccsdk-properties-node/pom.xml | 2 +- features/ccsdk-restapi-call-node/pom.xml | 2 +- features/ccsdk-restconf-client/pom.xml | 2 +- features/ccsdk-sli-plugins-all/pom.xml | 2 +- features/ccsdk-sshapi-call-node/pom.xml | 2 +- features/ccsdk-template-node/pom.xml | 2 +- features/features-sli-plugins/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- grToolkit/installer/pom.xml | 2 +- grToolkit/model/pom.xml | 2 +- grToolkit/pom.xml | 2 +- grToolkit/provider/pom.xml | 2 +- pom.xml | 2 +- properties-node/installer/pom.xml | 2 +- properties-node/pom.xml | 2 +- properties-node/provider/pom.xml | 2 +- restapi-call-node/installer/pom.xml | 2 +- restapi-call-node/pom.xml | 2 +- restapi-call-node/provider/pom.xml | 2 +- restconf-client/installer/pom.xml | 2 +- restconf-client/pom.xml | 2 +- restconf-client/provider/pom.xml | 2 +- sshapi-call-node/installer/pom.xml | 2 +- sshapi-call-node/pom.xml | 2 +- sshapi-call-node/provider/pom.xml | 2 +- template-node/installer/pom.xml | 2 +- template-node/pom.xml | 2 +- template-node/provider/pom.xml | 2 +- 31 files changed, 31 insertions(+), 31 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 27fe6ff2a..a6f406df9 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/ccsdk-gr-toolkit/pom.xml b/features/ccsdk-gr-toolkit/pom.xml index 975f163a7..308990411 100644 --- a/features/ccsdk-gr-toolkit/pom.xml +++ b/features/ccsdk-gr-toolkit/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/ccsdk-properties-node/pom.xml b/features/ccsdk-properties-node/pom.xml index 1e8b51fb8..2c1ca974a 100644 --- a/features/ccsdk-properties-node/pom.xml +++ b/features/ccsdk-properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/ccsdk-restapi-call-node/pom.xml b/features/ccsdk-restapi-call-node/pom.xml index f4d1e5673..3bb1ce31e 100644 --- a/features/ccsdk-restapi-call-node/pom.xml +++ b/features/ccsdk-restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/ccsdk-restconf-client/pom.xml b/features/ccsdk-restconf-client/pom.xml index 26e57af45..ad001ed1f 100644 --- a/features/ccsdk-restconf-client/pom.xml +++ b/features/ccsdk-restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index 31616b5f0..96f1b0079 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/ccsdk-sshapi-call-node/pom.xml b/features/ccsdk-sshapi-call-node/pom.xml index d2e51070d..5209d49b6 100644 --- a/features/ccsdk-sshapi-call-node/pom.xml +++ b/features/ccsdk-sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/ccsdk-template-node/pom.xml b/features/ccsdk-template-node/pom.xml index dc91b544a..8096d276c 100644 --- a/features/ccsdk-template-node/pom.xml +++ b/features/ccsdk-template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/features-sli-plugins/pom.xml b/features/features-sli-plugins/pom.xml index 26d3944a9..43bdaedbd 100644 --- a/features/features-sli-plugins/pom.xml +++ b/features/features-sli-plugins/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/installer/pom.xml b/features/installer/pom.xml index f8d886580..23f99d5da 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/pom.xml b/features/pom.xml index e4ec01a80..f68c07fbc 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/grToolkit/installer/pom.xml b/grToolkit/installer/pom.xml index f2b67a453..894ddb8bf 100755 --- a/grToolkit/installer/pom.xml +++ b/grToolkit/installer/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/grToolkit/model/pom.xml b/grToolkit/model/pom.xml index dbbea7f87..d03eae6db 100755 --- a/grToolkit/model/pom.xml +++ b/grToolkit/model/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.2-SNAPSHOT + 1.5.2 ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/grToolkit/pom.xml b/grToolkit/pom.xml index 8b76fe612..9db6a6ef3 100755 --- a/grToolkit/pom.xml +++ b/grToolkit/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/grToolkit/provider/pom.xml b/grToolkit/provider/pom.xml index 201ff86ad..17e69e9ea 100755 --- a/grToolkit/provider/pom.xml +++ b/grToolkit/provider/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.2-SNAPSHOT + 1.5.2 ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index e5527d4cc..f1a99b06f 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 org.onap.ccsdk.sli.plugins diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml index 4969e422e..731ca75e4 100755 --- a/properties-node/installer/pom.xml +++ b/properties-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 org.onap.ccsdk.sli.plugins diff --git a/properties-node/pom.xml b/properties-node/pom.xml index 19b2768b9..37defa622 100755 --- a/properties-node/pom.xml +++ b/properties-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 org.onap.ccsdk.sli.plugins diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml index 93bfd91ef..0cc077357 100755 --- a/properties-node/provider/pom.xml +++ b/properties-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.2-SNAPSHOT + 1.5.2 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/installer/pom.xml b/restapi-call-node/installer/pom.xml index 41306a93e..789117ea3 100755 --- a/restapi-call-node/installer/pom.xml +++ b/restapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/pom.xml b/restapi-call-node/pom.xml index ab138ffcc..cb8d96116 100755 --- a/restapi-call-node/pom.xml +++ b/restapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 org.onap.ccsdk.sli.plugins diff --git a/restapi-call-node/provider/pom.xml b/restapi-call-node/provider/pom.xml index ab62e01db..c2e69ebbe 100755 --- a/restapi-call-node/provider/pom.xml +++ b/restapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.2-SNAPSHOT + 1.5.2 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/installer/pom.xml b/restconf-client/installer/pom.xml index 8835ca665..b7171a2f5 100755 --- a/restconf-client/installer/pom.xml +++ b/restconf-client/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/pom.xml b/restconf-client/pom.xml index 75838fa4e..944f5a77d 100755 --- a/restconf-client/pom.xml +++ b/restconf-client/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 org.onap.ccsdk.sli.plugins diff --git a/restconf-client/provider/pom.xml b/restconf-client/provider/pom.xml index 22b8ecbe3..5ec3aa023 100755 --- a/restconf-client/provider/pom.xml +++ b/restconf-client/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.2-SNAPSHOT + 1.5.2 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/installer/pom.xml b/sshapi-call-node/installer/pom.xml index 1de775fa8..6b70a5de3 100755 --- a/sshapi-call-node/installer/pom.xml +++ b/sshapi-call-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/pom.xml b/sshapi-call-node/pom.xml index efb1afdc7..b75215529 100755 --- a/sshapi-call-node/pom.xml +++ b/sshapi-call-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 org.onap.ccsdk.sli.plugins diff --git a/sshapi-call-node/provider/pom.xml b/sshapi-call-node/provider/pom.xml index 95ca09cfe..a6e7b8f55 100755 --- a/sshapi-call-node/provider/pom.xml +++ b/sshapi-call-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.2-SNAPSHOT + 1.5.2 org.onap.ccsdk.sli.plugins diff --git a/template-node/installer/pom.xml b/template-node/installer/pom.xml index 1efeff5ad..bf581d464 100644 --- a/template-node/installer/pom.xml +++ b/template-node/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 org.onap.ccsdk.sli.plugins diff --git a/template-node/pom.xml b/template-node/pom.xml index 261259a61..b858e5e2b 100644 --- a/template-node/pom.xml +++ b/template-node/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 org.onap.ccsdk.sli.plugins diff --git a/template-node/provider/pom.xml b/template-node/provider/pom.xml index d3df4f9e7..5832ad12d 100644 --- a/template-node/provider/pom.xml +++ b/template-node/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.2-SNAPSHOT + 1.5.2 org.onap.ccsdk.sli.plugins -- cgit From 50ca197af9b9e0eadb2626ec6ca41dcd1d792b73 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 5 Mar 2020 10:32:43 -0500 Subject: Release version 0.7.1 Release version 0.7.1 (Frankfurt M4) Change-Id: I613836d98517a3877cce9a366c9a9796730aeec6 Issue-ID: CCSDK-2152 Signed-off-by: Dan Timoney --- releases/0.7.1.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releases/0.7.1.yaml diff --git a/releases/0.7.1.yaml b/releases/0.7.1.yaml new file mode 100644 index 000000000..990922216 --- /dev/null +++ b/releases/0.7.1.yaml @@ -0,0 +1,5 @@ +--- +distribution_type: 'maven' +version: '0.7.1' +project: 'ccsdk-sli-plugins' +log_dir: 'ccsdk-sli-plugins-maven-stage-master/301/' -- cgit From 71fb63595ff340651f1499705849a08d0eba954b Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 5 Mar 2020 11:53:23 -0500 Subject: Roll master to Guilin Roll versions of master for early Guilin development Change-Id: If777c42a3a6bf10589835b73b02f2fccdeca9490 Issue-ID: CCSDK-2152 Signed-off-by: Dan Timoney --- artifacts/pom.xml | 17 ++++++------ features/ccsdk-gr-toolkit/pom.xml | 4 +-- features/ccsdk-properties-node/pom.xml | 5 ++-- features/ccsdk-restapi-call-node/pom.xml | 5 ++-- features/ccsdk-restconf-client/pom.xml | 11 +++----- features/ccsdk-sli-plugins-all/pom.xml | 5 ++-- features/ccsdk-sshapi-call-node/pom.xml | 9 +++---- features/ccsdk-template-node/pom.xml | 4 +-- features/features-sli-plugins/pom.xml | 4 +-- features/installer/pom.xml | 4 +-- features/pom.xml | 4 +-- grToolkit/installer/pom.xml | 11 +++++--- grToolkit/model/pom.xml | 9 ++++--- grToolkit/pom.xml | 6 ++--- grToolkit/provider/pom.xml | 45 +++++++++++++++++--------------- pom.xml | 4 +-- properties-node/installer/pom.xml | 4 +-- properties-node/pom.xml | 4 +-- properties-node/provider/pom.xml | 5 ++-- restapi-call-node/installer/pom.xml | 4 +-- restapi-call-node/pom.xml | 4 +-- restapi-call-node/provider/pom.xml | 6 ++--- restconf-client/installer/pom.xml | 4 +-- restconf-client/pom.xml | 4 +-- restconf-client/provider/pom.xml | 5 ++-- sshapi-call-node/installer/pom.xml | 4 +-- sshapi-call-node/pom.xml | 4 +-- sshapi-call-node/provider/pom.xml | 15 +++++------ template-node/installer/pom.xml | 4 +-- template-node/pom.xml | 4 +-- template-node/provider/pom.xml | 21 +++++++-------- version.properties | 6 ++--- 32 files changed, 120 insertions(+), 125 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index a6f406df9..12109ce52 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -2,9 +2,15 @@ 4.0.0 + + org.onap.ccsdk.parent + parent + 2.0.0-SNAPSHOT + + org.onap.ccsdk.sli.plugins sli-plugins-artifacts - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT pom ccsdk-sli-plugins :: sli-plugins-artifacts @@ -13,13 +19,7 @@ ONAP - - - org.onap.ccsdk.parent - parent - 1.5.2 - - + @@ -102,5 +102,4 @@ - diff --git a/features/ccsdk-gr-toolkit/pom.xml b/features/ccsdk-gr-toolkit/pom.xml index 308990411..ceac41054 100644 --- a/features/ccsdk-gr-toolkit/pom.xml +++ b/features/ccsdk-gr-toolkit/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-gr-toolkit - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT feature ccsdk-sli-plugins :: gr-toolkit :: ${project.artifactId} diff --git a/features/ccsdk-properties-node/pom.xml b/features/ccsdk-properties-node/pom.xml index 2c1ca974a..c22b00aeb 100644 --- a/features/ccsdk-properties-node/pom.xml +++ b/features/ccsdk-properties-node/pom.xml @@ -5,18 +5,17 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-properties-node - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT feature ccsdk-sli-plugins :: properties-node :: ${project.artifactId} - diff --git a/features/ccsdk-restapi-call-node/pom.xml b/features/ccsdk-restapi-call-node/pom.xml index 3bb1ce31e..29111052e 100644 --- a/features/ccsdk-restapi-call-node/pom.xml +++ b/features/ccsdk-restapi-call-node/pom.xml @@ -5,18 +5,17 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restapi-call-node - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT feature ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId} - javax.ws.rs diff --git a/features/ccsdk-restconf-client/pom.xml b/features/ccsdk-restconf-client/pom.xml index ad001ed1f..0fb75b432 100644 --- a/features/ccsdk-restconf-client/pom.xml +++ b/features/ccsdk-restconf-client/pom.xml @@ -5,24 +5,21 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-restconf-client - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT feature + ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} + true - ccsdk-sli-plugins :: restconf-client :: ${project.artifactId} - - - - diff --git a/features/ccsdk-sli-plugins-all/pom.xml b/features/ccsdk-sli-plugins-all/pom.xml index 96f1b0079..132abd569 100644 --- a/features/ccsdk-sli-plugins-all/pom.xml +++ b/features/ccsdk-sli-plugins-all/pom.xml @@ -5,18 +5,17 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sli-plugins-all - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT feature ccsdk-sli-plugins :: features :: ${project.artifactId} - ${project.groupId} diff --git a/features/ccsdk-sshapi-call-node/pom.xml b/features/ccsdk-sshapi-call-node/pom.xml index 5209d49b6..5b600563c 100644 --- a/features/ccsdk-sshapi-call-node/pom.xml +++ b/features/ccsdk-sshapi-call-node/pom.xml @@ -5,20 +5,17 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.plugins ccsdk-sshapi-call-node - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT feature ccsdk-sli-plugins :: sshapi-call-node :: ${project.artifactId} - - - -