From 2b5b2c3003ba18259b424ffc48daeb94ca0e4e20 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Mon, 3 Dec 2018 12:34:39 -0500 Subject: Add Blueprint File utils Change-Id: I9896d934684343358d1c0c7e321725511430c7e6 Issue-ID: CCSDK-783 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../service/BluePrintEnhancerService.java | 12 ++++--- .../service/ConfigModelValidatorService.java | 2 +- .../service/enhancer/BluePrintEnhancerService.kt | 39 +++++++++++++--------- 3 files changed, 32 insertions(+), 21 deletions(-) (limited to 'ms/controllerblueprints/modules/service/src') diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java index ef3b4a48..7ea81da0 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java @@ -17,6 +17,8 @@ package org.onap.ccsdk.apps.controllerblueprints.service; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; import com.google.common.base.Preconditions; import org.apache.commons.collections.MapUtils; @@ -25,13 +27,14 @@ import org.jetbrains.annotations.NotNull; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant; import org.onap.ccsdk.apps.controllerblueprints.core.data.*; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService; -import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.BluePrintEnhancerDefaultService; import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService; +import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.BluePrintEnhancerDefaultService; import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.ResourceAssignmentEnhancerService; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.context.annotation.ScopedProxyMode; import org.springframework.stereotype.Service; import java.util.HashMap; @@ -45,6 +48,7 @@ import java.util.Map; */ @Service +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS) public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { private static EELFLogger log = EELFManager.getInstance().getLogger(BluePrintEnhancerService.class); diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java index 21b00f8c..3abdc04d 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java @@ -30,7 +30,7 @@ import org.springframework.stereotype.Service; * @author Brinda Santh * @version 1.0 */ - +@Deprecated @Service public class ConfigModelValidatorService { diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt index 46709c5f..2c13d864 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt @@ -17,14 +17,16 @@ package org.onap.ccsdk.apps.controllerblueprints.service.enhancer +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.format -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils import java.io.Serializable /** @@ -35,13 +37,13 @@ import java.io.Serializable interface BluePrintEnhancerService : Serializable { @Throws(BluePrintException::class) - fun enhance(content: String): ServiceTemplate + fun enhance(basePath: String, enrichedBasePath: String): BluePrintContext /** - * Read Blueprint from CSAR structure Directory + * Read Blueprint from CBA structure Directory */ @Throws(BluePrintException::class) - fun enhance(fileName: String, basePath: String): ServiceTemplate + fun enhance(basePath: String): BluePrintContext @Throws(BluePrintException::class) fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate @@ -62,16 +64,19 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe lateinit var serviceTemplate: ServiceTemplate - @Throws(BluePrintException::class) - override fun enhance(content: String): ServiceTemplate { - return JacksonReactorUtils.readValueFromFile(content, ServiceTemplate::class.java).map { serviceTemplate -> - enhance(serviceTemplate!!) - }.block()!! + override fun enhance(basePath: String, enrichedBasePath: String): BluePrintContext { + BluePrintFileUtils.copyBluePrint(basePath, enrichedBasePath) + BluePrintFileUtils.deleteBluePrintTypes(enrichedBasePath) + val enhancedBluePrintContext = enhance(enrichedBasePath) + BluePrintFileUtils.writeBluePrintTypes(enhancedBluePrintContext) + return enhancedBluePrintContext } @Throws(BluePrintException::class) - override fun enhance(fileName: String, basePath: String): ServiceTemplate { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + override fun enhance(basePath: String): BluePrintContext { + val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(basePath) + enhance(bluePrintContext.serviceTemplate) + return bluePrintContext } @Throws(BluePrintException::class) @@ -88,10 +93,12 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe serviceTemplate.artifactTypes?.clear() serviceTemplate.nodeTypes?.clear() serviceTemplate.dataTypes?.clear() + serviceTemplate.policyTypes?.clear() - serviceTemplate.artifactTypes = HashMap() - serviceTemplate.nodeTypes = HashMap() - serviceTemplate.dataTypes = HashMap() + serviceTemplate.artifactTypes = mutableMapOf() + serviceTemplate.nodeTypes = mutableMapOf() + serviceTemplate.dataTypes = mutableMapOf() + serviceTemplate.policyTypes = mutableMapOf() } -- cgit 1.2.3-korg