diff options
author | 2018-08-31 19:52:48 +0000 | |
---|---|---|
committer | 2018-08-31 19:52:48 +0000 | |
commit | 5dbc79162b53a0e97be4561719ae0e181944d2c8 (patch) | |
tree | 966a543d62a21df9d902f41ce47a0a464920235a /ms/controllerblueprints | |
parent | a6575b730739bc3e6a44e426758ca676d1f972b0 (diff) |
Controller Blueprints Microservice
Add resource assignment enhancer, resource definition repo functions and code improvements.
Change-Id: I751bf8149a36f80c20d48b86344cd6bd3054ed21
Issue-ID: CCSDK-431
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'ms/controllerblueprints')
42 files changed, 628 insertions, 195 deletions
diff --git a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java index 26b943b61..32d06d2ec 100644 --- a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java +++ b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java @@ -21,8 +21,8 @@ import org.junit.Before; import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class ControllerBluprintsApplicationTest {
- private static Logger log = LoggerFactory.getLogger(ControllerBluprintsApplicationTest.class);
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ControllerBluprintsApplicationTest.class);
@Autowired
private TestRestTemplate restTemplate;
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 85f1579e2..2e3edb65e 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 @@ -54,6 +54,8 @@ object BluePrintConstants { const val PATH_ATTRIBUTES: String = "attributes"
const val PATH_ARTIFACTS: String = "artifacts"
+ const val MODEL_DIR_MODEL_TYPE: String = "model_type"
+
const val MODEL_DEFINITION_TYPE_NODE_TYPE: String = "node_type"
const val MODEL_DEFINITION_TYPE_ARTIFACT_TYPE: String = "artifact_type"
const val MODEL_DEFINITION_TYPE_CAPABILITY_TYPE: String = "capability_type"
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 c90d65974..f38c317e7 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 @@ -23,6 +23,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.format
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils
import java.io.Serializable
/**
@@ -35,14 +36,23 @@ interface BluePrintEnhancerService : Serializable { @Throws(BluePrintException::class)
fun enhance(content: String): ServiceTemplate
- @Throws(BluePrintException::class)
- fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate
-
/**
* Read Blueprint from CSAR structure Directory
*/
@Throws(BluePrintException::class)
fun enhance(fileName: String, basePath: String): ServiceTemplate
+
+ @Throws(BluePrintException::class)
+ fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate
+
+ @Throws(BluePrintException::class)
+ fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate)
+
+ @Throws(BluePrintException::class)
+ fun enrichNodeType(nodeTypeName: String, nodeType: NodeType)
+
+ @Throws(BluePrintException::class)
+ fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition)
}
open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRepoService) : BluePrintEnhancerService {
@@ -51,20 +61,25 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe lateinit var serviceTemplate: ServiceTemplate
+ @Throws(BluePrintException::class)
override fun enhance(content: String): ServiceTemplate {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ return JacksonReactorUtils.readValueFromFile(content, ServiceTemplate::class.java).map { serviceTemplate ->
+ enhance(serviceTemplate!!)
+ }.block()!!
}
+ @Throws(BluePrintException::class)
override fun enhance(fileName: String, basePath: String): ServiceTemplate {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
+ @Throws(BluePrintException::class)
override fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate {
this.serviceTemplate = serviceTemplate
initialCleanUp()
enrichTopologyTemplate(serviceTemplate)
- // log.info("Enriched Blueprint :\n {}", JacksonUtils.getJson(serviceTemplate, true))
+ // log.info("Enriched Blueprint :\n {}", JacksonUtils.getJson(serviceTemplate, true))
return this.serviceTemplate
}
@@ -79,6 +94,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe }
+ @Throws(BluePrintException::class)
open fun enrichTopologyTemplate(serviceTemplate: ServiceTemplate) {
serviceTemplate.topologyTemplate?.let { topologyTemplate ->
enrichTopologyTemplateInputs(topologyTemplate)
@@ -86,6 +102,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe }
}
+ @Throws(BluePrintException::class)
open fun enrichTopologyTemplateInputs(topologyTemplate: TopologyTemplate) {
topologyTemplate.inputs?.let { inputs ->
enrichPropertyDefinitions(inputs)
@@ -99,7 +116,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe }
@Throws(BluePrintException::class)
- open fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) {
+ override fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) {
val nodeTypeName = nodeTemplate.type
// Get NodeType from Repo and Update Service Template
val nodeType = populateNodeType(nodeTypeName)
@@ -111,7 +128,8 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe enrichNodeTemplateArtifactDefinition(nodeTemplateName, nodeTemplate)
}
- open fun enrichNodeType(nodeTypeName: String, nodeType: NodeType) {
+ @Throws(BluePrintException::class)
+ override fun enrichNodeType(nodeTypeName: String, nodeType: NodeType) {
// NodeType Property Definitions
enrichNodeTypeProperties(nodeTypeName, nodeType)
@@ -132,7 +150,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe open fun enrichNodeTypeRequirements(nodeTypeName: String, nodeType: NodeType) {
- nodeType.requirements?.forEach { requirementDefinitionName, requirementDefinition ->
+ nodeType.requirements?.forEach { _, requirementDefinition ->
// Populate Requirement Node
requirementDefinition.node?.let { requirementNodeTypeName ->
// Get Requirement NodeType from Repo and Update Service Template
@@ -187,7 +205,8 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe }
}
- open fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition) {
+ @Throws(BluePrintException::class)
+ override fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition) {
val propertyType = propertyDefinition.type
if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt index 8d2557cdb..e1d1eac71 100644 --- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt +++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt @@ -17,15 +17,12 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service
-import com.google.common.base.Preconditions
-import org.apache.commons.io.FileUtils
-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.data.*
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils
import reactor.core.publisher.Mono
import java.io.File
import java.io.Serializable
@@ -57,15 +54,15 @@ interface BluePrintRepoService : Serializable { }
-class BluePrintRepoFileService(val basePath: String) : BluePrintRepoService {
+open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoService {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRepoFileService::class.toString())
- private val dataTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
- private val nodeTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE)
- private val artifactTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE)
- private val capabilityTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE)
- private val relationshipTypePath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE)
+ private val dataTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
+ private val nodeTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE)
+ private val artifactTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE)
+ private val capabilityTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE)
+ private val relationshipTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE)
private val extension = ".json"
override fun getDataType(dataTypeName: String): Mono<DataType>? {
@@ -98,17 +95,6 @@ class BluePrintRepoFileService(val basePath: String) : BluePrintRepoService { }
private fun <T> getModelType(fileName: String, valueType: Class<T>): Mono<T> {
- return getFileContent(fileName).map { content ->
- Preconditions.checkArgument(StringUtils.isNotBlank(content),
- String.format("Failed to get model content for file (%s)", fileName))
-
- JacksonUtils.readValue(content, valueType)
- ?: throw BluePrintException(String.format("Failed to get model file from content for file (%s)", fileName))
-
- }
- }
-
- private fun getFileContent(fileName: String): Mono<String> {
- return Mono.just(FileUtils.readFileToString(File(fileName), Charset.defaultCharset()))
+ return JacksonReactorUtils.readValueFromFile(fileName, valueType)
}
}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt new file mode 100644 index 000000000..0ed901702 --- /dev/null +++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt @@ -0,0 +1,108 @@ +/*
+ * 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.utils
+
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
+import reactor.core.publisher.Mono
+import reactor.core.publisher.toMono
+
+object JacksonReactorUtils {
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+
+ @JvmStatic
+ fun getContent(fileName: String): Mono<String> {
+ return JacksonUtils.getContent(fileName).toMono()
+ }
+
+ @JvmStatic
+ fun getClassPathFileContent(fileName: String): Mono<String> {
+ return JacksonUtils.getClassPathFileContent(fileName).toMono()
+ }
+
+ @JvmStatic
+ fun <T> readValue(content: String, valueType: Class<T>): Mono<T> {
+ return Mono.just(jacksonObjectMapper().readValue(content, valueType))
+ }
+
+ @JvmStatic
+ fun jsonNode(content: String): Mono<JsonNode> {
+ return Mono.just(jacksonObjectMapper().readTree(content))
+ }
+
+ @JvmStatic
+ fun getJson(any: kotlin.Any, pretty: Boolean = false): Mono<String> {
+ return Mono.just(JacksonUtils.getJson(any, pretty))
+ }
+
+ @JvmStatic
+ fun <T> getListFromJson(content: String, valueType: Class<T>): Mono<List<T>> {
+ val objectMapper = jacksonObjectMapper()
+ val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType)
+ return objectMapper.readValue<List<T>>(content, javaType).toMono()
+ }
+
+ @JvmStatic
+ fun <T> readValueFromFile(fileName: String, valueType: Class<T>): Mono<T> {
+ return getContent(fileName)
+ .flatMap { content ->
+ readValue(content, valueType)
+ }
+ }
+
+ @JvmStatic
+ fun <T> readValueFromClassPathFile(fileName: String, valueType: Class<T>): Mono<T> {
+ return getClassPathFileContent(fileName)
+ .flatMap { content ->
+ readValue(content, valueType)
+ }
+ }
+
+ @JvmStatic
+ fun jsonNodeFromFile(fileName: String): Mono<JsonNode> {
+ return getContent(fileName)
+ .flatMap { content ->
+ jsonNode(content)
+ }
+ }
+
+ @JvmStatic
+ fun jsonNodeFromClassPathFile(fileName: String): Mono<JsonNode> {
+ return getClassPathFileContent(fileName)
+ .flatMap { content ->
+ jsonNode(content)
+ }
+ }
+
+ @JvmStatic
+ fun <T> getListFromFile(fileName: String, valueType: Class<T>): Mono<List<T>> {
+ return getContent(fileName)
+ .flatMap { content ->
+ getListFromJson(content, valueType)
+ }
+ }
+
+ @JvmStatic
+ fun <T> getListFromClassPathFile(fileName: String, valueType: Class<T>): Mono<List<T>> {
+ return getClassPathFileContent(fileName)
+ .flatMap { content ->
+ getListFromJson(content, valueType)
+ }
+ }
+}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt index 7e72744c9..5075e7261 100644 --- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt +++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt @@ -23,9 +23,6 @@ import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.SerializationFeature
-import com.fasterxml.jackson.databind.node.ArrayNode
-import com.fasterxml.jackson.databind.node.NullNode
-import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import org.apache.commons.io.FileUtils
import org.apache.commons.io.IOUtils
@@ -53,6 +50,17 @@ object JacksonUtils { }
@JvmStatic
+ fun getContent(fileName: String): String {
+ return File(fileName).readText(Charsets.UTF_8)
+ }
+
+ @JvmStatic
+ fun getClassPathFileContent(fileName: String): String {
+ return IOUtils.toString(JacksonUtils::class.java.classLoader
+ .getResourceAsStream(fileName), Charset.defaultCharset())
+ }
+
+ @JvmStatic
fun <T> readValueFromFile(fileName: String, valueType: Class<T>): T? {
val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())
?: throw BluePrintException(format("Failed to read json file : {}", fileName))
@@ -61,8 +69,7 @@ object JacksonUtils { @JvmStatic
fun <T> readValueFromClassPathFile(fileName: String, valueType: Class<T>): T? {
- val content: String = IOUtils.toString(JacksonUtils::class.java.classLoader.getResourceAsStream(fileName), Charset.defaultCharset())
- ?: throw BluePrintException(String.format("Failed to read json file : %s", fileName))
+ val content: String = getClassPathFileContent(fileName)
return readValue(content, valueType)
}
@@ -71,8 +78,7 @@ object JacksonUtils { @JvmStatic
fun jsonNodeFromClassPathFile(fileName: String): JsonNode {
- val content: String = IOUtils.toString(JacksonUtils::class.java.classLoader.getResourceAsStream(fileName), Charset.defaultCharset())
- ?: throw BluePrintException(String.format("Failed to read json file : %s", fileName))
+ val content: String = getClassPathFileContent(fileName)
return jsonNode(content)
}
@@ -119,8 +125,7 @@ object JacksonUtils { @JvmStatic
fun <T> getListFromClassPathFile(fileName: String, valueType: Class<T>): List<T>? {
- val content: String = IOUtils.toString(JacksonUtils::class.java.classLoader.getResourceAsStream(fileName), Charset.defaultCharset())
- ?: throw BluePrintException(String.format("Failed to read json file : %s", fileName))
+ val content: String = getClassPathFileContent(fileName)
return getListFromJson(content, valueType)
}
@@ -144,39 +149,25 @@ object JacksonUtils { @JvmStatic
fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean {
when (primitiveType) {
- BluePrintConstants.DATA_TYPE_STRING -> {
- return jsonNode.isTextual
- }
- BluePrintConstants.DATA_TYPE_BOOLEAN -> {
- return jsonNode.isBoolean
- }
- BluePrintConstants.DATA_TYPE_INTEGER -> {
- return jsonNode.isInt
- }
- BluePrintConstants.DATA_TYPE_FLOAT -> {
- return jsonNode.isDouble
- }
- BluePrintConstants.DATA_TYPE_TIMESTAMP -> {
- return jsonNode.isTextual
- }
- else ->
- return false
+ BluePrintConstants.DATA_TYPE_STRING -> return jsonNode.isTextual
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> return jsonNode.isBoolean
+ BluePrintConstants.DATA_TYPE_INTEGER -> return jsonNode.isInt
+ BluePrintConstants.DATA_TYPE_FLOAT -> return jsonNode.isDouble
+ BluePrintConstants.DATA_TYPE_TIMESTAMP -> return jsonNode.isTextual
+ else -> return false
}
}
@JvmStatic
fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean {
when (type) {
- BluePrintConstants.DATA_TYPE_LIST ->
- return jsonNode.isArray
- BluePrintConstants.DATA_TYPE_MAP ->
- return jsonNode.isContainerNode
- else ->
- return false
+ BluePrintConstants.DATA_TYPE_LIST -> return jsonNode.isArray
+ BluePrintConstants.DATA_TYPE_MAP -> return jsonNode.isContainerNode
+ else -> return false
}
}
-
+/*
@JvmStatic
fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) {
if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) {
@@ -253,4 +244,5 @@ object JacksonUtils { objectNode.set(key, nodeValue)
}
}
+ */
}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt index 081f4fe3b..88aea919e 100644 --- a/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt +++ b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt @@ -28,30 +28,30 @@ import kotlin.test.assertNotNull */
class BluePrintRepoFileServiceTest {
- val basePath = "load/model_type"
+ private val basePath = "load/model_type"
private val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)
@Test
fun testGetDataType() {
- val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate")
+ val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate")?.block()
assertNotNull(dataType, "Failed to get DataType from repo")
}
@Test
fun testGetNodeType() {
- val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment")
+ val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment")?.block()
assertNotNull(nodeType, "Failed to get NodeType from repo")
}
@Test
fun testGetArtifactType() {
- val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity")
+ val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity")?.block()
assertNotNull(nodeType, "Failed to get ArtifactType from repo")
}
@Test(expected = FileNotFoundException::class)
fun testModelNotFound() {
- val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found")
+ val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found")?.block()
assertNotNull(dataType, "Failed to get DataType from repo")
}
}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt new file mode 100644 index 000000000..d13caa52c --- /dev/null +++ b/ms/controllerblueprints/modules/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt @@ -0,0 +1,51 @@ +/*
+ * 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.utils
+
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate
+import java.io.FileNotFoundException
+import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
+
+class JacksonReactorUtilsTest {
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+ @Test
+ fun testReadValues() {
+
+ val serviceTemplate = JacksonReactorUtils.readValueFromFile("load/blueprints/baseconfiguration/Definitions/activation-blueprint.json",
+ ServiceTemplate::class.java).block()
+
+ assertNotNull(serviceTemplate, "Failed to simple transform Service Template")
+ assertEquals(true, serviceTemplate is ServiceTemplate, "failed to get Service Template instance")
+
+ val jsonContent = JacksonReactorUtils.getJson(serviceTemplate!!, true).block()
+ assertNotNull(jsonContent, "Failed to get json content")
+
+ val jsonNode = JacksonReactorUtils.jsonNodeFromFile("load/blueprints/baseconfiguration/Definitions/activation-blueprint.json")
+ .block()
+ assertNotNull(jsonContent, "Failed to get json Node")
+ }
+
+ @Test(expected = FileNotFoundException::class)
+ fun testReadValuesFailure() {
+ JacksonReactorUtils.jsonNodeFromFile("load/blueprints/not-found.json")
+ .block()
+ }
+}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json index c53a6dd3f..92b16a212 100644 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json +++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json @@ -1,5 +1,5 @@ {
- "name": "bundle-id",
+ "name": "db-source",
"property" :{
"description": "name of the ",
"type": "string"
diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json index 91921b640..1c47f37b2 100644 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json +++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json @@ -1,6 +1,6 @@ {
"tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com",
- "name": "v4-ip-type",
+ "name": "default-source",
"property" :{
"description": "name of the ",
"type": "string"
diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json index c34c252b3..676d92f86 100644 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json +++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json @@ -1,5 +1,5 @@ {
- "name": "action-name",
+ "name": "input-source",
"property" :{
"description": "name of the ",
"type": "string"
diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json index 413d90446..b49146a0e 100644 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json +++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json @@ -1,6 +1,6 @@ {
"tags": "oam-local-ipv4-address",
- "name": "oam-local-ipv4-address",
+ "name": "mdsal-source",
"property" :{
"description": "based on service-instance-id,network-role,v4-ip-type and vm-type get the ipv4-gateway-prefix from the SDN-GC mdsal",
"type": "string"
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt index 9b89f6f40..aa6a9fb65 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt @@ -25,6 +25,8 @@ object ResourceDictionaryConstants { const val SOURCE_DEFAULT = "default" const val SOURCE_DB = "db" + const val MODEL_DIR_RESOURCE_DEFINITION: String = "resource_dictionary" + const val PROPERTY_TYPE = "type" const val PROPERTY_INPUT_KEY_MAPPING = "input-key-mapping" const val PROPERTY_OUTPUT_KEY_MAPPING = "output-key-mapping" diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt new file mode 100644 index 000000000..c5a78a9c9 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt @@ -0,0 +1,86 @@ +/*
+ * 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.resource.dict.service
+
+import com.att.eelf.configuration.EELFLogger
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDefaultService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerService
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
+import com.att.eelf.configuration.EELFManager
+
+/**
+ * ResourceAssignmentEnhancerService.
+ *
+ * @author Brinda Santh
+ */
+interface ResourceAssignmentEnhancerService {
+
+ @Throws(BluePrintException::class)
+ fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService,
+ resourceAssignments: List<ResourceAssignment>)
+
+ @Throws(BluePrintException::class)
+ fun enhanceBluePrint(resourceAssignments: List<ResourceAssignment>): ServiceTemplate
+}
+
+/**
+ * ResourceAssignmentEnhancerDefaultService.
+ *
+ * @author Brinda Santh
+ */
+open class ResourceAssignmentEnhancerDefaultService(private val resourceDefinitionRepoService: ResourceDefinitionRepoService)
+ : ResourceAssignmentEnhancerService {
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationDefaultService::class.java)
+
+ /**
+ * Get the defined source instance from the ResourceAssignment,
+ * then get the NodeType of the Sources assigned
+ */
+ override fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService,
+ resourceAssignments: List<ResourceAssignment>) {
+
+ // Iterate the Resource Assignment and
+ resourceAssignments.map { resourceAssignment ->
+ val dictionaryName = resourceAssignment.dictionaryName!!
+ val dictionarySource = resourceAssignment.dictionarySource!!
+ log.info("Enriching Assignment name({}), dictionary name({}), source({})", resourceAssignment.name,
+ dictionaryName, dictionarySource)
+ // Get the Resource Definition from Repo
+ val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName)
+
+ val sourceNodeTemplate = resourceDefinition.sources.get(dictionarySource)
+
+ // Enrich as NodeTemplate
+ bluePrintEnhancerService.enrichNodeTemplate(dictionarySource, sourceNodeTemplate!!)
+ }
+ }
+
+ override fun enhanceBluePrint(resourceAssignments: List<ResourceAssignment>): ServiceTemplate {
+ val bluePrintEnhancerService = BluePrintEnhancerDefaultService(resourceDefinitionRepoService)
+ bluePrintEnhancerService.serviceTemplate = ServiceTemplate()
+ bluePrintEnhancerService.initialCleanUp()
+ enhanceBluePrint(bluePrintEnhancerService, resourceAssignments)
+ return bluePrintEnhancerService.serviceTemplate
+ }
+
+ private fun getResourceDefinition(name: String): ResourceDefinition {
+ return resourceDefinitionRepoService.getResourceDefinition(name)!!.block()!!
+ }
+}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt index 4578aca7d..228b39e29 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt @@ -16,13 +16,14 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service +import com.att.eelf.configuration.EELFLogger import org.apache.commons.collections.CollectionUtils import org.apache.commons.lang3.StringUtils import org.apache.commons.lang3.text.StrBuilder import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment -import org.slf4j.LoggerFactory +import com.att.eelf.configuration.EELFManager import java.io.Serializable /** @@ -42,7 +43,7 @@ interface ResourceAssignmentValidationService : Serializable { * @author Brinda Santh */ open class ResourceAssignmentValidationDefaultService : ResourceAssignmentValidationService { - private val log = LoggerFactory.getLogger(ResourceAssignmentValidationDefaultService::class.java) + private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationDefaultService::class.java) open var resourceAssignmentMap: Map<String, ResourceAssignment> = hashMapOf() open val validationMessage = StrBuilder() diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt new file mode 100644 index 000000000..d51338caf --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt @@ -0,0 +1,61 @@ +/*
+ * 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.resource.dict.service
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoFileService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
+import reactor.core.publisher.Mono
+/**
+ * ResourceDefinitionRepoService.
+ *
+ * @author Brinda Santh
+ */
+interface ResourceDefinitionRepoService : BluePrintRepoService {
+
+ fun getResourceDefinition(resourceDefinitionName: String): Mono<ResourceDefinition>?
+}
+
+/**
+ * ResourceDefinitionFileRepoService.
+ *
+ * @author Brinda Santh
+ */
+open class ResourceDefinitionFileRepoService : BluePrintRepoFileService,
+ ResourceDefinitionRepoService {
+
+ private var resourceDefinitionPath: String
+ private val extension = ".json"
+
+ constructor(basePath: String) : this(basePath,
+ basePath.plus(BluePrintConstants.PATH_DIVIDER)
+ .plus(BluePrintConstants.MODEL_DIR_MODEL_TYPE))
+
+ constructor(basePath: String, modelTypePath: String) : super(modelTypePath) {
+ resourceDefinitionPath = basePath.plus("/resource_dictionary")
+ }
+
+ override fun getResourceDefinition(resourceDefinitionName: String): Mono<ResourceDefinition>? {
+
+ val fileName = resourceDefinitionPath.plus(BluePrintConstants.PATH_DIVIDER)
+ .plus(resourceDefinitionName).plus(extension)
+
+ return JacksonReactorUtils.readValueFromFile(fileName, ResourceDefinition::class.java)
+ }
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt index 1defa538c..14855d4b6 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt @@ -17,6 +17,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service +import com.att.eelf.configuration.EELFLogger import com.fasterxml.jackson.databind.JsonNode import com.google.common.base.Preconditions import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException @@ -29,7 +30,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpression 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 org.slf4j.LoggerFactory +import com.att.eelf.configuration.EELFManager import java.io.Serializable /** * ResourceDefinitionValidationService. @@ -49,7 +50,7 @@ interface ResourceDefinitionValidationService : Serializable { */ open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoService: BluePrintRepoService) : ResourceDefinitionValidationService { - private val log = LoggerFactory.getLogger(ResourceDefinitionValidationService::class.java) + private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDefinitionValidationService::class.java) override fun validate(resourceDefinition: ResourceDefinition) { Preconditions.checkNotNull(resourceDefinition, "Failed to get Resource Definition") diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt index 82fbd3ac1..747639c89 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt @@ -16,10 +16,11 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils
+import com.att.eelf.configuration.EELFLogger
import org.apache.commons.collections.CollectionUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.slf4j.LoggerFactory
+import com.att.eelf.configuration.EELFManager
import java.util.ArrayList
/**
* BulkResourceSequencingUtils.
@@ -27,7 +28,7 @@ import java.util.ArrayList * @author Brinda Santh
*/
object BulkResourceSequencingUtils {
- private val log = LoggerFactory.getLogger(BulkResourceSequencingUtils::class.java)
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BulkResourceSequencingUtils::class.java)
@JvmStatic
fun process(resourceAssignments: MutableList<ResourceAssignment>): List<List<ResourceAssignment>> {
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt index 733a443fd..a3456cd43 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt @@ -16,6 +16,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils +import com.att.eelf.configuration.EELFLogger import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode import org.apache.commons.collections.MapUtils @@ -25,11 +26,11 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants -import org.slf4j.LoggerFactory +import com.att.eelf.configuration.EELFManager object ResourceDictionaryUtils { - private val log = LoggerFactory.getLogger(ResourceDictionaryUtils::class.java) + private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDictionaryUtils::class.java) @JvmStatic fun populateSourceMapping(resourceAssignment: ResourceAssignment, diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java index 3e68d0991..fde800057 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java @@ -20,12 +20,12 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict; import org.junit.Assert;
import org.junit.Test;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
public class ResourceDefinitionTest {
- private Logger log = LoggerFactory.getLogger(ResourceDefinitionTest.class);
- String basePath = "load/resource_dictionary";
+ private EELFLogger log = EELFManager.getInstance().getLogger(ResourceDefinitionTest.class);
+ private String basePath = "load/resource_dictionary";
@Test
public void testDictionaryDefinitionInputSource(){
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerServiceTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerServiceTest.java new file mode 100644 index 000000000..57c8509d1 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerServiceTest.java @@ -0,0 +1,48 @@ +/*
+ * 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.resource.dict.service;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+
+import java.util.List;
+
+/**
+ * ResourceAssignmentEnhancerService.
+ *
+ * @author Brinda Santh
+ */
+public class ResourceAssignmentEnhancerServiceTest {
+
+ @Test
+ public void testEnhanceBluePrint() throws BluePrintException {
+
+ List<ResourceAssignment> resourceAssignments = JacksonReactorUtils
+ .getListFromClassPathFile("enrich/simple-enrich.json", ResourceAssignment.class).block();
+ Assert.assertNotNull("Failed to get Resource Assignment", resourceAssignments);
+ ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("load");
+ ResourceAssignmentEnhancerService resourceAssignmentEnhancerService =
+ new ResourceAssignmentEnhancerDefaultService(resourceDefinitionRepoService);
+ ServiceTemplate serviceTemplate = resourceAssignmentEnhancerService.enhanceBluePrint(resourceAssignments);
+ Assert.assertNotNull("Failed to get Enriched service Template", serviceTemplate);
+ }
+}
+
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt index 4d8301f4e..6216d5bf0 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt @@ -16,19 +16,20 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service
+import com.att.eelf.configuration.EELFLogger
import org.junit.Assert
import org.junit.Test
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.slf4j.LoggerFactory
+import com.att.eelf.configuration.EELFManager
/**
* ResourceAssignmentValidationServiceTest.
*
* @author Brinda Santh
*/
class ResourceAssignmentValidationServiceTest {
- private val log = LoggerFactory.getLogger(ResourceAssignmentValidationServiceTest::class.java)
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationServiceTest::class.java)
@Test
fun testValidateSuccess() {
log.info("**************** testValidateSuccess *****************")
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java new file mode 100644 index 000000000..1772277df --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java @@ -0,0 +1,36 @@ +/*
+ * 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.resource.dict.service;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
+
+public class ResourceDefinitionRepoServiceTest {
+
+ @Test
+ public void testGetResourceDefinition() throws Exception{
+ ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("load");
+ ResourceDefinition resourceDefinition = resourceDefinitionRepoService
+ .getResourceDefinition("db-source").block();
+ Assert.assertNotNull("Failed to get Resource Definition db-source", resourceDefinition);
+
+ NodeType nodeType = resourceDefinitionRepoService.getNodeType("source-db").block();
+ Assert.assertNotNull("Failed to get Node Type source-db", resourceDefinition);
+ }
+}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java index 5ee561713..13bf8195e 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java @@ -27,8 +27,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import java.util.HashMap;
import java.util.Map;
@@ -38,12 +38,13 @@ import java.util.Map; * @author Brinda Santh
*/
public class ResourceDictionaryUtilsTest {
- private static final Logger log = LoggerFactory.getLogger(ResourceDictionaryUtilsTest.class);
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(ResourceDictionaryUtilsTest.class);
@Test
public void testPopulateSourceMapping() {
ResourceAssignment resourceAssignment = new ResourceAssignment();
+ resourceAssignment.setName("sample-assignment");
ResourceDefinition resourceDefinition = new ResourceDefinition();
Map<String, NodeTemplate> sources = new HashMap<>();
resourceDefinition.setSources(sources);
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/resources/enrich/simple-enrich.json b/ms/controllerblueprints/modules/resource-dict/src/test/resources/enrich/simple-enrich.json new file mode 100644 index 000000000..641da80a2 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/resources/enrich/simple-enrich.json @@ -0,0 +1,37 @@ +[
+ {
+ "name": "rs-db-source",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "db-source",
+ "dictionary-source": "db",
+ "dependencies": [
+ "input-source"
+ ]
+ },
+ {
+ "name": "ra-default-source",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "default-source",
+ "dictionary-source": "default",
+ "dependencies": []
+ },
+ {
+ "name": "ra-input-source",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "input-source",
+ "dictionary-source": "input",
+ "dependencies": []
+ }
+]
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java index 5eba4fc7f..428c52451 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/AutoResourceMappingService.java @@ -29,8 +29,8 @@ import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDict import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@@ -49,7 +49,7 @@ import java.util.Map; @SuppressWarnings("unused")
public class AutoResourceMappingService {
- private static Logger log = LoggerFactory.getLogger(AutoResourceMappingService.class);
+ private static EELFLogger log = EELFManager.getInstance().getLogger(AutoResourceMappingService.class);
private ResourceDictionaryRepository dataDictionaryRepository;
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 28be75e66..8e98f9477 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 @@ -29,8 +29,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDe 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;
-import org.slf4j.LoggerFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.springframework.stereotype.Service;
import java.util.HashMap;
@@ -46,7 +46,7 @@ import java.util.Map; @Service
public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService {
- private static Logger log = LoggerFactory.getLogger(BluePrintEnhancerService.class);
+ private static EELFLogger log = EELFManager.getInstance().getLogger(BluePrintEnhancerService.class);
private Map<String, DataType> recipeDataTypes = new HashMap<>();
@@ -55,7 +55,7 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { }
@Override
- public void enrichTopologyTemplate(@NotNull ServiceTemplate serviceTemplate) {
+ public void enrichTopologyTemplate(@NotNull ServiceTemplate serviceTemplate) throws BluePrintException{
super.enrichTopologyTemplate(serviceTemplate);
// Update the Recipe Inputs and DataTypes
@@ -143,7 +143,7 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { }
private Map<String, PropertyDefinition> getCapabilityMappingProperties(String nodeTemplateName,
- NodeTemplate nodeTemplate) {
+ NodeTemplate nodeTemplate) throws BluePrintException {
Map<String, PropertyDefinition> dataTypeProperties = null;
if (nodeTemplate != null && MapUtils.isNotEmpty(nodeTemplate.getCapabilities())) {
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java index 9c1a045cd..3c92f7e94 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java @@ -31,8 +31,8 @@ import org.onap.ccsdk.apps.controllerblueprints.service.common.ApplicationConsta import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelRepository;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.springframework.stereotype.Service;
import java.io.IOException;
@@ -52,7 +52,7 @@ import java.util.Optional; @Service
public class ConfigModelCreateService {
- private static Logger log = LoggerFactory.getLogger(ConfigModelCreateService.class);
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ConfigModelCreateService.class);
private ConfigModelRepository configModelRepository;
private ConfigModelValidatorService configModelValidatorService;
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java index b729e3e6d..534394a3e 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java @@ -29,8 +29,8 @@ import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelContentRepository;
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelRepository;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -49,7 +49,7 @@ import java.util.Optional; @Service
public class ConfigModelService {
- private static Logger log = LoggerFactory.getLogger(ConfigModelService.class);
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ConfigModelService.class);
private ConfigModelRepository configModelRepository;
private ConfigModelContentRepository configModelContentRepository;
@@ -57,14 +57,14 @@ public class ConfigModelService { /**
* This is a ConfigModelService constructor.
- *
- * @param configModelRepository
- * @param configModelContentRepository
- * @param configModelCreateService
+ *
+ * @param configModelRepository configModelRepository
+ * @param configModelContentRepository configModelContentRepository
+ * @param configModelCreateService configModelCreateService
*/
public ConfigModelService(ConfigModelRepository configModelRepository,
- ConfigModelContentRepository configModelContentRepository,
- ConfigModelCreateService configModelCreateService) {
+ ConfigModelContentRepository configModelContentRepository,
+ ConfigModelCreateService configModelCreateService) {
this.configModelRepository = configModelRepository;
this.configModelContentRepository = configModelContentRepository;
this.configModelCreateService = configModelCreateService;
@@ -72,10 +72,10 @@ public class ConfigModelService { /**
* This is a getInitialConfigModel method
- *
- * @param templateName
+ *
+ * @param templateName templateName
* @return ConfigModel
- * @throws BluePrintException
+ * @throws BluePrintException BluePrintException
*/
public ConfigModel getInitialConfigModel(String templateName) throws BluePrintException {
ConfigModel configModel = null;
@@ -100,10 +100,10 @@ public class ConfigModelService { /**
* This is a saveConfigModel method
- *
- * @param configModel
+ *
+ * @param configModel configModel
* @return ConfigModel
- * @throws BluePrintException
+ * @throws BluePrintException BluePrintException
*/
public ConfigModel saveConfigModel(ConfigModel configModel) throws BluePrintException {
return this.configModelCreateService.saveConfigModel(configModel);
@@ -111,10 +111,10 @@ public class ConfigModelService { /**
* This is a publishConfigModel method
- *
- * @param id
+ *
+ * @param id id
* @return ConfigModel
- * @throws BluePrintException
+ * @throws BluePrintException BluePrintException
*/
public ConfigModel publishConfigModel(Long id) throws BluePrintException {
return this.configModelCreateService.publishConfigModel(id);
@@ -122,8 +122,8 @@ public class ConfigModelService { /**
* This is a searchConfigModels method
- *
- * @param tags
+ *
+ * @param tags tags
* @return ConfigModel
*/
public List<ConfigModel> searchConfigModels(String tags) {
@@ -138,9 +138,9 @@ public class ConfigModelService { /**
* This is a getConfigModelByNameAndVersion method
- *
- * @param name
- * @param version
+ *
+ * @param name name
+ * @param version version
* @return ConfigModel
*/
public ConfigModel getConfigModelByNameAndVersion(String name, String version) {
@@ -159,8 +159,8 @@ public class ConfigModelService { /**
* This is a getConfigModel method
- *
- * @param id
+ *
+ * @param id id
* @return ConfigModel
*/
public ConfigModel getConfigModel(Long id) {
@@ -176,9 +176,9 @@ public class ConfigModelService { /**
* This method returns clone of the given model id, by masking the other unrelated fields
- *
- * @param id
- * @return
+ *
+ * @param id id
+ * @return ConfigModel
*/
public ConfigModel getCloneConfigModel(Long id) {
@@ -232,8 +232,8 @@ public class ConfigModelService { /**
* This is a deleteConfigModel method
- *
- * @param id
+ *
+ * @param id id
*/
@Transactional
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java index 89d482962..4e7c3911c 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java @@ -22,6 +22,7 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.text.StrBuilder;
+import org.jetbrains.annotations.NotNull;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType;
@@ -33,8 +34,8 @@ import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -58,7 +59,7 @@ import java.util.List; @ConditionalOnProperty(name = "blueprints.load.initial-data", havingValue = "true")
public class DataBaseInitService {
- private static Logger log = LoggerFactory.getLogger(DataBaseInitService.class);
+ private static EELFLogger log = EELFManager.getInstance().getLogger(DataBaseInitService.class);
@Value("${blueprints.load.path}")
private String modelLoadPath;
private ModelTypeService modelTypeService;
@@ -91,6 +92,7 @@ public class DataBaseInitService { }
@PostConstruct
+ @SuppressWarnings("unused")
private void initDatabase() {
log.info("loading Blueprints from DIR : {}", modelLoadPath);
dataTypePath = modelLoadPath + "/model_type/data_type";
@@ -263,7 +265,7 @@ public class DataBaseInitService { }
}
- private void loadDataType(Resource file, StrBuilder errorBuilder) {
+ private void loadDataType(@NotNull Resource file, StrBuilder errorBuilder) {
try {
log.trace("Loading Data Type: {}", file.getFilename());
String dataKey = file.getFilename().replace(".json", "");
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java index a75651f19..04a95fd12 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java @@ -24,8 +24,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType; import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.service.common.SwaggerGenerator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import java.util.HashMap;
import java.util.Map;
@@ -39,7 +39,7 @@ import java.util.Map; */
public class SchemaGeneratorService {
- private static Logger log = LoggerFactory.getLogger(SchemaGeneratorService.class);
+ private static EELFLogger log = EELFManager.getInstance().getLogger(SchemaGeneratorService.class);
private Map<String, DataType> dataTypes;
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ServiceTemplateService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ServiceTemplateService.java index 3e3c8e286..898647eaa 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ServiceTemplateService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ServiceTemplateService.java @@ -81,7 +81,7 @@ public class ServiceTemplateService { * @param serviceTemplate serviceTemplate
* @return ServiceTemplate
*/
- public ServiceTemplate enrichServiceTemplate(ServiceTemplate serviceTemplate) {
+ public ServiceTemplate enrichServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
this.bluePrintEnhancerService.enhance(serviceTemplate);
return serviceTemplate;
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java index 60b3ed6b0..ae374a786 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java @@ -76,12 +76,11 @@ public class ConfigModelContent { @Override
public String toString() {
- StringBuilder builder = new StringBuilder("[");
- builder.append("id = " + id);
- builder.append(", name = " + name);
- builder.append(", contentType = " + contentType);
- builder.append("]");
- return builder.toString();
+ String builder = "[" + "id = " + id +
+ ", name = " + name +
+ ", contentType = " + contentType +
+ "]";
+ return builder;
}
@Override
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java index eaa335b3e..cb8d229f3 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java @@ -82,17 +82,16 @@ public class ModelType implements Serializable { @Override
public String toString() {
- StringBuilder buffer = new StringBuilder("[");
- buffer.append(", modelName = " + modelName);
- buffer.append(", derivedFrom = " + derivedFrom);
- buffer.append(", definitionType = " + definitionType);
- buffer.append(", description = " + description);
- buffer.append(", creationDate = " + creationDate);
- buffer.append(", version = " + version);
- buffer.append(", updatedBy = " + updatedBy);
- buffer.append(", tags = " + tags);
- buffer.append("]");
- return buffer.toString();
+ String buffer = "[" + ", modelName = " + modelName +
+ ", derivedFrom = " + derivedFrom +
+ ", definitionType = " + definitionType +
+ ", description = " + description +
+ ", creationDate = " + creationDate +
+ ", version = " + version +
+ ", updatedBy = " + updatedBy +
+ ", tags = " + tags +
+ "]";
+ return buffer;
}
public String getModelName() {
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java index 487586842..c88462202 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java @@ -92,20 +92,19 @@ public class ResourceDictionary implements Serializable { @Override
public String toString() {
- StringBuilder buffer = new StringBuilder("[");
- buffer.append(", name = " + name);
- buffer.append(", resourcePath = " + resourcePath);
- buffer.append(", resourceType = " + resourceType);
- buffer.append(", dataType = " + dataType);
- buffer.append(", entrySchema = " + entrySchema);
- buffer.append(", validValues = " + validValues);
- buffer.append(", definition =" + definition);
- buffer.append(", description = " + description);
- buffer.append(", updatedBy = " + updatedBy);
- buffer.append(", tags = " + tags);
- buffer.append(", creationDate = " + creationDate);
- buffer.append("]");
- return buffer.toString();
+ String buffer = "[" + ", name = " + name +
+ ", resourcePath = " + resourcePath +
+ ", resourceType = " + resourceType +
+ ", dataType = " + dataType +
+ ", entrySchema = " + entrySchema +
+ ", validValues = " + validValues +
+ ", definition =" + definition +
+ ", description = " + description +
+ ", updatedBy = " + updatedBy +
+ ", tags = " + tags +
+ ", creationDate = " + creationDate +
+ "]";
+ return buffer;
}
public String getResourcePath() {
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java index bfc89b4ee..dc24c3bfe 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java @@ -27,8 +27,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData; import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import java.io.File;
import java.io.IOException;
@@ -43,7 +43,7 @@ public class ConfigModelUtils { }
- private static Logger log = LoggerFactory.getLogger(ConfigModelUtils.class);
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ConfigModelUtils.class);
public static ConfigModel getConfigModel(String blueprintPath) throws Exception {
Preconditions.checkArgument(StringUtils.isNotBlank(blueprintPath), "Blueprint Path is missing");
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SchemaGeneratorServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SchemaGeneratorServiceTest.java index f846e9a11..b70651fba 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SchemaGeneratorServiceTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SchemaGeneratorServiceTest.java @@ -22,8 +22,8 @@ import org.junit.FixMethodOrder; import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.onap.ccsdk.apps.controllerblueprints.service.SchemaGeneratorService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import java.io.File;
import java.nio.charset.Charset;
@@ -32,7 +32,7 @@ import java.nio.charset.Charset; @FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class SchemaGeneratorServiceTest {
- private static Logger log = LoggerFactory.getLogger(SchemaGeneratorServiceTest.class);
+ private static EELFLogger log = EELFManager.getInstance().getLogger(SchemaGeneratorServiceTest.class);
@Test
public void test01GenerateSwaggerData() throws Exception {
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java index a4a787b08..4fa827c2a 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java @@ -22,8 +22,8 @@ import org.junit.runners.MethodSorters; import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -38,7 +38,7 @@ import java.util.List; @FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ConfigModelRestTest {
- private static Logger log = LoggerFactory.getLogger(ConfigModelRestTest.class);
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ConfigModelRestTest.class);
@Autowired
ConfigModelRest configModelRest;
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java index 08bfeb10c..8e88f0a69 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java @@ -23,8 +23,8 @@ import org.junit.runners.MethodSorters; import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -40,7 +40,7 @@ import java.util.List; @ContextConfiguration(classes = {TestApplication.class})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ModelTypeRestTest {
- private static Logger log = LoggerFactory.getLogger(ModelTypeRestTest.class);
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ModelTypeRestTest.class);
@Autowired
ModelTypeRest modelTypeRest;
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java index ec036eef3..8bb1f0b89 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java @@ -25,8 +25,8 @@ import org.junit.runner.RunWith; import org.junit.runners.MethodSorters;
import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -44,7 +44,7 @@ import java.util.List; @FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ResourceDictionaryRestTest {
- private static Logger log = LoggerFactory.getLogger(ResourceDictionaryRestTest.class);
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ResourceDictionaryRestTest.class);
@Autowired
protected ResourceDictionaryRest resourceDictionaryRest;
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java index fdc68e4e5..217eb8f06 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java @@ -30,8 +30,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -49,7 +49,7 @@ import java.util.List; @FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ServiceTemplateRestTest {
- private static Logger log = LoggerFactory.getLogger(ServiceTemplateRestTest.class);
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ServiceTemplateRestTest.class);
@Autowired
ModelTypeRest modelTypeRest;
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java index e41e90a2d..93ea4c498 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java @@ -23,15 +23,15 @@ import org.junit.Test; import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import java.io.File;
import java.nio.charset.Charset;
import java.util.List;
public class ServiceTemplateValidationTest {
- private static Logger log = LoggerFactory.getLogger(ServiceTemplateValidationTest.class);
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ServiceTemplateValidationTest.class);
@Test
public void testBluePrintDirs() {
|