aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt9
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt7
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt12
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt1
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt12
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt2
-rw-r--r--components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt4
-rw-r--r--components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt5
8 files changed, 43 insertions, 9 deletions
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt
index f6659e7db..f01f12620 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt
@@ -35,6 +35,8 @@ interface BluePrintNodeTemplateEnhancer : BluePrintEnhancer<NodeTemplate>
interface BluePrintNodeTypeEnhancer : BluePrintEnhancer<NodeType>
+interface BluePrintArtifactDefinitionEnhancer : BluePrintEnhancer<ArtifactDefinition>
+
interface BluePrintPolicyTypeEnhancer : BluePrintEnhancer<PolicyType>
interface BluePrintPropertyDefinitionEnhancer : BluePrintEnhancer<PropertyDefinition>
@@ -63,6 +65,8 @@ interface BluePrintTypeEnhancerService {
fun getNodeTypeEnhancers(): List<BluePrintNodeTypeEnhancer>
+ fun getArtifactDefinitionEnhancers(): List<BluePrintArtifactDefinitionEnhancer>
+
fun getPolicyTypeEnhancers(): List<BluePrintPolicyTypeEnhancer>
fun getPropertyDefinitionEnhancers(): List<BluePrintPropertyDefinitionEnhancer>
@@ -94,6 +98,11 @@ interface BluePrintTypeEnhancerService {
doEnhancement(bluePrintRuntimeService, name, nodeType, enhancers)
}
+ fun enhanceArtifactDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactDefinition: ArtifactDefinition) {
+ val enhancers = getArtifactDefinitionEnhancers()
+ doEnhancement(bluePrintRuntimeService, name, artifactDefinition, enhancers)
+ }
+
fun enhancePolicyType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, policyType: PolicyType) {
val enhancers = getPolicyTypeEnhancers()
doEnhancement(bluePrintRuntimeService, name, policyType, enhancers)
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
index cf518bd14..5540047c1 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
@@ -46,6 +46,8 @@ interface BluePrintRuntimeService<T> {
fun get(key: String): JsonNode?
+ fun check(key: String): Boolean
+
fun cleanRuntime()
fun getAsString(key: String): String?
@@ -114,6 +116,7 @@ interface BluePrintRuntimeService<T> {
open class DefaultBluePrintRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext)
: BluePrintRuntimeService<MutableMap<String, JsonNode>> {
+ @Transient
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRuntimeService::class.toString())
private var store: MutableMap<String, JsonNode> = hashMapOf()
@@ -145,6 +148,10 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
return store[key] ?: throw BluePrintProcessorException("failed to get execution property($key)")
}
+ override fun check(key: String): Boolean {
+ return store.containsKey(key)
+ }
+
override fun cleanRuntime() {
store.clear()
}
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt
index f02524ffa..c1ab4fc6e 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt
@@ -16,9 +16,12 @@
package org.onap.ccsdk.apps.controllerblueprints.core.utils
+import kotlinx.coroutines.async
+import kotlinx.coroutines.runBlocking
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream
import org.apache.commons.io.IOUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import java.io.*
import java.nio.charset.Charset
@@ -28,6 +31,15 @@ class BluePrintArchiveUtils {
companion object {
+ fun getFileContent(fileName: String): String = runBlocking {
+ async {
+ try {
+ File(fileName).readText(Charsets.UTF_8)
+ } catch (e: Exception) {
+ throw BluePrintException("couldn't find file($fileName)")
+ }
+ }.await()
+ }
fun compress(source: String, destination: String, absolute: Boolean): Boolean {
val rootDir = File(source)
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt
index 0ed901702..e3c2a710b 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt
@@ -23,6 +23,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import reactor.core.publisher.Mono
import reactor.core.publisher.toMono
+@Deprecated("Reactor will be replaced by coroutines by default")
object JacksonReactorUtils {
private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
index be23172a7..01874455a 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
@@ -25,10 +25,12 @@ import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.async
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import org.apache.commons.io.IOUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
import java.io.File
import java.nio.charset.Charset
@@ -55,12 +57,14 @@ object JacksonUtils {
}
@JvmStatic
- fun getContent(fileName: String): String {
- return runBlocking {
- withContext(Dispatchers.Default) {
+ fun getContent(fileName: String): String = runBlocking {
+ async {
+ try {
File(fileName).readText(Charsets.UTF_8)
+ } catch (e: Exception) {
+ throw BluePrintException("couldn't get file ($fileName) content : ${e.message}")
}
- }
+ }.await()
}
@JvmStatic
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt
index 1449e63df..0ed87f813 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt
@@ -242,7 +242,7 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) {
val artifactType = bluePrintContext.serviceTemplate.artifactTypes?.get(artifactTypeName)
- ?: throw BluePrintException("failed to artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)")
+ ?: throw BluePrintException("failed to get artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)")
checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom)
}
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt
index f7ffc3940..9348a237e 100644
--- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt
+++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt
@@ -18,7 +18,7 @@
package org.onap.ccsdk.apps.controllerblueprints.core.service
import org.junit.Test
-import java.io.FileNotFoundException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import kotlin.test.assertNotNull
/**
@@ -49,7 +49,7 @@ class BluePrintRepoFileServiceTest {
assertNotNull(nodeType, "Failed to get ArtifactType from repo")
}
- @Test(expected = FileNotFoundException::class)
+ @Test(expected = BluePrintException::class)
fun testModelNotFound() {
val dataType = bluePrintRepoFileService.getDataType("dt-not-found")
assertNotNull(dataType, "Failed to get DataType from repo")
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt
index be76593d8..ad55c7761 100644
--- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt
+++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt
@@ -19,11 +19,12 @@ 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.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate
-import java.io.FileNotFoundException
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
+@Deprecated("Reactor will be replacecd by coroutines by default.")
class JacksonReactorUtilsTest {
private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
@Test
@@ -43,7 +44,7 @@ class JacksonReactorUtilsTest {
assertNotNull(jsonContent, "Failed to get json Node")
}
- @Test(expected = FileNotFoundException::class)
+ @Test(expected = BluePrintException::class)
fun testReadValuesFailure() {
JacksonReactorUtils.jsonNodeFromFile("load/blueprints/not-found.json")
.block()