summaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/blueprint-validation
diff options
context:
space:
mode:
Diffstat (limited to 'ms/controllerblueprints/modules/blueprint-validation')
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt97
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactTypeValidatorImpl.kt4
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt63
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDataTypeValidatorImpl.kt8
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt (renamed from ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorServiceImpl.kt)7
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt59
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt15
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt6
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintServiceTemplateValidatorImpl.kt5
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTopologyTemplateValidatorImpl.kt6
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTypeValidatorServiceImpl.kt56
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorDefaultService.kt92
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt5
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt48
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt (renamed from ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorServiceImplTest.kt)4
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/MockBluePrintTypeValidatorService.kt17
16 files changed, 346 insertions, 146 deletions
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt
new file mode 100644
index 000000000..4ea5ab5bc
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt
@@ -0,0 +1,97 @@
+/*
+ * 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.controllerblueprints.validation
+
+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.ArtifactDefinition
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintArtifactDefinitionValidator
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+import java.io.File
+
+@Service("default-artifact-definition-validator")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class BluePrintArtifactDefinitionValidatorImpl(
+ private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintArtifactDefinitionValidator {
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintArtifactDefinitionValidatorImpl::class.toString())
+
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
+ lateinit var bluePrintContext: BluePrintContext
+ var paths: MutableList<String> = arrayListOf()
+
+ override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String,
+ artifactDefinition: ArtifactDefinition) {
+
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
+ paths.add(name)
+ val type: String = artifactDefinition.type
+ log.info("Validation ArtifactDefinition of type {$type}")
+ // Check Artifact Type
+ checkValidArtifactType(name, type)
+
+ val file: String = artifactDefinition.file
+
+ val completePath = bluePrintContext.rootPath.plus(File.separator).plus(file)
+
+ check(File(completePath).exists()) {
+ throw BluePrintException("couldn't file ($completePath)")
+ }
+
+ // Perform Extension Validation
+ validateExtension("$type-artifact-definition-validator", name, artifactDefinition)
+
+ paths.removeAt(paths.lastIndex)
+ }
+
+ open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) {
+
+ val artifactType = bluePrintContext.serviceTemplate.artifactTypes?.get(artifactTypeName)
+ ?: throw BluePrintException("failed to get artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)")
+
+ checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom)
+ }
+
+ @Throws(BluePrintException::class)
+ open fun checkValidArtifactTypeDerivedFrom(artifactTypeName: String, derivedFrom: String) {
+ check(BluePrintTypes.validArtifactTypeDerivedFroms.contains(derivedFrom)) {
+ throw BluePrintException("failed to get artifactType($artifactTypeName)'s derivedFrom($derivedFrom) definition")
+ }
+ }
+
+ private fun validateExtension(referencePrefix: String, name: String, artifactDefinition: ArtifactDefinition) {
+
+ val customValidators = bluePrintTypeValidatorService
+ .bluePrintValidators(referencePrefix, BluePrintArtifactDefinitionValidator::class.java)
+
+ customValidators?.let {
+ it.forEach { validator ->
+ validator.validate(bluePrintRuntimeService, name, artifactDefinition)
+ }
+
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactTypeValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactTypeValidatorImpl.kt
index b893c77dc..4824d2e92 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactTypeValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactTypeValidatorImpl.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -20,7 +21,9 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintArtifactTypeValidator
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.stereotype.Service
+@Service("default-artifact-type-validator")
open class BluePrintArtifactTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintArtifactTypeValidator {
override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactType: ArtifactType) {
@@ -28,6 +31,5 @@ open class BluePrintArtifactTypeValidatorImpl(private val bluePrintTypeValidator
artifactType.properties?.let {
bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, artifactType.properties!!)
}
- // TODO ("Files Present ")
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt
index 19e8f0bf4..11dbf058e 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -16,14 +17,72 @@
package org.onap.ccsdk.apps.controllerblueprints.validation
+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.AttributeDefinition
+import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintAttributeDefinitionValidator
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+@Service("default-attribute-definition-validator")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class BluePrintAttributeDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintAttributeDefinitionValidator {
- override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: AttributeDefinition) {
- //TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
+
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
+
+
+ override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String,
+ attributeDefinition: AttributeDefinition) {
+
+ log.trace("Validating AttributeDefinition($name)")
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ val dataType: String = attributeDefinition.type
+
+ when {
+ BluePrintTypes.validPrimitiveTypes().contains(dataType) -> {
+ // Do Nothing
+ }
+ BluePrintTypes.validCollectionTypes().contains(dataType) -> {
+ val entrySchemaType: String = attributeDefinition.entrySchema?.type
+ ?: throw BluePrintException("Entry schema for DataType ($dataType) for the property ($name) not found")
+ checkPrimitiveOrComplex(entrySchemaType, name)
+ }
+ else -> checkPropertyDataType(dataType, name)
+ }
+ }
+
+ private fun checkPrimitiveOrComplex(dataType: String, propertyName: String): Boolean {
+ if (BluePrintTypes.validPrimitiveTypes().contains(dataType) || checkDataType(dataType)) {
+ return true
+ } else {
+ throw BluePrintException("DataType($dataType) for the attribute($propertyName) is not valid")
+ }
+ }
+
+ private fun checkPropertyDataType(dataTypeName: String, propertyName: String) {
+
+ val dataType = bluePrintRuntimeService.bluePrintContext().serviceTemplate.dataTypes?.get(dataTypeName)
+ ?: throw BluePrintException(format("DataType ({}) for the property ({}) not found", dataTypeName, propertyName))
+
+ checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom)
+ }
+
+ private fun checkDataType(key: String): Boolean {
+ return bluePrintRuntimeService.bluePrintContext().serviceTemplate.dataTypes?.containsKey(key) ?: false
+ }
+
+ open fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) {
+ check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) {
+ throw BluePrintException("Failed to get DataType($dataTypeName)'s derivedFrom($derivedFrom) definition ")
+ }
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDataTypeValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDataTypeValidatorImpl.kt
index 6ee417743..1494bbc4c 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDataTypeValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDataTypeValidatorImpl.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -16,19 +17,16 @@
package org.onap.ccsdk.apps.controllerblueprints.validation
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintDataTypeValidator
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.stereotype.Service
+@Service("default-data-type-validator")
open class BluePrintDataTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintDataTypeValidator {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintDataTypeValidatorImpl::class.toString())
override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, dataType: DataType) {
- log.trace("Validating DataType($name)")
-
dataType.properties?.let {
bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, dataType.properties!!)
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorServiceImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt
index 5620cb773..84073ff2e 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorServiceImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -23,12 +24,14 @@ import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeVal
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.springframework.stereotype.Service
import java.util.*
-open class BluePrintValidatorServiceImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintValidatorService {
+@Service
+open class BluePrintDesignTimeValidatorService(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintValidatorService {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString())
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintDesignTimeValidatorService::class.toString())
override fun validateBluePrints(basePath: String): Boolean {
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt
index af0f88aa2..ded1f384c 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -29,8 +30,13 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpressionService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+@Service("default-node-template-validator")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTemplateValidator {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateValidatorImpl::class.toString())
@@ -39,25 +45,28 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
lateinit var bluePrintContext: BluePrintContext
var paths: MutableList<String> = arrayListOf()
- override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String, nodeTemplate: NodeTemplate) {
- log.info("Validating NodeTemplate($nodeTemplateName)")
+ override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) {
+ log.info("Validating NodeTemplate($name)")
this.bluePrintRuntimeService = bluePrintRuntimeService
this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
- paths.add(nodeTemplateName)
+ paths.add(name)
val type: String = nodeTemplate.type
val nodeType: NodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(type)
- ?: throw BluePrintException("Failed to get NodeType($type) definition for NodeTemplate($nodeTemplateName)")
+ ?: throw BluePrintException("Failed to get NodeType($type) definition for NodeTemplate($name)")
nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) }
- nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeType, nodeTemplateName, nodeTemplate) }
- nodeTemplate.requirements?.let { validateRequirementAssignments(nodeType, nodeTemplateName, nodeTemplate) }
- nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeType, nodeTemplateName, nodeTemplate) }
+ nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeType, name, nodeTemplate) }
+ nodeTemplate.requirements?.let { validateRequirementAssignments(nodeType, name, nodeTemplate) }
+ nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeType, name, nodeTemplate) }
nodeTemplate.artifacts?.let { validateArtifactDefinitions(nodeTemplate.artifacts!!) }
+ // Perform Extension Validation
+ validateExtension("$type-node-template-validator", name, nodeTemplate)
+
paths.removeAt(paths.lastIndex)
}
@@ -65,16 +74,8 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
open fun validateArtifactDefinitions(artifacts: MutableMap<String, ArtifactDefinition>) {
paths.add("artifacts")
artifacts.forEach { artifactDefinitionName, artifactDefinition ->
- paths.add(artifactDefinitionName)
- val type: String = artifactDefinition.type
- ?: throw BluePrintException("type is missing for ArtifactDefinition$artifactDefinitionName)")
- // Check Artifact Type
- checkValidArtifactType(artifactDefinitionName, type)
-
- val file: String = artifactDefinition.file
- ?: throw BluePrintException("file is missing for ArtifactDefinition($artifactDefinitionName)")
-
- paths.removeAt(paths.lastIndex)
+ bluePrintTypeValidatorService.validateArtifactDefinition(bluePrintRuntimeService,
+ artifactDefinitionName, artifactDefinition)
}
paths.removeAt(paths.lastIndex)
}
@@ -239,21 +240,6 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
}
- open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) {
-
- val artifactType = bluePrintContext.serviceTemplate.artifactTypes?.get(artifactTypeName)
- ?: throw BluePrintException("failed to get artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)")
-
- checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom)
- }
-
- @Throws(BluePrintException::class)
- open fun checkValidArtifactTypeDerivedFrom(artifactTypeName: String, derivedFrom: String) {
- check(BluePrintTypes.validArtifactTypeDerivedFroms.contains(derivedFrom)) {
- throw BluePrintException("failed to get artifactType($artifactTypeName)'s derivedFrom($derivedFrom) definition")
- }
- }
-
open fun checkPropertyValue(propertyName: String, propertyDefinition: PropertyDefinition, propertyAssignment: JsonNode) {
val propertyType = propertyDefinition.type
val isValid: Boolean
@@ -295,4 +281,13 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
}
}
+ private fun validateExtension(referencePrefix: String, name: String, nodeTemplate: NodeTemplate) {
+ val customValidator = bluePrintTypeValidatorService
+ .bluePrintValidator(referencePrefix, BluePrintNodeTemplateValidator::class.java)
+
+ customValidator?.let {
+ it.validate(bluePrintRuntimeService, name, nodeTemplate)
+ }
+ }
+
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt
index eb2f01025..1108c1b5f 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -26,8 +27,13 @@ import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTyp
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+@Service("default-node-type-validator")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTypeValidator {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
@@ -52,7 +58,14 @@ open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorServ
?: throw BluePrintException("Failed to get derivedFrom NodeType($derivedFrom)'s for NodeType($nodeTypeName)")
}
- nodeType.properties?.let { bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, nodeType.properties!!) }
+ nodeType.attributes?.let {
+ bluePrintTypeValidatorService.validateAttributeDefinitions(bluePrintRuntimeService, nodeType.attributes!!)
+ }
+
+ nodeType.properties?.let {
+ bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, nodeType.properties!!)
+ }
+
nodeType.capabilities?.let { validateCapabilityDefinitions(nodeTypeName, nodeType) }
nodeType.requirements?.let { validateRequirementDefinitions(nodeTypeName, nodeType) }
nodeType.interfaces?.let { validateInterfaceDefinitions(nodeType.interfaces!!) }
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt
index 2f3287164..7d81ba620 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -25,7 +26,12 @@ import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintPropertyDefinitionValidator
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+@Service("default-property-definition-validator")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class BluePrintPropertyDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintPropertyDefinitionValidator {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintServiceTemplateValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintServiceTemplateValidatorImpl.kt
index 8d49f291e..37d3d1bdc 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintServiceTemplateValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintServiceTemplateValidatorImpl.kt
@@ -26,7 +26,12 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintServiceTemplateValidator
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+@Service("default-service-template-validator")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintServiceTemplateValidator {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTopologyTemplateValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTopologyTemplateValidatorImpl.kt
index 9f9ad1fa9..841d86eab 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTopologyTemplateValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTopologyTemplateValidatorImpl.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -26,7 +27,12 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTopologyTemplateValidator
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+@Service("default-topology-template-validator")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class BluePrintTopologyTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintTopologyTemplateValidator {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTypeValidatorServiceImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTypeValidatorServiceImpl.kt
index e9bfc6130..d8c008ffe 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTypeValidatorServiceImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTypeValidatorServiceImpl.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -16,6 +17,7 @@
package org.onap.ccsdk.apps.controllerblueprints.validation
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.*
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationContext
@@ -24,43 +26,79 @@ import org.springframework.stereotype.Service
@Service
class BluePrintTypeValidatorServiceImpl : BluePrintTypeValidatorService {
+ companion object {
+ const val PREFIX_DEFAULT = "default"
+ }
+
@Autowired
private lateinit var context: ApplicationContext
+ override fun <T : BluePrintValidator<*>> bluePrintValidator(referenceName: String, classType: Class<T>): T? {
+ return if (context.containsBean(referenceName)) {
+ context.getBean(referenceName, classType)
+ } else {
+ null
+ }
+ }
+
+ override fun <T : BluePrintValidator<*>> bluePrintValidators(referenceNamePrefix: String, classType: Class<T>): List<T>? {
+ return context.getBeansOfType(classType)
+ .filter { it.key.startsWith(referenceNamePrefix) }
+ .mapNotNull { it.value }
+ }
+
+ override fun <T : BluePrintValidator<*>> bluePrintValidators(classType: Class<T>): List<T>? {
+ return context.getBeansOfType(classType).mapNotNull { it.value }
+ }
+
override fun getServiceTemplateValidators(): List<BluePrintServiceTemplateValidator> {
- return context.getBeansOfType(BluePrintServiceTemplateValidator::class.java).mapNotNull { it.value }
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintServiceTemplateValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default ServiceTemplate validators")
}
override fun getDataTypeValidators(): List<BluePrintDataTypeValidator> {
- return context.getBeansOfType(BluePrintDataTypeValidator::class.java).mapNotNull { it.value }
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintDataTypeValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default DataType validators")
}
override fun getArtifactTypeValidators(): List<BluePrintArtifactTypeValidator> {
- return context.getBeansOfType(BluePrintArtifactTypeValidator::class.java).mapNotNull { it.value }
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintArtifactTypeValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default ArtifactType validators")
+ }
+
+ override fun getArtifactDefinitionsValidators(): List<BluePrintArtifactDefinitionValidator> {
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintArtifactDefinitionValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default ArtifactDefinition validators")
}
override fun getNodeTypeValidators(): List<BluePrintNodeTypeValidator> {
- return context.getBeansOfType(BluePrintNodeTypeValidator::class.java).mapNotNull { it.value }
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintNodeTypeValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default NodeType validators")
}
override fun getTopologyTemplateValidators(): List<BluePrintTopologyTemplateValidator> {
- return context.getBeansOfType(BluePrintTopologyTemplateValidator::class.java).mapNotNull { it.value }
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintTopologyTemplateValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default TopologyTemplate validators")
}
override fun getNodeTemplateValidators(): List<BluePrintNodeTemplateValidator> {
- return context.getBeansOfType(BluePrintNodeTemplateValidator::class.java).mapNotNull { it.value }
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintNodeTemplateValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default NodeTemplate validators")
}
override fun getWorkflowValidators(): List<BluePrintWorkflowValidator> {
- return context.getBeansOfType(BluePrintWorkflowValidator::class.java).mapNotNull { it.value }
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintWorkflowValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default Workflow validators")
}
override fun getPropertyDefinitionValidators(): List<BluePrintPropertyDefinitionValidator> {
- return context.getBeansOfType(BluePrintPropertyDefinitionValidator::class.java).mapNotNull { it.value }
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintPropertyDefinitionValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default PropertyDefinition validators")
}
override fun getAttributeDefinitionValidators(): List<BluePrintAttributeDefinitionValidator> {
- return context.getBeansOfType(BluePrintAttributeDefinitionValidator::class.java).mapNotNull { it.value }
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintAttributeDefinitionValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default AttributeDefinition validators")
}
}
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorDefaultService.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorDefaultService.kt
deleted file mode 100644
index 8e26588b8..000000000
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorDefaultService.kt
+++ /dev/null
@@ -1,92 +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.
- */
-
-@file:Suppress("unused")
-package org.onap.ccsdk.apps.controllerblueprints.validation
-
-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.interfaces.BluePrintTypeValidatorService
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
-import org.springframework.stereotype.Service
-import java.util.*
-
-@Service
-class BluePrintTypeValidatorDefaultService(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintValidatorService {
-
- private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString())
-
- override fun validateBluePrints(basePath: String): Boolean {
-
- log.info("validating blueprint($basePath)")
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(), basePath)
- return validateBluePrints(bluePrintRuntimeService)
- }
-
- override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean {
-
- bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template",
- bluePrintRuntimeService.bluePrintContext().serviceTemplate)
-
- if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) {
- throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}")
- }
- return true
- }
-}
-
-// Core Validator Services
-
-@Service
-class DefaultBluePrintServiceTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintServiceTemplateValidatorImpl(bluePrintTypeValidatorService)
-
-@Service
-class DefaultBluePrintDataTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintDataTypeValidatorImpl(bluePrintTypeValidatorService)
-
-@Service
-class DefaultBluePrintArtifactTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintArtifactTypeValidatorImpl(bluePrintTypeValidatorService)
-
-@Service
-class DefaultBluePrintNodeTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintNodeTypeValidatorImpl(bluePrintTypeValidatorService)
-
-@Service
-class DefaultBluePrintTopologyTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintTopologyTemplateValidatorImpl(bluePrintTypeValidatorService)
-
-@Service
-class DefaulBluePrintNodeTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintNodeTemplateValidatorImpl(bluePrintTypeValidatorService)
-
-@Service
-class DefaultBluePrintWorkflowValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintWorkflowValidatorImpl(bluePrintTypeValidatorService)
-
-@Service
-class DefaultBluePrintPropertyDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintPropertyDefinitionValidatorImpl(bluePrintTypeValidatorService)
-
-@Service
-class DefaultBluePrintAttributeDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintAttributeDefinitionValidatorImpl(bluePrintTypeValidatorService) \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt
index 612ec6918..851a7c603 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt
@@ -23,7 +23,12 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowValidator
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+@Service("default-workflow-validator")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintWorkflowValidator {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt
new file mode 100644
index 000000000..6fe4fa36e
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt
@@ -0,0 +1,48 @@
+/*
+ * 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.controllerblueprints.validation.extension
+
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintArtifactDefinitionValidator
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl
+import org.springframework.stereotype.Service
+import java.io.File
+
+@Service("artifact-mapping-resource-artifact-definition-validator")
+open class ArtifactMappingResourceValidator(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService)
+ : BluePrintArtifactDefinitionValidator {
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(ArtifactMappingResourceValidator::class.toString())
+
+ override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String,
+ artifactDefinition: ArtifactDefinition) {
+
+ val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+ val file: String = artifactDefinition.file
+ val completePath = bluePrintContext.rootPath.plus(File.separator).plus(file)
+ log.info("Validation artifact-mapping-resource($completePath)")
+ val resourceAssignment = JacksonUtils.getListFromFile(completePath, ResourceAssignment::class.java)
+ val resourceAssignmentValidationService = ResourceAssignmentValidationServiceImpl()
+ resourceAssignmentValidationService.validate(resourceAssignment)
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorServiceImplTest.kt b/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt
index f5d157dd2..43c3e0e3e 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorServiceImplTest.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt
@@ -30,12 +30,12 @@ import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtil
import kotlin.test.assertEquals
import kotlin.test.assertTrue
-class BluePrintValidatorServiceImplTest {
+class BluePrintDesignTimeValidatorServiceTest {
private val blueprintBasePath: String = ("./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
private val bluePrintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath)
private val mockBluePrintTypeValidatorService = MockBluePrintTypeValidatorService()
- private val defaultBluePrintValidatorService = BluePrintValidatorServiceImpl(mockBluePrintTypeValidatorService)
+ private val defaultBluePrintValidatorService = BluePrintDesignTimeValidatorService(mockBluePrintTypeValidatorService)
private val workflowValidator = BluePrintWorkflowValidatorImpl(mockBluePrintTypeValidatorService)
@Test
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/MockBluePrintTypeValidatorService.kt b/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/MockBluePrintTypeValidatorService.kt
index 971099ca5..65574c229 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/MockBluePrintTypeValidatorService.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/MockBluePrintTypeValidatorService.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -20,6 +21,18 @@ import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.*
class MockBluePrintTypeValidatorService : BluePrintTypeValidatorService {
+ override fun <T : BluePrintValidator<*>> bluePrintValidator(referenceName: String, classType: Class<T>): T? {
+ return null
+ }
+
+ override fun <T : BluePrintValidator<*>> bluePrintValidators(referenceNamePrefix: String, classType: Class<T>): List<T>? {
+ return null
+ }
+
+ override fun <T : BluePrintValidator<*>> bluePrintValidators(classType: Class<T>): List<T>? {
+ return null
+ }
+
override fun getServiceTemplateValidators(): List<BluePrintServiceTemplateValidator> {
return listOf(BluePrintServiceTemplateValidatorImpl(this))
}
@@ -32,6 +45,10 @@ class MockBluePrintTypeValidatorService : BluePrintTypeValidatorService {
return listOf(BluePrintArtifactTypeValidatorImpl(this))
}
+ override fun getArtifactDefinitionsValidators(): List<BluePrintArtifactDefinitionValidator> {
+ return listOf(BluePrintArtifactDefinitionValidatorImpl(this))
+ }
+
override fun getNodeTypeValidators(): List<BluePrintNodeTypeValidator> {
return listOf(BluePrintNodeTypeValidatorImpl(this))
}