Optimise model type repository search for DB and file in blueprint repo service.
Change-Id: If5458e218b723d3fff451789a73a667dd75bc91c
Issue-ID: CCSDK-487
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
--- /dev/null
+{
+ "description": "This is Database Resource Source Node Type",
+ "version": "1.0.0",
+ "properties": {
+ "type": {
+ "required": true,
+ "type": "string",
+ "constraints": [
+ {
+ "valid_values": [
+ "SQL",
+ "PLSQL"
+ ]
+ }
+ ]
+ },
+ "query": {
+ "required": true,
+ "type": "string"
+ },
+ "input-key-mapping": {
+ "required": false,
+ "type": "map",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
+ "output-key-mapping": {
+ "required": false,
+ "type": "map",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
+ "key-dependencies": {
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.ResourceSource"
+}
\ No newline at end of file
--- /dev/null
+{
+ "description": "This is Default Resource Source Node Type",
+ "version": "1.0.0",
+ "properties": {
+ "key": {
+ "required": false,
+ "type": "string"
+ },
+ "key-dependencies": {
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.ResourceSource"
+}
\ No newline at end of file
--- /dev/null
+{
+ "description": "This is Input Resource Source Node Type",
+ "version": "1.0.0",
+ "properties": {
+ "key": {
+ "required": false,
+ "type": "string"
+ },
+ "key-dependencies": {
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.ResourceSource"
+}
\ No newline at end of file
--- /dev/null
+{
+ "description": "This is Rest Resource Source Node Type",
+ "version": "1.0.0",
+ "properties": {
+ "type": {
+ "required": false,
+ "type": "string",
+ "default": "JSON",
+ "constraints": [
+ {
+ "valid_values": [
+ "JSON"
+ ]
+ }
+ ]
+ },
+ "url-path": {
+ "required": true,
+ "type": "string"
+ },
+ "path": {
+ "required": true,
+ "type": "string"
+ },
+ "expression-type": {
+ "required": false,
+ "type": "string",
+ "default": "JSON_PATH",
+ "constraints": [
+ {
+ "valid_values": [
+ "JSON_PATH",
+ "JSON_POINTER"
+ ]
+ }
+ ]
+ },
+ "input-key-mapping": {
+ "required": false,
+ "type": "map",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
+ "output-key-mapping": {
+ "required": false,
+ "type": "map",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
+ "key-dependencies": {
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.ResourceSource"
+}
\ No newline at end of file
--- /dev/null
+{
+ "description": "TOSCA base type for Resource Sources",
+ "version": "1.0.0",
+ "derived_from": "tosca.nodes.Root"
+}
\ No newline at end of file
\r
package org.onap.ccsdk.apps.controllerblueprints;\r
\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
import org.onap.ccsdk.apps.controllerblueprints.service.common.ErrorMessage;\r
import org.springframework.http.HttpStatus;\r
@ControllerAdvice\r
@RestController\r
public class ApplicationExceptionHandler {\r
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ApplicationExceptionHandler.class);\r
@ExceptionHandler(Exception.class)\r
public final ResponseEntity<ErrorMessage> handleAllExceptions(Exception ex, WebRequest request) {\r
+ log.error("Application Exception", ex);\r
ErrorMessage exceptionResponse = new ErrorMessage( ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR.value(), ex.getLocalizedMessage());\r
return new ResponseEntity<>(exceptionResponse, HttpStatus.INTERNAL_SERVER_ERROR);\r
}\r
\r
@ExceptionHandler(BluePrintException.class)\r
public final ResponseEntity<ErrorMessage> handleBlueprintException(BluePrintException ex, WebRequest request) {\r
+ log.error("Application Blueprint Exception", ex);\r
ErrorMessage exceptionResponse = new ErrorMessage( ex.getMessage(), ex.getCode(), ex.getLocalizedMessage());\r
return new ResponseEntity<>(exceptionResponse, HttpStatus.INTERNAL_SERVER_ERROR);\r
}\r
<groupId>com.fasterxml.jackson.module</groupId>\r
<artifactId>jackson-module-jsonSchema</artifactId>\r
</dependency>\r
+ <dependency>\r
+ <groupId>io.projectreactor</groupId>\r
+ <artifactId>reactor-core</artifactId>\r
+ </dependency>\r
<dependency>\r
<groupId>org.yaml</groupId>\r
<artifactId>snakeyaml</artifactId>\r
}\r
\r
open fun populateNodeType(nodeTypeName: String): NodeType {\r
- val nodeType = bluePrintRepoService.getNodeType(nodeTypeName)\r
+ val nodeType = bluePrintRepoService.getNodeType(nodeTypeName)?.block()\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 = bluePrintRepoService.getArtifactType(artifactTypeName)\r
+ val artifactType = bluePrintRepoService.getArtifactType(artifactTypeName)?.block()\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 = bluePrintRepoService.getDataType(dataTypeName)\r
+ val dataType = bluePrintRepoService.getDataType(dataTypeName)?.block()\r
?: throw BluePrintException(format("Couldn't get DataType({}) from repo.", dataTypeName))\r
serviceTemplate.dataTypes?.put(dataTypeName, dataType)\r
return dataType\r
\r
package org.onap.ccsdk.apps.controllerblueprints.core.service\r
\r
+import com.google.common.base.Preconditions\r
import org.apache.commons.io.FileUtils\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.data.*\r
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
+import org.slf4j.Logger\r
+import org.slf4j.LoggerFactory\r
+import reactor.core.publisher.Mono\r
import java.io.File\r
import java.io.Serializable\r
import java.nio.charset.Charset\r
interface BluePrintRepoService : Serializable {\r
\r
@Throws(BluePrintException::class)\r
- fun getNodeType(nodeTypeName: String): NodeType?\r
+ fun getNodeType(nodeTypeName: String): Mono<NodeType>?\r
\r
@Throws(BluePrintException::class)\r
- fun getDataType(dataTypeName: String): DataType?\r
+ fun getDataType(dataTypeName: String): Mono<DataType>?\r
\r
@Throws(BluePrintException::class)\r
- fun getArtifactType(artifactTypeName: String): ArtifactType?\r
+ fun getArtifactType(artifactTypeName: String): Mono<ArtifactType>?\r
\r
@Throws(BluePrintException::class)\r
- fun getRelationshipType(relationshipTypeName: String): RelationshipType?\r
+ fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType>?\r
\r
@Throws(BluePrintException::class)\r
- fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition?\r
+ fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition>?\r
\r
}\r
\r
\r
class BluePrintRepoFileService(val basePath: String) : BluePrintRepoService {\r
\r
+ private val log: Logger = LoggerFactory.getLogger(BluePrintRepoFileService::class.java)\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
val artifactTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE)\r
val relationshipTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE)\r
val extension = ".json"\r
\r
- override fun getDataType(dataTypeName: String): DataType? {\r
- val content = FileUtils.readFileToString(File(dataTypePath.plus(BluePrintConstants.PATH_DIVIDER)\r
- .plus(dataTypeName).plus(extension)), Charset.defaultCharset())\r
- return JacksonUtils.readValue(content)\r
+ override fun getDataType(dataTypeName: String): Mono<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
+ val fileName = nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension)\r
+ return getModelType(fileName, NodeType::class.java)\r
}\r
\r
- override fun getNodeType(nodeTypeName: String): NodeType? {\r
- val content = FileUtils.readFileToString(File(nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER)\r
- .plus(nodeTypeName).plus(extension)), Charset.defaultCharset())\r
- return JacksonUtils.readValue(content)\r
+ override fun getArtifactType(artifactTypeName: String): Mono<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 getArtifactType(artifactTypeName: String): ArtifactType? {\r
- val content = FileUtils.readFileToString(File(artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER)\r
- .plus(artifactTypeName).plus(extension)), Charset.defaultCharset())\r
- return JacksonUtils.readValue(content)\r
+ override fun getRelationshipType(relationshipTypeName: String): Mono<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 getRelationshipType(relationshipTypeName: String): RelationshipType? {\r
- val content = FileUtils.readFileToString(File(relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER)\r
- .plus(relationshipTypeName).plus(extension)), Charset.defaultCharset())\r
- return JacksonUtils.readValue(content)\r
+ override fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<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 getFileContent(fileName).map { content ->\r
+ Preconditions.checkArgument(StringUtils.isNotBlank(content),\r
+ String.format("Failed to get model content for file (%s)", fileName))\r
+\r
+ JacksonUtils.readValue(content, valueType)\r
+ ?: throw BluePrintException(String.format("Failed to get model file from content for file (%s)", fileName))\r
+\r
+ }\r
}\r
\r
- override fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition? {\r
- val content = FileUtils.readFileToString(File(capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER)\r
- .plus(capabilityDefinitionName).plus(extension)), Charset.defaultCharset())\r
- return JacksonUtils.readValue(content)\r
+ private fun getFileContent(fileName: String): Mono<String> {\r
+ return Mono.just(FileUtils.readFileToString(File(fileName), Charset.defaultCharset()))\r
}\r
}
\ No newline at end of file
package org.onap.ccsdk.apps.controllerblueprints.core.service\r
\r
import org.junit.Test\r
+import java.io.FileNotFoundException\r
import kotlin.test.assertNotNull\r
\r
/**\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 bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)\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
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;\r
\r
import java.io.Serializable;\r
-\r
+@Deprecated\r
public interface ResourceSource extends Serializable {\r
}\r
/*
* Copyright © 2018 IBM.
+ * Modifications 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.
resourceDefinition.sources.forEach { (name, nodeTemplate) ->
val sourceType = nodeTemplate.type
- val sourceNodeType = bluePrintRepoService.getNodeType(sourceType)
+ val sourceNodeType = bluePrintRepoService.getNodeType(sourceType)?.block()
?: throw BluePrintException(format("Failed to get node type definition for source({})", sourceType))
// Validate Property Name, expression, values and Data Type
"resource-path": "action-name",\r
"resource-type": "ONAP",\r
"updated-by": "brindasanth@onap.com",\r
- "tags": null,\r
+ "tags": "action-name, brindasanth",\r
"sources": {\r
"input": {\r
"type": "source-input",\r
"resource-path": "vnf/v4-ip-type",\r
"resource-type": "ONAP",\r
"updated-by": "brindasanth@onap.com",\r
- "tags": null,\r
+ "tags": "v4-ip-type, source-input, brindasanth",\r
"sources": {\r
"input": {\r
"type": "source-input",\r
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;\r
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository;\r
import org.springframework.stereotype.Service;\r
+import reactor.core.publisher.Mono;\r
\r
import java.util.Optional;\r
\r
this.modelTypeRepository = modelTypeRepository;\r
}\r
\r
- \r
@Override\r
- public NodeType getNodeType(String nodeTypeName) throws BluePrintException {\r
- Preconditions.checkArgument(StringUtils.isNotBlank(nodeTypeName), "NodeType name is missing");\r
- String content = getModelDefinitions(nodeTypeName);\r
- Preconditions.checkArgument(StringUtils.isNotBlank(content), "NodeType content is missing");\r
- return JacksonUtils.readValue(content, NodeType.class);\r
+ public Mono<NodeType> getNodeType(String nodeTypeName) throws BluePrintException {\r
+ return getModelType(nodeTypeName, NodeType.class);\r
}\r
\r
- \r
@Override\r
- public DataType getDataType(String dataTypeName) throws BluePrintException {\r
- Preconditions.checkArgument(StringUtils.isNotBlank(dataTypeName), "DataType name is missing");\r
- String content = getModelDefinitions(dataTypeName);\r
- Preconditions.checkArgument(StringUtils.isNotBlank(content), "DataType content is missing");\r
- return JacksonUtils.readValue(content, DataType.class);\r
+ public Mono<DataType> getDataType(String dataTypeName) throws BluePrintException {\r
+ return getModelType(dataTypeName, DataType.class);\r
}\r
\r
- \r
@Override\r
- public ArtifactType getArtifactType(String artifactTypeName) throws BluePrintException {\r
- Preconditions.checkArgument(StringUtils.isNotBlank(artifactTypeName), "ArtifactType name is missing");\r
- String content = getModelDefinitions(artifactTypeName);\r
- Preconditions.checkArgument(StringUtils.isNotBlank(content), "ArtifactType content is missing");\r
- return JacksonUtils.readValue(content, ArtifactType.class);\r
+ public Mono<ArtifactType> getArtifactType(String artifactTypeName) throws BluePrintException {\r
+ return getModelType(artifactTypeName, ArtifactType.class);\r
}\r
\r
- \r
@Override\r
- public RelationshipType getRelationshipType(String relationshipTypeName) throws BluePrintException {\r
- Preconditions.checkArgument(StringUtils.isNotBlank(relationshipTypeName), "RelationshipType name is missing");\r
- String content = getModelDefinitions(relationshipTypeName);\r
- Preconditions.checkArgument(StringUtils.isNotBlank(content), "RelationshipType content is missing");\r
- return JacksonUtils.readValue(content, RelationshipType.class);\r
+ public Mono<RelationshipType> getRelationshipType(String relationshipTypeName) throws BluePrintException {\r
+ return getModelType(relationshipTypeName, RelationshipType.class);\r
}\r
\r
- \r
@Override\r
- public CapabilityDefinition getCapabilityDefinition(String capabilityDefinitionName) throws BluePrintException {\r
- Preconditions.checkArgument(StringUtils.isNotBlank(capabilityDefinitionName), "CapabilityDefinition name is missing");\r
- String content = getModelDefinitions(capabilityDefinitionName);\r
- Preconditions.checkArgument(StringUtils.isNotBlank(content), "CapabilityDefinition content is missing");\r
- return JacksonUtils.readValue(content, CapabilityDefinition.class);\r
+ public Mono<CapabilityDefinition> getCapabilityDefinition(String capabilityDefinitionName) throws BluePrintException {\r
+ return getModelType(capabilityDefinitionName, CapabilityDefinition.class);\r
}\r
\r
- private String getModelDefinitions(String modelName) throws BluePrintException {\r
+ private <T> Mono<T> getModelType(String modelName, Class<T> valueClass) throws BluePrintException {\r
+ Preconditions.checkArgument(StringUtils.isNotBlank(modelName),\r
+ "Failed to get model from repo, model name is missing");\r
+\r
+ return getModelDefinitions(modelName).map(content -> {\r
+ Preconditions.checkArgument(StringUtils.isNotBlank(content),\r
+ String.format("Failed to get model content for model name (%s)", modelName));\r
+ return JacksonUtils.readValue(content, valueClass);\r
+ }\r
+ );\r
+ }\r
+\r
+ private Mono<String> getModelDefinitions(String modelName) throws BluePrintException {\r
String modelDefinition = null;\r
- Optional<ModelType> modelTypedb = modelTypeRepository.findByModelName(modelName);\r
- if (modelTypedb.isPresent()) {\r
- modelDefinition = modelTypedb.get().getDefinition();\r
+ Optional<ModelType> modelTypeDb = modelTypeRepository.findByModelName(modelName);\r
+ if (modelTypeDb.isPresent()) {\r
+ modelDefinition = modelTypeDb.get().getDefinition();\r
} else {\r
throw new BluePrintException(String.format("failed to get model definition (%s) from repo", modelName));\r
}\r
- return modelDefinition;\r
+ return Mono.just(modelDefinition);\r
}\r
}\r
\r
package org.onap.ccsdk.apps.controllerblueprints.service;\r
\r
+import com.google.common.base.Preconditions;\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.EntrySchema;\r
*/\r
public ResourceDictionary saveResourceDictionary(ResourceDictionary resourceDictionary)\r
throws BluePrintException {\r
- if (resourceDictionary != null) {\r
- ResourceDictionaryValidator.validateResourceDictionary(resourceDictionary);\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
- "Resource dictionary definition is not valid content " + resourceDictionary.getDefinition());\r
- }\r
-\r
- resourceDefinition.setName(resourceDictionary.getName());\r
- resourceDefinition.setResourcePath(resourceDictionary.getResourcePath());\r
- resourceDefinition.setResourceType(resourceDictionary.getResourceType());\r
-\r
- PropertyDefinition propertyDefinition = new PropertyDefinition();\r
- propertyDefinition.setType(resourceDictionary.getDataType());\r
- propertyDefinition.setDescription(resourceDictionary.getDescription());\r
- if (StringUtils.isNotBlank(resourceDictionary.getEntrySchema())) {\r
- EntrySchema entrySchema = new EntrySchema();\r
- entrySchema.setType(resourceDictionary.getEntrySchema());\r
- propertyDefinition.setEntrySchema(entrySchema);\r
- } else {\r
- propertyDefinition.setEntrySchema(null);\r
- }\r
- resourceDefinition.setTags(resourceDictionary.getTags());\r
- resourceDefinition.setUpdatedBy(resourceDictionary.getUpdatedBy());\r
-\r
- String definitionContent = JacksonUtils.getJson(resourceDefinition, true);\r
- resourceDictionary.setDefinition(definitionContent);\r
-\r
- Optional<ResourceDictionary> dbResourceDictionaryData =\r
- resourceDictionaryRepository.findByName(resourceDictionary.getName());\r
- if (dbResourceDictionaryData.isPresent()) {\r
- ResourceDictionary dbResourceDictionary = dbResourceDictionaryData.get();\r
-\r
- dbResourceDictionary.setName(resourceDictionary.getName());\r
- dbResourceDictionary.setDefinition(resourceDictionary.getDefinition());\r
- dbResourceDictionary.setDescription(resourceDictionary.getDescription());\r
- dbResourceDictionary.setResourceType(resourceDictionary.getResourceType());\r
- dbResourceDictionary.setResourcePath(resourceDictionary.getResourcePath());\r
- dbResourceDictionary.setDataType(resourceDictionary.getDataType());\r
- dbResourceDictionary.setEntrySchema(resourceDictionary.getEntrySchema());\r
- dbResourceDictionary.setTags(resourceDictionary.getTags());\r
- dbResourceDictionary.setValidValues(resourceDictionary.getValidValues());\r
- resourceDictionary = resourceDictionaryRepository.save(dbResourceDictionary);\r
- } else {\r
- resourceDictionary = resourceDictionaryRepository.save(resourceDictionary);\r
- }\r
+ Preconditions.checkNotNull(resourceDictionary, "Resource Dictionary information is missing");\r
+ Preconditions.checkArgument(StringUtils.isNotBlank(resourceDictionary.getDefinition()),\r
+ "Resource Dictionary definition information is missing");\r
+\r
+ ResourceDefinition resourceDefinition =\r
+ JacksonUtils.readValue(resourceDictionary.getDefinition(), ResourceDefinition.class);\r
+ // Validate the Resource Definitions\r
+ resourceDictionaryValidationService.validate(resourceDefinition);\r
+\r
+ resourceDictionary.setResourceType(resourceDefinition.getResourceType());\r
+ resourceDictionary.setResourcePath(resourceDefinition.getResourcePath());\r
+ resourceDictionary.setTags(resourceDefinition.getTags());\r
+ resourceDefinition.setUpdatedBy(resourceDictionary.getUpdatedBy());\r
+ // Set the Property Definitions\r
+ PropertyDefinition propertyDefinition = resourceDefinition.getProperty();\r
+ resourceDictionary.setDescription(propertyDefinition.getDescription());\r
+ resourceDictionary.setDataType(propertyDefinition.getType());\r
+ if(propertyDefinition.getEntrySchema() != null){\r
+ resourceDictionary.setEntrySchema(propertyDefinition.getEntrySchema().getType());\r
+ }\r
+\r
+ String definitionContent = JacksonUtils.getJson(resourceDefinition, true);\r
+ resourceDictionary.setDefinition(definitionContent);\r
+\r
+ ResourceDictionaryValidator.validateResourceDictionary(resourceDictionary);\r
+\r
+ Optional<ResourceDictionary> dbResourceDictionaryData =\r
+ resourceDictionaryRepository.findByName(resourceDictionary.getName());\r
+ if (dbResourceDictionaryData.isPresent()) {\r
+ ResourceDictionary dbResourceDictionary = dbResourceDictionaryData.get();\r
+\r
+ dbResourceDictionary.setName(resourceDictionary.getName());\r
+ dbResourceDictionary.setDefinition(resourceDictionary.getDefinition());\r
+ dbResourceDictionary.setDescription(resourceDictionary.getDescription());\r
+ dbResourceDictionary.setResourceType(resourceDictionary.getResourceType());\r
+ dbResourceDictionary.setResourcePath(resourceDictionary.getResourcePath());\r
+ dbResourceDictionary.setTags(resourceDictionary.getTags());\r
+ dbResourceDictionary.setUpdatedBy(resourceDictionary.getUpdatedBy());\r
+ dbResourceDictionary.setDataType(resourceDictionary.getDataType());\r
+ dbResourceDictionary.setEntrySchema(resourceDictionary.getEntrySchema());\r
+ resourceDictionary = resourceDictionaryRepository.save(dbResourceDictionary);\r
} else {\r
- throw new BluePrintException("Resource Dictionary information is missing");\r
+ resourceDictionary = resourceDictionaryRepository.save(resourceDictionary);\r
}\r
+\r
return resourceDictionary;\r
}\r
\r
{\r
- "name": "v4-aggregat-list",\r
+ "name": "ipaddress",\r
"property": {\r
"description": "name of the ",\r
"type": "list",\r
"updated-by": "Brinda Santh (bs2796)",\r
"resource-type": "ONAP",\r
"resource-path": "/v4-aggregat-list",\r
- "tags": null,\r
+ "tags": "ipaddress",\r
"sources": {\r
"input": {\r
"type": "source-input"\r