From fd2d3f4f3a6f1041442edac382daf27669acbf9e Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Mon, 11 Mar 2019 11:41:37 -0400 Subject: Refractor processor core module name Change-Id: Ic4a40d6cbc5e53e79ddc36bea529fe16f6210a26 Issue-ID: CCSDK-1136 Signed-off-by: Muthuramalingam, Brinda Santh --- .../modules/commons/core/pom.xml | 37 ------- .../core/BluePrintCoreConfiguration.kt | 49 -------- .../core/BluePrintProperties.kt | 29 ----- .../core/api/data/BlueprintProcessorData.kt | 123 --------------------- .../core/factory/ComponentNodeFactory.kt | 68 ------------ .../blueprintsprocessor/core/utils/PayloadUtils.kt | 47 -------- .../core/src/main/resources/application.properties | 16 --- .../core/BluePrintPropertiesTest.kt | 20 ---- .../modules/commons/db-lib/pom.xml | 4 +- ms/blueprintsprocessor/modules/commons/pom.xml | 16 ++- .../modules/commons/processor-core/pom.xml | 37 +++++++ .../core/BluePrintCoreConfiguration.kt | 49 ++++++++ .../core/BluePrintProperties.kt | 29 +++++ .../core/api/data/BlueprintProcessorData.kt | 123 +++++++++++++++++++++ .../core/factory/ComponentNodeFactory.kt | 68 ++++++++++++ .../blueprintsprocessor/core/utils/PayloadUtils.kt | 47 ++++++++ .../src/main/resources/application.properties | 16 +++ .../core/BluePrintPropertiesTest.kt | 20 ++++ .../modules/commons/rest-lib/pom.xml | 2 +- 19 files changed, 405 insertions(+), 395 deletions(-) delete mode 100644 ms/blueprintsprocessor/modules/commons/core/pom.xml delete mode 100644 ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt delete mode 100644 ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt delete mode 100644 ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt delete mode 100644 ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt delete mode 100644 ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt delete mode 100644 ms/blueprintsprocessor/modules/commons/core/src/main/resources/application.properties delete mode 100644 ms/blueprintsprocessor/modules/commons/core/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintPropertiesTest.kt create mode 100644 ms/blueprintsprocessor/modules/commons/processor-core/pom.xml create mode 100644 ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt create mode 100644 ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt create mode 100644 ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt create mode 100644 ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt create mode 100644 ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt create mode 100644 ms/blueprintsprocessor/modules/commons/processor-core/src/main/resources/application.properties create mode 100644 ms/blueprintsprocessor/modules/commons/processor-core/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintPropertiesTest.kt (limited to 'ms/blueprintsprocessor/modules/commons') diff --git a/ms/blueprintsprocessor/modules/commons/core/pom.xml b/ms/blueprintsprocessor/modules/commons/core/pom.xml deleted file mode 100644 index 42710b517..000000000 --- a/ms/blueprintsprocessor/modules/commons/core/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - 4.0.0 - - org.onap.ccsdk.apps.blueprintsprocessor - commons - 0.4.1-SNAPSHOT - - - core - jar - Blueprints Processor Core - Blueprints Processor Core - - - org.springframework.boot - spring-boot-starter-webflux - - - diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt deleted file mode 100644 index 07e494a1a..000000000 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.blueprintsprocessor.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/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt deleted file mode 100644 index 10b8ceb5e..000000000 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.blueprintsprocessor.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 propertyBeanType(prefix: String, type: Class): T { - return bluePrintPropertyBinder.bind(prefix, Bindable.of(type)).get() - } -} \ No newline at end of file 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/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt deleted file mode 100644 index 41bbd1dfd..000000000 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt deleted file mode 100644 index 66643ee0f..000000000 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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, componentContext: MutableMap) - - @Throws(BluePrintProcessorException::class) - fun process(context: MutableMap, componentContext: MutableMap) - - @Throws(BluePrintProcessorException::class) - fun errorHandle(context: MutableMap, componentContext: MutableMap) - - @Throws(BluePrintProcessorException::class) - fun reTrigger(context: MutableMap, componentContext: MutableMap) -} - -/** - * ComponentNodeFactory - * - * @author Brinda Santh - */ -open class ComponentNodeFactory : ApplicationContextAware { - private val log = EELFManager.getInstance().getLogger(ComponentNodeFactory::class.java) - - var componentNodes: MutableMap = 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/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt deleted file mode 100644 index 31dca33b8..000000000 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.blueprintsprocessor.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/core/src/main/resources/application.properties b/ms/blueprintsprocessor/modules/commons/core/src/main/resources/application.properties deleted file mode 100644 index 2ce871476..000000000 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/resources/application.properties +++ /dev/null @@ -1,16 +0,0 @@ -# -# Copyright © 2017-2018 AT&T Intellectual Property. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - diff --git a/ms/blueprintsprocessor/modules/commons/core/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintPropertiesTest.kt b/ms/blueprintsprocessor/modules/commons/core/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintPropertiesTest.kt deleted file mode 100644 index 66de11fde..000000000 --- a/ms/blueprintsprocessor/modules/commons/core/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintPropertiesTest.kt +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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.core - -// TODO -open class BluePrintPropertiesTest \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml index 7c5aecb7a..1f8251bda 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml @@ -36,16 +36,14 @@ org.onap.ccsdk.apps.controllerblueprints db-resources - ${project.version} org.onap.ccsdk.apps.controllerblueprints blueprint-validation - ${project.version} org.onap.ccsdk.apps.blueprintsprocessor - core + processor-core org.springframework.boot diff --git a/ms/blueprintsprocessor/modules/commons/pom.xml b/ms/blueprintsprocessor/modules/commons/pom.xml index 9d5dc51c4..e1c07ddb9 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. --> - + 4.0.0 org.onap.ccsdk.apps.blueprintsprocessor @@ -30,9 +32,9 @@ Blueprints Processor Commons + processor-core db-lib rest-lib - core dmaap-lib @@ -41,6 +43,11 @@ resource-dict + + io.mockk + mockk + test + org.powermock powermock-api-mockito2 @@ -56,6 +63,11 @@ kotlin-test-junit test + + org.jetbrains.kotlinx + kotlinx-coroutines-test + test + io.projectreactor reactor-test diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/pom.xml b/ms/blueprintsprocessor/modules/commons/processor-core/pom.xml new file mode 100644 index 000000000..aadff9c9f --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/processor-core/pom.xml @@ -0,0 +1,37 @@ + + + + 4.0.0 + + org.onap.ccsdk.apps.blueprintsprocessor + commons + 0.4.1-SNAPSHOT + + + processor-core + jar + Blueprints Processor Core + Blueprints Processor Core + + + org.springframework.boot + spring-boot-starter-webflux + + + 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 propertyBeanType(prefix: String, type: Class): 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, componentContext: MutableMap) + + @Throws(BluePrintProcessorException::class) + fun process(context: MutableMap, componentContext: MutableMap) + + @Throws(BluePrintProcessorException::class) + fun errorHandle(context: MutableMap, componentContext: MutableMap) + + @Throws(BluePrintProcessorException::class) + fun reTrigger(context: MutableMap, componentContext: MutableMap) +} + +/** + * ComponentNodeFactory + * + * @author Brinda Santh + */ +open class ComponentNodeFactory : ApplicationContextAware { + private val log = EELFManager.getInstance().getLogger(ComponentNodeFactory::class.java) + + var componentNodes: MutableMap = 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. +# + diff --git a/ms/blueprintsprocessor/modules/commons/processor-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 new file mode 100644 index 000000000..66de11fde --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintPropertiesTest.kt @@ -0,0 +1,20 @@ +/* + * 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.core + +// TODO +open class BluePrintPropertiesTest \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml index f1d978965..8659089e2 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml @@ -34,7 +34,7 @@ org.onap.ccsdk.apps.blueprintsprocessor - core + processor-core -- cgit 1.2.3-korg