summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/commons/processor-core/src/main
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh <brindasanth@in.ibm.com>2019-03-11 11:41:37 -0400
committerMuthuramalingam, Brinda Santh <brindasanth@in.ibm.com>2019-03-11 11:41:37 -0400
commitfd2d3f4f3a6f1041442edac382daf27669acbf9e (patch)
treeb9e017dc4983568fdfea808cb6fd689e3a1ee491 /ms/blueprintsprocessor/modules/commons/processor-core/src/main
parent6f6a3c057d2d0e1b5fba8801a0789c31c2702f21 (diff)
Refractor processor core module name
Change-Id: Ic4a40d6cbc5e53e79ddc36bea529fe16f6210a26 Issue-ID: CCSDK-1136 Signed-off-by: Muthuramalingam, Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/processor-core/src/main')
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt49
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt29
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt123
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt68
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt47
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/resources/application.properties16
6 files changed, 332 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/processor-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
new file mode 100644
index 000000000..07e494a1a
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt
@@ -0,0 +1,49 @@
+/*
+ * 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.core
+
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.beans.factory.annotation.Value
+import org.springframework.boot.context.properties.bind.Binder
+import org.springframework.boot.context.properties.source.ConfigurationPropertySources
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import org.springframework.core.env.Environment
+
+
+@Configuration
+open class BluePrintCoreConfiguration {
+
+ @Value("\${blueprintsprocessor.blueprintDeployPath}")
+ lateinit var deployPath: String
+
+ @Value("\${blueprintsprocessor.blueprintArchivePath}")
+ lateinit var archivePath: String
+
+}
+
+@Configuration
+open class BlueprintPropertyConfiguration {
+ @Autowired
+ lateinit var environment: Environment
+
+ @Bean
+ open fun bluePrintPropertyBinder(): Binder {
+ val configurationPropertySource = ConfigurationPropertySources.get(environment)
+ return Binder(configurationPropertySource)
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/processor-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
new file mode 100644
index 000000000..10b8ceb5e
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt
@@ -0,0 +1,29 @@
+/*
+ * 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.core
+
+import org.springframework.boot.context.properties.bind.Bindable
+import org.springframework.boot.context.properties.bind.Binder
+import org.springframework.stereotype.Service
+
+@Service
+open class BluePrintProperties(var bluePrintPropertyBinder: Binder) {
+
+ fun <T> propertyBeanType(prefix: String, type: Class<T>): T {
+ return bluePrintPropertyBinder.bind(prefix, Bindable.of(type)).get()
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/processor-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
new file mode 100644
index 000000000..41bbd1dfd
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
@@ -0,0 +1,123 @@
+/*
+ * 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.api.data
+
+import com.fasterxml.jackson.annotation.JsonFormat
+import com.fasterxml.jackson.databind.node.ObjectNode
+import io.swagger.annotations.ApiModelProperty
+import java.util.*
+
+/**
+ * BlueprintProcessorData
+ * @author Brinda Santh
+ * DATE : 8/15/2018
+ */
+
+open class ExecutionServiceInput {
+ @get:ApiModelProperty(required = true)
+ lateinit var commonHeader: CommonHeader
+ @get:ApiModelProperty(required = true)
+ lateinit var actionIdentifiers: ActionIdentifiers
+ @get:ApiModelProperty(required = true)
+ lateinit var payload: ObjectNode
+}
+
+open class ExecutionServiceOutput {
+ @get:ApiModelProperty(required = true)
+ lateinit var commonHeader: CommonHeader
+ @get:ApiModelProperty(required = true)
+ lateinit var actionIdentifiers: ActionIdentifiers
+ @get:ApiModelProperty(required = true)
+ var status: Status = Status()
+ @get:ApiModelProperty(required = true)
+ lateinit var payload: ObjectNode
+}
+
+const val ACTION_MODE_ASYNC = "async"
+const val ACTION_MODE_SYNC = "sync"
+
+open class ActionIdentifiers {
+ @get:ApiModelProperty(required = false)
+ lateinit var blueprintName: String
+ @get:ApiModelProperty(required = false)
+ lateinit var blueprintVersion: String
+ @get:ApiModelProperty(required = true)
+ lateinit var actionName: String
+ @get:ApiModelProperty(required = true, allowableValues = "sync, async")
+ lateinit var mode: String
+}
+
+open class CommonHeader {
+ @get:ApiModelProperty(required = true, example = "2012-04-23T18:25:43.511Z")
+ @get:JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ var timestamp: Date = Date()
+ @get:ApiModelProperty(required = true)
+ lateinit var originatorId: String
+ @get:ApiModelProperty(required = true)
+ lateinit var requestId: String
+ @get:ApiModelProperty(required = true)
+ lateinit var subRequestId: String
+ @get:ApiModelProperty(required = false)
+ var flags: Flags? = null
+}
+
+open class Flags {
+ var isForce: Boolean = false
+ @get:ApiModelProperty(value = "3600")
+ var ttl: Int = 3600
+}
+
+open class Status {
+ @get:ApiModelProperty(required = true)
+ var code: Int = 200
+ @get:ApiModelProperty(required = true)
+ var eventType: String = "EVENT-ACTION-RESPONSE"
+ @get:ApiModelProperty(required = true, example = "2012-04-23T18:25:43.511Z")
+ @get:JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ var timestamp: Date = Date()
+ @get:ApiModelProperty(required = false)
+ var errorMessage: String? = null
+ @get:ApiModelProperty(required = true)
+ var message: String = "success"
+}
+
+open class BluePrintManagementInput {
+ @get:ApiModelProperty(required = true)
+ lateinit var commonHeader: CommonHeader
+ @get:ApiModelProperty(required = false)
+ lateinit var blueprintName: String
+ @get:ApiModelProperty(required = false)
+ lateinit var blueprintVersion: String
+ @get:ApiModelProperty(required = true)
+ lateinit var fileChunk: FileChunk
+}
+
+open class FileChunk {
+ @get:ApiModelProperty(required = true)
+ lateinit var chunk: ByteArray
+}
+
+open class BluePrintManagementOutput {
+ @get:ApiModelProperty(required = true)
+ lateinit var commonHeader: CommonHeader
+ @get:ApiModelProperty(required = true)
+ var status: Status = Status()
+}
+
+
+
diff --git a/ms/blueprintsprocessor/modules/commons/processor-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
new file mode 100644
index 000000000..9c6e50752
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt
@@ -0,0 +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)
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/processor-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
new file mode 100644
index 000000000..31dca33b8
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt
@@ -0,0 +1,47 @@
+/*
+ * 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.core.utils
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+
+
+class PayloadUtils {
+
+ companion object {
+
+ fun prepareInputsFromWorkflowPayload(bluePrintRuntimeService: BluePrintRuntimeService<*>, payload: JsonNode, workflowName: String) {
+ val input = payload.get("$workflowName-request")
+ bluePrintRuntimeService.assignWorkflowInputs(workflowName, input)
+ }
+
+ fun prepareDynamicInputsFromWorkflowPayload(bluePrintRuntimeService: BluePrintRuntimeService<*>, payload: JsonNode, workflowName: String) {
+ val input = payload.get("$workflowName-request")
+ val propertyFields = input.get("$workflowName-properties")
+ prepareDynamicInputsFromComponentPayload(bluePrintRuntimeService, propertyFields)
+ }
+
+ fun prepareDynamicInputsFromComponentPayload(bluePrintRuntimeService: BluePrintRuntimeService<*>, payload: JsonNode) {
+ payload.fields().forEach { property ->
+ val path = StringBuilder(BluePrintConstants.PATH_INPUTS)
+ .append(BluePrintConstants.PATH_DIVIDER).append(property.key).toString()
+ bluePrintRuntimeService.put(path, property.value)
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/resources/application.properties b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/resources/application.properties
new file mode 100644
index 000000000..c10e96ee2
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/resources/application.properties
@@ -0,0 +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.
+#
+