diff options
Diffstat (limited to 'ms/controllerblueprints')
15 files changed, 209 insertions, 86 deletions
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index 1bdd53073..85f1579e2 100644 --- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.
@@ -73,12 +74,21 @@ object BluePrintConstants { const val MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo"
const val MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo"
+ const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG"
+ const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component"
+ const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf"
+ @Deprecated("Artifacts will be attached to Node Template")
+ const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact"
+ const val MODEL_TYPE_NODE_RESOURCE_SOURCE = "tosca.nodes.ResourceSource"
+
const val MODEL_TYPE_NODES_COMPONENT_JAVA: String = "tosca.nodes.component.Java"
const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle"
const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script"
const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python"
const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript"
+ const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic"
+
const val EXPRESSION_GET_INPUT: String = "get_input"
const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute"
const val EXPRESSION_GET_ARTIFACT: String = "get_artifact"
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt index 978269125..845922040 100644 --- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt +++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.
@@ -26,12 +27,8 @@ object ConfigModelConstant { const val MODEL_CONTENT_TYPE_TOSCA_JSON = "TOSCA_JSON"
const val MODEL_CONTENT_TYPE_TEMPLATE = "TEMPLATE"
- const val MODEL_TYPE_DATA_TYPE = "tosca.datatypes.Root"
const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic"
- const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG"
- const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component"
- const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf"
const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact"
const val MODEL_TYPE_CAPABILITY_NETCONF = "tosca.capability.Netconf"
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt index 8f1728762..64fc57fcd 100644 --- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt +++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.
@@ -44,7 +45,7 @@ interface BluePrintEnhancerService : Serializable { fun enhance(fileName: String, basePath: String): ServiceTemplate
}
-open class BluePrintEnhancerDefaultService(val bluePrintEnhancerRepoService: BluePrintEnhancerRepoService) : BluePrintEnhancerService {
+open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRepoService) : BluePrintEnhancerService {
private val log: Logger = LoggerFactory.getLogger(BluePrintEnhancerDefaultService::class.java)
@@ -216,21 +217,21 @@ open class BluePrintEnhancerDefaultService(val bluePrintEnhancerRepoService: Blu }
open fun populateNodeType(nodeTypeName: String): NodeType {
- val nodeType = bluePrintEnhancerRepoService.getNodeType(nodeTypeName)
+ val nodeType = bluePrintRepoService.getNodeType(nodeTypeName)
?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName))
serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType)
return nodeType
}
open fun populateArtifactType(artifactTypeName: String): ArtifactType {
- val artifactType = bluePrintEnhancerRepoService.getArtifactType(artifactTypeName)
+ val artifactType = bluePrintRepoService.getArtifactType(artifactTypeName)
?: throw BluePrintException(format("Couldn't get ArtifactType({}) from repo.", artifactTypeName))
serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType)
return artifactType
}
open fun populateDataTypes(dataTypeName: String): DataType {
- val dataType = bluePrintEnhancerRepoService.getDataType(dataTypeName)
+ val dataType = bluePrintRepoService.getDataType(dataTypeName)
?: throw BluePrintException(format("Couldn't get DataType({}) from repo.", dataTypeName))
serviceTemplate.dataTypes?.put(dataTypeName, dataType)
return dataType
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerRepoService.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt index 5369d509b..a529a85f8 100644 --- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerRepoService.kt +++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.
@@ -26,12 +27,12 @@ import java.io.Serializable import java.nio.charset.Charset
/**
- * BluePrintEnhancerRepoFileService
+ * BluePrintRepoFileService
* @author Brinda Santh
*
*/
-interface BluePrintEnhancerRepoService : Serializable {
+interface BluePrintRepoService : Serializable {
@Throws(BluePrintException::class)
fun getNodeType(nodeTypeName: String): NodeType?
@@ -51,7 +52,7 @@ interface BluePrintEnhancerRepoService : Serializable { }
-class BluePrintEnhancerRepoFileService(val basePath: String) : BluePrintEnhancerRepoService {
+class BluePrintRepoFileService(val basePath: String) : BluePrintRepoService {
val dataTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
val nodeTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE)
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt index 08152313b..b03fdf92b 100644 --- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt +++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt @@ -65,8 +65,8 @@ class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var contex resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, nodeTypePropertyName, propertyAssignment)
} else {
// Assign default value to the Operation
- nodeTypeProperty.defaultValue?.let {
- resolvedValue = JacksonUtils.jsonNodeFromObject(nodeTypeProperty.defaultValue!!)
+ nodeTypeProperty.defaultValue?.let { defaultValue ->
+ resolvedValue = defaultValue
}
}
// Set for Return of method
diff --git a/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt index 6fc18532e..8e6d5efdf 100644 --- a/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt +++ b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.
@@ -30,7 +31,7 @@ class BluePrintEnhancerServiceTest { @Test
fun testEnrichBlueprint() {
- val bluePrintEnhancerRepoFileService = BluePrintEnhancerRepoFileService(basePath)
+ val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)
val bluePrintEnhancerService: BluePrintEnhancerService = BluePrintEnhancerDefaultService(bluePrintEnhancerRepoFileService)
val serviceTemplate = ServiceTemplateUtils.getServiceTemplate("load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json")
diff --git a/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerRepoFileServiceTest.kt b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt index ef4384ff2..574eae6d3 100644 --- a/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerRepoFileServiceTest.kt +++ b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.
@@ -20,31 +21,31 @@ import org.junit.Test import kotlin.test.assertNotNull
/**
- * BluePrintEnhancerRepoFileServiceTest
+ * BluePrintRepoFileServiceTest
* @author Brinda Santh
*
*/
-class BluePrintEnhancerRepoFileServiceTest {
+class BluePrintRepoFileServiceTest {
val basePath = "load/model_type"
@Test
fun testGetDataType() {
- val bluePrintEnhancerRepoFileService = BluePrintEnhancerRepoFileService(basePath)
+ val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)
val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate")
assertNotNull(dataType, "Failed to get DataType from repo")
}
@Test
fun testGetNodeType() {
- val bluePrintEnhancerRepoFileService = BluePrintEnhancerRepoFileService(basePath)
+ val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)
val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment")
assertNotNull(nodeType, "Failed to get NodeType from repo")
}
@Test
fun testGetArtifactType() {
- val bluePrintEnhancerRepoFileService = BluePrintEnhancerRepoFileService(basePath)
+ val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)
val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity")
assertNotNull(nodeType, "Failed to get ArtifactType from repo")
}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java index 96ab1ee1a..ddbd88bda 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java +++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java @@ -23,6 +23,7 @@ public class ResourceDictionaryConstants { public static final String SOURCE_DB = "db";
public static final String SOURCE_MDSAL = "mdsal";
+ public static final String PROPERTY_TYPE = "type";
public static final String PROPERTY_INPUT_KEY_MAPPING = "input-key-mapping";
public static final String PROPERTY_OUTPUT_KEY_MAPPING = "output-key-mapping";
public static final String PROPERTY_KEY_DEPENDENCY = "key-dependency";
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationService.kt new file mode 100644 index 000000000..cef1f1580 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationService.kt @@ -0,0 +1,80 @@ +/* + * 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 diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationServiceTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationServiceTest.java new file mode 100644 index 000000000..6eebdb2f0 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDictionaryValidationServiceTest.java @@ -0,0 +1,42 @@ +/* + * 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); + + } +} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java index afd12f219..0cf846c7a 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.
@@ -24,7 +25,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
import org.onap.ccsdk.apps.controllerblueprints.core.data.*;
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDefaultService;
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerRepoService;
+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.ResourceAssignment;
import org.slf4j.Logger;
@@ -48,7 +49,7 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { private HashMap<String, DataType> recipeDataTypes = new HashMap<>();
- public BluePrintEnhancerService(BluePrintEnhancerRepoService bluePrintEnhancerRepoDBService) {
+ public BluePrintEnhancerService(BluePrintRepoService bluePrintEnhancerRepoDBService) {
super(bluePrintEnhancerRepoDBService);
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerRepoDBService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java index a2e5b104c..4a26119c0 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerRepoDBService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.
@@ -20,7 +21,7 @@ import com.google.common.base.Preconditions; import org.apache.commons.lang3.StringUtils;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.core.data.*;
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerRepoService;
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository;
@@ -29,16 +30,16 @@ import org.springframework.stereotype.Service; import java.util.Optional;
/**
- * BluePrintEnhancerRepoDBService
+ * BluePrintRepoDBService
*
* @author Brinda Santh
*/
@Service
-public class BluePrintEnhancerRepoDBService implements BluePrintEnhancerRepoService {
+public class BluePrintRepoDBService implements BluePrintRepoService {
private ModelTypeRepository modelTypeRepository;
- public BluePrintEnhancerRepoDBService(ModelTypeRepository modelTypeRepository) {
+ public BluePrintRepoDBService(ModelTypeRepository modelTypeRepository) {
this.modelTypeRepository = modelTypeRepository;
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java index 4bb87d7fc..5420dd390 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java @@ -43,19 +43,23 @@ public class ResourceDictionaryService { private ResourceDictionaryRepository resourceDictionaryRepository;
+ private ResourceDictionaryValidationService resourceDictionaryValidationService;
+
/**
* This is a DataDictionaryService, used to save and get the Resource Mapping stored in database
- *
+ *
* @param dataDictionaryRepository
- *
+ * @param resourceDictionaryValidationService
*/
- public ResourceDictionaryService(ResourceDictionaryRepository dataDictionaryRepository) {
+ public ResourceDictionaryService(ResourceDictionaryRepository dataDictionaryRepository,
+ ResourceDictionaryValidationService resourceDictionaryValidationService) {
this.resourceDictionaryRepository = dataDictionaryRepository;
+ this.resourceDictionaryValidationService = resourceDictionaryValidationService;
}
/**
* This is a getDataDictionaryByName service
- *
+ *
* @param name
* @return DataDictionary
* @throws BluePrintException
@@ -70,7 +74,7 @@ public class ResourceDictionaryService { /**
* This is a searchResourceDictionaryByNames service
- *
+ *
* @param names
* @return List<ResourceDictionary>
* @throws BluePrintException
@@ -86,7 +90,7 @@ public class ResourceDictionaryService { /**
* This is a searchResourceDictionaryByTags service
- *
+ *
* @param tags
* @return List<ResourceDictionary>
* @throws BluePrintException
@@ -101,7 +105,7 @@ public class ResourceDictionaryService { /**
* This is a saveDataDictionary service
- *
+ *
* @param resourceDictionary
* @return DataDictionary
* @throws BluePrintException
@@ -113,6 +117,8 @@ public class ResourceDictionaryService { ResourceDefinition resourceDefinition =
JacksonUtils.readValue(resourceDictionary.getDefinition(), ResourceDefinition.class);
+ // Check the Source already Present
+ resourceDictionaryValidationService.validate(resourceDefinition);
if (resourceDefinition == null) {
throw new BluePrintException(
@@ -126,11 +132,11 @@ public class ResourceDictionaryService { PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType(resourceDictionary.getDataType());
propertyDefinition.setDescription(resourceDictionary.getDescription());
- if(StringUtils.isNotBlank(resourceDictionary.getEntrySchema())){
+ if (StringUtils.isNotBlank(resourceDictionary.getEntrySchema())) {
EntrySchema entrySchema = new EntrySchema();
entrySchema.setType(resourceDictionary.getEntrySchema());
propertyDefinition.setEntrySchema(entrySchema);
- }else{
+ } else {
propertyDefinition.setEntrySchema(null);
}
resourceDefinition.setTags(resourceDictionary.getTags());
@@ -165,7 +171,7 @@ public class ResourceDictionaryService { /**
* This is a deleteResourceDictionary service
- *
+ *
* @param name
* @throws BluePrintException
*/
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryValidationService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryValidationService.java new file mode 100644 index 000000000..7de7fc4c3 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryValidationService.java @@ -0,0 +1,31 @@ +/* + * 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); + } +} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java index 85f256ea7..1201f6b49 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java @@ -1,5 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications 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.
@@ -19,7 +20,6 @@ package org.onap.ccsdk.apps.controllerblueprints.service.validator; import org.apache.commons.lang3.StringUtils;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType;
import org.onap.ccsdk.apps.controllerblueprints.core.data.CapabilityDefinition;
import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType;
@@ -53,54 +53,6 @@ public class ModelTypeValidator { return validTypes;
}
- @Deprecated
- private static List<String> getValidModelDerivedFrom(String definitionType) {
- List<String> validTypes = new ArrayList<>();
- if (StringUtils.isNotBlank(definitionType)) {
- if (BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE.equalsIgnoreCase(definitionType)) {
- validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_DG);
- validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_COMPONENT);
- validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_VNF);
- validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_ARTIFACT);
- } else if (BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE.equalsIgnoreCase(definitionType)) {
- validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_NETCONF);
- validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_SSH);
- validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_SFTP);
- validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_CHEF);
- validTypes.add(ConfigModelConstant.MODEL_TYPE_CAPABILITY_ANSIBLEF);
- } else if (BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE.equalsIgnoreCase(definitionType)) {
- validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON);
- validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_HOSTED_ON);
- validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO);
- validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ATTACH_TO);
- validTypes.add(BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROUTES_TO);
- }
-
- }
- return validTypes;
- }
-
- /**
- * This is a validateNodeType
- *
- * @param definitionType
- * @param derivedFrom
- * @return boolean
- * @throws BluePrintException
- */
- public static boolean validateNodeType(String definitionType, String derivedFrom) throws BluePrintException {
- boolean valid = true;
- if (!BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE.equalsIgnoreCase(definitionType)
- && !BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE.equalsIgnoreCase(definitionType)) {
- List<String> validTypes = getValidModelDerivedFrom(definitionType);
- if (!validTypes.contains(derivedFrom)) {
- throw new BluePrintException(
- "Not Valid Model Type (" + derivedFrom + "), It sould be " + validTypes);
- }
- }
- return valid;
- }
-
/**
* This is a validateModelTypeDefinition
*
@@ -187,8 +139,6 @@ public class ModelTypeValidator { validateModelTypeDefinition(modelType.getDefinitionType(), modelType.getDefinition());
- validateNodeType(modelType.getDefinitionType(), modelType.getDerivedFrom());
-
} else {
throw new BluePrintException("Model Type Information is missing.");
}
|