diff options
Diffstat (limited to 'ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils')
11 files changed, 188 insertions, 188 deletions
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintArchiveUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintArchiveUtils.kt index a16f58042..1a7c23cf1 100644..100755 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintArchiveUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintArchiveUtils.kt @@ -30,7 +30,7 @@ import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream import org.apache.commons.compress.archivers.zip.ZipFile import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.slf4j.LoggerFactory import java.io.BufferedInputStream import java.io.ByteArrayInputStream @@ -56,11 +56,11 @@ enum class ArchiveType { Zip } -class BlueprintArchiveUtils { +class BluePrintArchiveUtils { companion object { - private val log = LoggerFactory.getLogger(BlueprintArchiveUtils::class.java) + private val log = LoggerFactory.getLogger(BluePrintArchiveUtils::class.java) /** * Create a new Zip from a root directory @@ -208,7 +208,7 @@ class BlueprintArchiveUtils { val destinationDir = File(targetPath) check(destinationDir.isDirectory && destinationDir.exists()) { - throw BlueprintProcessorException("failed to decompress blueprint(${archiveFile.absolutePath}) to ($targetPath) ") + throw BluePrintProcessorException("failed to decompress blueprint(${archiveFile.absolutePath}) to ($targetPath) ") } return destinationDir diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintFileUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtils.kt index 583709f08..292eca92e 100644..100755 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintFileUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtils.kt @@ -21,14 +21,14 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils import kotlinx.coroutines.runBlocking import org.apache.commons.io.FileUtils import org.apache.commons.lang3.StringUtils -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode import org.onap.ccsdk.cds.controllerblueprints.core.data.ImportDefinition import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintContext +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext import org.slf4j.LoggerFactory import java.io.File import java.io.FileFilter @@ -41,52 +41,52 @@ import java.nio.file.Path import java.nio.file.Paths import java.nio.file.StandardOpenOption -class BlueprintFileUtils { +class BluePrintFileUtils { companion object { const val COMPILED_JAR_SUFFIX = "cba-kts.jar" private val log = LoggerFactory.getLogger(this::class.toString()) - fun createEmptyBlueprint(basePath: String) { + fun createEmptyBluePrint(basePath: String) { val blueprintDir = File(basePath) FileUtils.deleteDirectory(blueprintDir) Files.createDirectories(blueprintDir.toPath()) - val metaDataDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BlueprintConstants.TOSCA_METADATA_DIR)) + val metaDataDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_METADATA_DIR)) Files.createDirectories(metaDataDir.toPath()) val metaFile = File( blueprintDir.absolutePath.plus(File.separator).plus( - BlueprintConstants + BluePrintConstants .TOSCA_METADATA_ENTRY_DEFINITION_FILE ) ) Files.write(metaFile.toPath(), getMetaDataContent().toByteArray(), StandardOpenOption.CREATE_NEW) - val definitionsDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BlueprintConstants.TOSCA_DEFINITIONS_DIR)) + val definitionsDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR)) Files.createDirectories(definitionsDir.toPath()) - val scriptsDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BlueprintConstants.TOSCA_SCRIPTS_DIR)) + val scriptsDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_SCRIPTS_DIR)) Files.createDirectories(scriptsDir.toPath()) - val plansDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BlueprintConstants.TOSCA_PLANS_DIR)) + val plansDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_PLANS_DIR)) Files.createDirectories(plansDir.toPath()) - val templatesDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BlueprintConstants.TOSCA_TEMPLATES_DIR)) + val templatesDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_TEMPLATES_DIR)) Files.createDirectories(templatesDir.toPath()) } - fun copyBlueprint(sourcePath: String, targetPath: String) { + fun copyBluePrint(sourcePath: String, targetPath: String) { val sourceFile = File(sourcePath) val targetFile = File(targetPath) sourceFile.copyRecursively(targetFile, true) } - fun deleteBlueprintTypes(basePath: String) { - val definitionPath = basePath.plus(File.separator).plus(BlueprintConstants.TOSCA_DEFINITIONS_DIR) + fun deleteBluePrintTypes(basePath: String) { + val definitionPath = basePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR) log.info("deleting definition types under : $definitionPath") val definitionDir = File(definitionPath) @@ -98,24 +98,24 @@ class BlueprintFileUtils { } } - fun writeEnhancedBlueprint(blueprintContext: BlueprintContext) { + fun writeEnhancedBluePrint(blueprintContext: BluePrintContext) { // Write Blueprint Types - writeBlueprintTypes(blueprintContext) + writeBluePrintTypes(blueprintContext) // Re Populate the Imports populateDefaultImports(blueprintContext) // Rewrite the Entry Definition Files writeEntryDefinitionFile(blueprintContext) } - fun writeBlueprintTypes(blueprintContext: BlueprintContext) { + fun writeBluePrintTypes(blueprintContext: BluePrintContext) { val basePath = blueprintContext.rootPath - val definitionPath = basePath.plus(File.separator).plus(BlueprintConstants.TOSCA_DEFINITIONS_DIR) + val definitionPath = basePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR) val definitionDir = File(definitionPath) check(definitionDir.exists()) { - throw BlueprintException( + throw BluePrintException( ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get definition file under " + "path(${definitionDir.absolutePath})" @@ -123,37 +123,37 @@ class BlueprintFileUtils { } blueprintContext.serviceTemplate.dataTypes?.let { - val dataTypesContent = JacksonUtils.getWrappedJson(BlueprintConstants.PATH_DATA_TYPES, it.toSortedMap(), true) - writeTypeFile(definitionDir.absolutePath, BlueprintConstants.PATH_DATA_TYPES, dataTypesContent) + val dataTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_DATA_TYPES, it.toSortedMap(), true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_DATA_TYPES, dataTypesContent) } blueprintContext.serviceTemplate.relationshipTypes?.let { - val nodeTypesContent = JacksonUtils.getWrappedJson(BlueprintConstants.PATH_RELATIONSHIP_TYPES, it.toSortedMap(), true) - writeTypeFile(definitionDir.absolutePath, BlueprintConstants.PATH_RELATIONSHIP_TYPES, nodeTypesContent) + val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_RELATIONSHIP_TYPES, it.toSortedMap(), true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_RELATIONSHIP_TYPES, nodeTypesContent) } blueprintContext.serviceTemplate.artifactTypes?.let { - val artifactTypesContent = JacksonUtils.getWrappedJson(BlueprintConstants.PATH_ARTIFACT_TYPES, it.toSortedMap(), true) - writeTypeFile(definitionDir.absolutePath, BlueprintConstants.PATH_ARTIFACT_TYPES, artifactTypesContent) + val artifactTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_ARTIFACT_TYPES, it.toSortedMap(), true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_ARTIFACT_TYPES, artifactTypesContent) } blueprintContext.serviceTemplate.nodeTypes?.let { - val nodeTypesContent = JacksonUtils.getWrappedJson(BlueprintConstants.PATH_NODE_TYPES, it.toSortedMap(), true) - writeTypeFile(definitionDir.absolutePath, BlueprintConstants.PATH_NODE_TYPES, nodeTypesContent) + val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_NODE_TYPES, it.toSortedMap(), true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_NODE_TYPES, nodeTypesContent) } blueprintContext.serviceTemplate.policyTypes?.let { - val nodeTypesContent = JacksonUtils.getWrappedJson(BlueprintConstants.PATH_POLICY_TYPES, it.toSortedMap(), true) - writeTypeFile(definitionDir.absolutePath, BlueprintConstants.PATH_POLICY_TYPES, nodeTypesContent) + val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_POLICY_TYPES, it.toSortedMap(), true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_POLICY_TYPES, nodeTypesContent) } } - private fun populateDefaultImports(blueprintContext: BlueprintContext) { + private fun populateDefaultImports(blueprintContext: BluePrintContext) { // Get the Default Types val types = arrayListOf( - BlueprintConstants.PATH_DATA_TYPES, BlueprintConstants.PATH_RELATIONSHIP_TYPES, - BlueprintConstants.PATH_ARTIFACT_TYPES, BlueprintConstants.PATH_NODE_TYPES, - BlueprintConstants.PATH_POLICY_TYPES + BluePrintConstants.PATH_DATA_TYPES, BluePrintConstants.PATH_RELATIONSHIP_TYPES, + BluePrintConstants.PATH_ARTIFACT_TYPES, BluePrintConstants.PATH_NODE_TYPES, + BluePrintConstants.PATH_POLICY_TYPES ) // Clean Type Imports @@ -162,7 +162,7 @@ class BlueprintFileUtils { val imports = mutableListOf<ImportDefinition>() types.forEach { typeName -> val import = ImportDefinition() - import.file = BlueprintConstants.TOSCA_DEFINITIONS_DIR.plus("/$typeName.json") + import.file = BluePrintConstants.TOSCA_DEFINITIONS_DIR.plus("/$typeName.json") imports.add(import) } @@ -181,9 +181,9 @@ class BlueprintFileUtils { } /** - * Re Generate the Blueprint Service Template Definition file based on Blueprint Context. + * Re Generate the Blueprint Service Template Definition file based on BluePrint Context. */ - private fun writeEntryDefinitionFile(blueprintContext: BlueprintContext) { + private fun writeEntryDefinitionFile(blueprintContext: BluePrintContext) { val absoluteEntryDefinitionFile = blueprintContext.rootPath.plus(File.separator).plus(blueprintContext.entryDefinition) @@ -208,7 +208,7 @@ class BlueprintFileUtils { Files.write(definitionFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW) check(definitionFile.exists()) { - throw BlueprintException( + throw BluePrintException( ErrorCode.BLUEPRINT_WRITING_FAIL.value, "couldn't write definition file under " + "path(${definitionFile.absolutePath})" @@ -221,7 +221,7 @@ class BlueprintFileUtils { Files.write(typeFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW) check(typeFile.exists()) { - throw BlueprintException( + throw BluePrintException( ErrorCode.BLUEPRINT_WRITING_FAIL.value, "couldn't write $type.json file under " + "path(${typeFile.absolutePath})" @@ -240,11 +240,11 @@ class BlueprintFileUtils { "\nTemplate-Tags: <TAGS>" } - fun getBlueprintFile(fileName: String, targetPath: Path): File { + fun getBluePrintFile(fileName: String, targetPath: Path): File { val filePath = targetPath.resolve(fileName).toString() val file = File(filePath) check(file.exists()) { - throw BlueprintException( + throw BluePrintException( ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get definition file under " + "path(${file.absolutePath})" @@ -255,7 +255,7 @@ class BlueprintFileUtils { fun getCbaStorageDirectory(path: String): Path { check(StringUtils.isNotBlank(path)) { - throw BlueprintException( + throw BluePrintException( ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get " + "Blueprint folder under path($path)" @@ -280,7 +280,7 @@ class BlueprintFileUtils { fun compileJarFilePathName(basePath: String, artifactName: String, artifactVersion: String): String { return normalizedPathName( - basePath, BlueprintConstants.TOSCA_SCRIPTS_KOTLIN_DIR, + basePath, BluePrintConstants.TOSCA_SCRIPTS_KOTLIN_DIR, compileJarFileName(artifactName, artifactVersion) ) } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintIOUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintIOUtils.kt index c2e0ec39c..d29fed0d9 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintIOUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintIOUtils.kt @@ -16,7 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -object BlueprintIOUtils { +object BluePrintIOUtils { suspend fun <T> retry( times: Int = 1, diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintMetadataUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt index ffaa9e72f..43f3a0b53 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintMetadataUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt @@ -19,45 +19,45 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils import com.fasterxml.jackson.databind.JsonNode import kotlinx.coroutines.runBlocking -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate import org.onap.ccsdk.cds.controllerblueprints.core.data.ToscaMetaData -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintDefinitions +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintDefinitions import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName import org.onap.ccsdk.cds.controllerblueprints.core.readNBLines -import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BlueprintScriptsServiceImpl -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintContext -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintImportService -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintRuntimeService -import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBlueprintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintScriptsServiceImpl +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintImportService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService import org.slf4j.LoggerFactory import java.io.File import java.util.Properties -class BlueprintMetadataUtils { +class BluePrintMetadataUtils { companion object { private val log = LoggerFactory.getLogger(this::class.toString()) suspend fun toscaMetaData(basePath: String): ToscaMetaData { - val toscaMetaPath = basePath.plus(BlueprintConstants.PATH_DIVIDER) - .plus(BlueprintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE) + val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE) return toscaMetaDataFromMetaFile(toscaMetaPath) } suspend fun entryDefinitionFile(basePath: String): String { - val toscaMetaPath = basePath.plus(BlueprintConstants.PATH_DIVIDER) - .plus(BlueprintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE) + val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE) return toscaMetaDataFromMetaFile(toscaMetaPath).entityDefinitions } fun bluePrintEnvProperties(basePath: String): Properties { val blueprintsEnvFilePath = basePath.plus(File.separator) - .plus(BlueprintConstants.TOSCA_ENVIRONMENTS_DIR) + .plus(BluePrintConstants.TOSCA_ENVIRONMENTS_DIR) return environmentFileProperties(blueprintsEnvFilePath) } @@ -103,59 +103,59 @@ class BlueprintMetadataUtils { } /** Get the default blueprint runtime for [id] and [blueprintBasePath] */ - suspend fun getBlueprintRuntime(id: String, blueprintBasePath: String): - BlueprintRuntimeService<MutableMap<String, JsonNode>> { - val bluePrintContext: BlueprintContext = getBlueprintContext(blueprintBasePath) - return getBlueprintRuntime(id, bluePrintContext) + suspend fun getBluePrintRuntime(id: String, blueprintBasePath: String): + BluePrintRuntimeService<MutableMap<String, JsonNode>> { + val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) + return getBluePrintRuntime(id, bluePrintContext) } /** Get the default blocking blueprint runtime api for [id] and [blueprintBasePath] used in testing */ fun bluePrintRuntime(id: String, blueprintBasePath: String): - BlueprintRuntimeService<MutableMap<String, JsonNode>> = runBlocking { - val bluePrintContext: BlueprintContext = getBlueprintContext(blueprintBasePath) - getBlueprintRuntime(id, bluePrintContext) + BluePrintRuntimeService<MutableMap<String, JsonNode>> = runBlocking { + val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) + getBluePrintRuntime(id, bluePrintContext) } /** Get the default blueprint runtime from [bluePrintContext] */ - fun getBlueprintRuntime(id: String, bluePrintContext: BlueprintContext): - BlueprintRuntimeService<MutableMap<String, JsonNode>> { + fun getBluePrintRuntime(id: String, bluePrintContext: BluePrintContext): + BluePrintRuntimeService<MutableMap<String, JsonNode>> { checkNotEmpty(bluePrintContext.rootPath) { "blueprint context root path is missing." } checkNotEmpty(bluePrintContext.entryDefinition) { "blueprint context entry definition is missing." } val blueprintBasePath = bluePrintContext.rootPath - val bluePrintRuntimeService = DefaultBlueprintRuntimeService(id, bluePrintContext) + val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) bluePrintRuntimeService.put( - BlueprintConstants.PROPERTY_BLUEPRINT_BASE_PATH, + BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH, blueprintBasePath.asJsonPrimitive() ) - bluePrintRuntimeService.put(BlueprintConstants.PROPERTY_BLUEPRINT_PROCESS_ID, id.asJsonPrimitive()) + bluePrintRuntimeService.put(BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID, id.asJsonPrimitive()) return bluePrintRuntimeService } /** Get the blueprint runtime for enhancement start for [id] and [blueprintBasePath] */ - suspend fun getBaseEnhancementBlueprintRuntime(id: String, blueprintBasePath: String): - BlueprintRuntimeService<MutableMap<String, JsonNode>> { + suspend fun getBaseEnhancementBluePrintRuntime(id: String, blueprintBasePath: String): + BluePrintRuntimeService<MutableMap<String, JsonNode>> { - val bluePrintContext: BlueprintContext = getBaseEnhancementBlueprintContext(blueprintBasePath) + val bluePrintContext: BluePrintContext = getBaseEnhancementBluePrintContext(blueprintBasePath) - val bluePrintRuntimeService = DefaultBlueprintRuntimeService(id, bluePrintContext) + val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) bluePrintRuntimeService.put( - BlueprintConstants.PROPERTY_BLUEPRINT_BASE_PATH, + BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH, blueprintBasePath.asJsonPrimitive() ) - bluePrintRuntimeService.put(BlueprintConstants.PROPERTY_BLUEPRINT_PROCESS_ID, id.asJsonPrimitive()) + bluePrintRuntimeService.put(BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID, id.asJsonPrimitive()) return bluePrintRuntimeService } /** Get the default blueprint runtime for enhancement start for [id], [blueprintBasePath] and [executionContext] */ - suspend fun getBlueprintRuntime( + suspend fun getBluePrintRuntime( id: String, blueprintBasePath: String, executionContext: MutableMap<String, JsonNode> ): - BlueprintRuntimeService<MutableMap<String, JsonNode>> { - val bluePrintContext: BlueprintContext = getBlueprintContext(blueprintBasePath) - val bluePrintRuntimeService = DefaultBlueprintRuntimeService(id, bluePrintContext) + BluePrintRuntimeService<MutableMap<String, JsonNode>> { + val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) + val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) executionContext.forEach { bluePrintRuntimeService.put(it.key, it.value) } @@ -165,7 +165,7 @@ class BlueprintMetadataUtils { } /** Get the default blueprint context for [blueprintBasePath]*/ - suspend fun getBlueprintContext(blueprintBasePath: String): BlueprintContext { + suspend fun getBluePrintContext(blueprintBasePath: String): BluePrintContext { val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath) @@ -176,24 +176,24 @@ class BlueprintMetadataUtils { // If the EntryDefinition is Kotlin file, compile and get Service Template val bluePrintContext = when (toscaMetaData.templateType.toUpperCase()) { - BlueprintConstants.BLUEPRINT_TYPE_KOTLIN_DSL -> readBlueprintKotlinFile( + BluePrintConstants.BLUEPRINT_TYPE_KOTLIN_DSL -> readBlueprintKotlinFile( toscaMetaData, blueprintBasePath ) - BlueprintConstants.BLUEPRINT_TYPE_GENERIC_SCRIPT -> readBlueprintGenericScript( + BluePrintConstants.BLUEPRINT_TYPE_GENERIC_SCRIPT -> readBlueprintGenericScript( toscaMetaData, blueprintBasePath ) - BlueprintConstants.BLUEPRINT_TYPE_DEFAULT -> readBlueprintFile( + BluePrintConstants.BLUEPRINT_TYPE_DEFAULT -> readBlueprintFile( toscaMetaData.entityDefinitions, blueprintBasePath ) else -> - throw BlueprintException( + throw BluePrintException( "Unknown blueprint type(${toscaMetaData.templateType}), " + - "It should be any one of these types[${BlueprintConstants.BLUEPRINT_TYPE_KOTLIN_DSL}," + - "${BlueprintConstants.BLUEPRINT_TYPE_GENERIC_SCRIPT}, " + - "${BlueprintConstants.BLUEPRINT_TYPE_DEFAULT}]" + "It should be any one of these types[${BluePrintConstants.BLUEPRINT_TYPE_KOTLIN_DSL}," + + "${BluePrintConstants.BLUEPRINT_TYPE_GENERIC_SCRIPT}, " + + "${BluePrintConstants.BLUEPRINT_TYPE_DEFAULT}]" ) } // Copy the metadata info @@ -202,11 +202,11 @@ class BlueprintMetadataUtils { return bluePrintContext } - private suspend fun getBaseEnhancementBlueprintContext(blueprintBasePath: String): BlueprintContext { + private suspend fun getBaseEnhancementBluePrintContext(blueprintBasePath: String): BluePrintContext { val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath) // Clean Type files - BlueprintFileUtils.deleteBlueprintTypes(blueprintBasePath) + BluePrintFileUtils.deleteBluePrintTypes(blueprintBasePath) val rootFilePath: String = blueprintBasePath.plus(File.separator).plus(toscaMetaData.entityDefinitions) val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath) @@ -214,9 +214,9 @@ class BlueprintMetadataUtils { copyMetaInfoToServiceTemplate(toscaMetaData, rootServiceTemplate) // Clean the Import Definitions - BlueprintFileUtils.cleanImportTypes(rootServiceTemplate) + BluePrintFileUtils.cleanImportTypes(rootServiceTemplate) - val blueprintContext = BlueprintContext(rootServiceTemplate) + val blueprintContext = BluePrintContext(rootServiceTemplate) blueprintContext.rootPath = blueprintBasePath blueprintContext.entryDefinition = toscaMetaData.entityDefinitions return blueprintContext @@ -226,36 +226,36 @@ class BlueprintMetadataUtils { private fun copyMetaInfoToServiceTemplate(toscaMetaData: ToscaMetaData, serviceTemplate: ServiceTemplate) { if (serviceTemplate.metadata == null) serviceTemplate.metadata = mutableMapOf() val metadata = serviceTemplate.metadata!! - metadata[BlueprintConstants.METADATA_TEMPLATE_AUTHOR] = toscaMetaData.createdBy - metadata[BlueprintConstants.METADATA_TEMPLATE_NAME] = toscaMetaData.templateName - metadata[BlueprintConstants.METADATA_TEMPLATE_VERSION] = toscaMetaData.templateVersion - metadata[BlueprintConstants.METADATA_TEMPLATE_TAGS] = toscaMetaData.templateTags - metadata[BlueprintConstants.METADATA_TEMPLATE_TYPE] = toscaMetaData.templateType + metadata[BluePrintConstants.METADATA_TEMPLATE_AUTHOR] = toscaMetaData.createdBy + metadata[BluePrintConstants.METADATA_TEMPLATE_NAME] = toscaMetaData.templateName + metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION] = toscaMetaData.templateVersion + metadata[BluePrintConstants.METADATA_TEMPLATE_TAGS] = toscaMetaData.templateTags + metadata[BluePrintConstants.METADATA_TEMPLATE_TYPE] = toscaMetaData.templateType } - private suspend fun readBlueprintFile(entityDefinitions: String, basePath: String): BlueprintContext { + private suspend fun readBlueprintFile(entityDefinitions: String, basePath: String): BluePrintContext { val normalizedBasePath = normalizedPathName(basePath) val rootFilePath = normalizedPathName(normalizedBasePath, entityDefinitions) val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath) // Recursively Import Template files - val schemaImportResolverUtils = BlueprintImportService(rootServiceTemplate, normalizedBasePath) + val schemaImportResolverUtils = BluePrintImportService(rootServiceTemplate, normalizedBasePath) val completeServiceTemplate = schemaImportResolverUtils.getImportResolvedServiceTemplate() - val blueprintContext = BlueprintContext(completeServiceTemplate) + val blueprintContext = BluePrintContext(completeServiceTemplate) blueprintContext.rootPath = normalizedBasePath blueprintContext.entryDefinition = entityDefinitions return blueprintContext } /** Reade the Service Template Definitions from the Kotlin file */ - private suspend fun readBlueprintKotlinFile(toscaMetaData: ToscaMetaData, basePath: String): BlueprintContext { + private suspend fun readBlueprintKotlinFile(toscaMetaData: ToscaMetaData, basePath: String): BluePrintContext { val definitionClassName = toscaMetaData.entityDefinitions.removeSuffix(".kt") val normalizedBasePath = normalizedPathName(basePath) - val bluePrintScriptsService = BlueprintScriptsServiceImpl() + val bluePrintScriptsService = BluePrintScriptsServiceImpl() val bluePrintDefinitions = bluePrintScriptsService - .scriptInstance<BlueprintDefinitions>( + .scriptInstance<BluePrintDefinitions>( normalizedBasePath, toscaMetaData.templateName, toscaMetaData.templateVersion, definitionClassName, false ) @@ -263,9 +263,9 @@ class BlueprintMetadataUtils { val serviceTemplate = bluePrintDefinitions.serviceTemplate() // Clean the Default type import Definitions - BlueprintFileUtils.cleanImportTypes(serviceTemplate) + BluePrintFileUtils.cleanImportTypes(serviceTemplate) - val blueprintContext = BlueprintContext(serviceTemplate) + val blueprintContext = BluePrintContext(serviceTemplate) blueprintContext.rootPath = normalizedBasePath blueprintContext.entryDefinition = toscaMetaData.entityDefinitions blueprintContext.otherDefinitions = bluePrintDefinitions.otherDefinitions() @@ -273,8 +273,8 @@ class BlueprintMetadataUtils { } /** Reade the Service Template Definitions from the generic script types */ - private fun readBlueprintGenericScript(toscaMetaData: ToscaMetaData, basePath: String): BlueprintContext { - return BlueprintContext(ServiceTemplate()) + private fun readBlueprintGenericScript(toscaMetaData: ToscaMetaData, basePath: String): BluePrintContext { + return BluePrintContext(ServiceTemplate()) } } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintRuntimeUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt index 1df185cf6..f4c51d455 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BlueprintRuntimeUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt @@ -18,8 +18,8 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintContext +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext import org.slf4j.LoggerFactory /** @@ -27,17 +27,17 @@ import org.slf4j.LoggerFactory * * @author Brinda Santh */ -object BlueprintRuntimeUtils { +object BluePrintRuntimeUtils { private val log = LoggerFactory.getLogger(this::class.toString()) - fun assignInputsFromFile(bluePrintContext: BlueprintContext, fileName: String, context: MutableMap<String, JsonNode>) { + fun assignInputsFromFile(bluePrintContext: BluePrintContext, fileName: String, context: MutableMap<String, JsonNode>) { val jsonNode: JsonNode = JacksonUtils.jsonNodeFromFile(fileName) return assignInputs(bluePrintContext, jsonNode, context) } fun assignInputsFromClassPathFile( - bluePrintContext: BlueprintContext, + bluePrintContext: BluePrintContext, fileName: String, context: MutableMap<String, JsonNode> @@ -46,17 +46,17 @@ object BlueprintRuntimeUtils { return assignInputs(bluePrintContext, jsonNode, context) } - fun assignInputsFromContent(bluePrintContext: BlueprintContext, content: String, context: MutableMap<String, JsonNode>) { + fun assignInputsFromContent(bluePrintContext: BluePrintContext, content: String, context: MutableMap<String, JsonNode>) { val jsonNode: JsonNode = JacksonUtils.jsonNode(content) return assignInputs(bluePrintContext, jsonNode, context) } - fun assignInputs(bluePrintContext: BlueprintContext, jsonNode: JsonNode, context: MutableMap<String, JsonNode>) { + fun assignInputs(bluePrintContext: BluePrintContext, jsonNode: JsonNode, context: MutableMap<String, JsonNode>) { log.info("assignInputs from input JSON ({})", jsonNode.toString()) bluePrintContext.inputs()?.forEach { propertyName, _ -> val valueNode: JsonNode = jsonNode.at("/".plus(propertyName)) ?: NullNode.getInstance() - val path = BlueprintConstants.PATH_INPUTS.plus(BlueprintConstants.PATH_DIVIDER).plus(propertyName) + val path = BluePrintConstants.PATH_INPUTS.plus(BluePrintConstants.PATH_DIVIDER).plus(propertyName) log.trace("setting input path ({}), values ({})", path, valueNode) context[path] = valueNode } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ClusterUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ClusterUtils.kt index cacfc2cd2..7fe955b03 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ClusterUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ClusterUtils.kt @@ -16,7 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import java.net.InetAddress object ClusterUtils { @@ -28,19 +28,19 @@ object ClusterUtils { } fun applicationName(): String { - return BlueprintConstants.APP_NAME + return BluePrintConstants.APP_NAME } fun clusterId(): String { - return System.getenv(BlueprintConstants.PROPERTY_CLUSTER_ID) ?: "cds-cluster" + return System.getenv(BluePrintConstants.PROPERTY_CLUSTER_ID) ?: "cds-cluster" } fun clusterNodeId(): String { - return System.getenv(BlueprintConstants.PROPERTY_CLUSTER_NODE_ID) ?: "cds-controller-0" + return System.getenv(BluePrintConstants.PROPERTY_CLUSTER_NODE_ID) ?: "cds-controller-0" } fun clusterNodeAddress(): String { - return System.getenv(BlueprintConstants.PROPERTY_CLUSTER_NODE_ADDRESS) + return System.getenv(BluePrintConstants.PROPERTY_CLUSTER_NODE_ADDRESS) ?: clusterNodeId() } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt index 14b308bc9..02dd2027d 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt @@ -16,7 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import java.text.SimpleDateFormat import java.time.LocalDateTime import java.time.ZoneId @@ -31,19 +31,19 @@ fun controllerDate(): Date { fun currentTimestamp(): String { val localDateTime = LocalDateTime.now(ZoneId.systemDefault()) - val formatter = DateTimeFormatter.ofPattern(BlueprintConstants.DATE_TIME_PATTERN) + val formatter = DateTimeFormatter.ofPattern(BluePrintConstants.DATE_TIME_PATTERN) return formatter.format(localDateTime) } /** Parse string date in CDS string format */ fun String.toControllerDate(): Date { - val formatter = SimpleDateFormat(BlueprintConstants.DATE_TIME_PATTERN) + val formatter = SimpleDateFormat(BluePrintConstants.DATE_TIME_PATTERN) return formatter.parse(this) } /** Return date to CDS string format */ fun Date.currentTimestamp(): String { - val formatter = SimpleDateFormat(BlueprintConstants.DATE_TIME_PATTERN) + val formatter = SimpleDateFormat(BluePrintConstants.DATE_TIME_PATTERN) return formatter.format(this) } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt index 1110f6f34..ace66cf7a 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt @@ -33,10 +33,10 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext import org.apache.commons.io.IOUtils -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintTypes +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile import org.onap.ccsdk.cds.controllerblueprints.core.readNBText import java.io.File @@ -76,7 +76,7 @@ class JacksonUtils { try { normalizedFile(fileName).readNBText() } catch (e: Exception) { - throw BlueprintException("couldn't get file ($fileName) content : ${e.message}") + throw BluePrintException("couldn't get file ($fileName) content : ${e.message}") } } @@ -191,13 +191,13 @@ class JacksonUtils { fun <T> getInstanceFromMap(properties: MutableMap<String, JsonNode>, classType: Class<T>): T { return readValue(getJson(properties), classType) - ?: throw BlueprintProcessorException("failed to transform content ($properties) to type ($classType)") + ?: throw BluePrintProcessorException("failed to transform content ($properties) to type ($classType)") } fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean { - if (BlueprintTypes.validPrimitiveTypes().contains(type.toLowerCase())) { + if (BluePrintTypes.validPrimitiveTypes().contains(type.toLowerCase())) { return checkJsonNodeValueOfPrimitiveType(type, jsonNode) - } else if (BlueprintTypes.validCollectionTypes().contains(type)) { + } else if (BluePrintTypes.validCollectionTypes().contains(type)) { return checkJsonNodeValueOfCollectionType(type, jsonNode) } return false @@ -205,31 +205,31 @@ class JacksonUtils { fun checkIfPrimitiveType(primitiveType: String): Boolean { return when (primitiveType.toLowerCase()) { - BlueprintConstants.DATA_TYPE_STRING -> true - BlueprintConstants.DATA_TYPE_BOOLEAN -> true - BlueprintConstants.DATA_TYPE_INTEGER -> true - BlueprintConstants.DATA_TYPE_FLOAT -> true - BlueprintConstants.DATA_TYPE_DOUBLE -> true - BlueprintConstants.DATA_TYPE_TIMESTAMP -> true + BluePrintConstants.DATA_TYPE_STRING -> true + BluePrintConstants.DATA_TYPE_BOOLEAN -> true + BluePrintConstants.DATA_TYPE_INTEGER -> true + BluePrintConstants.DATA_TYPE_FLOAT -> true + BluePrintConstants.DATA_TYPE_DOUBLE -> true + BluePrintConstants.DATA_TYPE_TIMESTAMP -> true else -> false } } fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean { return when (primitiveType.toLowerCase()) { - BlueprintConstants.DATA_TYPE_STRING -> jsonNode.isTextual - BlueprintConstants.DATA_TYPE_BOOLEAN -> jsonNode.isBoolean - BlueprintConstants.DATA_TYPE_INTEGER -> jsonNode.isInt - BlueprintConstants.DATA_TYPE_FLOAT -> jsonNode.isDouble - BlueprintConstants.DATA_TYPE_DOUBLE -> jsonNode.isDouble - BlueprintConstants.DATA_TYPE_TIMESTAMP -> jsonNode.isTextual + BluePrintConstants.DATA_TYPE_STRING -> jsonNode.isTextual + BluePrintConstants.DATA_TYPE_BOOLEAN -> jsonNode.isBoolean + BluePrintConstants.DATA_TYPE_INTEGER -> jsonNode.isInt + BluePrintConstants.DATA_TYPE_FLOAT -> jsonNode.isDouble + BluePrintConstants.DATA_TYPE_DOUBLE -> jsonNode.isDouble + BluePrintConstants.DATA_TYPE_TIMESTAMP -> jsonNode.isTextual else -> false } } fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean { return when (type.toLowerCase()) { - BlueprintConstants.DATA_TYPE_LIST -> jsonNode.isArray + BluePrintConstants.DATA_TYPE_LIST -> jsonNode.isArray else -> false } } @@ -247,62 +247,62 @@ class JacksonUtils { fun getValue(value: Any, type: String): Any { return when (type.toLowerCase()) { - BlueprintConstants.DATA_TYPE_BOOLEAN -> (value as BooleanNode).booleanValue() - BlueprintConstants.DATA_TYPE_INTEGER -> (value as IntNode).intValue() - BlueprintConstants.DATA_TYPE_FLOAT -> (value as FloatNode).floatValue() - BlueprintConstants.DATA_TYPE_DOUBLE -> (value as DoubleNode).doubleValue() - BlueprintConstants.DATA_TYPE_STRING -> (value as TextNode).textValue() + BluePrintConstants.DATA_TYPE_BOOLEAN -> (value as BooleanNode).booleanValue() + BluePrintConstants.DATA_TYPE_INTEGER -> (value as IntNode).intValue() + BluePrintConstants.DATA_TYPE_FLOAT -> (value as FloatNode).floatValue() + BluePrintConstants.DATA_TYPE_DOUBLE -> (value as DoubleNode).doubleValue() + BluePrintConstants.DATA_TYPE_STRING -> (value as TextNode).textValue() else -> (value as JsonNode) } } fun populatePrimitiveValues(key: String, value: JsonNode, primitiveType: String, objectNode: ObjectNode) { when (primitiveType.toLowerCase()) { - BlueprintConstants.DATA_TYPE_BOOLEAN, - BlueprintConstants.DATA_TYPE_INTEGER, - BlueprintConstants.DATA_TYPE_FLOAT, - BlueprintConstants.DATA_TYPE_DOUBLE, - BlueprintConstants.DATA_TYPE_TIMESTAMP, - BlueprintConstants.DATA_TYPE_STRING, - BlueprintConstants.DATA_TYPE_NULL -> + BluePrintConstants.DATA_TYPE_BOOLEAN, + BluePrintConstants.DATA_TYPE_INTEGER, + BluePrintConstants.DATA_TYPE_FLOAT, + BluePrintConstants.DATA_TYPE_DOUBLE, + BluePrintConstants.DATA_TYPE_TIMESTAMP, + BluePrintConstants.DATA_TYPE_STRING, + BluePrintConstants.DATA_TYPE_NULL -> objectNode.set(key, value) - else -> throw BlueprintException("populatePrimitiveValues expected only primitive values! Received: ($value)") + else -> throw BluePrintException("populatePrimitiveValues expected only primitive values! Received: ($value)") } } fun populatePrimitiveValues(value: JsonNode, primitiveType: String, arrayNode: ArrayNode) { when (primitiveType.toLowerCase()) { - BlueprintConstants.DATA_TYPE_BOOLEAN, - BlueprintConstants.DATA_TYPE_INTEGER, - BlueprintConstants.DATA_TYPE_FLOAT, - BlueprintConstants.DATA_TYPE_DOUBLE, - BlueprintConstants.DATA_TYPE_TIMESTAMP, - BlueprintConstants.DATA_TYPE_STRING, - BlueprintConstants.DATA_TYPE_NULL -> + BluePrintConstants.DATA_TYPE_BOOLEAN, + BluePrintConstants.DATA_TYPE_INTEGER, + BluePrintConstants.DATA_TYPE_FLOAT, + BluePrintConstants.DATA_TYPE_DOUBLE, + BluePrintConstants.DATA_TYPE_TIMESTAMP, + BluePrintConstants.DATA_TYPE_STRING, + BluePrintConstants.DATA_TYPE_NULL -> arrayNode.add(value) - else -> throw BlueprintException("populatePrimitiveValues expected only primitive values! Received: ($value)") + else -> throw BluePrintException("populatePrimitiveValues expected only primitive values! Received: ($value)") } } fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) { val defaultValue = getDefaultValueOfPrimitiveAsJsonNode(primitiveType) - ?: throw BlueprintException("populatePrimitiveDefaultValues expected only primitive values! Received type ($primitiveType)") + ?: throw BluePrintException("populatePrimitiveDefaultValues expected only primitive values! Received type ($primitiveType)") objectNode.set<JsonNode>(key, defaultValue) } fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) { val defaultValue = getDefaultValueOfPrimitiveAsJsonNode(primitiveType) - ?: throw BlueprintException("populatePrimitiveDefaultValuesForArrayNode expected only primitive values! Received type ($primitiveType)") + ?: throw BluePrintException("populatePrimitiveDefaultValuesForArrayNode expected only primitive values! Received type ($primitiveType)") arrayNode.add(defaultValue) } private fun getDefaultValueOfPrimitiveAsJsonNode(primitiveType: String): JsonNode? { return when (primitiveType.toLowerCase()) { - BlueprintConstants.DATA_TYPE_BOOLEAN -> BooleanNode.valueOf(false) - BlueprintConstants.DATA_TYPE_INTEGER -> IntNode.valueOf(0) - BlueprintConstants.DATA_TYPE_FLOAT -> FloatNode.valueOf(0.0f) - BlueprintConstants.DATA_TYPE_DOUBLE -> DoubleNode.valueOf(0.0) - BlueprintConstants.DATA_TYPE_STRING -> MissingNode.getInstance() + BluePrintConstants.DATA_TYPE_BOOLEAN -> BooleanNode.valueOf(false) + BluePrintConstants.DATA_TYPE_INTEGER -> IntNode.valueOf(0) + BluePrintConstants.DATA_TYPE_FLOAT -> FloatNode.valueOf(0.0f) + BluePrintConstants.DATA_TYPE_DOUBLE -> DoubleNode.valueOf(0.0) + BluePrintConstants.DATA_TYPE_STRING -> MissingNode.getInstance() else -> null } } @@ -310,7 +310,7 @@ class JacksonUtils { fun populateJsonNodeValues(key: String, nodeValue: JsonNode?, type: String, objectNode: ObjectNode) { if (nodeValue == null || nodeValue is NullNode) { objectNode.set<JsonNode>(key, nodeValue) - } else if (BlueprintTypes.validPrimitiveTypes().contains(type)) { + } else if (BluePrintTypes.validPrimitiveTypes().contains(type)) { populatePrimitiveValues(key, nodeValue, type, objectNode) } else { objectNode.set<JsonNode>(key, nodeValue) @@ -319,11 +319,11 @@ class JacksonUtils { fun convertPrimitiveResourceValue(type: String, value: String): JsonNode { return when (type.toLowerCase()) { - BlueprintConstants.DATA_TYPE_BOOLEAN -> jsonNodeFromObject(value.toBoolean()) - BlueprintConstants.DATA_TYPE_INTEGER -> jsonNodeFromObject(value.toInt()) - BlueprintConstants.DATA_TYPE_FLOAT -> jsonNodeFromObject(value.toFloat()) - BlueprintConstants.DATA_TYPE_DOUBLE -> jsonNodeFromObject(value.toDouble()) - BlueprintConstants.DATA_TYPE_STRING -> jsonNodeFromObject(value) + BluePrintConstants.DATA_TYPE_BOOLEAN -> jsonNodeFromObject(value.toBoolean()) + BluePrintConstants.DATA_TYPE_INTEGER -> jsonNodeFromObject(value.toInt()) + BluePrintConstants.DATA_TYPE_FLOAT -> jsonNodeFromObject(value.toFloat()) + BluePrintConstants.DATA_TYPE_DOUBLE -> jsonNodeFromObject(value.toDouble()) + BluePrintConstants.DATA_TYPE_STRING -> jsonNodeFromObject(value) else -> getJsonNode(value) } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/PropertyDefinitionUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/PropertyDefinitionUtils.kt index 1a082d353..48319325c 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/PropertyDefinitionUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/PropertyDefinitionUtils.kt @@ -16,7 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants.LOG_PROTECT +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants.LOG_PROTECT import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition class PropertyDefinitionUtils { diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ResourceResolverUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ResourceResolverUtils.kt index 1b8af5897..c0204af8d 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ResourceResolverUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ResourceResolverUtils.kt @@ -17,7 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.isNotEmpty import org.slf4j.LoggerFactory import java.io.File @@ -56,7 +56,7 @@ object ResourceResolverUtils { // FIXME("Convert into reactive") return JacksonUtils.getContent(resolvedFileName) } catch (e: Exception) { - throw BlueprintException(e, "failed to file (%s), basePath (%s) ", filename, basePath) + throw BluePrintException(e, "failed to file (%s), basePath (%s) ", filename, basePath) } } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/WorkflowGraphUtils.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/WorkflowGraphUtils.kt index 6ebe7c11a..fea637f61 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/WorkflowGraphUtils.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/WorkflowGraphUtils.kt @@ -16,7 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.data.EdgeLabel import org.onap.ccsdk.cds.controllerblueprints.core.data.Graph import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow @@ -36,10 +36,10 @@ object WorkflowGraphUtils { } } graph.startNodes().forEach { rootNode -> - graph.addEdge(BlueprintConstants.GRAPH_START_NODE_NAME, rootNode.id, EdgeLabel.SUCCESS) + graph.addEdge(BluePrintConstants.GRAPH_START_NODE_NAME, rootNode.id, EdgeLabel.SUCCESS) } graph.endNodes().forEach { endNode -> - graph.addEdge(endNode.id, BlueprintConstants.GRAPH_END_NODE_NAME, EdgeLabel.SUCCESS) + graph.addEdge(endNode.id, BluePrintConstants.GRAPH_END_NODE_NAME, EdgeLabel.SUCCESS) } return graph } |