Renaming Files having BluePrint to have Blueprint
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / inbounds / designer-api / src / main / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / designer / api / load / ResourceDictionaryLoadService.kt
index 0350bc7..295e89a 100644 (file)
@@ -20,11 +20,9 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.load
 import kotlinx.coroutines.async
 import kotlinx.coroutines.awaitAll
 import kotlinx.coroutines.coroutineScope
-import org.apache.commons.lang3.StringUtils
 import org.apache.commons.lang3.text.StrBuilder
-import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ResourceDictionary
 import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler.ResourceDictionaryHandler
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException
 import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
 import org.onap.ccsdk.cds.controllerblueprints.core.readNBText
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
@@ -70,39 +68,17 @@ open class ResourceDictionaryLoadService(private val resourceDictionaryHandler:
 
     private suspend fun loadResourceDictionary(errorBuilder: StrBuilder, file: File) {
         try {
-            log.trace("Loading NodeType(${file.name}}")
+            log.trace("Loading Resource Dictionary(${file.name}}")
             val definitionContent = file.readNBText()
             val resourceDefinition = JacksonUtils.readValue(definitionContent, ResourceDefinition::class.java)
             if (resourceDefinition != null) {
-
-                checkNotNull(resourceDefinition.property) { "Failed to get Property Definition" }
-                val resourceDictionary = ResourceDictionary()
-                resourceDictionary.name = resourceDefinition.name
-                resourceDictionary.definition = resourceDefinition
-
-                checkNotNull(resourceDefinition.property) { "Property field is missing" }
-                resourceDictionary.description = resourceDefinition.property.description!!
-                resourceDictionary.dataType = resourceDefinition.property.type
-
-                if (resourceDefinition.property.entrySchema != null) {
-                    resourceDictionary.entrySchema = resourceDefinition.property.entrySchema!!.type
-                }
-                resourceDictionary.updatedBy = resourceDefinition.updatedBy
-
-                if (StringUtils.isBlank(resourceDefinition.tags)) {
-                    resourceDictionary.tags = (resourceDefinition.name + ", " + resourceDefinition.updatedBy +
-                            ", " + resourceDefinition.updatedBy)
-                } else {
-                    resourceDictionary.tags = resourceDefinition.tags!!
-                }
-                resourceDictionaryHandler.saveResourceDictionary(resourceDictionary)
-
+                resourceDictionaryHandler.saveResourceDefinition(resourceDefinition)
                 log.trace("Resource dictionary(${file.name}) loaded successfully ")
             } else {
-                throw BluePrintException("couldn't get dictionary from content information")
+                throw BlueprintException("couldn't get dictionary from content information")
             }
         } catch (e: Exception) {
-            errorBuilder.appendln("Couldn't load Resource dictionary (${file.name}: ${e.message}")
+            errorBuilder.appendln("Couldn't load Resource dictionary (${file.name}: ${e.message})")
         }
     }
 }