package org.onap.ccsdk.cds.controllerblueprints.validation
import org.jetbrains.kotlin.utils.addToStdlib.ifNotEmpty
-import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException
-import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintTypeValidatorService
-import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintValidatorService
-import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintRuntimeService
-import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintMetadataUtils
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDictionaryConstants
import java.util.UUID
@Service("bluePrintDesignTimeValidatorService")
-open class BlueprintDesignTimeValidatorService(
- private val bluePrintTypeValidatorService: BlueprintTypeValidatorService,
+open class BluePrintDesignTimeValidatorService(
+ private val bluePrintTypeValidatorService: BluePrintTypeValidatorService,
private val resourceDefinitionValidator: ResourceDefinitionValidator
) :
- BlueprintValidatorService {
+ BluePrintValidatorService {
- private val log = LoggerFactory.getLogger(BlueprintDesignTimeValidatorService::class.toString())
+ private val log = LoggerFactory.getLogger(BluePrintDesignTimeValidatorService::class.toString())
- override suspend fun validateBlueprints(basePath: String): Boolean {
+ override suspend fun validateBluePrints(basePath: String): Boolean {
- val bluePrintRuntimeService = BlueprintMetadataUtils.getBlueprintRuntime(UUID.randomUUID().toString(), basePath)
- return validateBlueprints(bluePrintRuntimeService)
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(), basePath)
+ return validateBluePrints(bluePrintRuntimeService)
}
- override suspend fun validateBlueprints(bluePrintRuntimeService: BlueprintRuntimeService<*>): Boolean {
+ override suspend fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean {
bluePrintTypeValidatorService.validateServiceTemplate(
bluePrintRuntimeService, "service_template",
// Validate Resource Definitions
validateResourceDefinitions(bluePrintRuntimeService)
- bluePrintRuntimeService.getBlueprintError().allErrors().ifNotEmpty {
- throw BlueprintException("failed in blueprint validation : ${this.joinToString("\n")}")
+ bluePrintRuntimeService.getBluePrintError().allErrors().ifNotEmpty {
+ throw BluePrintException("failed in blueprint validation : ${this.joinToString("\n")}")
}
return true
}
- private fun validateResourceDefinitions(bluePrintRuntimeService: BlueprintRuntimeService<*>) {
+ private fun validateResourceDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>) {
// Validate Resource Dictionary
val blueprintBasePath = bluePrintRuntimeService.bluePrintContext().rootPath
val resourceDefinitionsPath = blueprintBasePath.plus(File.separator)
- .plus(BlueprintConstants.TOSCA_DEFINITIONS_DIR).plus(File.separator)
+ .plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR).plus(File.separator)
.plus("${ResourceDictionaryConstants.PATH_RESOURCE_DEFINITION_TYPE}.json")
val resourceDefinitionFile = File(resourceDefinitionsPath)