Add resource dictionary validation implementation services, validation repository services and Junit Test cases.
Change-Id: Ia746b86b7d9098eabe5e643dcba558ef9aa7160f
Issue-ID: CCSDK-487
Signed-off-by: Brinda Santh <brindasanth@in.ibm.com>
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
const val MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo"\r
const val MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo"\r
\r
+ const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG"\r
+ const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component"\r
+ const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf"\r
+ @Deprecated("Artifacts will be attached to Node Template")\r
+ const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact"\r
+ const val MODEL_TYPE_NODE_RESOURCE_SOURCE = "tosca.nodes.ResourceSource"\r
+\r
const val MODEL_TYPE_NODES_COMPONENT_JAVA: String = "tosca.nodes.component.Java"\r
const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle"\r
const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script"\r
const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python"\r
const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript"\r
\r
+ const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic"\r
+\r
const val EXPRESSION_GET_INPUT: String = "get_input"\r
const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute"\r
const val EXPRESSION_GET_ARTIFACT: String = "get_artifact"\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
const val MODEL_CONTENT_TYPE_TOSCA_JSON = "TOSCA_JSON"\r
const val MODEL_CONTENT_TYPE_TEMPLATE = "TEMPLATE"\r
\r
- const val MODEL_TYPE_DATA_TYPE = "tosca.datatypes.Root"\r
const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic"\r
\r
- const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG"\r
- const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component"\r
- const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf"\r
const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact"\r
\r
const val MODEL_TYPE_CAPABILITY_NETCONF = "tosca.capability.Netconf"\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
fun enhance(fileName: String, basePath: String): ServiceTemplate\r
}\r
\r
-open class BluePrintEnhancerDefaultService(val bluePrintEnhancerRepoService: BluePrintEnhancerRepoService) : BluePrintEnhancerService {\r
+open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRepoService) : BluePrintEnhancerService {\r
\r
private val log: Logger = LoggerFactory.getLogger(BluePrintEnhancerDefaultService::class.java)\r
\r
}\r
\r
open fun populateNodeType(nodeTypeName: String): NodeType {\r
- val nodeType = bluePrintEnhancerRepoService.getNodeType(nodeTypeName)\r
+ val nodeType = bluePrintRepoService.getNodeType(nodeTypeName)\r
?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName))\r
serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType)\r
return nodeType\r
}\r
\r
open fun populateArtifactType(artifactTypeName: String): ArtifactType {\r
- val artifactType = bluePrintEnhancerRepoService.getArtifactType(artifactTypeName)\r
+ val artifactType = bluePrintRepoService.getArtifactType(artifactTypeName)\r
?: throw BluePrintException(format("Couldn't get ArtifactType({}) from repo.", artifactTypeName))\r
serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType)\r
return artifactType\r
}\r
\r
open fun populateDataTypes(dataTypeName: String): DataType {\r
- val dataType = bluePrintEnhancerRepoService.getDataType(dataTypeName)\r
+ val dataType = bluePrintRepoService.getDataType(dataTypeName)\r
?: throw BluePrintException(format("Couldn't get DataType({}) from repo.", dataTypeName))\r
serviceTemplate.dataTypes?.put(dataTypeName, dataType)\r
return dataType\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
import java.nio.charset.Charset\r
\r
/**\r
- * BluePrintEnhancerRepoFileService\r
+ * BluePrintRepoFileService\r
* @author Brinda Santh\r
*\r
*/\r
\r
-interface BluePrintEnhancerRepoService : Serializable {\r
+interface BluePrintRepoService : Serializable {\r
\r
@Throws(BluePrintException::class)\r
fun getNodeType(nodeTypeName: String): NodeType?\r
}\r
\r
\r
-class BluePrintEnhancerRepoFileService(val basePath: String) : BluePrintEnhancerRepoService {\r
+class BluePrintRepoFileService(val basePath: String) : BluePrintRepoService {\r
\r
val dataTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)\r
val nodeTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE)\r
resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, nodeTypePropertyName, propertyAssignment)\r
} else {\r
// Assign default value to the Operation\r
- nodeTypeProperty.defaultValue?.let {\r
- resolvedValue = JacksonUtils.jsonNodeFromObject(nodeTypeProperty.defaultValue!!)\r
+ nodeTypeProperty.defaultValue?.let { defaultValue ->\r
+ resolvedValue = defaultValue\r
}\r
}\r
// Set for Return of method\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
\r
@Test\r
fun testEnrichBlueprint() {\r
- val bluePrintEnhancerRepoFileService = BluePrintEnhancerRepoFileService(basePath)\r
+ val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)\r
val bluePrintEnhancerService: BluePrintEnhancerService = BluePrintEnhancerDefaultService(bluePrintEnhancerRepoFileService)\r
\r
val serviceTemplate = ServiceTemplateUtils.getServiceTemplate("load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json")\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
import kotlin.test.assertNotNull\r
\r
/**\r
- * BluePrintEnhancerRepoFileServiceTest\r
+ * BluePrintRepoFileServiceTest\r
* @author Brinda Santh\r
*\r
*/\r
-class BluePrintEnhancerRepoFileServiceTest {\r
+class BluePrintRepoFileServiceTest {\r
\r
val basePath = "load/model_type"\r
\r
@Test\r
fun testGetDataType() {\r
- val bluePrintEnhancerRepoFileService = BluePrintEnhancerRepoFileService(basePath)\r
+ val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)\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 bluePrintEnhancerRepoFileService = BluePrintEnhancerRepoFileService(basePath)\r
+ val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)\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 bluePrintEnhancerRepoFileService = BluePrintEnhancerRepoFileService(basePath)\r
+ val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)\r
val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity")\r
assertNotNull(nodeType, "Failed to get ArtifactType from repo")\r
}\r
public static final String SOURCE_DB = "db";\r
public static final String SOURCE_MDSAL = "mdsal";\r
\r
+ public static final String PROPERTY_TYPE = "type";\r
public static final String PROPERTY_INPUT_KEY_MAPPING = "input-key-mapping";\r
public static final String PROPERTY_OUTPUT_KEY_MAPPING = "output-key-mapping";\r
public static final String PROPERTY_KEY_DEPENDENCY = "key-dependency";\r
--- /dev/null
+/*
+ * 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.resource.dict.service
+
+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.data.NodeTemplate
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.apps.controllerblueprints.core.format
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpressionService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
+import org.slf4j.LoggerFactory
+import java.io.Serializable
+
+interface ResourceDictionaryValidationService : Serializable {
+
+ @Throws(BluePrintException::class)
+ fun validate(resourceDefinition: ResourceDefinition)
+
+}
+
+open class ResourceDictionaryDefaultValidationService(val bluePrintRepoService: BluePrintRepoService) : ResourceDictionaryValidationService {
+
+ private val log = LoggerFactory.getLogger(ResourceDictionaryDefaultValidationService::class.java)
+
+ override fun validate(resourceDefinition: ResourceDefinition) {
+ Preconditions.checkNotNull(resourceDefinition, "Failed to get Resource Definition")
+
+ resourceDefinition.sources.forEach { (name, nodeTemplate) ->
+ val sourceType = nodeTemplate.type
+
+ val sourceNodeType = bluePrintRepoService.getNodeType(sourceType)
+ ?: throw BluePrintException(format("Failed to get node type definition for source({})", sourceType))
+
+ // Validate Property Name, expression, values and Data Type
+ validateNodeTemplateProperties(nodeTemplate, sourceNodeType)
+ }
+ }
+
+
+ open fun validateNodeTemplateProperties(nodeTemplate: NodeTemplate, nodeType: NodeType) {
+ nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) }
+ }
+
+
+ open fun validatePropertyAssignments(nodeTypeProperties: MutableMap<String, PropertyDefinition>,
+ properties: MutableMap<String, JsonNode>) {
+ properties.forEach { propertyName, propertyAssignment ->
+ val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName]
+ ?: throw BluePrintException(format("failed to get definition for the property ({})", propertyName))
+ // Check and Validate if Expression Node
+ val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment)
+ if (!expressionData.isExpression) {
+ checkPropertyValue(propertyDefinition, propertyName, propertyAssignment)
+ }
+ }
+ }
+
+ open fun checkPropertyValue(propertyDefinition: PropertyDefinition, propertyName: String, jsonNode: JsonNode) {
+ //log.info("validating Property {}, name ({}) value ({})", propertyDefinition, propertyName, jsonNode)
+ //TODO
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.resource.dict.service;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoFileService;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
+
+public class ResourceDictionaryValidationServiceTest {
+ private String basePath = "load/model_type";
+ String dictionaryPath = "load/resource_dictionary";
+
+ @Test
+ public void testValidate() throws Exception {
+ BluePrintRepoFileService bluePrintRepoFileService = new BluePrintRepoFileService(basePath);
+
+ String fileName = dictionaryPath + "/db-source.json";
+ ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class);
+ Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", resourceDefinition);
+
+ ResourceDictionaryValidationService resourceDictionaryValidationService =
+ new ResourceDictionaryDefaultValidationService(bluePrintRepoFileService);
+ resourceDictionaryValidationService.validate(resourceDefinition);
+
+ }
+}
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;\r
import org.onap.ccsdk.apps.controllerblueprints.core.data.*;\r
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDefaultService;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerRepoService;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService;\r
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
import org.slf4j.Logger;\r
\r
private HashMap<String, DataType> recipeDataTypes = new HashMap<>();\r
\r
- public BluePrintEnhancerService(BluePrintEnhancerRepoService bluePrintEnhancerRepoDBService) {\r
+ public BluePrintEnhancerService(BluePrintRepoService bluePrintEnhancerRepoDBService) {\r
super(bluePrintEnhancerRepoDBService);\r
}\r
\r
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
import org.apache.commons.lang3.StringUtils;\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
import org.onap.ccsdk.apps.controllerblueprints.core.data.*;\r
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerRepoService;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService;\r
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;\r
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository;\r
import java.util.Optional;\r
\r
/**\r
- * BluePrintEnhancerRepoDBService\r
+ * BluePrintRepoDBService\r
*\r
* @author Brinda Santh\r
*/\r
@Service\r
-public class BluePrintEnhancerRepoDBService implements BluePrintEnhancerRepoService {\r
+public class BluePrintRepoDBService implements BluePrintRepoService {\r
\r
private ModelTypeRepository modelTypeRepository;\r
\r
- public BluePrintEnhancerRepoDBService(ModelTypeRepository modelTypeRepository) {\r
+ public BluePrintRepoDBService(ModelTypeRepository modelTypeRepository) {\r
this.modelTypeRepository = modelTypeRepository;\r
}\r
\r
\r
private ResourceDictionaryRepository resourceDictionaryRepository;\r
\r
+ private ResourceDictionaryValidationService resourceDictionaryValidationService;\r
+\r
/**\r
* This is a DataDictionaryService, used to save and get the Resource Mapping stored in database\r
- * \r
+ *\r
* @param dataDictionaryRepository\r
- * \r
+ * @param resourceDictionaryValidationService\r
*/\r
- public ResourceDictionaryService(ResourceDictionaryRepository dataDictionaryRepository) {\r
+ public ResourceDictionaryService(ResourceDictionaryRepository dataDictionaryRepository,\r
+ ResourceDictionaryValidationService resourceDictionaryValidationService) {\r
this.resourceDictionaryRepository = dataDictionaryRepository;\r
+ this.resourceDictionaryValidationService = resourceDictionaryValidationService;\r
}\r
\r
/**\r
* This is a getDataDictionaryByName service\r
- * \r
+ *\r
* @param name\r
* @return DataDictionary\r
* @throws BluePrintException\r
\r
/**\r
* This is a searchResourceDictionaryByNames service\r
- * \r
+ *\r
* @param names\r
* @return List<ResourceDictionary>\r
* @throws BluePrintException\r
\r
/**\r
* This is a searchResourceDictionaryByTags service\r
- * \r
+ *\r
* @param tags\r
* @return List<ResourceDictionary>\r
* @throws BluePrintException\r
\r
/**\r
* This is a saveDataDictionary service\r
- * \r
+ *\r
* @param resourceDictionary\r
* @return DataDictionary\r
* @throws BluePrintException\r
\r
ResourceDefinition resourceDefinition =\r
JacksonUtils.readValue(resourceDictionary.getDefinition(), ResourceDefinition.class);\r
+ // Check the Source already Present\r
+ resourceDictionaryValidationService.validate(resourceDefinition);\r
\r
if (resourceDefinition == null) {\r
throw new BluePrintException(\r
PropertyDefinition propertyDefinition = new PropertyDefinition();\r
propertyDefinition.setType(resourceDictionary.getDataType());\r
propertyDefinition.setDescription(resourceDictionary.getDescription());\r
- if(StringUtils.isNotBlank(resourceDictionary.getEntrySchema())){\r
+ if (StringUtils.isNotBlank(resourceDictionary.getEntrySchema())) {\r
EntrySchema entrySchema = new EntrySchema();\r
entrySchema.setType(resourceDictionary.getEntrySchema());\r
propertyDefinition.setEntrySchema(entrySchema);\r
- }else{\r
+ } else {\r
propertyDefinition.setEntrySchema(null);\r
}\r
resourceDefinition.setTags(resourceDictionary.getTags());\r
\r
/**\r
* This is a deleteResourceDictionary service\r
- * \r
+ *\r
* @param name\r
* @throws BluePrintException\r
*/\r
--- /dev/null
+/*
+ * 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.service;
+
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDictionaryDefaultValidationService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ResourceDictionaryValidationService extends ResourceDictionaryDefaultValidationService {
+
+ private BluePrintRepoService bluePrintRepoService;
+
+ public ResourceDictionaryValidationService(BluePrintRepoService bluePrintRepoService) {
+ super(bluePrintRepoService);
+ }
+}
/*\r
* Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
import org.apache.commons.lang3.StringUtils;\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.ConfigModelConstant;\r
import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType;\r
import org.onap.ccsdk.apps.controllerblueprints.core.data.CapabilityDefinition;\r
import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType;\r
return validTypes;\r
}\r
\r
- @Deprecated\r
- private static List<String> getValidModelDerivedFrom(String definitionType) {\r
- List<String> validTypes = new ArrayList<>();\r
- if (StringUtils.isNotBlank(definitionType)) {\r
- if (BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE.equalsIgnoreCase(definitionType)) {\r
- validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_DG);\r
- validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_COMPONENT);\r
- validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_VNF);\r
- validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_ARTIFACT);\r
- } else if (BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE.equalsIgnoreCase(definitionType)) {\r
- validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_NETCONF);\r
- validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_SSH);\r
- validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_SFTP);\r
- validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_CHEF);\r
- validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_ANSIBLEF);\r
- } else if (BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE.equalsIgnoreCase(definitionType)) {\r
- validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON);\r
- validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_HOSTED_ON);\r
- validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO);\r
- validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ATTACH_TO);\r
- validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROUTES_TO);\r
- }\r
-\r
- }\r
- return validTypes;\r
- }\r
-\r
- /**\r
- * This is a validateNodeType\r
- * \r
- * @param definitionType\r
- * @param derivedFrom\r
- * @return boolean\r
- * @throws BluePrintException\r
- */\r
- public static boolean validateNodeType(String definitionType, String derivedFrom) throws BluePrintException {\r
- boolean valid = true;\r
- if (!BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE.equalsIgnoreCase(definitionType)\r
- && !BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE.equalsIgnoreCase(definitionType)) {\r
- List<String> validTypes = getValidModelDerivedFrom(definitionType);\r
- if (!validTypes.contains(derivedFrom)) {\r
- throw new BluePrintException(\r
- "Not Valid Model Type (" + derivedFrom + "), It sould be " + validTypes);\r
- }\r
- }\r
- return valid;\r
- }\r
-\r
/**\r
* This is a validateModelTypeDefinition\r
* \r
\r
validateModelTypeDefinition(modelType.getDefinitionType(), modelType.getDefinition());\r
\r
- validateNodeType(modelType.getDefinitionType(), modelType.getDerivedFrom());\r
-\r
} else {\r
throw new BluePrintException("Model Type Information is missing.");\r
}\r