package org.onap.ccsdk.apps.controllerblueprints.core
-class BluePrintValidationError {
+class BluePrintError {
var errors: MutableList<String> = arrayListOf()
fun addError(type: String, name: String, error: String) {
--- /dev/null
+/*
+ * 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.core.interfaces
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+
+interface BluePrintEnhancer<T> {
+ fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: T)
+}
+
+interface BluePrintServiceTemplateEnhancer : BluePrintEnhancer<ServiceTemplate>
+
+interface BluePrintTopologyTemplateEnhancer : BluePrintEnhancer<TopologyTemplate>
+
+interface BluePrintWorkflowEnhancer : BluePrintEnhancer<Workflow>
+
+interface BluePrintNodeTemplateEnhancer : BluePrintEnhancer<NodeTemplate>
+
+interface BluePrintNodeTypeEnhancer : BluePrintEnhancer<NodeType>
+
+interface BluePrintPolicyTypeEnhancer : BluePrintEnhancer<PolicyType>
+
+interface BluePrintPropertyDefinitionEnhancer : BluePrintEnhancer<PropertyDefinition>
+
+interface BluePrintAttributeDefinitionEnhancer : BluePrintEnhancer<AttributeDefinition>
+
+
+interface BluePrintEnhancerService {
+
+ @Throws(BluePrintException::class)
+ fun enhance(basePath: String, enrichedBasePath: String): BluePrintContext
+
+ @Throws(BluePrintException::class)
+ fun enhance(basePath: String): BluePrintContext
+
+ @Throws(BluePrintException::class)
+ fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate
+}
+
+interface BluePrintTypeEnhancerService {
+
+ fun getServiceTemplateEnhancers(): List<BluePrintServiceTemplateEnhancer>
+
+ fun getTopologyTemplateEnhancers(): List<BluePrintTopologyTemplateEnhancer>
+
+ fun getWorkflowEnhancers(): List<BluePrintWorkflowEnhancer>
+
+ fun getNodeTemplateEnhancers(): List<BluePrintNodeTemplateEnhancer>
+
+ fun getNodeTypeEnhancers(): List<BluePrintNodeTypeEnhancer>
+
+ fun getPolicyTypeEnhancers(): List<BluePrintPolicyTypeEnhancer>
+
+ fun getPropertyDefinitionEnhancers(): List<BluePrintPropertyDefinitionEnhancer>
+
+ fun getAttributeDefinitionEnhancers(): List<BluePrintAttributeDefinitionEnhancer>
+
+ fun enhanceServiceTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, serviceTemplate: ServiceTemplate) {
+ val enhancers = getServiceTemplateEnhancers()
+ doEnhancement(bluePrintContext, error, name, serviceTemplate, enhancers)
+ }
+
+ fun enhanceTopologyTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, topologyTemplate: TopologyTemplate) {
+ val enhancers = getTopologyTemplateEnhancers()
+ doEnhancement(bluePrintContext, error, name, topologyTemplate, enhancers)
+ }
+
+ fun enhanceWorkflow(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, workflow: Workflow) {
+ val enhancers = getWorkflowEnhancers()
+ doEnhancement(bluePrintContext, error, name, workflow, enhancers)
+ }
+
+ fun enhanceNodeTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeTemplate: NodeTemplate) {
+ val enhancers = getNodeTemplateEnhancers()
+ doEnhancement(bluePrintContext, error, name, nodeTemplate, enhancers)
+ }
+
+ fun enhanceNodeType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeType: NodeType) {
+ val enhancers = getNodeTypeEnhancers()
+ doEnhancement(bluePrintContext, error, name, nodeType, enhancers)
+ }
+
+ fun enhancePolicyType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, policyType: PolicyType) {
+ val enhancers = getPolicyTypeEnhancers()
+ doEnhancement(bluePrintContext, error, name, policyType, enhancers)
+ }
+
+ fun enhancePropertyDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, propertyDefinition: PropertyDefinition) {
+ val enhancers = getPropertyDefinitionEnhancers()
+ doEnhancement(bluePrintContext, error, name, propertyDefinition, enhancers)
+ }
+
+ fun enhanceAttributeDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, attributeDefinition: AttributeDefinition) {
+ val enhancers = getAttributeDefinitionEnhancers()
+ doEnhancement(bluePrintContext, error, name, attributeDefinition, enhancers)
+ }
+
+ private fun <T> doEnhancement(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, definition: Any, enhancers: List<BluePrintEnhancer<T>>) {
+ if (enhancers.isNotEmpty()) {
+ enhancers.forEach {
+ it.enhance(bluePrintContext, error, name, definition as T)
+ }
+ }
+ }
+}
\ No newline at end of file
package org.onap.ccsdk.apps.controllerblueprints.core.interfaces
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
interface BluePrintValidator<T> {
- fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, type: T)
+ fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: T)
}
fun getAttributeDefinitionValidators(): List<BluePrintAttributeDefinitionValidator>
- fun validateServiceTemplate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, serviceTemplate: ServiceTemplate) {
+ fun validateServiceTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, serviceTemplate: ServiceTemplate) {
val validators = getServiceTemplateValidators()
doValidation(bluePrintContext, error, name, serviceTemplate, validators)
}
- fun validateArtifactType(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, artifactType: ArtifactType) {
+ fun validateArtifactType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, artifactType: ArtifactType) {
val validators = getArtifactTypeValidators()
doValidation(bluePrintContext, error, name, artifactType, validators)
}
- fun validateDataType(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, dataType: DataType) {
+ fun validateDataType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, dataType: DataType) {
val validators = getDataTypeValidators()
doValidation(bluePrintContext, error, name, dataType, validators)
}
- fun validateNodeType(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, nodeType: NodeType) {
+ fun validateNodeType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeType: NodeType) {
val validators = getNodeTypeValidators()
doValidation(bluePrintContext, error, name, nodeType, validators)
}
- fun validateTopologyTemplate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, topologyTemplate: TopologyTemplate) {
+ fun validateTopologyTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, topologyTemplate: TopologyTemplate) {
val validators = getTopologyTemplateValidators()
doValidation(bluePrintContext, error, name, topologyTemplate, validators)
}
- fun validateNodeTemplate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, nodeTemplate: NodeTemplate) {
+ fun validateNodeTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeTemplate: NodeTemplate) {
val validators = getNodeTemplateValidators()
doValidation(bluePrintContext, error, name, nodeTemplate, validators)
}
- fun validateWorkflow(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, workflow: Workflow) {
+ fun validateWorkflow(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, workflow: Workflow) {
val validators = getWorkflowValidators()
doValidation(bluePrintContext, error, name, workflow, validators)
}
- fun validatePropertyDefinitions(bluePrintContext: BluePrintContext, error: BluePrintValidationError, properties: MutableMap<String, PropertyDefinition>) {
+ fun validatePropertyDefinitions(bluePrintContext: BluePrintContext, error: BluePrintError, properties: MutableMap<String, PropertyDefinition>) {
properties.forEach { propertyName, propertyDefinition ->
validatePropertyDefinition(bluePrintContext, error, propertyName, propertyDefinition)
}
}
- fun validatePropertyDefinition(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, propertyDefinition: PropertyDefinition) {
+ fun validatePropertyDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, propertyDefinition: PropertyDefinition) {
val validators = getPropertyDefinitionValidators()
doValidation(bluePrintContext, error, name, propertyDefinition, validators)
}
- fun validateAttributeDefinitions(bluePrintContext: BluePrintContext, error: BluePrintValidationError, attributes: MutableMap<String, AttributeDefinition>) {
+ fun validateAttributeDefinitions(bluePrintContext: BluePrintContext, error: BluePrintError, attributes: MutableMap<String, AttributeDefinition>) {
attributes.forEach { attributeName, attributeDefinition ->
validateAttributeDefinition(bluePrintContext, error, attributeName, attributeDefinition)
}
}
- fun validateAttributeDefinition(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, attributeDefinition: AttributeDefinition) {
+ fun validateAttributeDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, attributeDefinition: AttributeDefinition) {
val validators = getAttributeDefinitionValidators()
doValidation(bluePrintContext, error, name, attributeDefinition, validators)
}
- private fun <T> doValidation(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, definition: Any, validators: List<BluePrintValidator<T>>) {
+ private fun <T> doValidation(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, definition: Any, validators: List<BluePrintValidator<T>>) {
validators.forEach {
it.validate(bluePrintContext, error, name, definition as T)
}
\r
package org.onap.ccsdk.apps.controllerblueprints.core.service\r
\r
+import com.att.eelf.configuration.EELFLogger\r
+import com.att.eelf.configuration.EELFManager\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
import org.onap.ccsdk.apps.controllerblueprints.core.data.*\r
-import com.att.eelf.configuration.EELFLogger\r
-import com.att.eelf.configuration.EELFManager\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils\r
-import reactor.core.publisher.Mono\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
import java.io.Serializable\r
\r
/**\r
interface BluePrintRepoService : Serializable {\r
\r
@Throws(BluePrintException::class)\r
- fun getNodeType(nodeTypeName: String): Mono<NodeType>\r
+ fun getNodeType(nodeTypeName: String): NodeType\r
\r
@Throws(BluePrintException::class)\r
- fun getDataType(dataTypeName: String): Mono<DataType>\r
+ fun getDataType(dataTypeName: String): DataType\r
\r
@Throws(BluePrintException::class)\r
- fun getArtifactType(artifactTypeName: String): Mono<ArtifactType>\r
+ fun getArtifactType(artifactTypeName: String): ArtifactType\r
\r
@Throws(BluePrintException::class)\r
- fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType>\r
+ fun getRelationshipType(relationshipTypeName: String): RelationshipType\r
\r
@Throws(BluePrintException::class)\r
- fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition>\r
+ fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition\r
\r
}\r
\r
private val relationshipTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE)\r
private val extension = ".json"\r
\r
- override fun getDataType(dataTypeName: String): Mono<DataType> {\r
+ override fun getDataType(dataTypeName: String): DataType {\r
val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER)\r
.plus(dataTypeName).plus(extension)\r
return getModelType(fileName, DataType::class.java)\r
}\r
\r
- override fun getNodeType(nodeTypeName: String): Mono<NodeType> {\r
+ override fun getNodeType(nodeTypeName: String): NodeType {\r
val fileName = nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension)\r
return getModelType(fileName, NodeType::class.java)\r
}\r
\r
- override fun getArtifactType(artifactTypeName: String): Mono<ArtifactType> {\r
+ override fun getArtifactType(artifactTypeName: String): ArtifactType {\r
val fileName = artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER)\r
.plus(artifactTypeName).plus(extension)\r
return getModelType(fileName, ArtifactType::class.java)\r
}\r
\r
- override fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType> {\r
+ override fun getRelationshipType(relationshipTypeName: String): RelationshipType {\r
val fileName = relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER)\r
.plus(relationshipTypeName).plus(extension)\r
return getModelType(fileName, RelationshipType::class.java)\r
}\r
\r
- override fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition> {\r
+ override fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition {\r
val fileName = capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER)\r
.plus(capabilityDefinitionName).plus(extension)\r
return getModelType(fileName, CapabilityDefinition::class.java)\r
}\r
\r
- private fun <T> getModelType(fileName: String, valueType: Class<T>): Mono<T> {\r
- return JacksonReactorUtils.readValueFromFile(fileName, valueType)\r
+ private fun <T> getModelType(fileName: String, valueType: Class<T>): T {\r
+ return JacksonUtils.readValueFromFile(fileName, valueType)\r
+ ?: throw BluePrintException("couldn't get file($fileName) for type(${valueType.name}")\r
}\r
}
\ No newline at end of file
import com.fasterxml.jackson.databind.JsonNode\r
import com.fasterxml.jackson.databind.SerializationFeature\r
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper\r
-import org.apache.commons.io.FileUtils\r
+import kotlinx.coroutines.Dispatchers\r
+import kotlinx.coroutines.runBlocking\r
+import kotlinx.coroutines.withContext\r
import org.apache.commons.io.IOUtils\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes\r
-import org.onap.ccsdk.apps.controllerblueprints.core.format\r
import java.io.File\r
import java.nio.charset.Charset\r
\r
\r
@JvmStatic\r
fun getContent(fileName: String): String {\r
- return File(fileName).readText(Charsets.UTF_8)\r
+ return runBlocking {\r
+ withContext(Dispatchers.Default) {\r
+ File(fileName).readText(Charsets.UTF_8)\r
+ }\r
+ }\r
}\r
\r
@JvmStatic\r
fun getClassPathFileContent(fileName: String): String {\r
- return IOUtils.toString(JacksonUtils::class.java.classLoader\r
- .getResourceAsStream(fileName), Charset.defaultCharset())\r
+ return runBlocking {\r
+ withContext(Dispatchers.Default) {\r
+ IOUtils.toString(JacksonUtils::class.java.classLoader\r
+ .getResourceAsStream(fileName), Charset.defaultCharset())\r
+ }\r
+ }\r
}\r
\r
@JvmStatic\r
fun <T> readValueFromFile(fileName: String, valueType: Class<T>): T? {\r
- val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())\r
- ?: throw BluePrintException(format("Failed to read json file : {}", fileName))\r
+ val content: String = getContent(fileName)\r
return readValue(content, valueType)\r
}\r
\r
\r
@JvmStatic\r
fun jsonNodeFromFile(fileName: String): JsonNode {\r
- val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())\r
- ?: throw BluePrintException(format("Failed to read json file : {}", fileName))\r
+ val content: String = getContent(fileName)\r
return jsonNode(content)\r
}\r
\r
\r
@JvmStatic\r
fun <T> getListFromFile(fileName: String, valueType: Class<T>): List<T>? {\r
- val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())\r
- ?: throw BluePrintException(format("Failed to read json file : {}", fileName))\r
+ val content: String = getContent(fileName)\r
return getListFromJson(content, valueType)\r
}\r
\r
\r
@JvmStatic\r
fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T>? {\r
- val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())\r
- ?: throw BluePrintException(format("Failed to read json file : {}", fileName))\r
+ val content: String = getContent(fileName)\r
return getMapFromJson(content, valueType)\r
}\r
\r
package org.onap.ccsdk.apps.controllerblueprints.core.validation
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
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
open class BluePrintArtifactTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintArtifactTypeValidator {
- override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, artifactType: ArtifactType) {
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, artifactType: ArtifactType) {
artifactType.properties?.let {
bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext, error, artifactType.properties!!)
}
package org.onap.ccsdk.apps.controllerblueprints.core.validation
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.data.AttributeDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintAttributeDefinitionValidator
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
class BluePrintAttributeDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintAttributeDefinitionValidator {
- override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, type: AttributeDefinition) {
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: AttributeDefinition) {
//TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
\ No newline at end of file
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
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
open class BluePrintDataTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintDataTypeValidator {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintDataTypeValidatorImpl::class.toString())
- override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, dataType: DataType) {
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, dataType: DataType) {
log.trace("Validating DataType($name)")
dataType.properties?.let {
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTemplateValidator
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateValidatorImpl::class.toString())
var bluePrintContext: BluePrintContext? = null
- var error: BluePrintValidationError? = null
+ var error: BluePrintError? = null
var paths: MutableList<String> = arrayListOf()
- override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, nodeTemplateName: String, nodeTemplate: NodeTemplate) {
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, nodeTemplateName: String, nodeTemplate: NodeTemplate) {
log.trace("Validating NodeTemplate($nodeTemplateName)")
this.bluePrintContext = bluePrintContext
this.error = error
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.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyNThrow
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTypeValidator
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
var bluePrintContext: BluePrintContext? = null
- var error: BluePrintValidationError? = null
+ var error: BluePrintError? = null
var paths: MutableList<String> = arrayListOf()
- override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, nodeTypeName: String, nodeType: NodeType) {
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, nodeTypeName: String, nodeType: NodeType) {
log.trace("Validating NodeType($nodeTypeName)")
this.bluePrintContext = bluePrintContext
this.error = error
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.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintPropertyDefinitionValidator
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
var bluePrintContext: BluePrintContext? = null
- var error: BluePrintValidationError? = null
+ var error: BluePrintError? = null
- override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, propertyDefinition: PropertyDefinition) {
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, propertyDefinition: PropertyDefinition) {
this.bluePrintContext = bluePrintContext
this.error = error
import com.google.common.base.Preconditions
import org.apache.commons.lang3.StringUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
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
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
var bluePrintContext: BluePrintContext? = null
- var error: BluePrintValidationError? = null
+ var error: BluePrintError? = null
var paths: MutableList<String> = arrayListOf()
- override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, serviceTemplate: ServiceTemplate) {
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, serviceTemplate: ServiceTemplate) {
log.trace("Validating Service Template..")
try {
this.bluePrintContext = bluePrintContext
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.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.data.TopologyTemplate
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
var bluePrintContext: BluePrintContext? = null
- var error: BluePrintValidationError? = null
+ var error: BluePrintError? = null
- override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, topologyTemplate: TopologyTemplate) {
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, topologyTemplate: TopologyTemplate) {
log.trace("Validating Topology Template..")
this.bluePrintContext = bluePrintContext
this.error = error
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.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
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.BluePrintContext
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString())
override fun validateBluePrints(bluePrintContext: BluePrintContext, properties: MutableMap<String, Any>): Boolean {
- val error = BluePrintValidationError()
+ val error = BluePrintError()
bluePrintTypeValidatorService.validateServiceTemplate(bluePrintContext, error, "default", bluePrintContext.serviceTemplate)
if (error.errors.size > 0) {
throw BluePrintException("failed in blueprint validation : ${error.errors.joinToString("\n")}")
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
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
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
var bluePrintContext: BluePrintContext? = null
- var error: BluePrintValidationError? = null
+ var error: BluePrintError? = null
var paths: MutableList<String> = arrayListOf()
- override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, workflowName: String, workflow: Workflow) {
+ override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, workflowName: String, workflow: Workflow) {
log.info("Validating Workflow($workflowName)")
this.bluePrintContext = bluePrintContext
\r
@Test\r
fun testGetDataType() {\r
- val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate").block()\r
+ val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate")\r
assertNotNull(dataType, "Failed to get DataType from repo")\r
}\r
\r
@Test\r
fun testGetNodeType() {\r
- val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment").block()\r
+ val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment")\r
assertNotNull(nodeType, "Failed to get NodeType from repo")\r
}\r
\r
@Test\r
fun testGetArtifactType() {\r
- val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity").block()\r
+ val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity")\r
assertNotNull(nodeType, "Failed to get ArtifactType from repo")\r
}\r
\r
@Test(expected = FileNotFoundException::class)\r
fun testModelNotFound() {\r
- val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found").block()\r
+ val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found")\r
assertNotNull(dataType, "Failed to get DataType from repo")\r
}\r
}
\ No newline at end of file
"type": "string"
}
},
- "derived_from": "tosca.datatypes.Root"
+ "derived_from": "tosca.datatypes.Dynamic"
},
"resource-assignment-properties": {
"description": "This is Dynamically generated data type for workflow activate",
"type": "string"
}
},
- "derived_from": "tosca.datatypes.Root"
+ "derived_from": "tosca.datatypes.Dynamic"
},
"assign-activate-properties": {
"description": "This is Dynamically generated data type for workflow assign-activate",
"type": "string"
}
},
- "derived_from": "tosca.datatypes.Root"
+ "derived_from": "tosca.datatypes.Dynamic"
}
}
}
\ No newline at end of file
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoFileService\r
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition\r
-import reactor.core.publisher.Mono\r
\r
/**\r
* ResourceDefinitionRepoService.\r
interface ResourceDefinitionRepoService : BluePrintRepoService {\r
\r
@Throws(BluePrintException::class)\r
- fun getResourceDefinition(resourceDefinitionName: String): Mono<ResourceDefinition>\r
+ fun getResourceDefinition(resourceDefinitionName: String): ResourceDefinition\r
}\r
\r
/**\r
resourceDefinitionPath = basePath.plus("/resource-dictionary/starter-dictionary")\r
}\r
\r
- override fun getResourceDefinition(resourceDefinitionName: String): Mono<ResourceDefinition> {\r
+ override fun getResourceDefinition(resourceDefinitionName: String): ResourceDefinition {\r
\r
val fileName = resourceDefinitionPath.plus(BluePrintConstants.PATH_DIVIDER)\r
.plus(resourceDefinitionName).plus(extension)\r
\r
- return JacksonReactorUtils.readValueFromFile(fileName, ResourceDefinition::class.java)\r
+ return JacksonUtils.readValueFromFile(fileName, ResourceDefinition::class.java)\r
+ ?: throw BluePrintException("couldn't get resource definition for file($fileName)")\r
}\r
}\r
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service
import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
import com.fasterxml.jackson.databind.JsonNode
import com.google.common.base.Preconditions
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
-import com.att.eelf.configuration.EELFManager
import java.io.Serializable
+
/**
* ResourceDefinitionValidationService.
*
fun validate(resourceDefinition: ResourceDefinition)
}
+
/**
* ResourceDefinitionValidationService.
*
resourceDefinition.sources.forEach { (name, nodeTemplate) ->
val sourceType = nodeTemplate.type
- val sourceNodeType = bluePrintRepoService.getNodeType(sourceType).block()
- ?: throw BluePrintException(format("Failed to get source({}) node type definition({})", name, sourceType))
+ val sourceNodeType = bluePrintRepoService.getNodeType(sourceType)
// Validate Property Name, expression, values and Data Type
validateNodeTemplateProperties(nodeTemplate, sourceNodeType)
open fun checkPropertyValue(propertyDefinition: PropertyDefinition, propertyName: String, propertyAssignment: JsonNode) {
val propertyType = propertyDefinition.type
- val isValid : Boolean
+ val isValid: Boolean
if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment)
isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment)
} else {
- bluePrintRepoService.getDataType(propertyType).block()
- ?: throw BluePrintException(format("property({}) defined of data type({}) is not in repository",
- propertyName, propertyType))
+ bluePrintRepoService.getDataType(propertyType)
isValid = true
}
public class ResourceDefinitionRepoServiceTest {\r
\r
@Test\r
- public void testGetResourceDefinition() throws Exception{\r
+ public void testGetResourceDefinition() throws Exception {\r
ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("./../model-catalog");\r
ResourceDefinition resourceDefinition = resourceDefinitionRepoService\r
- .getResourceDefinition("db-source").block();\r
+ .getResourceDefinition("db-source");\r
Assert.assertNotNull("Failed to get Resource Definition db-source", resourceDefinition);\r
\r
- NodeType nodeType = resourceDefinitionRepoService.getNodeType("source-db").block();\r
+ NodeType nodeType = resourceDefinitionRepoService.getNodeType("source-db");\r
Assert.assertNotNull("Failed to get Node Type source-db", resourceDefinition);\r
}\r
}
\ No newline at end of file