import com.google.common.base.Preconditions
import org.apache.commons.lang3.StringUtils
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintError
+import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintError
import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType
import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
import org.onap.ccsdk.cds.controllerblueprints.core.data.TopologyTemplate
-import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintServiceTemplateValidator
-import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
-import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintServiceTemplateValidator
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintTypeValidatorService
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintRuntimeService
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
@Service("default-service-template-validator")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) :
- BluePrintServiceTemplateValidator {
+open class BlueprintServiceTemplateValidatorImpl(private val bluePrintTypeValidatorService: BlueprintTypeValidatorService) :
+ BlueprintServiceTemplateValidator {
- private val log = LoggerFactory.getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
+ private val log = LoggerFactory.getLogger(BlueprintServiceTemplateValidatorImpl::class.toString())
- lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
- lateinit var error: BluePrintError
+ lateinit var bluePrintRuntimeService: BlueprintRuntimeService<*>
+ lateinit var error: BlueprintError
var paths: MutableList<String> = arrayListOf()
- override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, serviceTemplate: ServiceTemplate) {
+ override fun validate(bluePrintRuntimeService: BlueprintRuntimeService<*>, name: String, serviceTemplate: ServiceTemplate) {
log.trace("Validating Service Template..")
try {
this.bluePrintRuntimeService = bluePrintRuntimeService
- this.error = bluePrintRuntimeService.getBluePrintError()
+ this.error = bluePrintRuntimeService.getBlueprintError()
serviceTemplate.metadata?.let { validateMetadata(serviceTemplate.metadata!!) }
serviceTemplate.dataTypes?.let { validateDataTypes(serviceTemplate.dataTypes!!) }
serviceTemplate.topologyTemplate?.let { validateTopologyTemplate(serviceTemplate.topologyTemplate!!) }
} catch (e: Exception) {
log.error("failed in blueprint service template validation", e)
- error.addError(BluePrintConstants.PATH_SERVICE_TEMPLATE, paths.joinToString(BluePrintConstants.PATH_DIVIDER), e.message!!)
+ error.addError(BlueprintConstants.PATH_SERVICE_TEMPLATE, paths.joinToString(BlueprintConstants.PATH_DIVIDER), e.message!!)
}
}
fun validateMetadata(metaDataMap: MutableMap<String, String>) {
- paths.add(BluePrintConstants.PATH_METADATA)
+ paths.add(BlueprintConstants.PATH_METADATA)
- val templateName = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_NAME]
- val templateVersion = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_VERSION]
- val templateTags = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_TAGS]
- val templateAuthor = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_AUTHOR]
+ val templateName = metaDataMap[BlueprintConstants.METADATA_TEMPLATE_NAME]
+ val templateVersion = metaDataMap[BlueprintConstants.METADATA_TEMPLATE_VERSION]
+ val templateTags = metaDataMap[BlueprintConstants.METADATA_TEMPLATE_TAGS]
+ val templateAuthor = metaDataMap[BlueprintConstants.METADATA_TEMPLATE_AUTHOR]
Preconditions.checkArgument(StringUtils.isNotBlank(templateName), "failed to get template name metadata")
Preconditions.checkArgument(StringUtils.isNotBlank(templateVersion), "failed to get template version metadata")
fun validateDataTypes(dataTypes: MutableMap<String, DataType>) {
- paths.add(BluePrintConstants.PATH_DATA_TYPES)
+ paths.add(BlueprintConstants.PATH_DATA_TYPES)
dataTypes.forEach { dataTypeName, dataType ->
// Validate Single Data Type
bluePrintTypeValidatorService.validateDataType(bluePrintRuntimeService, dataTypeName, dataType)
}
fun validateArtifactTypes(artifactTypes: MutableMap<String, ArtifactType>) {
- paths.add(BluePrintConstants.PATH_ARTIFACT_TYPES)
+ paths.add(BlueprintConstants.PATH_ARTIFACT_TYPES)
artifactTypes.forEach { artifactName, artifactType ->
// Validate Single Artifact Type
bluePrintTypeValidatorService.validateArtifactType(bluePrintRuntimeService, artifactName, artifactType)
}
fun validateNodeTypes(nodeTypes: MutableMap<String, NodeType>) {
- paths.add(BluePrintConstants.PATH_NODE_TYPES)
+ paths.add(BlueprintConstants.PATH_NODE_TYPES)
nodeTypes.forEach { nodeTypeName, nodeType ->
// Validate Single Node Type
bluePrintTypeValidatorService.validateNodeType(bluePrintRuntimeService, nodeTypeName, nodeType)
}
fun validateTopologyTemplate(topologyTemplate: TopologyTemplate) {
- paths.add(BluePrintConstants.PATH_TOPOLOGY_TEMPLATE)
+ paths.add(BlueprintConstants.PATH_TOPOLOGY_TEMPLATE)
bluePrintTypeValidatorService.validateTopologyTemplate(bluePrintRuntimeService, "topologyTemplate", topologyTemplate)
paths.removeAt(paths.lastIndex)
}