aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor')
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt18
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt13
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt3
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt40
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt16
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt41
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt30
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt16
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/pom.xml4
-rwxr-xr-xms/blueprintsprocessor/modules/commons/pom.xml16
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/pom.xml (renamed from ms/blueprintsprocessor/modules/commons/core/pom.xml)2
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt (renamed from ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt)0
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt (renamed from ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt)0
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt (renamed from ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt)0
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt (renamed from ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt)134
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt (renamed from ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt)0
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/resources/application.properties (renamed from ms/blueprintsprocessor/modules/commons/core/src/main/resources/application.properties)32
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintPropertiesTest.kt (renamed from ms/blueprintsprocessor/modules/commons/core/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintPropertiesTest.kt)0
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml10
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt1
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt10
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt76
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt51
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt73
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt24
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt99
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt38
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/utils/WebClientUtils.kt25
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt13
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/pom.xml2
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/pom.xml23
-rwxr-xr-xms/blueprintsprocessor/modules/services/pom.xml35
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/pom.xml21
-rwxr-xr-xms/blueprintsprocessor/parent/pom.xml19
34 files changed, 495 insertions, 390 deletions
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
index 55085216..02c0a342 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
@@ -57,6 +57,24 @@ interface NetconfRpcService {
editDefaultOperation: String = ModifyAction.NONE.action): DeviceResponse
/**
+ * Invoke custom RPC as provided as input.
+ *
+ * Some use cases might required one to directly invoke a device
+ * specific RPC. The RPC must be correctly formatted.
+ *
+ * Ex: in order to rollback last submitted configuration
+ * for JUNOS devices, such RPC can be use:
+ * <code>
+ * &lt;rpc>
+ * &lt;load-configuration rollback="1"/>
+ * &lt;/rpc>
+ * </code>
+ *
+ * @param rpc the rpc content.
+ */
+ fun invokeRpc(rpc: String): DeviceResponse
+
+ /**
* Validate
*
* @param configTarget running or candidate, default candidate
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
index 8d8e0ea4..15fb3122 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
@@ -41,6 +41,19 @@ class NetconfRpcServiceImpl(private var deviceInfo: DeviceInfo) : NetconfRpcServ
this.netconfSession = netconfSession
}
+ override fun invokeRpc(rpc: String): DeviceResponse {
+ var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
+ log.info("$deviceInfo: invokeRpc: messageId($messageId)")
+ try {
+ output = asyncRpc(rpc, messageId)
+ } catch (e: Exception) {
+ output.status = RpcStatus.FAILURE
+ output.errorMessage = "$deviceInfo: failed in invokeRpc command $e.message"
+ }
+ return output
+ }
+
override fun getConfig(filter: String, configTarget: String): DeviceResponse {
var output = DeviceResponse()
val messageId = messageIdInteger.getAndIncrement().toString()
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
index 1c357446..25fc8c01 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
@@ -48,6 +48,9 @@ open class DatabaseResourceSource : ResourceSourceProperties() {
}
open class RestResourceSource : ResourceSourceProperties() {
+ lateinit var verb: String
+ @get:JsonProperty("payload")
+ var payload: String? = null
lateinit var type: String
@get:JsonProperty("endpoint-selector")
var endpointSelector: String? = null
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 39be14c9..c76bff32 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
@@ -18,11 +18,18 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
import com.fasterxml.jackson.databind.node.JsonNodeFactory
+import com.fasterxml.jackson.databind.node.MissingNode
import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.DBLibGenericService
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.*
+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.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
@@ -31,7 +38,6 @@ 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
@@ -54,11 +60,8 @@ open class DatabaseResourceAssignmentProcessor(private val dBLibGenericService:
validate(resourceAssignment)
// Check if It has Input
- try {
- val value = raRuntimeService.getInputValue(resourceAssignment.name)
- logger.info("primary-db source template key (${resourceAssignment.name}) found from input and value is ($value)")
- ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
- } catch (e: BluePrintProcessorException) {
+ val value = getFromInput(resourceAssignment)
+ if (value == null || value is MissingNode) {
val dName = resourceAssignment.dictionaryName
val dSource = resourceAssignment.dictionarySource
val resourceDefinition = resourceDictionaries[dName]
@@ -71,12 +74,16 @@ open class DatabaseResourceAssignmentProcessor(private val dBLibGenericService:
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 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(sql, populateNamedParameter(inputKeyMapping))
+ val rows = jdbcTemplate.queryForList(resolvedSql, resolvedInputKeyMapping)
if (rows.isNullOrEmpty()) {
- logger.warn("Failed to get $dSource result for dictionary name ($dName) the query ($sql)")
+ logger.warn("Failed to get $dSource result for dictionary name ($dName) the query ($resolvedSql)")
} else {
populateResource(resourceAssignment, sourceProperties, rows)
}
@@ -91,7 +98,7 @@ open class DatabaseResourceAssignmentProcessor(private val dBLibGenericService:
}
private fun blueprintDBLibService(sourceProperties: DatabaseResourceSource): NamedParameterJdbcTemplate {
- return if (checkNotEmpty(sourceProperties.endpointSelector!!)) {
+ return if (checkNotEmpty(sourceProperties.endpointSelector)) {
val dbPropertiesJson = raRuntimeService.resolveDSLExpression(sourceProperties.endpointSelector!!)
dBLibGenericService.remoteJdbcTemplate(dbPropertiesJson)
} else {
@@ -109,17 +116,6 @@ open class DatabaseResourceAssignmentProcessor(private val dBLibGenericService:
}
}
- 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)
private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: DatabaseResourceSource, rows: List<Map<String, Any>>) {
val dName = resourceAssignment.dictionaryName
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
index 528705f1..d487eab6 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
@@ -17,7 +17,7 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
-import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.node.MissingNode
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
@@ -44,19 +44,11 @@ open class DefaultResourceResolutionProcessor : ResourceAssignmentProcessor() {
override fun process(resourceAssignment: ResourceAssignment) {
try {
- // Check if It has Input
- var value: JsonNode?
- try {
- value = raRuntimeService.getInputValue(resourceAssignment.name)
- } catch (e: BluePrintProcessorException) {
- // If value is null get it from default source
- logger.info("Looking for defaultValue as couldn't find value in input For template key (${resourceAssignment.name})")
+ var value = getFromInput(resourceAssignment)
+ if (value == null || value is MissingNode) {
value = resourceAssignment.property?.defaultValue
+ ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
}
-
- logger.info("For template key (${resourceAssignment.name}) setting value as ($value)")
- ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
-
// Check the value has populated for mandatory case
ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment)
} catch (e: Exception) {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
index 9b7c70aa..64cc1d2d 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
@@ -17,12 +17,18 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
+import com.fasterxml.jackson.databind.JsonNode
+import org.apache.commons.collections.MapUtils
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
+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.interfaces.BlueprintFunctionNode
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintTemplateService
+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.ResourceDefinition
import org.slf4j.LoggerFactory
+import java.util.*
abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssignment, ResourceAssignment> {
@@ -38,12 +44,43 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
*/
open fun <T> scriptPropertyInstanceType(name: String): T {
return scriptPropertyInstances as? T
- ?: throw BluePrintProcessorException("couldn't get script property instance ($name)")
+ ?: throw BluePrintProcessorException("couldn't get script property instance ($name)")
+ }
+
+ open fun getFromInput(resourceAssignment: ResourceAssignment): JsonNode? {
+ var value: JsonNode? = null
+ try {
+ value = raRuntimeService.getInputValue(resourceAssignment.name)
+ ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
+ } catch (e: BluePrintProcessorException) {
+ // NoOp - couldn't find value from input
+ }
+ return value
}
open fun resourceDefinition(name: String): ResourceDefinition {
return resourceDictionaries[name]
- ?: throw BluePrintProcessorException("couldn't get resource definition for ($name)")
+ ?: throw BluePrintProcessorException("couldn't get resource definition for ($name)")
+ }
+
+ open fun resolveInputKeyMappingVariables(inputKeyMapping: Map<String, String>): Map<String, Any> {
+ val resolvedInputKeyMapping = HashMap<String, Any>()
+ if (MapUtils.isNotEmpty(inputKeyMapping)) {
+ for ((key, value) in inputKeyMapping) {
+ val resultValue = raRuntimeService.getResolutionStore(value)
+ val expressionValue = JacksonUtils.getValue(resultValue)
+ log.trace("Reference dictionary key ({}), value ({})", key, expressionValue)
+ resolvedInputKeyMapping[key] = expressionValue
+ }
+ }
+ return resolvedInputKeyMapping
+ }
+
+ open fun resolveFromInputKeyMapping(valueToResolve: String, keyMapping: Map<String, Any>): String {
+ if (valueToResolve.isEmpty() || !valueToResolve.contains("$")) {
+ return valueToResolve
+ }
+ return BluePrintTemplateService.generateContent(valueToResolve, additionalContext = keyMapping)
}
override fun prepareRequest(resourceAssignment: ResourceAssignment): ResourceAssignment {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
index 37b4774a..f279f544 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
@@ -20,8 +20,6 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.pr
import com.fasterxml.jackson.databind.node.ArrayNode
import com.fasterxml.jackson.databind.node.JsonNodeFactory
import com.fasterxml.jackson.databind.node.MissingNode
-import com.fasterxml.jackson.databind.node.NullNode
-import com.fasterxml.jackson.databind.node.ObjectNode
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.RestResourceSource
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
@@ -63,11 +61,8 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
validate(resourceAssignment)
// Check if It has Input
- val value = raRuntimeService.getInputValue(resourceAssignment.name)
- if (value !is MissingNode && value !is NullNode) {
- logger.info("primary-db source template key (${resourceAssignment.name}) found from input and value is ($value)")
- ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
- } else {
+ val value = getFromInput(resourceAssignment)
+ if (value == null || value is MissingNode) {
val dName = resourceAssignment.dictionaryName
val dSource = resourceAssignment.dictionarySource
val resourceDefinition = resourceDictionaries[dName]
@@ -78,17 +73,22 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
checkNotNull(resourceSource.properties) { "failed to get source properties for $dName " }
val sourceProperties =
JacksonUtils.getInstanceFromMap(resourceSourceProperties, RestResourceSource::class.java)
-
- val urlPath =
- checkNotNull(sourceProperties.urlPath) { "failed to get request urlPath for $dName under $dSource properties" }
val path = nullToEmpty(sourceProperties.path)
val inputKeyMapping =
checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
+ val resolvedInputKeyMapping = resolveInputKeyMappingVariables(inputKeyMapping)
+
+ // Resolving content Variables
+ val payload = resolveFromInputKeyMapping(nullToEmpty(sourceProperties.payload), resolvedInputKeyMapping)
+ val urlPath =
+ resolveFromInputKeyMapping(checkNotNull(sourceProperties.urlPath), resolvedInputKeyMapping)
+ val verb = resolveFromInputKeyMapping(nullToEmpty(sourceProperties.verb), resolvedInputKeyMapping)
logger.info("$dSource dictionary information : ($urlPath), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})")
// Get the Rest Client Service
val restClientService = blueprintWebClientService(resourceAssignment, sourceProperties)
- val response = restClientService.getResource(urlPath, String::class.java)
+
+ val response = restClientService.exchangeResource(verb, urlPath, payload)
if (response.isBlank()) {
logger.warn("Failed to get $dSource result for dictionary name ($dName) using urlPath ($urlPath)")
} else {
@@ -104,8 +104,8 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
}
}
- open fun blueprintWebClientService(resourceAssignment: ResourceAssignment,
- restResourceSource: RestResourceSource): BlueprintWebClientService {
+ private fun blueprintWebClientService(resourceAssignment: ResourceAssignment,
+ restResourceSource: RestResourceSource): BlueprintWebClientService {
return if (checkNotEmpty(restResourceSource.endpointSelector)) {
val restPropertiesJson = raRuntimeService.resolveDSLExpression(restResourceSource.endpointSelector!!)
blueprintRestLibPropertyService.blueprintWebClientService(restPropertiesJson)
@@ -165,7 +165,9 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
}
else -> {
// Complex Types
- val objectNode = responseNode as ObjectNode
+ entrySchemaType =
+ returnNotEmptyOrThrow(resourceAssignment.property?.type) { "Entry schema is not defined for dictionary ($dName) info" }
+ val objectNode = JsonNodeFactory.instance.objectNode()
outputKeyMapping.map {
val responseKeyValue = responseNode.get(it.key)
val propertyTypeForDataType =
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
index b5b126ab..d55ccacb 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
@@ -24,7 +24,13 @@ import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.node.NullNode
import com.fasterxml.jackson.databind.node.ObjectNode
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
-import org.onap.ccsdk.apps.controllerblueprints.core.*
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
+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.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
@@ -36,7 +42,6 @@ class ResourceAssignmentUtils {
private val logger: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentUtils::class.toString())
// TODO("Modify Value type from Any to JsonNode")
- @Synchronized
@Throws(BluePrintProcessorException::class)
fun setResourceDataValue(resourceAssignment: ResourceAssignment,
raRuntimeService: ResourceAssignmentRuntimeService, value: Any?) {
@@ -85,7 +90,6 @@ class ResourceAssignmentUtils {
}
- @Synchronized
fun setFailedResourceDataValue(resourceAssignment: ResourceAssignment, message: String?) {
if (checkNotEmpty(resourceAssignment.name)) {
resourceAssignment.updatedDate = Date()
@@ -95,7 +99,6 @@ class ResourceAssignmentUtils {
}
}
- @Synchronized
@Throws(BluePrintProcessorException::class)
fun assertTemplateKeyValueNotNull(resourceAssignment: ResourceAssignment) {
val resourceProp = checkNotNull(resourceAssignment.property) { "Failed to populate mandatory resource resource mapping $resourceAssignment" }
@@ -105,7 +108,6 @@ class ResourceAssignmentUtils {
}
}
- @Synchronized
@Throws(BluePrintProcessorException::class)
fun generateResourceDataForAssignments(assignments: List<ResourceAssignment>): String {
val result: String
@@ -139,10 +141,6 @@ class ResourceAssignmentUtils {
return resourceAssignmentRuntimeService
}
- /*
- * Populate the Field property type for the Data type
- */
- @Synchronized
@Throws(BluePrintProcessorException::class)
fun getPropertyType(raRuntimeService: ResourceAssignmentRuntimeService, dataTypeName: String, propertyName: String): String {
lateinit var type: String
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml
index 7c5aecb7..1f8251bd 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml
@@ -36,16 +36,14 @@
<dependency>
<groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
<artifactId>db-resources</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
<artifactId>blueprint-validation</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
- <artifactId>core</artifactId>
+ <artifactId>processor-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
diff --git a/ms/blueprintsprocessor/modules/commons/pom.xml b/ms/blueprintsprocessor/modules/commons/pom.xml
index 9d5dc51c..e1c07ddb 100755
--- a/ms/blueprintsprocessor/modules/commons/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/pom.xml
@@ -3,6 +3,7 @@
~ Copyright © 2017-2018 AT&T Intellectual Property.
~
~ Modifications Copyright © 2019 Bell Canada.
+ ~ Modifications Copyright © 2019 IBM.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
@@ -16,7 +17,8 @@
~ 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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
@@ -30,9 +32,9 @@
<description>Blueprints Processor Commons</description>
<modules>
+ <module>processor-core</module>
<module>db-lib</module>
<module>rest-lib</module>
- <module>core</module>
<module>dmaap-lib</module>
</modules>
<dependencies>
@@ -42,6 +44,11 @@
</dependency>
<!-- Test Dependencies -->
<dependency>
+ <groupId>io.mockk</groupId>
+ <artifactId>mockk</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<scope>test</scope>
@@ -57,6 +64,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
diff --git a/ms/blueprintsprocessor/modules/commons/core/pom.xml b/ms/blueprintsprocessor/modules/commons/processor-core/pom.xml
index 42710b51..aadff9c9 100644
--- a/ms/blueprintsprocessor/modules/commons/core/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/pom.xml
@@ -24,7 +24,7 @@
<version>0.4.1-SNAPSHOT</version>
</parent>
- <artifactId>core</artifactId>
+ <artifactId>processor-core</artifactId>
<packaging>jar</packaging>
<name>Blueprints Processor Core</name>
<description>Blueprints Processor Core</description>
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt
index 07e494a1..07e494a1 100644
--- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt
index 10b8ceb5..10b8ceb5 100644
--- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
index 41bbd1df..41bbd1df 100644
--- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt
index 66643ee0..9c6e5075 100644
--- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt
@@ -1,68 +1,68 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.core.factory
-
-import com.att.eelf.configuration.EELFManager
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
-import org.springframework.context.ApplicationContext
-import org.springframework.context.ApplicationContextAware
-
-/**
- * ComponentNode
- *
- * @author Brinda Santh
- */
-interface ComponentNode {
-
- @Throws(BluePrintProcessorException::class)
- fun validate(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>)
-
- @Throws(BluePrintProcessorException::class)
- fun process(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>)
-
- @Throws(BluePrintProcessorException::class)
- fun errorHandle(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>)
-
- @Throws(BluePrintProcessorException::class)
- fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>)
-}
-
-/**
- * ComponentNodeFactory
- *
- * @author Brinda Santh
- */
-open class ComponentNodeFactory : ApplicationContextAware {
- private val log = EELFManager.getInstance().getLogger(ComponentNodeFactory::class.java)
-
- var componentNodes: MutableMap<String, ComponentNode> = hashMapOf()
-
- fun getInstance(instanceName: String): ComponentNode? {
- log.trace("looking for Component Nodes : {}", instanceName)
- return componentNodes.get(instanceName)
- }
-
- fun injectInstance(instanceName: String, componentNode: ComponentNode) {
- this.componentNodes[instanceName] = componentNode
- }
-
- override fun setApplicationContext(context: ApplicationContext) {
- componentNodes = context.getBeansOfType(ComponentNode::class.java)
- log.info("Injected Component Nodes : {}", componentNodes)
- }
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.core.factory
+
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.springframework.context.ApplicationContext
+import org.springframework.context.ApplicationContextAware
+
+/**
+ * ComponentNode
+ *
+ * @author Brinda Santh
+ */
+interface ComponentNode {
+
+ @Throws(BluePrintProcessorException::class)
+ fun validate(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>)
+
+ @Throws(BluePrintProcessorException::class)
+ fun process(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>)
+
+ @Throws(BluePrintProcessorException::class)
+ fun errorHandle(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>)
+
+ @Throws(BluePrintProcessorException::class)
+ fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>)
+}
+
+/**
+ * ComponentNodeFactory
+ *
+ * @author Brinda Santh
+ */
+open class ComponentNodeFactory : ApplicationContextAware {
+ private val log = EELFManager.getInstance().getLogger(ComponentNodeFactory::class.java)
+
+ var componentNodes: MutableMap<String, ComponentNode> = hashMapOf()
+
+ fun getInstance(instanceName: String): ComponentNode? {
+ log.trace("looking for Component Nodes : {}", instanceName)
+ return componentNodes.get(instanceName)
+ }
+
+ fun injectInstance(instanceName: String, componentNode: ComponentNode) {
+ this.componentNodes[instanceName] = componentNode
+ }
+
+ override fun setApplicationContext(context: ApplicationContext) {
+ componentNodes = context.getBeansOfType(ComponentNode::class.java)
+ log.info("Injected Component Nodes : {}", componentNodes)
+ }
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt
index 31dca33b..31dca33b 100644
--- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/resources/application.properties b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/resources/application.properties
index 2ce87147..c10e96ee 100644
--- a/ms/blueprintsprocessor/modules/commons/core/src/main/resources/application.properties
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/resources/application.properties
@@ -1,16 +1,16 @@
-#
-# 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.
-#
-
+#
+# 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.
+#
+
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintPropertiesTest.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintPropertiesTest.kt
index 66de11fd..66de11fd 100644
--- a/ms/blueprintsprocessor/modules/commons/core/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintPropertiesTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintPropertiesTest.kt
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
index f1d97896..625297bf 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
@@ -15,7 +15,8 @@
~ 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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
@@ -34,7 +35,12 @@
</dependency>
<dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
- <artifactId>core</artifactId>
+ <artifactId>processor-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>${apache.httpcomponents.client.version}</version>
</dependency>
</dependencies>
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
index f63e39f3..7af91c6f 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
@@ -30,6 +30,7 @@ open class BluePrintRestLibConfiguration
class RestLibConstants {
companion object {
const val SERVICE_BLUEPRINT_REST_LIB_PROPERTY = "blueprint-rest-lib-property-service"
+ const val TYPE_TOKEN_AUTH = "token-auth"
const val TYPE_BASIC_AUTH = "basic-auth"
const val TYPE_SSL_BASIC_AUTH = "ssl-basic-auth"
const val TYPE_DME2_PROXY = "dme2-proxy"
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt
index 41e45458..dd4d9f7d 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt
@@ -19,19 +19,23 @@ package org.onap.ccsdk.apps.blueprintsprocessor.rest
open class RestClientProperties {
lateinit var type: String
lateinit var url: String
- lateinit var userId: String
}
open class BasicAuthRestClientProperties : RestClientProperties() {
+ lateinit var password: String
+ lateinit var username: String
+}
+
+open class TokenAuthRestClientProperties : RestClientProperties() {
var token: String? = null
}
open class SSLBasicAuthRestClientProperties : RestClientProperties() {
lateinit var keyStoreInstance: String // JKS, PKCS12
lateinit var sslTrust: String
- lateinit var sslTrustPasswd: String
+ lateinit var sslTrustPassword: String
lateinit var sslKey: String
- lateinit var sslKeyPasswd: String
+ lateinit var sslKeyPassword: String
}
open class DME2RestClientProperties : RestClientProperties() {
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
index 130706d7..0502f67c 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
@@ -1,5 +1,5 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Copyright © 2017-2019 AT&T, Bell Canada
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,67 +16,31 @@
package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
+import org.apache.http.message.BasicHeader
import org.onap.ccsdk.apps.blueprintsprocessor.rest.BasicAuthRestClientProperties
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.utils.WebClientUtils
import org.springframework.http.HttpHeaders
import org.springframework.http.MediaType
-import org.springframework.web.reactive.function.BodyInserters
-import org.springframework.web.reactive.function.client.ExchangeFilterFunctions
-import org.springframework.web.reactive.function.client.WebClient
-
-
-class BasicAuthRestClientService(private val restClientProperties: BasicAuthRestClientProperties) : BlueprintWebClientService {
-
- private var webClient: WebClient? = null
-
- override fun webClient(): WebClient {
- if (webClient == null) {
- webClient = WebClient.builder()
- .baseUrl(restClientProperties.url)
- .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
- .defaultHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
- .filter(ExchangeFilterFunctions
- .basicAuthentication(restClientProperties.userId, restClientProperties.token))
- .filter(WebClientUtils.logRequest())
- .filter(WebClientUtils.logResponse())
- .build()
- }
- return webClient!!
- }
-
- override fun <T> getResource(path: String, responseType: Class<T>): T {
- return getResource(path, null, responseType)
- }
-
- override fun <T> getResource(path: String, headers: Map<String, String>?, responseType: Class<T>): T {
- return webClient().get()
- .uri(path)
- .headers { httpHeaders ->
- headers?.forEach {
- httpHeaders.set(it.key, it.value)
- }
- }
- .retrieve()
- .bodyToMono(responseType).block()!!
- }
-
- override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
- return postResource(path, null, request, responseType)
+import java.nio.charset.Charset
+import java.util.*
+
+class BasicAuthRestClientService(private val restClientProperties: BasicAuthRestClientProperties) :
+ BlueprintWebClientService {
+
+ override fun headers(): Array<BasicHeader> {
+ val encodedCredentials = setBasicAuth(restClientProperties.username, restClientProperties.password)
+ val params = arrayListOf<BasicHeader>()
+ params.add(BasicHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE))
+ params.add(BasicHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE))
+ params.add(BasicHeader(HttpHeaders.AUTHORIZATION, "Basic $encodedCredentials"))
+ return params.toTypedArray()
}
- override fun <T> postResource(path: String, headers: Map<String, String>?, request: Any, responseType: Class<T>): T {
- return webClient().post()
- .uri(path)
- .headers { httpHeaders ->
- headers?.forEach {
- httpHeaders.set(it.key, it.value)
- }
- }
- .body(BodyInserters.fromObject(request))
- .retrieve().bodyToMono(responseType).block()!!
+ override fun host(uri: String): String {
+ return restClientProperties.url + uri
}
- override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ private fun setBasicAuth(username: String, password: String): String {
+ val credentialsString = "$username:$password"
+ return Base64.getEncoder().encodeToString(credentialsString.toByteArray(Charset.defaultCharset()))
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
index 705caa2e..3888bb72 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
@@ -1,5 +1,5 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Copyright © 2017-2019 AT&T, Bell Canada
* Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +19,13 @@ package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.*
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.BasicAuthRestClientProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.DME2RestClientProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.PolicyManagerRestClientProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestLibConstants
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.SSLBasicAuthRestClientProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.TokenAuthRestClientProperties
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.springframework.stereotype.Service
@@ -27,6 +33,17 @@ import org.springframework.stereotype.Service
@Service(RestLibConstants.SERVICE_BLUEPRINT_REST_LIB_PROPERTY)
open class BluePrintRestLibPropertyService(private var bluePrintProperties: BluePrintProperties) {
+ fun blueprintWebClientService(jsonNode: JsonNode): BlueprintWebClientService {
+ val restClientProperties = restClientProperties(jsonNode)
+ return blueprintWebClientService(restClientProperties)
+ }
+
+ fun blueprintWebClientService(selector: String): BlueprintWebClientService {
+ val prefix = "blueprintsprocessor.restclient.$selector"
+ val restClientProperties = restClientProperties(prefix)
+ return blueprintWebClientService(restClientProperties)
+ }
+
fun restClientProperties(prefix: String): RestClientProperties {
val type = bluePrintProperties.propertyBeanType("$prefix.type", String::class.java)
return when (type) {
@@ -48,9 +65,12 @@ open class BluePrintRestLibPropertyService(private var bluePrintProperties: Blue
}
}
- fun restClientProperties(jsonNode: JsonNode): RestClientProperties {
+ private fun restClientProperties(jsonNode: JsonNode): RestClientProperties {
val type = jsonNode.get("type").textValue()
return when (type) {
+ RestLibConstants.TYPE_TOKEN_AUTH -> {
+ JacksonUtils.readValue(jsonNode, TokenAuthRestClientProperties::class.java)!!
+ }
RestLibConstants.TYPE_BASIC_AUTH -> {
JacksonUtils.readValue(jsonNode, BasicAuthRestClientProperties::class.java)!!
}
@@ -69,20 +89,11 @@ open class BluePrintRestLibPropertyService(private var bluePrintProperties: Blue
}
}
-
- fun blueprintWebClientService(selector: String): BlueprintWebClientService {
- val prefix = "blueprintsprocessor.restclient.$selector"
- val restClientProperties = restClientProperties(prefix)
- return blueprintWebClientService(restClientProperties)
- }
-
- fun blueprintWebClientService(jsonNode: JsonNode): BlueprintWebClientService {
- val restClientProperties = restClientProperties(jsonNode)
- return blueprintWebClientService(restClientProperties)
- }
-
- fun blueprintWebClientService(restClientProperties: RestClientProperties): BlueprintWebClientService {
+ private fun blueprintWebClientService(restClientProperties: RestClientProperties): BlueprintWebClientService {
when (restClientProperties) {
+ is TokenAuthRestClientProperties -> {
+ return TokenAuthRestClientService(restClientProperties)
+ }
is BasicAuthRestClientProperties -> {
return BasicAuthRestClientService(restClientProperties)
}
@@ -98,19 +109,19 @@ open class BluePrintRestLibPropertyService(private var bluePrintProperties: Blue
}
}
- fun basicAuthRestClientProperties(prefix: String): BasicAuthRestClientProperties {
+ private fun basicAuthRestClientProperties(prefix: String): BasicAuthRestClientProperties {
return bluePrintProperties.propertyBeanType(prefix, BasicAuthRestClientProperties::class.java)
}
- fun sslBasicAuthRestClientProperties(prefix: String): SSLBasicAuthRestClientProperties {
+ private fun sslBasicAuthRestClientProperties(prefix: String): SSLBasicAuthRestClientProperties {
return bluePrintProperties.propertyBeanType(prefix, SSLBasicAuthRestClientProperties::class.java)
}
- fun dme2ProxyClientProperties(prefix: String): DME2RestClientProperties {
+ private fun dme2ProxyClientProperties(prefix: String): DME2RestClientProperties {
return bluePrintProperties.propertyBeanType(prefix, DME2RestClientProperties::class.java)
}
- fun policyManagerRestClientProperties(prefix: String): PolicyManagerRestClientProperties {
+ private fun policyManagerRestClientProperties(prefix: String): PolicyManagerRestClientProperties {
return bluePrintProperties.propertyBeanType(prefix, PolicyManagerRestClientProperties::class.java)
}
}
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
index 8106c077..9c2caad7 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
@@ -1,5 +1,5 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Copyright © 2017-2019 AT&T, Bell Canada
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,21 +16,76 @@
package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
-import org.springframework.web.reactive.function.client.WebClient
+import org.apache.commons.io.IOUtils
+import org.apache.http.client.methods.HttpDelete
+import org.apache.http.client.methods.HttpGet
+import org.apache.http.client.methods.HttpPost
+import org.apache.http.client.methods.HttpPut
+import org.apache.http.entity.StringEntity
+import org.apache.http.impl.client.CloseableHttpClient
+import org.apache.http.impl.client.HttpClients
+import org.apache.http.message.BasicHeader
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.utils.WebClientUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.springframework.http.HttpMethod
+import java.nio.charset.Charset
interface BlueprintWebClientService {
- fun webClient(): WebClient
+ fun headers(): Array<BasicHeader>
- fun <T> getResource(path: String, responseType: Class<T>): T
+ fun host(uri: String): String
- fun <T> getResource(path: String, headers: Map<String, String>?, responseType: Class<T>): T
+ fun httpClient(): CloseableHttpClient {
+ return HttpClients.custom()
+ .addInterceptorFirst(WebClientUtils.logRequest())
+ .addInterceptorLast(WebClientUtils.logResponse())
+ .build()
+ }
- fun <T> postResource(path: String, request: Any, responseType: Class<T>): T
+ fun exchangeResource(methodType: String, path: String, request: String): String {
+ return when (HttpMethod.resolve(methodType)) {
+ HttpMethod.DELETE -> delete(path)
+ HttpMethod.GET -> get(path)
+ HttpMethod.POST -> post(path, request)
+ HttpMethod.PUT -> put(path, request)
+ else -> throw BluePrintProcessorException("Unsupported methodType($methodType)")
+ }
+ }
- fun <T> postResource(path: String, headers: Map<String, String>?, request: Any, responseType: Class<T>): T
+ fun delete(path: String): String {
+ val httpDelete = HttpDelete(host(path))
+ httpDelete.setHeaders(headers())
+ httpClient().execute(httpDelete).entity.content.use {
+ return IOUtils.toString(it, Charset.defaultCharset())
+ }
+ }
- fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T
+ fun get(path: String): String {
+ val httpGet = HttpGet(host(path))
+ httpGet.setHeaders(headers())
+ httpClient().execute(httpGet).entity.content.use {
+ return IOUtils.toString(it, Charset.defaultCharset())
+ }
+ }
-}
+ fun post(path: String, request: String): String {
+ val httpPost = HttpPost(host(path))
+ val entity = StringEntity(request)
+ httpPost.entity = entity
+ httpPost.setHeaders(headers())
+ httpClient().execute(httpPost).entity.content.use {
+ return IOUtils.toString(it, Charset.defaultCharset())
+ }
+ }
+ fun put(path: String, request: String): String {
+ val httpPut = HttpPut(host(path))
+ val entity = StringEntity(request)
+ httpPut.entity = entity
+ httpPut.setHeaders(headers())
+ httpClient().execute(httpPut).entity.content.use {
+ return IOUtils.toString(it, Charset.defaultCharset())
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt
index 27dbe6f8..2b2578a3 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt
@@ -1,5 +1,5 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Copyright © 2017-2019 AT&T, Bell Canada
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,31 +16,15 @@
package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
+import org.apache.http.message.BasicHeader
import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
-import org.springframework.web.reactive.function.client.WebClient
class DME2ProxyRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService {
- override fun webClient(): WebClient {
+ override fun headers(): Array<BasicHeader> {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
- override fun <T> getResource(path: String, responseType: Class<T>): T {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override fun <T> getResource(path: String, headers: Map<String, String>?, responseType: Class<T>): T {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override fun <T> postResource(path: String, headers: Map<String, String>?, request: Any, responseType: Class<T>): T {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
+ override fun host(uri: String): String {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt
index 71727b93..dc2993d9 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt
@@ -1,5 +1,5 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Copyright © 2017-2019 AT&T, Bell Canada
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,82 +16,59 @@
package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
-import io.netty.handler.ssl.SslContextBuilder
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory
+import org.apache.http.impl.client.CloseableHttpClient
+import org.apache.http.impl.client.HttpClients
+import org.apache.http.message.BasicHeader
+import org.apache.http.ssl.SSLContextBuilder
import org.onap.ccsdk.apps.blueprintsprocessor.rest.SSLBasicAuthRestClientProperties
import org.onap.ccsdk.apps.blueprintsprocessor.rest.utils.WebClientUtils
import org.springframework.http.HttpHeaders
import org.springframework.http.MediaType
-import org.springframework.http.client.reactive.ReactorClientHttpConnector
-import org.springframework.web.reactive.function.BodyInserters
-import org.springframework.web.reactive.function.client.WebClient
-import reactor.netty.http.client.HttpClient
import java.io.File
+import java.io.FileInputStream
import java.security.KeyStore
import java.security.cert.X509Certificate
+class SSLBasicAuthRestClientService(private val restClientProperties: SSLBasicAuthRestClientProperties) :
+ BlueprintWebClientService {
-class SSLBasicAuthRestClientService(private val restClientProperties: SSLBasicAuthRestClientProperties) : BlueprintWebClientService {
+ override fun headers(): Array<BasicHeader> {
+ val params = arrayListOf<BasicHeader>()
+ params.add(BasicHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE))
+ params.add(BasicHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE))
+ return params.toTypedArray()
+ }
- override fun webClient(): WebClient {
+ override fun host(uri: String): String {
+ return restClientProperties.url + uri
+ }
- // Load the Keystore Information
- val ketInputStream = File(restClientProperties.sslKey).inputStream()
- val ks = KeyStore.getInstance(restClientProperties.keyStoreInstance)
- ks.load(ketInputStream, restClientProperties.sslKeyPasswd.toCharArray())
+ override fun httpClient(): CloseableHttpClient {
- // Manage Trust Store
- val trustCertCollection = ks.aliases().toList().map { alias ->
- ks.getCertificate(alias) as X509Certificate
- }.toTypedArray()
- val sslContext = SslContextBuilder
- .forClient()
- .trustManager(*trustCertCollection)
- .build()
+ val keystoreInstance = restClientProperties.keyStoreInstance
+ val sslKey = restClientProperties.sslKey
+ val sslKeyPwd = restClientProperties.sslKeyPassword
+ val sslTrust = restClientProperties.sslTrust
+ val sslTrustPwd = restClientProperties.sslTrustPassword
- // Create Http Client
- val httpClient = HttpClient.create().secure { t -> t.sslContext(sslContext) }
+ val acceptingTrustStrategy = { chain: Array<X509Certificate>, authType: String -> true }
- return WebClient.builder()
- .baseUrl(restClientProperties.url)
- .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
- .defaultHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
- .filter(WebClientUtils.logRequest())
- .clientConnector(ReactorClientHttpConnector(httpClient)).build()
- }
+ FileInputStream(sslKey).use { keyInput ->
+ val keyStore = KeyStore.getInstance(keystoreInstance)
+ keyStore.load(keyInput, sslKeyPwd.toCharArray())
- override fun <T> getResource(path: String, responseType: Class<T>): T {
- return getResource(path, null, responseType)
- }
+ val sslContext =
+ SSLContextBuilder.create()
+ .loadKeyMaterial(keyStore, sslKeyPwd.toCharArray())
+ .loadTrustMaterial(File(sslTrust), sslTrustPwd.toCharArray(), acceptingTrustStrategy).build()
- override fun <T> getResource(path: String, headers: Map<String, String>?, responseType: Class<T>): T {
- return webClient().get()
- .uri(path)
- .headers { httpHeaders ->
- headers?.forEach {
- httpHeaders.set(it.key, it.value)
- }
- }
- .retrieve()
- .bodyToMono(responseType).block()!!
- }
-
- override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
- return postResource(path, null, request, responseType)
- }
-
- override fun <T> postResource(path: String, headers: Map<String, String>?, request: Any, responseType: Class<T>): T {
- return webClient().post()
- .uri(path)
- .headers { httpHeaders ->
- headers?.forEach {
- httpHeaders.set(it.key, it.value)
- }
- }
- .body(BodyInserters.fromObject(request))
- .retrieve().bodyToMono(responseType).block()!!
- }
+ val csf = SSLConnectionSocketFactory(sslContext!!)
- override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ return HttpClients.custom()
+ .addInterceptorFirst(WebClientUtils.logRequest())
+ .addInterceptorLast(WebClientUtils.logResponse())
+ .setSSLSocketFactory(csf).build()
+ }
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt
new file mode 100644
index 00000000..6e90957d
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt
@@ -0,0 +1,38 @@
+/*
+ * Copyright © 2019 Bell Canada
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.rest.service
+
+import org.apache.http.message.BasicHeader
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.TokenAuthRestClientProperties
+import org.springframework.http.HttpHeaders
+import org.springframework.http.MediaType
+
+class TokenAuthRestClientService(private val restClientProperties: TokenAuthRestClientProperties) :
+ BlueprintWebClientService {
+
+ override fun headers(): Array<BasicHeader> {
+ val params = arrayListOf<BasicHeader>()
+ params.add(BasicHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE))
+ params.add(BasicHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE))
+ params.add(BasicHeader(HttpHeaders.AUTHORIZATION, restClientProperties.token))
+ return params.toTypedArray()
+ }
+
+ override fun host(uri: String): String {
+ return restClientProperties.url + uri
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/utils/WebClientUtils.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/utils/WebClientUtils.kt
index 40d6ba63..d6167a87 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/utils/WebClientUtils.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/utils/WebClientUtils.kt
@@ -16,29 +16,20 @@
package org.onap.ccsdk.apps.blueprintsprocessor.rest.utils
+import org.apache.http.HttpRequestInterceptor
+import org.apache.http.HttpResponseInterceptor
+import org.slf4j.Logger
import org.slf4j.LoggerFactory
-import org.springframework.web.reactive.function.client.ExchangeFilterFunction
-import reactor.core.publisher.Mono
-
class WebClientUtils {
companion object {
- val log = LoggerFactory.getLogger(WebClientUtils::class.java)!!
-
- fun logRequest(): ExchangeFilterFunction {
+ val log: Logger = LoggerFactory.getLogger(WebClientUtils::class.java)
- return ExchangeFilterFunction.ofRequestProcessor { clientRequest ->
- log.info("Rest request method(${clientRequest.method()}), url(${clientRequest.url()})")
- Mono.just(clientRequest)
- }
- }
+ fun logRequest(): HttpRequestInterceptor =
+ HttpRequestInterceptor { request, _ -> log.info("Rest request method(${request?.requestLine?.method}), url(${request?.requestLine?.uri})") }
- fun logResponse(): ExchangeFilterFunction {
- return ExchangeFilterFunction.ofResponseProcessor { clientResponse ->
- log.info("Response status(${clientResponse.statusCode()})")
- Mono.just(clientResponse)
- }
- }
+ fun logResponse(): HttpResponseInterceptor =
+ HttpResponseInterceptor { response, _ -> log.info("Response status(${response.statusLine.statusCode})") }
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt
index 25821966..4fa82df2 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt
@@ -24,6 +24,7 @@ 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
+import org.springframework.http.HttpMethod
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
@@ -39,11 +40,10 @@ import kotlin.test.assertNotNull
@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, BlueprintPropertyConfiguration::class,
SampleController::class, BluePrintProperties::class, BluePrintProperties::class])
@TestPropertySource(properties =
-["server.port=9111",
- "blueprintsprocessor.restclient.sample.type=basic-auth",
- "blueprintsprocessor.restclient.sample.url=http://127.0.0.1:9111",
- "blueprintsprocessor.restclient.sample.userId=sampleuser",
- "blueprintsprocessor.restclient.sample.token=sampletoken"])
+["blueprintsprocessor.restclient.sample.type=basic-auth",
+ "blueprintsprocessor.restclient.sample.url=http://127.0.0.1:8080",
+ "blueprintsprocessor.restclient.sample.username=sampleuser",
+ "blueprintsprocessor.restclient.sample.password=sampletoken"])
class RestClientServiceTest {
@Autowired
@@ -51,11 +51,10 @@ class RestClientServiceTest {
@Test
fun testBaseAuth() {
-
val restClientService = bluePrintRestLibPropertyService.blueprintWebClientService("sample")
val headers = mutableMapOf<String, String>()
headers["X-Transaction-Id"] = "1234"
- val response = restClientService.getResource("/sample/name", headers, String::class.java)
+ val response = restClientService.exchangeResource(HttpMethod.GET.name, "/sample/name", "")
assertNotNull(response, "failed to get response")
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/pom.xml b/ms/blueprintsprocessor/modules/inbounds/pom.xml
index d7c0cc4f..273abd51 100644
--- a/ms/blueprintsprocessor/modules/inbounds/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/pom.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright © 2017-2018 AT&T Intellectual Property.
+ ~ Modifications Copyright © 2019 IBM.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
@@ -64,6 +65,7 @@
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
index df68b952..f5e3b3d0 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
+++ b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
@@ -44,7 +44,7 @@
</dependency>
<dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
- <artifactId>core</artifactId>
+ <artifactId>processor-core</artifactId>
</dependency>
<dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
@@ -67,26 +67,5 @@
<groupId>org.onap.ccsdk.sli.core</groupId>
<artifactId>sli-provider</artifactId>
</dependency>
-
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito2</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-test-junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.projectreactor</groupId>
- <artifactId>reactor-test</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git a/ms/blueprintsprocessor/modules/services/pom.xml b/ms/blueprintsprocessor/modules/services/pom.xml
index 469899d0..4388eeb9 100755
--- a/ms/blueprintsprocessor/modules/services/pom.xml
+++ b/ms/blueprintsprocessor/modules/services/pom.xml
@@ -3,6 +3,7 @@
~ Copyright © 2017-2018 AT&T Intellectual Property.
~
~ Modifications Copyright © 2019 Bell Canada.
+ ~ Modifications Copyright © 2019 IBM.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
@@ -33,4 +34,38 @@
<module>execution-service</module>
<module>workflow-service</module>
</modules>
+
+ <dependencies>
+ <!-- Test Dependencies -->
+ <dependency>
+ <groupId>io.mockk</groupId>
+ <artifactId>mockk</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-test-junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.projectreactor</groupId>
+ <artifactId>reactor-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml b/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml
index 4f929064..634d2233 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml
@@ -40,27 +40,6 @@
<groupId>org.onap.ccsdk.sli.core</groupId>
<artifactId>sli-provider</artifactId>
</dependency>
-
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito2</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-test-junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.projectreactor</groupId>
- <artifactId>reactor-test</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml
index 045ce711..210943ae 100755
--- a/ms/blueprintsprocessor/parent/pom.xml
+++ b/ms/blueprintsprocessor/parent/pom.xml
@@ -264,10 +264,10 @@
</dependency>
- <!-- Application Module Dependencies -->
+ <!-- Blueprint Processor Application Module Dependencies -->
<dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
- <artifactId>application</artifactId>
+ <artifactId>processor-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -282,7 +282,7 @@
</dependency>
<dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
- <artifactId>core</artifactId>
+ <artifactId>dmaap-lib</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -305,6 +305,11 @@
<artifactId>selfservice-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>application</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- Functions -->
<dependency>
@@ -328,7 +333,7 @@
<version>${project.version}</version>
</dependency>
- <!-- Application Component Dependency -->
+ <!-- Controller Blueprints Application Dependency -->
<dependency>
<groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
<artifactId>resource-dict</artifactId>
@@ -346,6 +351,11 @@
</dependency>
<dependency>
<groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+ <artifactId>db-resources</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
<artifactId>blueprint-validation</artifactId>
<version>${project.version}</version>
</dependency>
@@ -357,6 +367,7 @@
<version>${h2database.version}</version>
<scope>test</scope>
</dependency>
+
<!-- Test Dependency -->
<dependency>
<groupId>io.mockk</groupId>