diff options
author | Muthuramalingam, Brinda Santh <brindasanth@in.ibm.com> | 2019-02-27 20:16:47 -0500 |
---|---|---|
committer | Muthuramalingam, Brinda Santh <brindasanth@in.ibm.com> | 2019-03-11 09:13:22 -0400 |
commit | a5130dcf4e70f394c1432baefffc198882f04dc1 (patch) | |
tree | d0eaa477c7795db5066726def23aa6bc2cd4e363 /ms/controllerblueprints/modules/service/src/main/kotlin/org | |
parent | fc3e34836f7be8eda28a8f996d733e8dfca01450 (diff) |
Add blueprint runtime validator
Change-Id: I9e2aa1aec392fc4191d547115fa90e8811f0f9e9
Issue-ID: CCSDK-1110
Signed-off-by: Muthuramalingam, Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'ms/controllerblueprints/modules/service/src/main/kotlin/org')
2 files changed, 17 insertions, 17 deletions
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt index f856b9efe..88589eb7d 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2019 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,21 +25,10 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationServiceImpl import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository import org.springframework.stereotype.Service -// Resource Dictionary Validation Services - -@Service -class DefaultResourceAssignmentValidationService : ResourceAssignmentValidationServiceImpl() - -@Service -class DefalutResourceDefinitionValidationService(bluePrintRepoService: BluePrintRepoService) - : ResourceDefinitionValidationServiceImpl(bluePrintRepoService) - interface ResourceDefinitionRepoService : BluePrintRepoService { @Throws(BluePrintException::class) diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt index c24931484..ec7d8aebc 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2019 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,17 +21,15 @@ import com.google.common.base.Preconditions import org.apache.commons.collections.CollectionUtils import org.apache.commons.lang3.StringUtils import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationService import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository -import org.onap.ccsdk.apps.controllerblueprints.service.validator.ResourceDictionaryValidator import org.springframework.stereotype.Service @Service -class ResourceDictionaryHandler(private val resourceDictionaryRepository: ResourceDictionaryRepository, - private val resourceDictionaryValidationService: ResourceDefinitionValidationService) { +class ResourceDictionaryHandler(private val resourceDictionaryRepository: ResourceDictionaryRepository) { /** @@ -86,7 +85,8 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour val resourceDefinition = resourceDictionary.definition Preconditions.checkNotNull(resourceDefinition, "failed to get resource definition from content") // Validate the Resource Definitions - resourceDictionaryValidationService.validate(resourceDefinition) + //TODO( Save Validator) + //validate(resourceDefinition) resourceDictionary.tags = resourceDefinition.tags resourceDefinition.updatedBy = resourceDictionary.updatedBy @@ -98,7 +98,7 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour resourceDictionary.entrySchema = propertyDefinition.entrySchema!!.type } - ResourceDictionaryValidator.validateResourceDictionary(resourceDictionary) + validateResourceDictionary(resourceDictionary) val dbResourceDictionaryData = resourceDictionaryRepository.findByName(resourceDictionary.name) if (dbResourceDictionaryData.isPresent) { @@ -135,4 +135,14 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour fun getResourceSourceMapping(): ResourceSourceMapping { return ResourceSourceMappingFactory.getRegisterSourceMapping() } + + private fun validateResourceDictionary(resourceDictionary: ResourceDictionary): Boolean { + checkNotEmptyOrThrow(resourceDictionary.name, "DataDictionary Definition name is missing.") + checkNotNull(resourceDictionary.definition) { "DataDictionary Definition Information is missing." } + checkNotEmptyOrThrow(resourceDictionary.description, "DataDictionary Definition Information is missing.") + checkNotEmptyOrThrow(resourceDictionary.tags, "DataDictionary Definition tags is missing.") + checkNotEmptyOrThrow(resourceDictionary.updatedBy, "DataDictionary Definition updatedBy is missing.") + return true + + } }
\ No newline at end of file |