aboutsummaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/blueprint-validation/src
diff options
context:
space:
mode:
Diffstat (limited to 'ms/controllerblueprints/modules/blueprint-validation/src')
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintTypeValidatorServiceImpl.kt66
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintValidatorDefaultService.kt100
2 files changed, 166 insertions, 0 deletions
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintTypeValidatorServiceImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintTypeValidatorServiceImpl.kt
new file mode 100644
index 00000000..76dfa73e
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintTypeValidatorServiceImpl.kt
@@ -0,0 +1,66 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.blueprint.validation
+
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.*
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.context.ApplicationContext
+import org.springframework.stereotype.Service
+
+@Service
+class BluePrintTypeValidatorServiceImpl : BluePrintTypeValidatorService {
+
+ @Autowired
+ private lateinit var context: ApplicationContext
+
+ override fun getServiceTemplateValidators(): List<BluePrintServiceTemplateValidator> {
+ return context.getBeansOfType(BluePrintServiceTemplateValidator::class.java).mapNotNull { it.value }
+ }
+
+ override fun getDataTypeValidators(): List<BluePrintDataTypeValidator> {
+ return context.getBeansOfType(BluePrintDataTypeValidator::class.java).mapNotNull { it.value }
+ }
+
+ override fun getArtifactTypeValidators(): List<BluePrintArtifactTypeValidator> {
+ return context.getBeansOfType(BluePrintArtifactTypeValidator::class.java).mapNotNull { it.value }
+ }
+
+ override fun getNodeTypeValidators(): List<BluePrintNodeTypeValidator> {
+ return context.getBeansOfType(BluePrintNodeTypeValidator::class.java).mapNotNull { it.value }
+ }
+
+ override fun getTopologyTemplateValidators(): List<BluePrintTopologyTemplateValidator> {
+ return context.getBeansOfType(BluePrintTopologyTemplateValidator::class.java).mapNotNull { it.value }
+ }
+
+ override fun getNodeTemplateValidators(): List<BluePrintNodeTemplateValidator> {
+ return context.getBeansOfType(BluePrintNodeTemplateValidator::class.java).mapNotNull { it.value }
+ }
+
+ override fun getWorkflowValidators(): List<BluePrintWorkflowValidator> {
+ return context.getBeansOfType(BluePrintWorkflowValidator::class.java).mapNotNull { it.value }
+ }
+
+ override fun getPropertyDefinitionValidators(): List<BluePrintPropertyDefinitionValidator> {
+ return context.getBeansOfType(BluePrintPropertyDefinitionValidator::class.java).mapNotNull { it.value }
+ }
+
+ override fun getAttributeDefinitionValidators(): List<BluePrintAttributeDefinitionValidator> {
+ return context.getBeansOfType(BluePrintAttributeDefinitionValidator::class.java).mapNotNull { it.value }
+ }
+}
+
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintValidatorDefaultService.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintValidatorDefaultService.kt
new file mode 100644
index 00000000..2993b3d3
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintValidatorDefaultService.kt
@@ -0,0 +1,100 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.blueprint.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.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintArtifactTypeValidatorImpl
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintAttributeDefinitionValidatorImpl
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintDataTypeValidatorImpl
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintNodeTemplateValidatorImpl
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintNodeTypeValidatorImpl
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintPropertyDefinitionValidatorImpl
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintServiceTemplateValidatorImpl
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintTopologyTemplateValidatorImpl
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintValidatorServiceImpl
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintWorkflowValidatorImpl
+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 DefaulBluePrintPropertyDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
+ : BluePrintPropertyDefinitionValidatorImpl(bluePrintTypeValidatorService)
+
+@Service
+class DefaultBluePrintAttributeDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
+ : BluePrintAttributeDefinitionValidatorImpl(bluePrintTypeValidatorService) \ No newline at end of file