diff options
83 files changed, 1326 insertions, 537 deletions
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/node_types.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/node_types.json index 8f6c44f9..68a8ae6b 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/node_types.json +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/node_types.json @@ -223,7 +223,7 @@ }, "derived_from": "tosca.nodes.ResourceSource" }, - "source-primary-db": { + "source-processor-db": { "description": "This is Database Resource Source Node Type", "version": "1.0.0", "properties": { diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json index eaf45b35..6e3d5e94 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json @@ -26,8 +26,8 @@ "type": "source-input", "properties": {} }, - "primary-db": { - "type": "source-primary-db", + "processor-db": { + "type": "source-processor-db", "properties": { "endpoint-selector": "dynamic-db-source", "query": "SELECT artifact_name FROM sdnctl.BLUEPRINT_RUNTIME where artifact_version=\"1.0.0\"", diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/node_types.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/node_types.json index b0586921..f143e560 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/node_types.json +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/node_types.json @@ -236,7 +236,7 @@ }, "derived_from" : "tosca.nodes.ResourceSource" }, - "source-primary-db" : { + "source-processor-db" : { "description" : "This is Database Resource Source Node Type", "version" : "1.0.0", "properties" : { diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/resources_definition_types.json index 446a8a68..15f02a1c 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/resources_definition_types.json +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/resources_definition_types.json @@ -129,8 +129,8 @@ }, "updated-by" : "adetalhouet", "sources" : { - "primary-db" : { - "type" : "source-primary-db", + "processor-db" : { + "type" : "source-processor-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.demo.value as value from sdnctl.demo where sdnctl.demo.id=:vfmoduleid", diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vf-module-1-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vf-module-1-mapping.json index eba259e3..b7335b51 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vf-module-1-mapping.json +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vf-module-1-mapping.json @@ -18,7 +18,7 @@ "type": "string" }, "dictionary-name": "vf-module-type", - "dictionary-source": "primary-db", + "dictionary-source": "processor-db", "dependencies": [ "vf-module-number" ] diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vfw-interface-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vfw-interface-mapping.json index 149d3eb2..c1ebe568 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vfw-interface-mapping.json +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vfw-interface-mapping.json @@ -55,7 +55,7 @@ "type": "string" }, "dictionary-name": "vf-module-type", - "dictionary-source": "primary-db", + "dictionary-source": "processor-db", "dependencies": [ "vf-module-number" ] diff --git a/components/model-catalog/definition-type/starter-type/node_type/source-processor-db.json b/components/model-catalog/definition-type/starter-type/node_type/source-processor-db.json new file mode 100644 index 00000000..702748f8 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/source-processor-db.json @@ -0,0 +1,48 @@ +{ + "description": "This is Database Resource Source Node Type", + "version": "1.0.0", + "properties": { + "type": { + "required": true, + "type": "string", + "constraints": [ + { + "valid_values": [ + "SQL", + "PLSQL" + ] + } + ] + }, + "endpoint-selector": { + "required": false, + "type": "string" + }, + "query": { + "required": true, + "type": "string" + }, + "input-key-mapping": { + "required": false, + "type": "map", + "entry_schema": { + "type": "string" + } + }, + "output-key-mapping": { + "required": false, + "type": "map", + "entry_schema": { + "type": "string" + } + }, + "key-dependencies": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "derived_from": "tosca.nodes.ResourceSource" +}
\ No newline at end of file diff --git a/components/model-catalog/proto-definition/pom.xml b/components/model-catalog/proto-definition/pom.xml index 35fc9a9a..d1247084 100644 --- a/components/model-catalog/proto-definition/pom.xml +++ b/components/model-catalog/proto-definition/pom.xml @@ -20,7 +20,7 @@ <parent> <groupId>org.onap.ccsdk.apps</groupId> <artifactId>ccsdk-apps</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> <relativePath>../../../</relativePath> </parent> diff --git a/components/model-catalog/resource-dictionary/test-dictionary/vf-module-type.json b/components/model-catalog/resource-dictionary/test-dictionary/vf-module-type.json index b06057c4..9e8c4096 100644 --- a/components/model-catalog/resource-dictionary/test-dictionary/vf-module-type.json +++ b/components/model-catalog/resource-dictionary/test-dictionary/vf-module-type.json @@ -7,8 +7,8 @@ }, "updated-by": "adetalhouet", "sources": { - "primary-db": { - "type": "source-primary-db", + "processor-db": { + "type": "source-processor-db", "properties": { "type": "SQL", "query": "select sdnctl.demo.value as value from sdnctl.demo where sdnctl.demo.id=:vfmoduleid", diff --git a/components/parent/pom.xml b/components/parent/pom.xml index dd74622d..0d5d964e 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.onap.ccsdk.apps</groupId> <artifactId>components</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <groupId>org.onap.ccsdk.apps.components</groupId> <artifactId>parent</artifactId> diff --git a/components/pom.xml b/components/pom.xml index 1915fecf..115b3a98 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -19,7 +19,7 @@ <parent> <groupId>org.onap.ccsdk.apps</groupId> <artifactId>ccsdk-apps</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>components</artifactId> diff --git a/ms/blueprintsprocessor/application/pom.xml b/ms/blueprintsprocessor/application/pom.xml index ff7680d5..8757a036 100755 --- a/ms/blueprintsprocessor/application/pom.xml +++ b/ms/blueprintsprocessor/application/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>parent</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> <relativePath>../parent</relativePath> </parent> <artifactId>application</artifactId> diff --git a/ms/blueprintsprocessor/distribution/pom.xml b/ms/blueprintsprocessor/distribution/pom.xml index 8fcad07b..2bd16e5c 100755 --- a/ms/blueprintsprocessor/distribution/pom.xml +++ b/ms/blueprintsprocessor/distribution/pom.xml @@ -19,7 +19,7 @@ <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>parent</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> <relativePath>../parent</relativePath> </parent> <artifactId>distribution</artifactId> diff --git a/ms/blueprintsprocessor/functions/cli-executor/pom.xml b/ms/blueprintsprocessor/functions/cli-executor/pom.xml index 52a78907..9077c13c 100644 --- a/ms/blueprintsprocessor/functions/cli-executor/pom.xml +++ b/ms/blueprintsprocessor/functions/cli-executor/pom.xml @@ -14,14 +14,11 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <artifactId>functions</artifactId> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>cli-executor</artifactId> @@ -37,4 +34,4 @@ </dependencies> -</project>
\ No newline at end of file +</project> diff --git a/ms/blueprintsprocessor/functions/netconf-executor/pom.xml b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml index 3041132d..2e6d77ed 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/pom.xml +++ b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml @@ -18,7 +18,7 @@ <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>functions</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId> diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt index cf11cfdd..2dd73ef1 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt @@ -19,8 +19,10 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.core import com.google.common.collect.ImmutableList import com.google.common.collect.ImmutableSet import org.apache.sshd.client.SshClient +import org.apache.sshd.client.channel.ChannelSubsystem import org.apache.sshd.client.channel.ClientChannel import org.apache.sshd.client.session.ClientSession +import org.apache.sshd.client.session.ClientSessionImpl import org.apache.sshd.common.FactoryManager import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api.DeviceInfo @@ -40,6 +42,7 @@ import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ExecutionException import java.util.concurrent.TimeUnit import java.util.concurrent.TimeoutException +import java.util.concurrent.atomic.AtomicReference class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcService: NetconfRpcService) : NetconfSession { @@ -273,4 +276,12 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ } } } + + fun sessionstatus(state:String): Boolean{ + return when (state){ + "Close" -> channel.isClosed + "Open" -> channel.isOpen + else -> false + } + } }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfSessionImplTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfSessionImplTest.kt index 045725c7..e7a51434 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfSessionImplTest.kt +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfSessionImplTest.kt @@ -15,13 +15,18 @@ */ package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor +import org.apache.sshd.client.channel.ChannelSubsystem +import org.apache.sshd.client.session.ClientSessionImpl import org.junit.After import org.junit.Assert import org.junit.Before +import org.junit.Test import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api.DeviceInfo import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.core.NetconfRpcServiceImpl import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.core.NetconfSessionImpl import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.mocks.NetconfDeviceSimulator +import java.util.concurrent.atomic.AtomicReference +import kotlin.script.experimental.api.asSuccess class NetconfSessionImplTest { @@ -62,4 +67,45 @@ class NetconfSessionImplTest { Assert.assertTrue(!netconfSession.getDeviceCapabilitiesSet().isEmpty()) } + @Test + fun testNetconfSessionconnect() { + val netconfSession = NetconfSessionImpl(deviceInfo!!, NetconfRpcServiceImpl(deviceInfo!!)) + netconfSession.connect() + Assert.assertTrue(netconfSession.sessionstatus("Open")) + } + + @Test + fun testNetconfSessionreconnect() { + val netconfSession = NetconfSessionImpl(deviceInfo!!, NetconfRpcServiceImpl(deviceInfo!!)) + netconfSession.connect() + netconfSession.reconnect() + Assert.assertTrue(netconfSession.sessionstatus("Open")) + + } + @Test + fun testNetconfSessiondisconnect() { + val netconfSession = NetconfSessionImpl(deviceInfo!!, NetconfRpcServiceImpl(deviceInfo!!)) + netconfSession.connect() + netconfSession.disconnect() + Assert.assertTrue(netconfSession.sessionstatus("Close")) + + } + @Test + fun testNetconfSessioncheckAndReestablish() { + val netconfSession = NetconfSessionImpl(deviceInfo!!, NetconfRpcServiceImpl(deviceInfo!!)) + netconfSession.connect() + netconfSession.checkAndReestablish() + Assert.assertTrue(netconfSession.sessionstatus("Open")) + + + } + @Test + fun testNetconfSessionconnecgetDeviceInfo() { + val netconfSession = NetconfSessionImpl(deviceInfo!!, NetconfRpcServiceImpl(deviceInfo!!)) + netconfSession.connect() + Assert.assertNotNull(netconfSession.getDeviceInfo()) + Assert.assertFalse(!netconfSession.getDeviceCapabilitiesSet().isEmpty()) + } + + } diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImplTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImplTest.kt new file mode 100644 index 00000000..8f1f7150 --- /dev/null +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImplTest.kt @@ -0,0 +1,124 @@ +package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.core + +import org.junit.After +import org.junit.Assert +import org.junit.Before +import org.junit.Test + +import org.junit.Assert.* +import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api.DeviceInfo +import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.mocks.NetconfDeviceSimulator + +class NetconfRpcServiceImplTest { + + private var device: NetconfDeviceSimulator? = null + private var deviceInfo: DeviceInfo? = null + + @Before + fun before() { + deviceInfo = DeviceInfo().apply { + username = "username" + password = "password" + ipAddress = "localhost" + port = 2224 + connectTimeout = 10 + } + + device = NetconfDeviceSimulator(deviceInfo!!.port) + device!!.start() + } + + @After + fun after() { + device!!.stop() + } + + @Test + fun setNetconfSession() { + + } + + @Test + fun getConfig() { + + val netconfRpcServiceImpl = NetconfRpcServiceImpl(deviceInfo!!) + val netconfSession = NetconfSessionImpl(deviceInfo!!, netconfRpcServiceImpl) + netconfRpcServiceImpl.setNetconfSession(netconfSession) + netconfSession.connect() + Assert.assertTrue(netconfRpcServiceImpl.getConfig("filter","target").status.equals("failure")) + } + + + @Test + fun deleteConfig() { + + val netconfRpcServiceImpl = NetconfRpcServiceImpl(deviceInfo!!) + val netconfSession = NetconfSessionImpl(deviceInfo!!, netconfRpcServiceImpl) + netconfRpcServiceImpl.setNetconfSession(netconfSession) + netconfSession.connect() + Assert.assertTrue(netconfRpcServiceImpl.deleteConfig("target").status.equals("failure")) + } + + @Test + fun lock() { + val netconfRpcServiceImpl = NetconfRpcServiceImpl(deviceInfo!!) + val netconfSession = NetconfSessionImpl(deviceInfo!!, netconfRpcServiceImpl) + netconfRpcServiceImpl.setNetconfSession(netconfSession) + netconfSession.connect() + Assert.assertTrue(netconfRpcServiceImpl.lock("target").status.equals("failure")) + } + + @Test + fun unLock() { + val netconfRpcServiceImpl = NetconfRpcServiceImpl(deviceInfo!!) + val netconfSession = NetconfSessionImpl(deviceInfo!!, netconfRpcServiceImpl) + netconfRpcServiceImpl.setNetconfSession(netconfSession) + netconfSession.connect() + Assert.assertTrue(netconfRpcServiceImpl.unLock("target").status.equals("failure")) + } + + @Test + fun commit() { + val netconfRpcServiceImpl = NetconfRpcServiceImpl(deviceInfo!!) + val netconfSession = NetconfSessionImpl(deviceInfo!!, netconfRpcServiceImpl) + netconfRpcServiceImpl.setNetconfSession(netconfSession) + netconfSession.connect() + Assert.assertTrue(netconfRpcServiceImpl.commit(true,60,"persist","1").status.equals("failure")) + + } + + @Test + fun cancelCommit() { + val netconfSession = NetconfSessionImpl(deviceInfo!!, NetconfRpcServiceImpl(DeviceInfo())) + val netconfRpcServiceImpl = NetconfRpcServiceImpl(DeviceInfo()) + netconfRpcServiceImpl.setNetconfSession(netconfSession) + netconfSession.connect() + + Assert.assertNotNull(netconfRpcServiceImpl.cancelCommit("1")) + } + + @Test + fun discardConfig() { + val netconfRpcServiceImpl = NetconfRpcServiceImpl(deviceInfo!!) + val netconfSession = NetconfSessionImpl(deviceInfo!!, netconfRpcServiceImpl) + netconfRpcServiceImpl.setNetconfSession(netconfSession) + netconfSession.connect() + Assert.assertTrue(netconfRpcServiceImpl.discardConfig().status.equals("failure")) + + } + + @Test + fun editConfig() { + } + + @Test + fun validate() { + val netconfRpcServiceImpl = NetconfRpcServiceImpl(deviceInfo!!) + val netconfSession = NetconfSessionImpl(deviceInfo!!, netconfRpcServiceImpl) + netconfRpcServiceImpl.setNetconfSession(netconfSession) + netconfSession.connect() + Assert.assertTrue(netconfRpcServiceImpl.validate("target").status.equals("failure")) + + } + +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt index d4c27b1c..8a60d809 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt @@ -35,7 +35,7 @@ class RpcMessageUtilsTest { val filterContent = "Test-Filter-Content" val result = - NetconfMessageUtils.getConfig(messageId, configType, filterContent).replace("[\n\r\t]".toRegex(), "") + NetconfMessageUtils.getConfig(messageId, configType, filterContent).replace("[\n\r\t]".toRegex(), "") assertTrue(NetconfMessageUtils.validateRPCXML(result)) Assert.assertEquals(checkString, result) @@ -46,15 +46,16 @@ class RpcMessageUtilsTest { fun editConfig() { val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" - + "<get-config><source><candidate/></source><filter type=\"subtree\">Test-Filter-Content</filter>" - + "</get-config></rpc>") + + "<edit-config><target><candidate/></target><default-operation>Test-Default-Operation</default-operation>" + + "<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">Test-Filter-Content</config></edit-config></rpc>") val messageId = "Test-Message-ID" val configType = NetconfDatastore.CANDIDATE.datastore val filterContent = "Test-Filter-Content" + val defaultOperation = "Test-Default-Operation" val result = - NetconfMessageUtils.getConfig(messageId, configType, filterContent).replace("[\n\r\t]".toRegex(), "") + NetconfMessageUtils.editConfig(messageId, configType, defaultOperation, filterContent).replace("[\n\r\t]".toRegex(), "") assertTrue(NetconfMessageUtils.validateRPCXML(result)) Assert.assertEquals(checkString, result) @@ -78,16 +79,16 @@ class RpcMessageUtilsTest { @Test fun cancelCommit() { val checkString = - ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + - "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + - "<cancel-commit>" + - "<persist-id>1234</persist-id>" + - "</cancel-commit></rpc>") + ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + + "<cancel-commit>" + + "<persist-id>1234</persist-id>" + + "</cancel-commit></rpc>") val messageId = "Test-Message-ID" val cancelCommitPersistId = - NetconfMessageUtils.cancelCommit(messageId, "1234").replace("[\n\r\t]".toRegex(), "") + NetconfMessageUtils.cancelCommit(messageId, "1234").replace("[\n\r\t]".toRegex(), "") assertTrue(NetconfMessageUtils.validateRPCXML(cancelCommitPersistId)) Assert.assertEquals(checkString, cancelCommitPersistId) @@ -96,10 +97,10 @@ class RpcMessageUtilsTest { @Test fun cancelCommitNoPersistId() { val checkString = - ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + - "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + - "<cancel-commit>" + - "</cancel-commit></rpc>") + ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + + "<cancel-commit>" + + "</cancel-commit></rpc>") val messageId = "Test-Message-ID" @@ -120,7 +121,7 @@ class RpcMessageUtilsTest { val commit = NetconfMessageUtils.commit(messageId, false, 0, "", "").replace("[\n\r\t]".toRegex(), "") val commitWithPersistButNotConfirmed = - NetconfMessageUtils.commit(messageId, false, 0, "1234", "").replace("[\n\r\t]".toRegex(), "") + NetconfMessageUtils.commit(messageId, false, 0, "1234", "").replace("[\n\r\t]".toRegex(), "") assertTrue(NetconfMessageUtils.validateRPCXML(commit)) Assert.assertEquals(checkString, commit) @@ -131,11 +132,11 @@ class RpcMessageUtilsTest { @Test fun commitPersistId() { val checkString = - ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + - "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + - "<commit>" + - "<persist-id>1234</persist-id>" + - "</commit></rpc>") + ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + + "<commit>" + + "<persist-id>1234</persist-id>" + + "</commit></rpc>") val messageId = "Test-Message-ID" @@ -147,7 +148,7 @@ class RpcMessageUtilsTest { NetconfMessageUtils.commit(messageId, true, 30, "", "1234").replace("[\n\r\t]".toRegex(), "") } catch (e: NetconfException) { Assert.assertEquals("Can't proceed <commit> with both confirmed flag and persistId(1234) specified. Only one should be specified.", - e.message) + e.message) return } @@ -157,13 +158,13 @@ class RpcMessageUtilsTest { @Test fun commitPersist() { val checkString = - ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + - "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + - "<commit>" + - "<confirmed/>" + - "<confirm-timeout>30</confirm-timeout>" + - "<persist>1234</persist>" + - "</commit></rpc>") + ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + + "<commit>" + + "<confirmed/>" + + "<confirm-timeout>30</confirm-timeout>" + + "<persist>1234</persist>" + + "</commit></rpc>") val messageId = "Test-Message-ID" @@ -176,7 +177,7 @@ class RpcMessageUtilsTest { NetconfMessageUtils.commit(messageId, false, 30, "1234", "1234").replace("[\n\r\t]".toRegex(), "") } catch (e: NetconfException) { Assert.assertEquals("Can't proceed <commit> with both persist(1234) and persistId(1234) specified. Only one should be specified.", - e.message) + e.message) return } fail() @@ -240,5 +241,66 @@ class RpcMessageUtilsTest { Assert.assertEquals(checkString, result) } + @Test + fun getMsgId() { + val checkString = ("testmessage") + + var messageId = "message-id=\"testmessage\"" + var result = NetconfMessageUtils.getMsgId(messageId).replace("[\n\r\t]".toRegex(), "") + Assert.assertEquals(checkString, result) + + messageId = "message-id=\"hello\"" + result = NetconfMessageUtils.getMsgId(messageId).replace("[\n\r\t]".toRegex(), "") + Assert.assertEquals("hello", result) + + messageId = "message-id" + result = NetconfMessageUtils.getMsgId(messageId).replace("[\n\r\t]".toRegex(), "") + Assert.assertEquals("", result) + } + + @Test + fun createHelloString() { + val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"> " + +"<capabilities> <capability>hi</capability> <capability>hello</capability> </capabilities></hello>]]>]]>") + + val capability = listOf<String>("hi", "hello") + + val result = NetconfMessageUtils.createHelloString(capability).replace("[\n\r\t]".toRegex(), "") + Assert.assertEquals(checkString, result) + } + + @Test + fun validateChunkedFraming() { + val reply = ("hello") + val result = NetconfMessageUtils.validateChunkedFraming(reply) + Assert.assertFalse(result) + } + + @Test + fun checkReply(){ + assertTrue(NetconfMessageUtils.checkReply("ok")) + } + + @Test + fun formatRPCRequest(){ + val checkString = ("#199" + + "<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"> <capabilities> <capability>hi</capability> <capability>hello</capability> </capabilities></hello>" + + "##") + + val request = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"> " + +"<capabilities> <capability>hi</capability> <capability>hello</capability> </capabilities></hello>]]>]]>") + + val messageId = "Test-Message-ID" + + val capabilities = setOf<String>("hi", "hello","urn:ietf:params:netconf:base:1.1") + + val result = NetconfMessageUtils.formatRPCRequest(request,messageId,capabilities).replace("[\n\r\t]".toRegex(), "") + Assert.assertEquals(checkString, result) + + + } + + + }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/pom.xml b/ms/blueprintsprocessor/functions/pom.xml index 4bc0159f..5bc26d5f 100755 --- a/ms/blueprintsprocessor/functions/pom.xml +++ b/ms/blueprintsprocessor/functions/pom.xml @@ -19,7 +19,7 @@ <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>parent</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> <relativePath>../parent</relativePath> </parent> <modelVersion>4.0.0</modelVersion> diff --git a/ms/blueprintsprocessor/functions/python-executor/pom.xml b/ms/blueprintsprocessor/functions/python-executor/pom.xml index 120ded78..e0c61749 100644 --- a/ms/blueprintsprocessor/functions/python-executor/pom.xml +++ b/ms/blueprintsprocessor/functions/python-executor/pom.xml @@ -18,7 +18,7 @@ <parent> <artifactId>functions</artifactId> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> diff --git a/ms/blueprintsprocessor/functions/resource-resolution/pom.xml b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml index 840124fa..eafdb9a0 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/pom.xml +++ b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml @@ -19,7 +19,7 @@ <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>functions</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId> <artifactId>resource-resolution</artifactId> diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt index e38a1cca..a192989e 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt @@ -19,40 +19,37 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.pr import com.fasterxml.jackson.databind.node.JsonNodeFactory import com.fasterxml.jackson.databind.node.MissingNode -import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.DBLibGenericService +import com.fasterxml.jackson.databind.node.NullNode +import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibGenericService +import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.BluePrintDBLibPropertySevice +import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.PrimaryDBLibGenericService import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.DatabaseResourceSource import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.apps.controllerblueprints.core.checkEqualsOrThrow -import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmpty -import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow -import org.onap.ccsdk.apps.controllerblueprints.core.nullToEmpty -import org.onap.ccsdk.apps.controllerblueprints.core.returnNotEmptyOrThrow +import org.onap.ccsdk.apps.controllerblueprints.core.* import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants import org.slf4j.LoggerFactory import org.springframework.beans.factory.config.ConfigurableBeanFactory import org.springframework.context.annotation.Scope -import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate import org.springframework.stereotype.Service +import java.util.* /** * DatabaseResourceAssignmentProcessor * * @author Kapil Singal */ -@Service("${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-primary-db") +@Service("${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-processor-db") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -open class DatabaseResourceAssignmentProcessor(private val dBLibGenericService: DBLibGenericService) +open class DatabaseResourceAssignmentProcessor(private val bluePrintDBLibPropertySevice: BluePrintDBLibPropertySevice, private val primaryDBLibGenericService: PrimaryDBLibGenericService) : ResourceAssignmentProcessor() { private val logger = LoggerFactory.getLogger(DatabaseResourceAssignmentProcessor::class.java) override fun getName(): String { - return "${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-primary-db" + return "${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-processor-db" } override fun process(resourceAssignment: ResourceAssignment) { @@ -60,33 +57,16 @@ open class DatabaseResourceAssignmentProcessor(private val dBLibGenericService: validate(resourceAssignment) // Check if It has Input - val value = getFromInput(resourceAssignment) - if (value == null || value is MissingNode) { - val dName = resourceAssignment.dictionaryName - val dSource = resourceAssignment.dictionarySource - val resourceDefinition = resourceDictionaries[dName] - ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dName") - val resourceSource = resourceDefinition.sources[dSource] - ?: throw BluePrintProcessorException("couldn't get resource definition $dName source($dSource)") - val resourceSourceProperties = checkNotNull(resourceSource.properties) { "failed to get source properties for $dName " } - val sourceProperties = JacksonUtils.getInstanceFromMap(resourceSourceProperties, DatabaseResourceSource::class.java) - - val sql = checkNotNull(sourceProperties.query) { "failed to get request query for $dName under $dSource properties" } - val inputKeyMapping = checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" } - - val resolvedInputKeyMapping = resolveInputKeyMappingVariables(inputKeyMapping) - - val resolvedSql = resolveFromInputKeyMapping(sql, resolvedInputKeyMapping) - - logger.info("$dSource dictionary information : ($resolvedSql), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})") - val jdbcTemplate = blueprintDBLibService(sourceProperties) - - val rows = jdbcTemplate.queryForList(resolvedSql, resolvedInputKeyMapping) - if (rows.isNullOrEmpty()) { - logger.warn("Failed to get $dSource result for dictionary name ($dName) the query ($resolvedSql)") + try { + val value = raRuntimeService.getInputValue(resourceAssignment.name) + if (value !is NullNode && value !is MissingNode) { + logger.info("processor-db source template key (${resourceAssignment.name}) found from input and value is ($value)") + ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value) } else { - populateResource(resourceAssignment, sourceProperties, rows) + setValueFromDB(resourceAssignment) } + } catch (e: BluePrintProcessorException) { + setValueFromDB(resourceAssignment) } // Check the value has populated for mandatory case @@ -97,12 +77,36 @@ open class DatabaseResourceAssignmentProcessor(private val dBLibGenericService: } } - private fun blueprintDBLibService(sourceProperties: DatabaseResourceSource): NamedParameterJdbcTemplate { + private fun setValueFromDB(resourceAssignment: ResourceAssignment) { + val dName = resourceAssignment.dictionaryName + val dSource = resourceAssignment.dictionarySource + val resourceDefinition = resourceDictionaries[dName] + ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dName") + val resourceSource = resourceDefinition.sources[dSource] + ?: throw BluePrintProcessorException("couldn't get resource definition $dName source($dSource)") + val resourceSourceProperties = checkNotNull(resourceSource.properties) { "failed to get source properties for $dName " } + val sourceProperties = JacksonUtils.getInstanceFromMap(resourceSourceProperties, DatabaseResourceSource::class.java) + + val sql = checkNotNull(sourceProperties.query) { "failed to get request query for $dName under $dSource properties" } + val inputKeyMapping = checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" } + + logger.info("$dSource dictionary information : ($sql), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})") + val jdbcTemplate = blueprintDBLibService(sourceProperties) + + val rows = jdbcTemplate.query(sql, populateNamedParameter(inputKeyMapping)) + if (rows.isNullOrEmpty()) { + logger.warn("Failed to get $dSource result for dictionary name ($dName) the query ($sql)") + } else { + populateResource(resourceAssignment, sourceProperties, rows) + } + } + + private fun blueprintDBLibService(sourceProperties: DatabaseResourceSource): BluePrintDBLibGenericService { return if (checkNotEmpty(sourceProperties.endpointSelector)) { val dbPropertiesJson = raRuntimeService.resolveDSLExpression(sourceProperties.endpointSelector!!) - dBLibGenericService.remoteJdbcTemplate(dbPropertiesJson) + bluePrintDBLibPropertySevice.JdbcTemplate(dbPropertiesJson) } else { - dBLibGenericService.primaryJdbcTemplate() + primaryDBLibGenericService } } @@ -111,9 +115,20 @@ open class DatabaseResourceAssignmentProcessor(private val dBLibGenericService: private fun validate(resourceAssignment: ResourceAssignment) { checkNotEmptyOrThrow(resourceAssignment.name, "resource assignment template key is not defined") checkNotEmptyOrThrow(resourceAssignment.dictionaryName, "resource assignment dictionary name is not defined for template key (${resourceAssignment.name})") - checkEqualsOrThrow(ResourceDictionaryConstants.SOURCE_PRIMARY_DB, resourceAssignment.dictionarySource) { - "resource assignment source is not ${ResourceDictionaryConstants.SOURCE_PRIMARY_DB} but it is ${resourceAssignment.dictionarySource}" + checkEqualsOrThrow(ResourceDictionaryConstants.SOURCE_PROCESSOR_DB, resourceAssignment.dictionarySource) { + "resource assignment source is not ${ResourceDictionaryConstants.SOURCE_PROCESSOR_DB} but it is ${resourceAssignment.dictionarySource}" + } + } + + private fun populateNamedParameter(inputKeyMapping: Map<String, String>): Map<String, Any> { + val namedParameters = HashMap<String, Any>() + inputKeyMapping.forEach { + val expressionValue = raRuntimeService.getDictionaryStore(it.value).textValue() + logger.trace("Reference dictionary key (${it.key}) resulted in value ($expressionValue)") + namedParameters[it.key] = expressionValue } + logger.info("Parameter information : ({})", namedParameters) + return namedParameters } @Throws(BluePrintProcessorException::class) @@ -126,7 +141,7 @@ open class DatabaseResourceAssignmentProcessor(private val dBLibGenericService: logger.info("Response processing type($type)") // Primitive Types - when(type) { + when (type) { in BluePrintTypes.validPrimitiveTypes() -> { val dbColumnValue = rows[0][outputKeyMapping[dName]] logger.info("For template key (${resourceAssignment.name}) setting value as ($dbColumnValue)") @@ -134,7 +149,7 @@ open class DatabaseResourceAssignmentProcessor(private val dBLibGenericService: } in BluePrintTypes.validCollectionTypes() -> { val entrySchemaType = returnNotEmptyOrThrow(resourceAssignment.property?.entrySchema?.type) { "Entry schema is not defined for dictionary ($dName) info" } - var arrayNode = JsonNodeFactory.instance.arrayNode() + val arrayNode = JsonNodeFactory.instance.arrayNode() rows.forEach { if (entrySchemaType in BluePrintTypes.validPrimitiveTypes()) { val dbColumnValue = it[outputKeyMapping[dName]] @@ -157,7 +172,7 @@ open class DatabaseResourceAssignmentProcessor(private val dBLibGenericService: else -> { // Complex Types val row = rows[0] - var objectNode = JsonNodeFactory.instance.objectNode() + val objectNode = JsonNodeFactory.instance.objectNode() for (mapping in outputKeyMapping.entries) { val dbColumnValue = checkNotNull(row[mapping.key]) val propertyTypeForDataType = ResourceAssignmentUtils.getPropertyType(raRuntimeService, type, mapping.key) diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt index b3e3e4ed..91997e34 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt @@ -25,7 +25,6 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfigurati import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.apps.blueprintsprocessor.core.utils.PayloadUtils import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibConfiguration -import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.DBLibGenericService import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.* import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode @@ -44,7 +43,7 @@ import org.springframework.test.context.junit4.SpringRunner @ContextConfiguration(classes = [ResourceResolutionServiceImpl::class, InputResourceResolutionProcessor::class, DefaultResourceResolutionProcessor::class, DatabaseResourceAssignmentProcessor::class, RestResourceResolutionProcessor::class, - CapabilityResourceResolutionProcessor::class, DBLibGenericService::class, + CapabilityResourceResolutionProcessor::class, BlueprintPropertyConfiguration::class, BluePrintProperties::class, BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class]) @TestPropertySource(locations = ["classpath:application-test.properties"]) diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt index 905c8e0b..d560e8c3 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt @@ -25,12 +25,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfigurati import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.apps.blueprintsprocessor.core.utils.PayloadUtils import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibConfiguration -import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.DBLibGenericService -import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.CapabilityResourceResolutionProcessor -import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.DatabaseResourceAssignmentProcessor -import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.DefaultResourceResolutionProcessor -import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.InputResourceResolutionProcessor -import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.RestResourceResolutionProcessor +import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.* import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils @@ -53,7 +48,7 @@ import kotlin.test.assertTrue @ContextConfiguration(classes = [ResourceResolutionServiceImpl::class, InputResourceResolutionProcessor::class, DefaultResourceResolutionProcessor::class, DatabaseResourceAssignmentProcessor::class, RestResourceResolutionProcessor::class, - CapabilityResourceResolutionProcessor::class, DBLibGenericService::class, + CapabilityResourceResolutionProcessor::class, BlueprintPropertyConfiguration::class, BluePrintProperties::class, BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class]) @TestPropertySource(locations = ["classpath:application-test.properties"]) @@ -70,7 +65,7 @@ class ResourceResolutionServiceTest { fun testRegisteredSource() { val sources = resourceResolutionService.registeredResourceSources() assertNotNull(sources, "failed to get registered sources") - assertTrue(sources.containsAll(arrayListOf("source-input", "source-default", "source-primary-db", + assertTrue(sources.containsAll(arrayListOf("source-input", "source-default", "source-processor-db", "source-rest")), "failed to get registered sources : $sources") } diff --git a/ms/blueprintsprocessor/functions/restconf-executor/pom.xml b/ms/blueprintsprocessor/functions/restconf-executor/pom.xml index e81c5276..1ee23d3d 100644 --- a/ms/blueprintsprocessor/functions/restconf-executor/pom.xml +++ b/ms/blueprintsprocessor/functions/restconf-executor/pom.xml @@ -18,7 +18,7 @@ <parent> <artifactId>functions</artifactId> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId> diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml index 1f8251bd..045c871f 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml @@ -20,7 +20,7 @@ <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>commons</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <artifactId>db-lib</artifactId> diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt index 276ece13..3e9ec0ce 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt @@ -40,6 +40,7 @@ class DBLibConstants { //list of database const val MARIA_DB: String = "maria-db" + const val PRIMARY_DB: String = "primary-db" const val MYSQL_DB: String = "mysql-db" const val ORACLE_DB: String = "oracle-db" const val POSTGRES_DB: String = "postgres-db" diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibData.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibData.kt index a16e5565..ab2c19a4 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibData.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibData.kt @@ -17,13 +17,36 @@ package org.onap.ccsdk.apps.blueprintsprocessor.db -open class PrimaryDataSourceProperties { +open class DBDataSourceProperties { lateinit var url: String lateinit var username: String lateinit var password: String - lateinit var driverClassName: String + open lateinit var driverClassName: String + +} + +open class PrimaryDataSourceProperties: DBDataSourceProperties() { + lateinit var hibernateHbm2ddlAuto: String + lateinit var hibernateDDLAuto: String + lateinit var hibernateNamingStrategy: String + lateinit var hibernateDialect: String +} + +open class MariaDataSourceProperties: DBDataSourceProperties() { lateinit var hibernateHbm2ddlAuto: String lateinit var hibernateDDLAuto: String lateinit var hibernateNamingStrategy: String + lateinit var type: String lateinit var hibernateDialect: String -}
\ No newline at end of file + override var driverClassName = DBLibConstants.DRIVER_MARIA_DB +} + +open class MySqlDataSourceProperties: DBDataSourceProperties() { + lateinit var hibernateHbm2ddlAuto: String + lateinit var hibernateDDLAuto: String + lateinit var hibernateNamingStrategy: String + lateinit var type: String + lateinit var hibernateDialect: String + override var driverClassName = DBLibConstants.DRIVER_MYSQL_DB +} + diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/BluePrintDBLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/BluePrintDBLibPropertyService.kt new file mode 100644 index 00000000..f93c241d --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/BluePrintDBLibPropertyService.kt @@ -0,0 +1,105 @@ +/* + * Copyright © 2019 Bell Canada Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.db.primary + +import com.fasterxml.jackson.databind.JsonNode +import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties +import org.onap.ccsdk.apps.blueprintsprocessor.db.* +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import org.springframework.stereotype.Service + +@Service +class BluePrintDBLibPropertySevice(private var bluePrintProperties: BluePrintProperties) { + + fun JdbcTemplate(jsonNode: JsonNode): BluePrintDBLibGenericService { + val dBConnetionProperties = dBDataSourceProperties(jsonNode) + return blueprintDBDataSourceService(dBConnetionProperties) + } + + fun JdbcTemplate(selector: String): BluePrintDBLibGenericService { + val prefix = "blueprintsprocessor.database.$selector" + val dBConnetionProperties = dBDataSourceProperties(prefix) + return blueprintDBDataSourceService(dBConnetionProperties) + } + + private fun dBDataSourceProperties(jsonNode: JsonNode): DBDataSourceProperties { + val type = jsonNode.get("type").textValue() + return when (type) { + DBLibConstants.MYSQL_DB -> { + JacksonUtils.readValue(jsonNode, MySqlDataSourceProperties::class.java)!! + } + DBLibConstants.MARIA_DB -> { + JacksonUtils.readValue(jsonNode, MariaDataSourceProperties::class.java)!! + } + else -> { + throw BluePrintProcessorException("Rest adaptor($type) is not supported") + } + } + } + + private fun dBDataSourceProperties(prefix: String): DBDataSourceProperties { + val type = bluePrintProperties.propertyBeanType("$prefix.type", String::class.java) + return when (type) { + DBLibConstants.MARIA_DB -> { + mariaDBConnectionProperties(prefix) + } + DBLibConstants.MYSQL_DB -> { + mySqlDBConnectionProperties(prefix) + } + DBLibConstants.ORACLE_DB -> { + TODO("not implemented") + } + DBLibConstants.POSTGRES_DB -> { + TODO("not implemented") + } + DBLibConstants.PRIMARY_DB -> { + primaryDBConnectionProperties(prefix) + } + else -> { + throw BluePrintProcessorException("Rest adaptor($type) is not supported") + } + } + } + + private fun blueprintDBDataSourceService(dBConnetionProperties: DBDataSourceProperties): BluePrintDBLibGenericService { + when (dBConnetionProperties) { + is MariaDataSourceProperties -> { + return MariaDatabaseConfiguration(dBConnetionProperties) + } + is MySqlDataSourceProperties -> { + return MySqlDatabaseConfiguration(dBConnetionProperties) + } + else -> { + throw BluePrintProcessorException("couldn't get rest service for") + } + } + } + + private fun mySqlDBConnectionProperties(prefix: String): MySqlDataSourceProperties { + return bluePrintProperties.propertyBeanType(prefix, MySqlDataSourceProperties::class.java) + } + + private fun mariaDBConnectionProperties(prefix: String): MariaDataSourceProperties { + return bluePrintProperties.propertyBeanType(prefix, MariaDataSourceProperties::class.java) + } + + private fun primaryDBConnectionProperties(prefix: String): PrimaryDataSourceProperties { + return bluePrintProperties.propertyBeanType(prefix, PrimaryDataSourceProperties::class.java) + } + +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/DBLibGenericService.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/DBLibGenericService.kt deleted file mode 100644 index af7ab054..00000000 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/DBLibGenericService.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.blueprintsprocessor.db.primary - -import com.fasterxml.jackson.databind.JsonNode -import org.onap.ccsdk.apps.blueprintsprocessor.db.AbstractDBLibGenericService -import org.onap.ccsdk.apps.blueprintsprocessor.db.DBLibConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException -import org.springframework.boot.jdbc.DataSourceBuilder -import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate -import org.springframework.stereotype.Service - -@Service -open class DBLibGenericService(primaryNamedParameterJdbcTemplate: NamedParameterJdbcTemplate) - : AbstractDBLibGenericService(primaryNamedParameterJdbcTemplate) { - - fun primaryJdbcTemplate():NamedParameterJdbcTemplate{ - return namedParameterJdbcTemplate() - } - - fun remoteJdbcTemplate(jsonNode: JsonNode): NamedParameterJdbcTemplate { - val type = jsonNode.get("type").textValue() - val driverDB: String - - return when (type) { - DBLibConstants.MARIA_DB -> { - driverDB = DBLibConstants.DRIVER_MARIA_DB - jdbcTemplate(jsonNode, driverDB) - } - DBLibConstants.MYSQL_DB -> { - driverDB = DBLibConstants.DRIVER_MYSQL_DB - jdbcTemplate(jsonNode, driverDB) - } - DBLibConstants.ORACLE_DB -> { - driverDB = DBLibConstants.DRIVER_ORACLE_DB - jdbcTemplate(jsonNode, driverDB) - } - DBLibConstants.POSTGRES_DB -> { - driverDB = DBLibConstants.DRIVER_POSTGRES_DB - jdbcTemplate(jsonNode, driverDB) - } - else -> { - throw BluePrintProcessorException("Rest adaptor($type) is not supported") - } - } - } - - fun jdbcTemplate(jsonNode: JsonNode, driver: String): NamedParameterJdbcTemplate { - val dataSourceBuilder = DataSourceBuilder - .create() - .username(jsonNode.get("username").textValue()) - .password(jsonNode.get("password").textValue()) - .url(jsonNode.get("url").textValue()) - .driverClassName(driver) - .build() - return NamedParameterJdbcTemplate(dataSourceBuilder) - } -}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/MariaDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/MariaDatabaseConfiguration.kt new file mode 100644 index 00000000..c67fb339 --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/MariaDatabaseConfiguration.kt @@ -0,0 +1,59 @@ +/* + * Copyright © 2019 Bell Canada Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.db.primary + +import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibGenericService +import org.onap.ccsdk.apps.blueprintsprocessor.db.MariaDataSourceProperties +import org.slf4j.LoggerFactory +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate +import org.springframework.jdbc.datasource.DriverManagerDataSource +import org.springframework.orm.jpa.JpaTransactionManager +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter +import org.springframework.transaction.PlatformTransactionManager +import java.util.* +import javax.sql.DataSource + +class MariaDatabaseConfiguration(private val mariaDataSourceProperties: MariaDataSourceProperties) : BluePrintDBLibGenericService { + + override fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate { + return mariaNamedParameterJdbcTemplate(mariaDataSource()) + } + + override fun query(sql: String, params: Map<String, Any>): List<Map<String, Any>> { + return mariaNamedParameterJdbcTemplate(mariaDataSource()).queryForList(sql, params) + } + + override fun update(sql: String, params: Map<String, Any>): Int { + return mariaNamedParameterJdbcTemplate(mariaDataSource()).update(sql, params) + } + + val log = LoggerFactory.getLogger(PrimaryDatabaseConfiguration::class.java)!! + + fun mariaDataSource(): DataSource { + val dataSource = DriverManagerDataSource() + dataSource.setDriverClassName(mariaDataSourceProperties.driverClassName) + dataSource.url = mariaDataSourceProperties.url + dataSource.username = mariaDataSourceProperties.username + dataSource.password = mariaDataSourceProperties.password + return dataSource + } + + fun mariaNamedParameterJdbcTemplate(mariaDataSource: DataSource): NamedParameterJdbcTemplate { + return NamedParameterJdbcTemplate(mariaDataSource) + } +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/MySqlDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/MySqlDatabaseConfiguration.kt new file mode 100644 index 00000000..2a0dec73 --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/MySqlDatabaseConfiguration.kt @@ -0,0 +1,55 @@ +/* + * Copyright © 2019 Bell Canada Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.db.primary + +import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibGenericService +import org.onap.ccsdk.apps.blueprintsprocessor.db.MySqlDataSourceProperties +import org.slf4j.LoggerFactory +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate +import org.springframework.jdbc.datasource.DriverManagerDataSource +import javax.sql.DataSource + +class MySqlDatabaseConfiguration(private val mySqlDataSourceProperties: MySqlDataSourceProperties) : BluePrintDBLibGenericService { + override fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate { + return mySqlNamedParameterJdbcTemplate(mySqlDataSource()) + } + + override fun query(sql: String, params: Map<String, Any>): List<Map<String, Any>> { + return mySqlNamedParameterJdbcTemplate(mySqlDataSource()).queryForList(sql, params) + } + + override fun update(sql: String, params: Map<String, Any>): Int { + return mySqlNamedParameterJdbcTemplate(mySqlDataSource()).update(sql, params) + } + + val log = LoggerFactory.getLogger(PrimaryDatabaseConfiguration::class.java)!! + + fun mySqlDataSource(): DataSource { + val dataSource = DriverManagerDataSource() + dataSource.setDriverClassName(mySqlDataSourceProperties.driverClassName) + dataSource.url = mySqlDataSourceProperties.url + dataSource.username = mySqlDataSourceProperties.username + dataSource.password = mySqlDataSourceProperties.password + return dataSource + } + + fun mySqlNamedParameterJdbcTemplate(mySqlDataSource: DataSource): NamedParameterJdbcTemplate { + return NamedParameterJdbcTemplate(mySqlDataSource) + } + + +} diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDBLibGenericService.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDBLibGenericService.kt new file mode 100644 index 00000000..5a926534 --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDBLibGenericService.kt @@ -0,0 +1,27 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.db.primary + +import org.onap.ccsdk.apps.blueprintsprocessor.db.AbstractDBLibGenericService +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate +import org.springframework.stereotype.Service + +@Service +open class PrimaryDBLibGenericService(primaryNamedParameterJdbcTemplate: NamedParameterJdbcTemplate) + : AbstractDBLibGenericService(primaryNamedParameterJdbcTemplate) { + +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml index 0dd3da35..30f83d38 100644 --- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>commons</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <artifactId>dmaap-lib</artifactId> @@ -31,9 +31,6 @@ <name>Blueprints Processor Dmaap Lib</name> <description>Blueprints Processor Dmaap Lib</description> - <properties> - <dmaap.client.version>1.1.5</dmaap.client.version> - </properties> <dependencies> <dependency> @@ -71,6 +68,10 @@ <artifactId>kotlin-test-junit</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> + <artifactId>processor-core</artifactId> + </dependency> </dependencies> </project> diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/AafAuthDmaapClientService.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/AafAuthDmaapClientService.kt new file mode 100644 index 00000000..dd884092 --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/AafAuthDmaapClientService.kt @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CDS + * ================================================================================ + * 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.apps.blueprintsprocessor.dmaap + +import com.att.nsa.mr.client.MRBatchingPublisher +import com.att.nsa.mr.client.MRClientFactory +import com.att.nsa.mr.client.impl.MRSimplerBatchPublisher + +/** + * Representation of DMAAP client service for AAF auth type. + */ +class AafAuthDmaapClientService(private val clientProps: + AafAuthDmaapClientProperties) + : BluePrintDmaapClientService { + + /** + * The constructed DMAAP client. + */ + var clients: MutableList<MRBatchingPublisher> = mutableListOf() + + + /** + * Returns the DMAAP client after constructing it properly with the data + * that is required for AAF auth connection. + */ + override fun getDmaapClient(): MutableList<MRBatchingPublisher> { + if (!clients.isEmpty()) { + return clients + } + val topics = mutableListOf<String>() + topics.addAll(clientProps.topic.split(",")) + + for (t in topics) { + val client = MRClientFactory.createBatchingPublisher( + clientProps.host, t, clientProps.username, + clientProps.password, 1, 1, false, + clientProps.type, "") + val batchPublisher = client as MRSimplerBatchPublisher + batchPublisher.props = clientProps.props + clients.add(client) + } + return clients + } + +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/BluePrintDmaapClientService.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/BluePrintDmaapClientService.kt new file mode 100644 index 00000000..21d7128e --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/BluePrintDmaapClientService.kt @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CDS + * ================================================================================ + * 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.apps.blueprintsprocessor.dmaap + +import com.att.nsa.mr.client.MRBatchingPublisher +import com.att.nsa.mr.client.MRPublisher +import org.slf4j.LoggerFactory +import java.io.IOException +import java.util.concurrent.TimeUnit + + +/** + * Abstraction of DMAAP client services that could form DMAAP client from the + * properties provided. This abstraction also provides a mechanism to send + * messages with the given partition in a session and closing the same. + */ +interface BluePrintDmaapClientService { + + /** + * Static variable for logging. + */ + companion object { + var log = LoggerFactory.getLogger( + BluePrintDmaapClientService::class.java)!! + } + + /** + * Returns the properly constructed DMAAP client with the type. + */ + fun getDmaapClient(): MutableList<MRBatchingPublisher> + + /** + * Sends messages to the sessions created by the information provided from + * application.properties and event.properties file + */ + fun sendMessage(msgs: Collection<String>): Boolean { + var success = true + val clients = getDmaapClient() + val dmaapMsgs = mutableListOf<MRPublisher.message>() + for (m in msgs) { + dmaapMsgs.add(MRPublisher.message("1", m)) + } + log.info("Sending messages to the DMAAP Server") + for (client in clients) { + try { + client.send(dmaapMsgs) + } catch (e: IOException) { + success = false + log.error(e.message, e) + } + } + return success + } + + /** + * Sends message to the sessions created by the information provided from + * application.properties and event.properties file + */ + fun sendMessage(msg: String): Boolean { + val msgs = mutableListOf<String>() + msgs.add(msg) + return sendMessage(msgs) + } + + /** + * Closes the opened session that was used for sending messages. + */ + fun close(timeout: Long): MutableList<MutableList<MRPublisher.message>>? { + log.debug("Closing the DMAAP producer clients") + var msgs: MutableList<MutableList<MRPublisher.message>> = + mutableListOf() + val clients = getDmaapClient() + for (client in clients) { + try { + var ms = client.close(timeout, TimeUnit.SECONDS) + msgs.add(ms) + } catch (e: IOException) { + log.warn("Unable to cleanly close the connection from the " + + "client $client", e) + } + } + return msgs + } +} diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EnvironmentContext.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/BluePrintDmaapLibConfiguration.kt index 1d2a28ce..ca1a07ba 100644 --- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EnvironmentContext.kt +++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/BluePrintDmaapLibConfiguration.kt @@ -20,37 +20,27 @@ package org.onap.ccsdk.apps.blueprintsprocessor.dmaap -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.core.env.Environment -import org.springframework.stereotype.Component -import javax.annotation.PostConstruct +import org.springframework.boot.context.properties.EnableConfigurationProperties +import org.springframework.context.annotation.ComponentScan +import org.springframework.context.annotation.Configuration /** - * Abstraction of environment context information component. + * Representation of DMAAP lib configuration to load the required property + * files into the application context. */ -@Component -class EnvironmentContext { +@Configuration +@ComponentScan +@EnableConfigurationProperties +open class BluePrintDmaapLibConfiguration - /** - * Environment information. - */ +/** + * Util constants required for DMAAP library to use. + */ +class DmaapLibConstants { companion object { - var env: Environment? = null - } - - /** - * Environment auto-wired information. - */ - @Autowired - var environment: Environment? = null - - /** - * Initiates the static variable after the instantiation takes place to - * the auto-wired variable. - */ - @PostConstruct - private fun initStaticContext() { - env = environment + const val SERVICE_BLUEPRINT_DMAAP_LIB_PROPERTY = "blueprint" + + "-dmaap-lib-property-service" + const val TYPE_HTTP_NO_AUTH = "HTTPNOAUTH" + const val TYPE_HTTP_AAF_AUTH = "HTTPAAF" } - }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/BluePrintDmaapLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/BluePrintDmaapLibPropertyService.kt new file mode 100644 index 00000000..7abbefbc --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/BluePrintDmaapLibPropertyService.kt @@ -0,0 +1,187 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CDS + * ================================================================================ + * 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.apps.blueprintsprocessor.dmaap + +import com.fasterxml.jackson.databind.JsonNode +import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties +import org.onap.ccsdk.apps.blueprintsprocessor.dmaap.DmaapLibConstants.Companion.SERVICE_BLUEPRINT_DMAAP_LIB_PROPERTY +import org.onap.ccsdk.apps.blueprintsprocessor.dmaap.DmaapLibConstants.Companion.TYPE_HTTP_AAF_AUTH +import org.onap.ccsdk.apps.blueprintsprocessor.dmaap.DmaapLibConstants.Companion.TYPE_HTTP_NO_AUTH +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.PropertySource +import org.springframework.context.annotation.PropertySources +import org.springframework.core.env.ConfigurableEnvironment +import org.springframework.core.env.Environment +import org.springframework.core.io.support.ResourcePropertySource +import org.springframework.stereotype.Service +import java.util.Properties + +/** + * Representation of DMAAP lib property service to load the properties + * according to the connection type to the DMAAP server and returning back + * the appropriate DMAAP client to send messages DMAAP client. + */ +@Service(SERVICE_BLUEPRINT_DMAAP_LIB_PROPERTY) +@Configuration +@PropertySources(PropertySource("classpath:event.properties")) +open class BluePrintDmaapLibPropertyService(private var bluePrintProperties: + BluePrintProperties) { + + /** + * Static variable for logging. + */ + companion object { + var log = LoggerFactory.getLogger( + BluePrintDmaapLibPropertyService::class.java)!! + } + + /** + * Environment entity to derive it from the system to load a specific + * property file. + */ + @Autowired + lateinit var env: Environment + + /** + * Returns the DMAAP client by providing the input properties as a JSON + * node. + */ + fun blueprintDmaapClientService(jsonNode: JsonNode): + BluePrintDmaapClientService { + val dmaapProps = dmaapClientProperties(jsonNode) + return blueprintDmaapClientService(dmaapProps) + } + + /** + * Returns the DMAAP client by providing the input properties as a + * selector string. + */ + fun blueprintDmaapClientService(selector: String): + BluePrintDmaapClientService { + val prefix = "blueprintsprocessor.dmaapclient.$selector" + val dmaapProps = dmaapClientProperties(prefix) + return blueprintDmaapClientService(dmaapProps) + } + + /** + * Returns the DMAAP client properties from the type of connection it + * requires. + */ + fun dmaapClientProperties(prefix: String): DmaapClientProperties { + val type = bluePrintProperties.propertyBeanType( + "$prefix.type", String::class.java) + val clientProps : DmaapClientProperties + + when (type) { + TYPE_HTTP_NO_AUTH -> { + clientProps = bluePrintProperties.propertyBeanType( + prefix, HttpNoAuthDmaapClientProperties::class.java) + clientProps.props = parseEventProps() + } + + TYPE_HTTP_AAF_AUTH -> { + clientProps = bluePrintProperties.propertyBeanType( + prefix, AafAuthDmaapClientProperties::class.java) + clientProps.props = parseEventProps() + } + + else -> { + throw BluePrintProcessorException("DMAAP adaptor($type) is " + + "not supported") + } + } + return clientProps + } + + /** + * Returns the DMAAP client properties from the type of connection it + * requires. + */ + fun dmaapClientProperties(jsonNode: JsonNode): DmaapClientProperties { + val type = jsonNode.get("type").textValue() + val clientProps : DmaapClientProperties + + when (type) { + TYPE_HTTP_NO_AUTH -> { + clientProps = JacksonUtils.readValue(jsonNode, + HttpNoAuthDmaapClientProperties::class.java)!! + clientProps.props = parseEventProps() + } + + TYPE_HTTP_AAF_AUTH -> { + clientProps = JacksonUtils.readValue(jsonNode, + AafAuthDmaapClientProperties::class.java)!! + clientProps.props = parseEventProps() + } + + else -> { + throw BluePrintProcessorException("DMAAP adaptor($type) is " + + "not supported") + } + } + return clientProps + } + + /** + * Returns DMAAP client service according to the type of client properties. + */ + private fun blueprintDmaapClientService(clientProps: DmaapClientProperties): + BluePrintDmaapClientService { + when (clientProps) { + is HttpNoAuthDmaapClientProperties -> { + return HttpNoAuthDmaapClientService(clientProps) + } + + is AafAuthDmaapClientProperties -> { + return AafAuthDmaapClientService(clientProps) + } + + else -> { + throw BluePrintProcessorException("Unable to get the DMAAP " + + "client") + } + } + } + + /** + * Parses the event.properties file which contains the default values for + * the connection required. + */ + private fun parseEventProps(): Properties { + val prodProps = Properties() + val proProps = (env as ConfigurableEnvironment).propertySources.get( + "class path resource [event.properties]") + + if (proProps != null) { + val entries = (proProps as ResourcePropertySource).source.entries + for (e in entries) { + prodProps.put(e.key, e.value) + } + } else { + log.error("Unable to load the event.properties file") + } + return prodProps + } +} diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EventPublisher.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/DmaapClientProperties.kt index 7d02e806..97df2723 100644 --- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EventPublisher.kt +++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/DmaapClientProperties.kt @@ -20,20 +20,27 @@ package org.onap.ccsdk.apps.blueprintsprocessor.dmaap +import java.util.Properties + /** - * Abstraction of a publisher, to send messages with the given partition in a - * session and closing the same. + * Representation of data required for all DMAAP client. */ -interface EventPublisher { - - /** - * Sends messages through a session on a given partition. - */ - fun sendMessage(partition: String, messages: Collection<String>): Boolean +open class DmaapClientProperties { + lateinit var props: Properties + lateinit var type: String + lateinit var host: String + lateinit var topic: String +} - /** - * Closes the session with the given time. - */ - fun close(timeout: Long) +/** + * Representation of data required for HTTP no auth DMAAP client. + */ +open class HttpNoAuthDmaapClientProperties : DmaapClientProperties() +/** + * Representation of data required for AAF auth DMAAP client. + */ +open class AafAuthDmaapClientProperties : DmaapClientProperties() { + lateinit var username: String + lateinit var password: String } diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/DmaapEventPublisher.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/DmaapEventPublisher.kt deleted file mode 100644 index 7c686f08..00000000 --- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/DmaapEventPublisher.kt +++ /dev/null @@ -1,181 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CDS - * ================================================================================ - * 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.apps.blueprintsprocessor.dmaap - -import com.att.nsa.mr.client.MRBatchingPublisher -import com.att.nsa.mr.client.MRClientFactory -import com.att.nsa.mr.client.MRPublisher -import org.slf4j.LoggerFactory -import org.springframework.boot.context.properties.bind.Binder -import org.springframework.boot.context.properties.source.ConfigurationPropertySources -import org.springframework.context.annotation.Configuration -import org.springframework.context.annotation.PropertySource -import org.springframework.context.annotation.PropertySources -import org.springframework.core.env.ConfigurableEnvironment -import org.springframework.core.env.Environment -import org.springframework.core.io.support.ResourcePropertySource -import java.io.IOException -import java.util.Properties -import java.util.concurrent.TimeUnit - -/** - * Representation of DMaap event publisher, to create a session with the - * message router and send messages when asked for. The producer.properties - * is used for creating a session. In order to overwrite the parameters such - * as host, topic, username and password, the event.properties can be used. - * - * compName : Name of the component appended in the event.properties file - * to overwrite. - * (E.g., so.topic=cds_so : In this "so" is the component name) - */ -@Configuration -@PropertySources(PropertySource("classpath:event.properties", - "classpath:producer.properties")) -open class DmaapEventPublisher(compName: String = ""): EventPublisher { - - /** - * Static variable for logging. - */ - companion object { - var log = LoggerFactory.getLogger(DmaapEventPublisher::class.java)!! - } - - /** - * The component name used in defining the event.properties file. - */ - private var cName:String? = null - - /** - * List of topics for a given message to be sent. - */ - var topics = mutableListOf<String>() - - /** - * List of clients formed for the list of topics where the messages has to - * be sent. - */ - var clients = mutableListOf<MRBatchingPublisher>() - - /** - * The populated values from producer.properties which are overwritten - * by the event.properties values according to the component information. - */ - var prodProps: Properties = Properties() - - - init { - cName = compName - } - - /** - * Loads the producer.properties file and populates all the parameters - * and then loads the event.properties file and populates the finalized - * parameters such as host, topic, username and password if available for - * the specified component. With this updated producer.properties, for - * each topic a client will be created. - */ - private fun loadPropertiesInfo() { - if (prodProps.isEmpty) { - parseEventProps(cName!!) - addClients() - } - } - - /** - * Adds clients for each topic into a client list. - */ - private fun addClients() { - for (topic in topics) { - prodProps.setProperty("topic", topic) - val client = MRClientFactory.createBatchingPublisher(prodProps) - clients.add(client) - } - } - - /** - * Parses the event.properties file and update it into the producer - * .properties, where both the files are loaded and stored. - */ - private fun parseEventProps(cName: String) { - val env = EnvironmentContext.env as Environment - val propSrc = ConfigurationPropertySources.get(env) - val proProps = (env as ConfigurableEnvironment).propertySources.get( - "class path resource [producer.properties]") - - if (proProps != null) { - val entries = (proProps as ResourcePropertySource).source.entries - for (e in entries) { - prodProps.put(e.key, e.value) - } - } else { - log.info("Unable to load the producer.properties file") - } - - val eProps = Binder(propSrc).bind(cName, Properties::class.java).get() - val top = eProps.get("topic").toString() - if (top != "") { - topics.addAll(top.split(",")) - } - prodProps.putAll(eProps) - } - - /** - * Sends message to the sessions created by the information provided in - * the producer.properties file. - */ - override fun sendMessage(partition: String , messages: Collection<String>): - Boolean { - loadPropertiesInfo() - var success = true - val dmaapMsgs = mutableListOf<MRPublisher.message>() - for (m in messages) { - dmaapMsgs.add(MRPublisher.message(partition, m)) - } - for (client in clients) { - log.info("Sending messages to the DMaap Server") - try { - client.send(dmaapMsgs) - } catch (e: IOException) { - log.error(e.message, e) - success = false - } - } - return success - } - - /** - * Closes the opened session that was used for sending messages. - */ - override fun close(timeout: Long) { - log.debug("Closing the DMaap producer clients") - if (!clients.isEmpty()) { - for (client in clients) { - try { - client.close(timeout, TimeUnit.SECONDS) - } catch (e : IOException) { - log.warn("Unable to cleanly close the connection from " + - "the client $client", e) - } - } - } - } - -}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/HttpNoAuthDmaapClientService.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/HttpNoAuthDmaapClientService.kt new file mode 100644 index 00000000..ad023b96 --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/HttpNoAuthDmaapClientService.kt @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CDS + * ================================================================================ + * 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.apps.blueprintsprocessor.dmaap + +import com.att.nsa.mr.client.MRBatchingPublisher +import com.att.nsa.mr.client.MRClientFactory.createSimplePublisher +import com.att.nsa.mr.client.impl.MRSimplerBatchPublisher + +/** + * Representation of DMAAP client service for HTTP no auth type. + */ +class HttpNoAuthDmaapClientService(private val clientProps: + HttpNoAuthDmaapClientProperties) + : BluePrintDmaapClientService { + + /** + * The constructed DMAAP client. + */ + var clients: MutableList<MRBatchingPublisher> = mutableListOf() + + + /** + * Returns the DMAAP client after constructing it properly with the data + * that is required for HTTP no auth connection. + */ + override fun getDmaapClient(): MutableList<MRBatchingPublisher> { + if (!clients.isEmpty()) { + return clients + } + val topics = mutableListOf<String>() + topics.addAll(clientProps.topic.split(",")) + + for (t in topics) { + val client = createSimplePublisher(clientProps.host, t) + val batchPublisher = client as MRSimplerBatchPublisher + batchPublisher.setProtocolFlag(clientProps.type) + batchPublisher.props = clientProps.props + clients.add(client) + } + + return clients + } + +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/event.properties b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/event.properties index be764d84..320b08e8 100644 --- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/event.properties +++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/event.properties @@ -18,9 +18,9 @@ # ============LICENSE_END========================================================= # +#TransportType-Specify which way user want to use. I.e. <HTTPAAF,DME2,HTTPAUTH > +Protocol =http +partition=1 +contenttype = application/json -so.topic=cds_so -so.username=admin -so.password=admin -so.host=10.12.6.236:30226 diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/producer.properties b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/producer.properties deleted file mode 100644 index c3c228ba..00000000 --- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/producer.properties +++ /dev/null @@ -1,52 +0,0 @@ -# -# ============LICENSE_START======================================================= -# ONAP - CDS -# ================================================================================ -# 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========================================================= -# - -#TransportType-Specify which way user want to use. I.e. <HTTPAAF,DME2,HTTPAUTH > -TransportType=HTTPNOAUTH -Latitude =50.000000 -Longitude =-100.000000 -Version =3.1 -ServiceName =dmaap-v1.dev.dmaap.dt.saat.acsi.att.com/events -Environment =TEST -Partner=BOT_R -routeOffer=MR1 -SubContextPath =/ -Protocol =http -MethodType =POST -username =admin -password =admin -contenttype = application/json -authKey=01234567890abcde:01234567890abcdefghijklmn -authDate=2016-07-20T11:30:56-0700 -host=10.12.6.236:30227 -topic=org.onap.appc.UNIT-TEST -partition=1 -maxBatchSize=100 -maxAgeMs=250 -AFT_DME2_EXCHANGE_REQUEST_HANDLERS=com.att.nsa.test.PreferredRouteRequestHandler -AFT_DME2_EXCHANGE_REPLY_HANDLERS=com.att.nsa.test.PreferredRouteReplyHandler -AFT_DME2_REQ_TRACE_ON=true -AFT_ENVIRONMENT=AFTUAT -AFT_DME2_EP_CONN_TIMEOUT=15000 -AFT_DME2_ROUNDTRIP_TIMEOUT_MS=240000 -AFT_DME2_EP_READ_TIMEOUT_MS=50000 -sessionstickinessrequired=NO -DME2preferredRouterFilePath=src/test/resources/preferredRoute.txt -MessageSentThreadOccurance=50 diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/apps/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/apps/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt index ac888218..9b3aae5e 100644 --- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/apps/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt +++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/apps/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt @@ -20,10 +20,14 @@ package org.ccsdk.apps.blueprintprocessor.dmaap +import com.fasterxml.jackson.databind.ObjectMapper import org.junit.Test import org.junit.runner.RunWith -import org.onap.ccsdk.apps.blueprintsprocessor.dmaap.DmaapEventPublisher -import org.onap.ccsdk.apps.blueprintsprocessor.dmaap.EnvironmentContext +import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties +import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfiguration +import org.onap.ccsdk.apps.blueprintsprocessor.dmaap.BluePrintDmaapLibConfiguration +import org.onap.ccsdk.apps.blueprintsprocessor.dmaap.BluePrintDmaapLibPropertyService +import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration import org.springframework.boot.test.context.SpringBootTest @@ -45,32 +49,53 @@ import kotlin.test.assertNotNull @RunWith(SpringRunner::class) @EnableAutoConfiguration(exclude = [DataSourceAutoConfiguration::class]) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) -@ContextConfiguration(classes = [EnvironmentContext::class, TestController::class, - DmaapEventPublisher::class]) -@TestPropertySource(properties = ["server.port=9111","aai.topic=cds_aai", - "aai.username=admin","aai.password=admin","aai.host=127.0.0.1:9111", - "mul.topic=cds_mul_1,cds_mul_2", "mul.username=admin","mul.password=admin", - "mul.host=127.0.0.1:9111"]) +@ContextConfiguration(classes = [BluePrintDmaapLibConfiguration::class, TestController::class, + BlueprintPropertyConfiguration::class, BluePrintProperties::class]) +@TestPropertySource(properties = ["server.port=9111", + "blueprintsprocessor.dmaapclient.aai.topic=cds_aai", + "blueprintsprocessor.dmaapclient.aai.type=HTTPNOAUTH", + "blueprintsprocessor.dmaapclient.aai.host=127.0.0.1:9111", + "blueprintsprocessor.dmaapclient.multi.topic=cds_multi1,cds_multi2", + "blueprintsprocessor.dmaapclient.multi.type=HTTPNOAUTH", + "blueprintsprocessor.dmaapclient.multi.host=127.0.0.1:9111"]) class TestDmaapEventPublisher { + @Autowired + lateinit var dmaapService : BluePrintDmaapLibPropertyService + /** * Tests the event properties being set properly and sent as request. */ @Test fun testEventProperties() { val strList = mutableListOf<String>() - val pub = DmaapEventPublisher(compName = "aai") + val dmaapClient = dmaapService.blueprintDmaapClientService("aai") + strList.add("{\n" + " \"a\" : \"hello\"\n" + "}") - pub.sendMessage("1", strList) - pub.close(2) - pub.prodProps - assertNotNull(pub.prodProps, "The property file updation failed") - assertEquals(pub.prodProps.get("topic"), "cds_aai") - assertEquals(pub.prodProps.get("username"), "admin") - assertEquals(pub.prodProps.get("password"), "admin") - assertEquals(pub.prodProps.get("host"), "127.0.0.1:9111") + dmaapClient.sendMessage(strList) + val msgs = dmaapClient.close(2) + assertEquals(msgs!!.size, 1) + val topic1 = msgs.get(0) + assertEquals(topic1!!.size, 0) + } + + /** + * Tests the event properties being set properly and sent as request with + * single message. + */ + @Test + fun testEventPropertiesWithSingleMsg() { + val dmaapClient = dmaapService.blueprintDmaapClientService("aai") + val str : String = "{\n" + + " \"a\" : \"hello\"\n" + + "}" + dmaapClient.sendMessage(str) + val msgs = dmaapClient.close(2) + assertEquals(msgs!!.size, 1) + val topic1 = msgs.get(0) + assertEquals(topic1!!.size, 0) } /** @@ -79,21 +104,93 @@ class TestDmaapEventPublisher { @Test fun testMultiTopicProperties() { val strList = mutableListOf<String>() - val pub = DmaapEventPublisher(compName = "mul") + val dmaapClient = dmaapService.blueprintDmaapClientService("multi") + + strList.add("{\n" + + " \"a\" : \"hello\"\n" + + "}") + dmaapClient.sendMessage(strList) + val msgs = dmaapClient.close(2) + assertEquals(msgs!!.size, 2) + val topic1 = msgs.get(0) + assertEquals(topic1!!.size, 0) + val topic2 = msgs.get(1) + assertEquals(topic2!!.size, 0) + } + + + /** + * Tests the event properties with multiple topics with JSON node as input. + */ + @Test + fun testMultiTopicPropertiesWithJsonInput() { + val jsonString = "{\n" + + " \"topic\" : \"cds_json1,cds_json2\",\n" + + " \"type\" : \"HTTPNOAUTH\",\n" + + " \"host\" : \"127.0.0.1:9111\"\n" + + "}" + val mapper = ObjectMapper() + val node = mapper.readTree(jsonString) + val strList = mutableListOf<String>() + val dmaapClient = dmaapService.blueprintDmaapClientService(node) + + strList.add("{\n" + + " \"a\" : \"hello\"\n" + + "}") + dmaapClient.sendMessage(strList) + val msgs = dmaapClient.close(2) + assertEquals(msgs!!.size, 2) + val topic1 = msgs.get(0) + assertEquals(topic1!!.size, 0) + val topic2 = msgs.get(1) + assertEquals(topic2!!.size, 0) + } + + + /** + * Tests the event properties with multiple messages. + */ + @Test + fun testMultiMsgsProperties() { + val strList = mutableListOf<String>() + val dmaapClient = dmaapService.blueprintDmaapClientService("aai") + strList.add("{\n" + " \"a\" : \"hello\"\n" + "}") - pub.sendMessage("1", strList) - pub.close(2) - var tops = pub.topics - assertNotNull(pub.prodProps, "The property file updation failed") - assertEquals(tops[0], "cds_mul_1") - assertEquals(tops[1], "cds_mul_2") - //assertEquals(pub.topics.contains("cds_mul_2`"), true) - assertEquals(pub.prodProps.get("username"), "admin") - assertEquals(pub.prodProps.get("password"), "admin") - assertEquals(pub.prodProps.get("host"), "127.0.0.1:9111") + strList.add("{\n" + + " \"a\" : \"second\"\n" + + "}") + dmaapClient.sendMessage(strList) + val msgs = dmaapClient.close(2) + assertEquals(msgs!!.size, 1) + val topic1 = msgs.get(0) + assertEquals(topic1!!.size, 0) } + + /** + * Tests the DMAAP client properties generated with the complete prefix. + */ + @Test + fun testDmaapClientProperties() { + val properties = dmaapService.dmaapClientProperties( + "blueprintsprocessor.dmaapclient.aai") + assertNotNull(properties, "failed to create property bean") + assertNotNull(properties.host, "failed to get url property" + + " in property bean") + } + + /** + * Tests the blueprint DMAAP client service with only selector prefix. + */ + @Test + fun testBlueprintDmaapClientService() { + val blueprintDmaapClientService = + dmaapService.blueprintDmaapClientService("aai") + assertNotNull(blueprintDmaapClientService, + "failed to create blueprintDmaapClientService") + } + } /** diff --git a/ms/blueprintsprocessor/modules/commons/pom.xml b/ms/blueprintsprocessor/modules/commons/pom.xml index 07d7551f..205fd94c 100755 --- a/ms/blueprintsprocessor/modules/commons/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>modules</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <artifactId>commons</artifactId> diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/pom.xml b/ms/blueprintsprocessor/modules/commons/processor-core/pom.xml index aadff9c9..32e4b3d4 100644 --- a/ms/blueprintsprocessor/modules/commons/processor-core/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/processor-core/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>commons</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <artifactId>processor-core</artifactId> diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml index 0c8e163f..1ed157dc 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml @@ -20,7 +20,7 @@ <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>commons</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <artifactId>rest-lib</artifactId> diff --git a/ms/blueprintsprocessor/modules/inbounds/pom.xml b/ms/blueprintsprocessor/modules/inbounds/pom.xml index 273abd51..060c7e42 100644 --- a/ms/blueprintsprocessor/modules/inbounds/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/pom.xml @@ -20,7 +20,7 @@ <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>modules</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <artifactId>inbounds</artifactId> diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml index dcf42c20..26ce4a8c 100644 --- a/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml @@ -19,7 +19,7 @@ <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>inbounds</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <artifactId>resource-api</artifactId> diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml index abd76dc1..0c6b8e77 100755 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>inbounds</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <artifactId>selfservice-api</artifactId> diff --git a/ms/blueprintsprocessor/modules/outbounds/pom.xml b/ms/blueprintsprocessor/modules/outbounds/pom.xml index b6c26e67..3fb7e382 100644 --- a/ms/blueprintsprocessor/modules/outbounds/pom.xml +++ b/ms/blueprintsprocessor/modules/outbounds/pom.xml @@ -19,7 +19,7 @@ <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>modules</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <artifactId>outbounds</artifactId> diff --git a/ms/blueprintsprocessor/modules/pom.xml b/ms/blueprintsprocessor/modules/pom.xml index 5cc31c46..26500f50 100644 --- a/ms/blueprintsprocessor/modules/pom.xml +++ b/ms/blueprintsprocessor/modules/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>parent</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> <relativePath>../parent</relativePath> </parent> diff --git a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml index 42d2e074..913ce467 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml +++ b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml @@ -20,7 +20,7 @@ <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>services</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <artifactId>execution-service</artifactId> diff --git a/ms/blueprintsprocessor/modules/services/pom.xml b/ms/blueprintsprocessor/modules/services/pom.xml index 4388eeb9..ee5b73cc 100755 --- a/ms/blueprintsprocessor/modules/services/pom.xml +++ b/ms/blueprintsprocessor/modules/services/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>modules</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <artifactId>services</artifactId> diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml b/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml index 634d2233..4331eec7 100644 --- a/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml +++ b/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml @@ -19,7 +19,7 @@ <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>services</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml index 48f18eff..f1c601ff 100755 --- a/ms/blueprintsprocessor/parent/pom.xml +++ b/ms/blueprintsprocessor/parent/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onap.ccsdk.apps</groupId> <artifactId>blueprintsprocessor</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>parent</artifactId> @@ -50,6 +50,7 @@ <onap.logger.slf4j>1.2.2</onap.logger.slf4j> <powermock.version>1.7.4</powermock.version> <mockk.version>1.9</mockk.version> + <dmaap.client.version>1.1.5</dmaap.client.version> </properties> <dependencyManagement> <dependencies> diff --git a/ms/blueprintsprocessor/pom.xml b/ms/blueprintsprocessor/pom.xml index 774e177e..2f257678 100755 --- a/ms/blueprintsprocessor/pom.xml +++ b/ms/blueprintsprocessor/pom.xml @@ -20,7 +20,7 @@ <parent> <groupId>org.onap.ccsdk.apps</groupId> <artifactId>ccsdk-apps-ms</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <artifactId>blueprintsprocessor</artifactId> <packaging>pom</packaging> diff --git a/ms/cds-sdc-listener/application/pom.xml b/ms/cds-sdc-listener/application/pom.xml index 54f59b7c..412c5918 100644 --- a/ms/cds-sdc-listener/application/pom.xml +++ b/ms/cds-sdc-listener/application/pom.xml @@ -11,7 +11,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>spring-boot-1-starter-parent</artifactId> - <version>1.2.1</version> + <version>1.2.2-SNAPSHOT</version> <relativePath/> </parent> diff --git a/ms/cds-sdc-listener/pom.xml b/ms/cds-sdc-listener/pom.xml index 0f2a4613..538185eb 100644 --- a/ms/cds-sdc-listener/pom.xml +++ b/ms/cds-sdc-listener/pom.xml @@ -10,7 +10,7 @@ <parent> <artifactId>ccsdk-apps-ms</artifactId> <groupId>org.onap.ccsdk.apps</groupId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> diff --git a/ms/controllerblueprints/application/pom.xml b/ms/controllerblueprints/application/pom.xml index a01a6134..4a733549 100644 --- a/ms/controllerblueprints/application/pom.xml +++ b/ms/controllerblueprints/application/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> <artifactId>parent</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> <relativePath>../parent</relativePath> </parent> <artifactId>application</artifactId> diff --git a/ms/controllerblueprints/application/src/main/resources/application-dev.properties b/ms/controllerblueprints/application/src/main/resources/application-dev.properties index 1c9029d5..3401ece0 100755 --- a/ms/controllerblueprints/application/src/main/resources/application-dev.properties +++ b/ms/controllerblueprints/application/src/main/resources/application-dev.properties @@ -49,7 +49,7 @@ spring.jpa.hibernate.ddl-auto=none spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect # Load Resource Source Mappings -resourceSourceMappings=primary-db=source-primary-db,input=source-input,default=source-default,primary-config-data=source-rest,capability=source-capability +resourceSourceMappings=processor-db=source-processor-db,input=source-input,default=source-default,primary-config-data=source-rest,capability=source-capability # Controller Blueprints Core Configuration controllerblueprints.blueprintDeployPath=/etc/blueprints/deploy controllerblueprints.blueprintArchivePath=/etc/blueprints/archive diff --git a/ms/controllerblueprints/application/src/main/resources/application.properties b/ms/controllerblueprints/application/src/main/resources/application.properties index 03409388..8789c24e 100755 --- a/ms/controllerblueprints/application/src/main/resources/application.properties +++ b/ms/controllerblueprints/application/src/main/resources/application.properties @@ -52,7 +52,7 @@ spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect # Load Resource Source Mappings -resourceSourceMappings=primary-db=source-primary-db,input=source-input,default=source-default,primary-config-data=source-rest,capability=source-capability +resourceSourceMappings=processor-db=source-processor-db,input=source-input,default=source-default,primary-config-data=source-rest,capability=source-capability # Controller Blueprints Core Configuration controllerblueprints.blueprintDeployPath=/etc/blueprints/deploy diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties index e0369aea..8ad9f2c0 100755 --- a/ms/controllerblueprints/application/src/test/resources/application.properties +++ b/ms/controllerblueprints/application/src/test/resources/application.properties @@ -33,7 +33,7 @@ swagger.contact.url=www.onap.com swagger.contact.email=brindasanth@onap.com
# Load Resource Source Mappings
-resourceSourceMappings=primary-db=source-primary-db,input=source-input,default=source-default,primary-config-data=source-rest,capability=source-capability
+resourceSourceMappings=processor-db=source-processor-db,input=source-input,default=source-default,primary-config-data=source-rest,capability=source-capability
# Controller Blueprints Core Configuration
controllerblueprints.blueprintDeployPath=./target/blueprints/deploy
diff --git a/ms/controllerblueprints/distribution/pom.xml b/ms/controllerblueprints/distribution/pom.xml index c73d15b6..4a1b6049 100755 --- a/ms/controllerblueprints/distribution/pom.xml +++ b/ms/controllerblueprints/distribution/pom.xml @@ -20,7 +20,7 @@ <parent> <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> <artifactId>parent</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> <relativePath>../parent</relativePath> </parent> <artifactId>distribution</artifactId> diff --git a/ms/controllerblueprints/modules/blueprint-core/pom.xml b/ms/controllerblueprints/modules/blueprint-core/pom.xml index ca47b59a..ee321b71 100644 --- a/ms/controllerblueprints/modules/blueprint-core/pom.xml +++ b/ms/controllerblueprints/modules/blueprint-core/pom.xml @@ -20,7 +20,7 @@ <parent> <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> <artifactId>modules</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <artifactId>blueprint-core</artifactId> <name>Controller Blueprints Core</name> diff --git a/ms/controllerblueprints/modules/blueprint-scripts/pom.xml b/ms/controllerblueprints/modules/blueprint-scripts/pom.xml index cb2c33ed..81f0cc77 100644 --- a/ms/controllerblueprints/modules/blueprint-scripts/pom.xml +++ b/ms/controllerblueprints/modules/blueprint-scripts/pom.xml @@ -18,7 +18,7 @@ <parent> <artifactId>modules</artifactId> <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>blueprint-scripts</artifactId> diff --git a/ms/controllerblueprints/modules/blueprint-validation/pom.xml b/ms/controllerblueprints/modules/blueprint-validation/pom.xml index 59b0e095..7ac6a020 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/pom.xml +++ b/ms/controllerblueprints/modules/blueprint-validation/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> <artifactId>modules</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <artifactId>blueprint-validation</artifactId> <name>Controller Blueprints Validation Service</name> diff --git a/ms/controllerblueprints/modules/db-resources/pom.xml b/ms/controllerblueprints/modules/db-resources/pom.xml index b2f4370b..d1c3c44c 100644 --- a/ms/controllerblueprints/modules/db-resources/pom.xml +++ b/ms/controllerblueprints/modules/db-resources/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> <artifactId>modules</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <artifactId>db-resources</artifactId> <name>Controller Blueprints DB Resources</name> diff --git a/ms/controllerblueprints/modules/pom.xml b/ms/controllerblueprints/modules/pom.xml index 1ef81ea4..9275921e 100644 --- a/ms/controllerblueprints/modules/pom.xml +++ b/ms/controllerblueprints/modules/pom.xml @@ -20,7 +20,7 @@ <parent> <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> <artifactId>parent</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> <relativePath>../parent</relativePath> </parent> <artifactId>modules</artifactId> diff --git a/ms/controllerblueprints/modules/resource-dict/pom.xml b/ms/controllerblueprints/modules/resource-dict/pom.xml index edffdfb6..22533dbe 100644 --- a/ms/controllerblueprints/modules/resource-dict/pom.xml +++ b/ms/controllerblueprints/modules/resource-dict/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> <artifactId>modules</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <artifactId>resource-dict</artifactId> <name>Controller Blueprints Resource Dictionary</name> diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt index d33a2f04..75368684 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt @@ -24,6 +24,8 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict object ResourceDictionaryConstants { const val SOURCE_INPUT = "input" const val SOURCE_DEFAULT = "default" + //const val SOURCE_PRIMARY_CONFIG_DATA = "rest" + const val SOURCE_PROCESSOR_DB = "processor-db" const val SOURCE_PRIMARY_CONFIG_DATA = "primary-config-data" const val SOURCE_PRIMARY_DB = "primary-db" diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java index e4ddac13..45fc739d 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java @@ -59,9 +59,9 @@ public class ResourceDictionaryUtilsTest { Assert.assertEquals("Expected First source Default, but.", ResourceDictionaryConstants.SOURCE_DEFAULT, resourceAssignment.getDictionarySource()); // To Check Assigned Source - resourceAssignment.setDictionarySource(ResourceDictionaryConstants.SOURCE_PRIMARY_DB); + resourceAssignment.setDictionarySource(ResourceDictionaryConstants.SOURCE_PROCESSOR_DB); ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - Assert.assertEquals("Expected Assigned source DB, but.", ResourceDictionaryConstants.SOURCE_PRIMARY_DB, resourceAssignment.getDictionarySource()); + Assert.assertEquals("Expected Assigned source DB, but.", ResourceDictionaryConstants.SOURCE_PROCESSOR_DB, resourceAssignment.getDictionarySource()); } @@ -78,7 +78,7 @@ public class ResourceDictionaryUtilsTest { Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, inputFirstSource); // TO check the multiple Source - sources.put(ResourceDictionaryConstants.SOURCE_PRIMARY_DB, new NodeTemplate()); + sources.put(ResourceDictionaryConstants.SOURCE_PROCESSOR_DB, new NodeTemplate()); String multipleFirstSource = ResourceDictionaryUtils.findFirstSource(sources); Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, multipleFirstSource); diff --git a/ms/controllerblueprints/modules/service/pom.xml b/ms/controllerblueprints/modules/service/pom.xml index 73fe0739..7ca7e0db 100644 --- a/ms/controllerblueprints/modules/service/pom.xml +++ b/ms/controllerblueprints/modules/service/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> <artifactId>modules</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <artifactId>service</artifactId> <name>Controller Blueprints Service</name> diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt index 48183f4c..e0ecf039 100644 --- a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt +++ b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt @@ -31,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner +import java.io.File import java.nio.file.Paths @RunWith(SpringRunner::class) @@ -81,11 +82,20 @@ class BluePrintEnhancerServiceImplTest { testComponentInvokeEnhancementAndValidation(basePath, "golden-enhance") } + @Test + @Throws(Exception::class) + fun testCapabilityRestconfEnhancementAndValidation() { + val basePath = "./../../../../components/model-catalog/blueprint-model/test-blueprint/capability_restconf" + testComponentInvokeEnhancementAndValidation(basePath, "capability_restconf-enhance") + + } private fun testComponentInvokeEnhancementAndValidation(basePath: String, targetDirName: String) { val targetPath = Paths.get("target", targetDirName).toUri().path + deleteTargetDirectory(targetPath) + val bluePrintContext = bluePrintEnhancerService.enhance(basePath, targetPath) Assert.assertNotNull("failed to get blueprintContext ", bluePrintContext) @@ -94,4 +104,9 @@ class BluePrintEnhancerServiceImplTest { Assert.assertTrue("blueprint($basePath) validation failed ", valid) } + private fun deleteTargetDirectory(targetPath: String) { + val targetDirectory = File(targetPath) + targetDirectory.deleteRecursively() + } + }
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/resources/application.properties b/ms/controllerblueprints/modules/service/src/test/resources/application.properties index 20450f44..011bad32 100755 --- a/ms/controllerblueprints/modules/service/src/test/resources/application.properties +++ b/ms/controllerblueprints/modules/service/src/test/resources/application.properties @@ -20,7 +20,7 @@ logging.level.org.springframework.web=INFO logging.level.org.hibernate.SQL=warn logging.level.org.hibernate.type.descriptor.sql=debug # Load Resource Source Mappings -resourceSourceMappings=primary-db=source-primary-db,input=source-input,default=source-default,primary-config-data=source-rest,capability=source-capability +resourceSourceMappings=processor-db=source-processor-db,input=source-input,default=source-default,primary-config-data=source-rest,capability=source-capability # Controller Blueprints Core Configuration controllerblueprints.blueprintDeployPath=./target/blueprints/deploy controllerblueprints.blueprintArchivePath=./target/blueprints/archive diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index 9ba4a2d4..44a5ec84 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.onap.ccsdk.apps</groupId> <artifactId>controllerblueprints</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> <artifactId>parent</artifactId> diff --git a/ms/controllerblueprints/pom.xml b/ms/controllerblueprints/pom.xml index 6d6dae6b..39808233 100644 --- a/ms/controllerblueprints/pom.xml +++ b/ms/controllerblueprints/pom.xml @@ -18,12 +18,12 @@ <parent> <groupId>org.onap.ccsdk.apps</groupId> <artifactId>ccsdk-apps-ms</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>controllerblueprints</artifactId> <name>Controller Blueprints Root</name> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> <properties> <service.name>ControllerBlueprints</service.name> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> diff --git a/ms/neng/pom.xml b/ms/neng/pom.xml index e9477f9e..23a34615 100644 --- a/ms/neng/pom.xml +++ b/ms/neng/pom.xml @@ -23,7 +23,7 @@ <groupId>org.onap.ccsdk.apps</groupId> <artifactId>ccsdk-apps-ms-neng</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> <name>Naming Generation</name> <properties> @@ -243,7 +243,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>spring-boot-1-starter-parent</artifactId> - <version>1.2.1</version> + <version>1.2.2-SNAPSHOT</version> <relativePath/> </parent> @@ -24,11 +24,11 @@ <parent> <groupId>org.onap.ccsdk.apps</groupId> <artifactId>ccsdk-apps</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> </parent> <artifactId>ccsdk-apps-ms</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> <packaging>pom</packaging> <name>Micro-services Root</name> diff --git a/ms/vlantag-api/pom.xml b/ms/vlantag-api/pom.xml index c033e858..58e63aae 100644 --- a/ms/vlantag-api/pom.xml +++ b/ms/vlantag-api/pom.xml @@ -4,7 +4,7 @@ <groupId>org.onap.ccsdk.apps.ms.vlantagapi</groupId> <artifactId>vlantag-api</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> <packaging>jar</packaging> <name>Vlantag API</name> @@ -40,7 +40,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>spring-boot-starter-parent</artifactId> - <version>1.2.1</version> + <version>1.2.2-SNAPSHOT</version> <relativePath/> </parent> @@ -5,13 +5,13 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>1.2.1</version> + <version>1.2.2-SNAPSHOT</version> <relativePath/> </parent> <groupId>org.onap.ccsdk.apps</groupId> <artifactId>ccsdk-apps</artifactId> - <version>0.4.1-SNAPSHOT</version> + <version>0.4.2-SNAPSHOT</version> <packaging>pom</packaging> <name>ccsdk-apps</name> diff --git a/version.properties b/version.properties index b1967d0a..1c98ae9b 100644 --- a/version.properties +++ b/version.properties @@ -6,7 +6,7 @@ release_name=0 sprint_number=4 -feature_revision=1 +feature_revision=2 base_version=${release_name}.${sprint_number}.${feature_revision} |