summaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/service/src/main/kotlin
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-12-13 15:10:35 -0500
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-12-13 15:10:35 -0500
commit3854151c6f07ae1bb4c68ce114aae247011f98c8 (patch)
treeb303de4283511e91c637f7f05179cf85907a920a /ms/controllerblueprints/modules/service/src/main/kotlin
parentcd8493304ad2c0f33ebf25ff66ad9e8e58aeaf34 (diff)
Add blueprint runtime service to validator
Change-Id: I0e4375e422b55002f1666ee9e61a1469482f77d2 Issue-ID: CCSDK-757 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'ms/controllerblueprints/modules/service/src/main/kotlin')
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintTypeValidatorServiceImpl.kt66
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt103
2 files changed, 169 insertions, 0 deletions
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintTypeValidatorServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintTypeValidatorServiceImpl.kt
new file mode 100644
index 000000000..9d4797ff9
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/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.service.validator
+
+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/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt
new file mode 100644
index 000000000..89f4d9e38
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt
@@ -0,0 +1,103 @@
+/*
+ * 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.service.validator
+
+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.BluePrintRepoService
+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.*
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationServiceImpl
+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)
+
+// Resource Dictionary Validation Services
+
+@Service
+class DefaultResourceAssignmentValidationService : ResourceAssignmentValidationServiceImpl()
+
+@Service
+class DefalutResourceDefinitionValidationService(bluePrintRepoService: BluePrintRepoService)
+ : ResourceDefinitionValidationServiceImpl(bluePrintRepoService) \ No newline at end of file