aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt46
-rwxr-xr-xcomponents/model-catalog/blueprint-model/test-blueprints/CBA_Zip_Test.zipbin0 -> 5382 bytes
-rw-r--r--components/parent/pom.xml9
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/ResourceAssignmentProcessor.kt3
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt3
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt52
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt4
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt8
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt69
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/utils/WebClientUtils.kt44
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt69
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt4
-rw-r--r--ms/blueprintsprocessor/parent/pom.xml5
-rwxr-xr-x[-rw-r--r--]ms/controllerblueprints/application/opt/app/onap/config/application-dev.properties5
-rwxr-xr-x[-rw-r--r--]ms/controllerblueprints/application/opt/app/onap/config/application.properties5
-rwxr-xr-x[-rw-r--r--]ms/controllerblueprints/application/src/test/resources/application.properties8
-rwxr-xr-xms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CBAContentService.java97
-rwxr-xr-xms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaFileManagementService.java128
-rwxr-xr-xms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaService.java192
-rwxr-xr-xms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaToDatabaseService.java132
-rwxr-xr-x[-rw-r--r--]ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java8
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java148
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java165
-rwxr-xr-xms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/CbaContent.java114
-rwxr-xr-x[-rw-r--r--]ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java12
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java2
-rwxr-xr-xms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/BlueprintModelResponse.java78
-rwxr-xr-xms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/ItemCbaResponse.java58
-rwxr-xr-xms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/CBAContentRepository.java59
-rwxr-xr-xms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/CbaRest.java84
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java10
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java22
-rwxr-xr-xms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/CbaStateEnum.java15
-rwxr-xr-xms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/CloseCondition.java36
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt4
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ModelTypeController.kt56
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ModelTypeHandler.kt116
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt138
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt10
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ResourceDictionaryLoadService.kt6
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.kt (renamed from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java)192
-rwxr-xr-xms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaFileManagementServiceTest.java89
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java23
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java46
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java3
-rwxr-xr-x[-rw-r--r--]ms/controllerblueprints/modules/service/src/test/resources/application.properties8
-rw-r--r--ms/controllerblueprints/parent/pom.xml5
47 files changed, 1883 insertions, 507 deletions
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt
index 67ae3987..2be9f19c 100644..100755
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt
@@ -20,6 +20,7 @@ import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
import kotlinx.coroutines.runBlocking
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.ImportDefinition
@@ -28,7 +29,16 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import java.io.File
import java.io.FileFilter
import java.nio.file.Files
+import java.nio.file.Path
+import java.nio.file.Paths
import java.nio.file.StandardOpenOption
+import java.text.MessageFormat
+import java.time.Instant
+import java.time.temporal.ChronoUnit
+import java.time.ZoneId
+import java.time.format.DateTimeFormatter
+
+
class BluePrintFileUtils {
companion object {
@@ -196,6 +206,42 @@ class BluePrintFileUtils {
"\nEntry-Definitions: Definitions/<BLUEPRINT_NAME>.json" +
"\nTemplate-Tags: <TAGS>"
}
+
+ fun getBluePrintFile(fileName: String, targetPath: Path) : File {
+ val filePath = targetPath.resolve(fileName).toString()
+ val file = File(filePath)
+ check(file.exists()) {
+ throw BluePrintException("couldn't get definition file under path(${file.absolutePath})")
+ }
+ return file
+ }
+
+ fun getCBAGeneratedFileName(fileName: String, prefix: String): String {
+ val DATE_FORMAT = "yyyyMMddHHmmss"
+ val formatter = DateTimeFormatter.ofPattern(DATE_FORMAT)
+ val datePrefix = Instant.now().atZone(ZoneId.systemDefault()).toLocalDateTime().format(formatter)
+ return MessageFormat.format(prefix, datePrefix, fileName)
+ }
+
+ fun getCbaStorageDirectory(path: String): Path {
+ check(StringUtils.isNotBlank(path)) {
+ throw BluePrintException("CBA Path is missing.")
+ }
+
+ val fileStorageLocation = Paths.get(path).toAbsolutePath().normalize()
+
+ if (!Files.exists(fileStorageLocation))
+ Files.createDirectories(fileStorageLocation)
+
+ return fileStorageLocation
+ }
+
+ fun stripFileExtension(fileName: String): String {
+ val dotIndexe = fileName.lastIndexOf('.')
+
+ // In case dot is in first position, we are dealing with a hidden file rather than an extension
+ return if (dotIndexe > 0) fileName.substring(0, dotIndexe) else fileName
+ }
}
} \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/test-blueprints/CBA_Zip_Test.zip b/components/model-catalog/blueprint-model/test-blueprints/CBA_Zip_Test.zip
new file mode 100755
index 00000000..77882ef1
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprints/CBA_Zip_Test.zip
Binary files differ
diff --git a/components/parent/pom.xml b/components/parent/pom.xml
index 03656ebd..1330279e 100644
--- a/components/parent/pom.xml
+++ b/components/parent/pom.xml
@@ -120,6 +120,11 @@
<version>${kotlin.couroutines.version}</version>
</dependency>
<dependency>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-reactor</artifactId>
+ <version>${kotlin.couroutines.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${kotlin.version}</version>
@@ -259,6 +264,10 @@
<artifactId>kotlinx-coroutines-core</artifactId>
</dependency>
<dependency>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-reactor</artifactId>
+ </dependency>
+ <dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
</dependency>
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/ResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/ResourceAssignmentProcessor.kt
index d13df9bc..a55e615e 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/ResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/ResourceAssignmentProcessor.kt
@@ -55,7 +55,4 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
return prepareResponse()
}
- override abstract fun process(executionRequest: ResourceAssignment)
-
- override abstract fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment)
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt
index faf4fd4d..41e45458 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt
@@ -23,10 +23,11 @@ open class RestClientProperties {
}
open class BasicAuthRestClientProperties : RestClientProperties() {
- var passwd: String? = null
+ var token: String? = null
}
open class SSLBasicAuthRestClientProperties : RestClientProperties() {
+ lateinit var keyStoreInstance: String // JKS, PKCS12
lateinit var sslTrust: String
lateinit var sslTrustPasswd: String
lateinit var sslKey: String
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
index b79034b4..130706d7 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
@@ -16,22 +16,64 @@
package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.BasicAuthRestClientProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.utils.WebClientUtils
+import org.springframework.http.HttpHeaders
+import org.springframework.http.MediaType
+import org.springframework.web.reactive.function.BodyInserters
+import org.springframework.web.reactive.function.client.ExchangeFilterFunctions
import org.springframework.web.reactive.function.client.WebClient
-class BasicAuthRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService {
+class BasicAuthRestClientService(private val restClientProperties: BasicAuthRestClientProperties) : BlueprintWebClientService {
+
+ private var webClient: WebClient? = null
override fun webClient(): WebClient {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ if (webClient == null) {
+ webClient = WebClient.builder()
+ .baseUrl(restClientProperties.url)
+ .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
+ .defaultHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
+ .filter(ExchangeFilterFunctions
+ .basicAuthentication(restClientProperties.userId, restClientProperties.token))
+ .filter(WebClientUtils.logRequest())
+ .filter(WebClientUtils.logResponse())
+ .build()
+ }
+ return webClient!!
}
override fun <T> getResource(path: String, responseType: Class<T>): T {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ return getResource(path, null, responseType)
+ }
+
+ override fun <T> getResource(path: String, headers: Map<String, String>?, responseType: Class<T>): T {
+ return webClient().get()
+ .uri(path)
+ .headers { httpHeaders ->
+ headers?.forEach {
+ httpHeaders.set(it.key, it.value)
+ }
+ }
+ .retrieve()
+ .bodyToMono(responseType).block()!!
}
override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ return postResource(path, null, request, responseType)
+ }
+
+ override fun <T> postResource(path: String, headers: Map<String, String>?, request: Any, responseType: Class<T>): T {
+ return webClient().post()
+ .uri(path)
+ .headers { httpHeaders ->
+ headers?.forEach {
+ httpHeaders.set(it.key, it.value)
+ }
+ }
+ .body(BodyInserters.fromObject(request))
+ .retrieve().bodyToMono(responseType).block()!!
}
override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
index 232f4bb0..8106c077 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
@@ -24,8 +24,12 @@ interface BlueprintWebClientService {
fun <T> getResource(path: String, responseType: Class<T>): T
+ fun <T> getResource(path: String, headers: Map<String, String>?, responseType: Class<T>): T
+
fun <T> postResource(path: String, request: Any, responseType: Class<T>): T
+ fun <T> postResource(path: String, headers: Map<String, String>?, request: Any, responseType: Class<T>): T
+
fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T
}
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt
index bd46ced1..27dbe6f8 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt
@@ -28,10 +28,18 @@ class DME2ProxyRestClientService(restClientProperties: RestClientProperties) : B
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
+ override fun <T> getResource(path: String, headers: Map<String, String>?, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
+ override fun <T> postResource(path: String, headers: Map<String, String>?, request: Any, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt
index 8b4add10..71727b93 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt
@@ -16,20 +16,79 @@
package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
+import io.netty.handler.ssl.SslContextBuilder
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.SSLBasicAuthRestClientProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.utils.WebClientUtils
+import org.springframework.http.HttpHeaders
+import org.springframework.http.MediaType
+import org.springframework.http.client.reactive.ReactorClientHttpConnector
+import org.springframework.web.reactive.function.BodyInserters
import org.springframework.web.reactive.function.client.WebClient
+import reactor.netty.http.client.HttpClient
+import java.io.File
+import java.security.KeyStore
+import java.security.cert.X509Certificate
+
+
+class SSLBasicAuthRestClientService(private val restClientProperties: SSLBasicAuthRestClientProperties) : BlueprintWebClientService {
-class SSLBasicAuthRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService {
override fun webClient(): WebClient {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+
+ // Load the Keystore Information
+ val ketInputStream = File(restClientProperties.sslKey).inputStream()
+ val ks = KeyStore.getInstance(restClientProperties.keyStoreInstance)
+ ks.load(ketInputStream, restClientProperties.sslKeyPasswd.toCharArray())
+
+ // Manage Trust Store
+ val trustCertCollection = ks.aliases().toList().map { alias ->
+ ks.getCertificate(alias) as X509Certificate
+ }.toTypedArray()
+ val sslContext = SslContextBuilder
+ .forClient()
+ .trustManager(*trustCertCollection)
+ .build()
+
+ // Create Http Client
+ val httpClient = HttpClient.create().secure { t -> t.sslContext(sslContext) }
+
+ return WebClient.builder()
+ .baseUrl(restClientProperties.url)
+ .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
+ .defaultHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
+ .filter(WebClientUtils.logRequest())
+ .clientConnector(ReactorClientHttpConnector(httpClient)).build()
}
override fun <T> getResource(path: String, responseType: Class<T>): T {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ return getResource(path, null, responseType)
+ }
+
+ override fun <T> getResource(path: String, headers: Map<String, String>?, responseType: Class<T>): T {
+ return webClient().get()
+ .uri(path)
+ .headers { httpHeaders ->
+ headers?.forEach {
+ httpHeaders.set(it.key, it.value)
+ }
+ }
+ .retrieve()
+ .bodyToMono(responseType).block()!!
}
override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ return postResource(path, null, request, responseType)
+ }
+
+ override fun <T> postResource(path: String, headers: Map<String, String>?, request: Any, responseType: Class<T>): T {
+ return webClient().post()
+ .uri(path)
+ .headers { httpHeaders ->
+ headers?.forEach {
+ httpHeaders.set(it.key, it.value)
+ }
+ }
+ .body(BodyInserters.fromObject(request))
+ .retrieve().bodyToMono(responseType).block()!!
}
override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/utils/WebClientUtils.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/utils/WebClientUtils.kt
new file mode 100644
index 00000000..40d6ba63
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/utils/WebClientUtils.kt
@@ -0,0 +1,44 @@
+/*
+ * 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.blueprintsprocessor.rest.utils
+
+import org.slf4j.LoggerFactory
+import org.springframework.web.reactive.function.client.ExchangeFilterFunction
+import reactor.core.publisher.Mono
+
+
+class WebClientUtils {
+ companion object {
+
+ val log = LoggerFactory.getLogger(WebClientUtils::class.java)!!
+
+ fun logRequest(): ExchangeFilterFunction {
+
+ return ExchangeFilterFunction.ofRequestProcessor { clientRequest ->
+ log.info("Rest request method(${clientRequest.method()}), url(${clientRequest.url()})")
+ Mono.just(clientRequest)
+ }
+ }
+
+ fun logResponse(): ExchangeFilterFunction {
+ return ExchangeFilterFunction.ofResponseProcessor { clientResponse ->
+ log.info("Response status(${clientResponse.statusCode()})")
+ Mono.just(clientResponse)
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt
new file mode 100644
index 00000000..502758a4
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt
@@ -0,0 +1,69 @@
+/*
+ * 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.blueprintsprocessor.rest.service
+
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfiguration
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.BluePrintRestLibConfiguration
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import org.springframework.web.bind.annotation.GetMapping
+import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.RestController
+import kotlin.test.Test
+import kotlin.test.assertNotNull
+
+@EnableAutoConfiguration
+@RunWith(SpringRunner::class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
+@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, BlueprintPropertyConfiguration::class,
+ SampleController::class, BluePrintProperties::class])
+@TestPropertySource(properties =
+["server.port=9111",
+ "blueprintsprocessor.restclient.sample.type=basic-auth",
+ "blueprintsprocessor.restclient.sample.url=http://127.0.0.1:9111",
+ "blueprintsprocessor.restclient.sample.userId=sampleuser",
+ "blueprintsprocessor.restclient.sample.token=sampletoken"])
+class RestClientServiceTest {
+
+ @Autowired
+ lateinit var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService
+
+ @Test
+ fun testBaseAuth() {
+
+ val restClientService = bluePrintRestLibPropertyService.blueprintWebClientService("sample")
+ val headers = mutableMapOf<String, String>()
+ headers["X-Transaction-Id"] = "1234"
+ val response = restClientService.getResource("/sample/name", headers, String::class.java)
+ assertNotNull(response, "failed to get response")
+ }
+
+}
+
+@RestController
+@RequestMapping("/sample")
+open class SampleController {
+ @GetMapping("/name")
+ fun getName(): String = "Sample Controller"
+}
+
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
index 363899ea..c9e147ba 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
@@ -120,4 +120,8 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
return operationInputs[key]
?: throw BluePrintProcessorException("couldn't get the operation input($key) value.")
}
+
+ fun setAttribute(key: String, value: JsonNode) {
+ bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName, key, value)
+ }
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml
index 22661294..369b84b4 100644
--- a/ms/blueprintsprocessor/parent/pom.xml
+++ b/ms/blueprintsprocessor/parent/pom.xml
@@ -81,6 +81,11 @@
<version>${kotlin.couroutines.version}</version>
</dependency>
<dependency>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-reactor</artifactId>
+ <version>${kotlin.couroutines.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${kotlin.version}</version>
diff --git a/ms/controllerblueprints/application/opt/app/onap/config/application-dev.properties b/ms/controllerblueprints/application/opt/app/onap/config/application-dev.properties
index 46aa2fa0..46d85307 100644..100755
--- a/ms/controllerblueprints/application/opt/app/onap/config/application-dev.properties
+++ b/ms/controllerblueprints/application/opt/app/onap/config/application-dev.properties
@@ -61,4 +61,7 @@ controllerblueprints.loadBluePrintPaths=./../../../components/model-catalog/blue
controllerblueprints.loadModelType=true
controllerblueprints.loadModeTypePaths=./../../../components/model-catalog/definition-type/starter-type
controllerblueprints.loadResourceDictionary=true
-controllerblueprints.loadResourceDictionaryPaths=./../../../components/model-catalog/resource-dictionary/starter-dictionary \ No newline at end of file
+controllerblueprints.loadResourceDictionaryPaths=./../../../components/model-catalog/resource-dictionary/starter-dictionary
+
+# CBA file extension
+controllerblueprints.loadCbaExtension=zip \ No newline at end of file
diff --git a/ms/controllerblueprints/application/opt/app/onap/config/application.properties b/ms/controllerblueprints/application/opt/app/onap/config/application.properties
index 2ac4ad37..d618e015 100644..100755
--- a/ms/controllerblueprints/application/opt/app/onap/config/application.properties
+++ b/ms/controllerblueprints/application/opt/app/onap/config/application.properties
@@ -65,4 +65,7 @@ controllerblueprints.loadBluePrintPaths=model-catalog/blueprint-model/starter-bl
controllerblueprints.loadModelType=true
controllerblueprints.loadModeTypePaths=model-catalog/definition-type/starter-type
controllerblueprints.loadResourceDictionary=true
-controllerblueprints.loadResourceDictionaryPaths=model-catalog/resource-dictionary/starter-dictionary \ No newline at end of file
+controllerblueprints.loadResourceDictionaryPaths=model-catalog/resource-dictionary/starter-dictionary
+
+# CBA file extension
+controllerblueprints.loadCbaExtension=zip \ No newline at end of file
diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties
index 48f70b0e..9c8a96cb 100644..100755
--- a/ms/controllerblueprints/application/src/test/resources/application.properties
+++ b/ms/controllerblueprints/application/src/test/resources/application.properties
@@ -46,4 +46,10 @@ controllerblueprints.loadBluePrintPaths=./../../../../components/model-catalog/b
controllerblueprints.loadModelType=false
controllerblueprints.loadModeTypePaths=./../../../../components/model-catalog/definition-type/starter-type
controllerblueprints.loadResourceDictionary=false
-controllerblueprints.loadResourceDictionaryPaths=./../../../../components/model-catalog/resource-dictionary/starter-dictionary \ No newline at end of file
+controllerblueprints.loadResourceDictionaryPaths=./../../../../components/model-catalog/resource-dictionary/starter-dictionary
+
+# CBA file extension
+controllerblueprints.loadCbaExtension=zip
+
+# CBA examples for tests cases
+controllerblueprints.loadBlueprintsExamplesPath=./../../../../components/model-catalog/blueprint-model/test-blueprints \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CBAContentService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CBAContentService.java
new file mode 100755
index 00000000..66ef6a93
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CBAContentService.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright © 2018 IBM Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.apps.controllerblueprints.service;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.CbaContent;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.CBAContentRepository;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * CBAContentService.java Purpose: Provide CBAContent Template Service processing
+ * CBAContentService
+ *
+ * @author Ruben Chang
+ * @version 1.0
+ */
+
+@Service
+public class CBAContentService {
+
+ private static EELFLogger log = EELFManager.getInstance().getLogger(CBAContentService.class);
+
+ private CBAContentRepository cbaContentRepository;
+
+ /**
+ * Constructor of the class
+ * @param cbaContentRepository CRUD methods for entity CBAContentRepository
+ */
+ public CBAContentService(CBAContentRepository cbaContentRepository) {
+ this.cbaContentRepository = cbaContentRepository;
+ log.info("CBAContentRepository sucessfully instantiated");
+ }
+
+ /**
+ * Save the CBAContent into the CBA_CONTENT table
+ * @param cbaName The name of the file
+ * @param cbaVersion version number of the CBA archive
+ * @param cbaState int that would represent the state. Refer to the CbaStateEnum
+ * @param cbaDescription Brief description that would help to identify and recognize the CBA archive
+ * @param file the file
+ * @return CbaContent the record saved into the table CBA_CONTENT
+ */
+ public CbaContent saveCBAContent(String cbaName, String cbaVersion, int cbaState, String cbaDescription, byte[] file){
+ CbaContent cbaContent = new CbaContent();
+ cbaContent.setCbaName(cbaName);
+ cbaContent.setCbaVersion(cbaVersion);
+ cbaContent.setCbaState(cbaState);
+ cbaContent.setCbaDescription(cbaDescription);
+ cbaContent.setCbaFile(file);
+ cbaContentRepository.saveAndFlush(cbaContent);
+ return cbaContent;
+ }
+
+ /**
+ * Get the list of Controller Blueprint archives
+ * @return List<CbaContent> list with the controller blueprint archives
+ */
+ public List<CbaContent> getList(){
+ return cbaContentRepository.findAll();
+ }
+
+ /**
+ * Get a single Controller Blueprint archive by uuID
+ * @param uuID the userID controller blueprint identifier
+ * @return Optional<CbaContent>
+ */
+ public Optional<CbaContent> findByUUID(String uuID) {
+ return cbaContentRepository.findById(uuID);
+ }
+
+ /**
+ * Method deleteCBAById: Delete a CBA in data base with it associated Blueprint Model
+ * @param uuid the uuid that identify the CBA
+ */
+ public void deleteCBAById(String uuid) {
+ cbaContentRepository.deleteById(uuid);
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaFileManagementService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaFileManagementService.java
new file mode 100755
index 00000000..2011172d
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaFileManagementService.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright © 2018 IBM Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintArchiveUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.codec.multipart.FilePart;
+import org.springframework.stereotype.Service;
+import org.springframework.util.FileSystemUtils;
+import org.springframework.util.StringUtils;
+import reactor.core.publisher.Mono;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+/**
+ * CbaFileManagementService.java Purpose: Provide Service processing CBA file management
+ *
+ * @author Steve Siani
+ * @version 1.0
+ */
+@Service
+public class CbaFileManagementService {
+ private static EELFLogger log = EELFManager.getInstance().getLogger(CbaFileManagementService.class);
+
+ @Value("${controllerblueprints.loadCbaExtension}")
+ private String cbaExtension;
+
+ private static final String CBA_FILE_NAME_PATTERN = "CBA_{0}_{1}";
+
+
+ /**
+ * cleanupSavedCBA: This method cleanup the Zip file and the unzip directory that was added.
+ *
+ * @param zipFileName zipFileName
+ * @param cbaFileLocation cbaFileLocation
+ * @return
+ * @throws BluePrintException BluePrintException
+ */
+ public void cleanupSavedCBA(String zipFileName, Path cbaFileLocation) throws BluePrintException {
+
+ String fileNameWithoutExtension = BluePrintFileUtils.Companion.stripFileExtension(zipFileName);
+
+ //Delete the Zip file from the repository
+ FileSystemUtils.deleteRecursively(BluePrintFileUtils.Companion.getBluePrintFile(zipFileName,cbaFileLocation));
+
+ //Delete the CBA directory from the repository
+ FileSystemUtils.deleteRecursively(BluePrintFileUtils.Companion.getBluePrintFile(fileNameWithoutExtension,cbaFileLocation));
+ }
+
+ /**
+ * This is a saveCBAFile method
+ * take a {@link FilePart}, transfer it to disk using a Flux of FilePart and return a {@link Mono} representing the CBA file name
+ *
+ * @param (filePart, targetDirectory) - the request part containing the file to be saved and the default directory where to save
+ * @return a {@link Mono} String representing the result of the operation
+ * @throws (BluePrintException, IOException) BluePrintException, IOException
+ */
+ public Mono<String> saveCBAFile(FilePart filePart, Path targetDirectory) throws BluePrintException, IOException {
+
+ // Normalize file name
+ final String fileName = StringUtils.cleanPath(filePart.filename());
+
+ // Check if the file's extension is "CBA"
+ if(!StringUtils.getFilenameExtension(fileName).equals(cbaExtension)) {
+ throw new BluePrintException("Invalid file extension required " + cbaExtension);
+ }
+
+ // Change file name to match a pattern
+ String changedFileName = BluePrintFileUtils.Companion.getCBAGeneratedFileName(fileName, this.CBA_FILE_NAME_PATTERN);
+
+ // Copy file to the target location (Replacing existing file with the same name)
+ Path targetLocation = targetDirectory.resolve(changedFileName);
+
+ // if a file with the same name already exists in a repository, delete and recreate it
+ File file = new File(targetLocation.toString());
+ if (file.exists())
+ file.delete();
+ file.createNewFile();
+
+ return filePart.transferTo(file).thenReturn(changedFileName);
+ }
+
+ /**
+ * Decompress the file into the cbaFileLocation parameter
+ * @param zipFileName name of the zipped file
+ * @param cbaFileLocation path in which the zipped file will get decompressed
+ * @return String the path in which the file is decompressed
+ * @throws BluePrintException Exception in the process
+ */
+ public String decompressCBAFile(final String zipFileName, Path cbaFileLocation) throws BluePrintException {
+
+ File file = BluePrintFileUtils.Companion.getBluePrintFile(zipFileName, cbaFileLocation);
+ try {
+ Path directoryPath = Files.createDirectories(cbaFileLocation.resolve(BluePrintFileUtils.Companion.stripFileExtension(zipFileName)));
+ BluePrintArchiveUtils.Companion.deCompress(file, directoryPath.toString());
+ return directoryPath.toString();
+
+ } catch (BluePrintProcessorException | IOException ex) {
+ throw new BluePrintException(" Fail to decompress " + zipFileName, ex);
+ }
+
+ }
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaService.java
new file mode 100755
index 00000000..7d616a76
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaService.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright © 2018 IBM Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.jetbrains.annotations.NotNull;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.CbaContent;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.onap.ccsdk.apps.controllerblueprints.service.model.BlueprintModelResponse;
+import org.onap.ccsdk.apps.controllerblueprints.service.model.ItemCbaResponse;
+import org.onap.ccsdk.apps.controllerblueprints.service.utils.CbaStateEnum;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.event.ApplicationReadyEvent;
+import org.springframework.context.event.EventListener;
+import org.springframework.core.io.ByteArrayResource;
+import org.springframework.core.io.Resource;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.http.codec.multipart.FilePart;
+import org.springframework.stereotype.Service;
+import reactor.core.publisher.Mono;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * CbaService.java Purpose: Provide Service Template Service processing CbaService
+ *
+ * @author Steve Siani
+ * @version 1.0
+ */
+
+@Service
+public class CbaService {
+
+ private static EELFLogger log = EELFManager.getInstance().getLogger(CbaService.class);
+
+ @Value("${controllerblueprints.blueprintArchivePath}")
+ private String cbaArchivePath;
+ private Path cbaLocation;
+
+ @Autowired
+ private CbaFileManagementService cbaFileManagementService;
+
+ @Autowired
+ private CbaToDatabaseService cbaToDatabaseService;
+
+
+ /**
+ * This method would be used by SpringBoot to initialize the cba location
+ */
+ @EventListener(ApplicationReadyEvent.class)
+ private void initCbaService() {
+ this.cbaLocation = BluePrintFileUtils.Companion.getCbaStorageDirectory(cbaArchivePath);
+ log.info("CBA service Initiated...");
+ }
+
+ /**
+ * This is a uploadCBAFile method
+ * take a {@link FilePart}, transfer it to disk using WebFlux and return a {@link Mono} representing the result
+ *
+ * @param filePart - the request part containing the file to be saved
+ * @return a {@link Mono< BlueprintModelResponse >} representing the result of the operation
+ */
+ public Mono<BlueprintModelResponse> uploadCBAFile(FilePart filePart) {
+
+ try {
+ return this.cbaFileManagementService.saveCBAFile(filePart, cbaLocation).map(fileName -> {
+ ConfigModel configModel;
+ BlueprintModelResponse blueprintModelResponse = null;
+
+ try {
+ String cbaDirectory = this.cbaFileManagementService.decompressCBAFile(fileName, cbaLocation);
+ configModel = this.cbaToDatabaseService.storeBluePrints(cbaDirectory, fileName, cbaLocation.resolve(fileName));
+ blueprintModelResponse = new BlueprintModelResponse(configModel.getId(), configModel.getArtifactName(), configModel.getArtifactVersion(), configModel.getArtifactDescription(), configModel.getConfigModelCBA().getCbaUUID());
+ } catch (BluePrintException be) {
+ Mono.error(new BluePrintException("Error loading CBA in database.", be));
+ } finally {
+ try {
+ this.cbaFileManagementService.cleanupSavedCBA(fileName, cbaLocation);
+ } catch (BluePrintException be) {
+ Mono.error(new BluePrintException("Error while cleaning up.", be));
+ }
+ }
+ return blueprintModelResponse;
+ });
+ } catch (IOException | BluePrintException e) {
+ return Mono.error(new BluePrintException("Error uploading the CBA file in channel.", e));
+ }
+ }
+
+ /**
+ * This is a deleteCba method
+ *
+ * @param id id
+ * @throws BluePrintException BluePrintException
+ */
+ public void deleteCBA(@NotNull Long id) throws BluePrintException {
+ this.cbaToDatabaseService.deleteCBA(id);
+ }
+
+ /**
+ * This is a downloadCBAFile method to find the target file to download and return a file ressource using MONO
+ *
+ * @param (id)
+ * @return ResponseEntity<Resource>
+ */
+ public ResponseEntity<Resource> downloadCBAFile(@NotNull String id) {
+ Optional<CbaContent> optionalContent = this.cbaToDatabaseService.findByUUID(id);
+
+ CbaContent cbaContent = optionalContent.get();
+
+ return ResponseEntity.ok()
+ .contentType(MediaType.parseMediaType("text/plain"))
+ .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + cbaContent.getCbaName() + "\"")
+ .body(new ByteArrayResource(cbaContent.getCbaFile()));
+ }
+
+ /**
+ * This is a findCBAByID method to find a CBA By the UUID
+ *
+ * @param (id)
+ * @return ItemCbaResponse
+ */
+ public ItemCbaResponse findCBAByID(@NotNull String id) {
+ ItemCbaResponse response = new ItemCbaResponse();
+ Optional<CbaContent> optionalContent = this.cbaToDatabaseService.findByUUID(id);
+
+ CbaContent cbaContent = optionalContent.get();
+ response.setName(cbaContent.getCbaName());
+ response.setState(cbaContent.getCbaState());
+ response.setId(cbaContent.getCbaUUID());
+ response.setVersion(cbaContent.getCbaVersion());
+ response.setDescription(cbaContent.getCbaDescription());
+ return response;
+ }
+
+ /**
+ * This is a findAllCBA method to retrieve all the CBAs in Database
+ *
+ * @return List<ItemCbaResponse> list with the controller blueprint archives
+ */
+ public List<ItemCbaResponse> findAllCBA() {
+ List<ItemCbaResponse> responseList = new ArrayList<>();
+ List<CbaContent> cbaContents = this.cbaToDatabaseService.listCBAFiles();
+
+ for(CbaContent content: cbaContents){
+ ItemCbaResponse response = new ItemCbaResponse();
+ response.setName(content.getCbaName());
+ response.setState(content.getCbaState());
+ response.setId(content.getCbaUUID());
+ response.setVersion(content.getCbaVersion());
+ response.setDescription(content.getCbaDescription());
+
+ responseList.add(response);
+ }
+ return responseList;
+ }
+
+ /**
+ * This is a findCBAByNameAndVersion method to find a CBA by Name and version
+ *
+ * @param (name, version)
+ * @return
+ * @throws BluePrintException BluePrintException
+ */
+ public ItemCbaResponse findCBAByNameAndVersion(@NotNull String name, @NotNull String version) throws BluePrintException {
+ return null;
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaToDatabaseService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaToDatabaseService.java
new file mode 100755
index 00000000..34204202
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaToDatabaseService.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright © 2018 IBM Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.apache.commons.collections.CollectionUtils;
+import org.jetbrains.annotations.NotNull;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.CbaContent;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelContentRepository;
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ConfigModelRepository;
+import org.onap.ccsdk.apps.controllerblueprints.service.utils.CbaStateEnum;
+import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * This class acts as a Rest Service that would store in the Database the Blueprints.
+ * @author Ruben Chang
+ */
+
+@Service
+public class CbaToDatabaseService {
+
+ //Log used to trace the transactions using the EELFLogger class
+ private static EELFLogger log = EELFManager.getInstance().getLogger(CbaToDatabaseService.class);
+
+ @Autowired
+ private ConfigModelRepository configModelRepository;
+ @Autowired
+ private ConfigModelContentRepository configModelContentRepository;
+ @Autowired
+ private ConfigModelCreateService configModelCreateService;
+ @Autowired
+ private CBAContentService cbaContentService;
+
+ /**
+ * This method will store the blueprints into the DB on the tables CONFIG_MODEL and CONFIG_MODEL_CONTENT
+ * @param cbaArchiveToSave Path in which the components are stored
+ * @return ConfigModel The Blueprint object stored in the DB
+ */
+ public ConfigModel storeBluePrints(String cbaDirectory, String cbaFileName, Path cbaArchiveToSave) throws BluePrintException {
+ log.info("*************************** storeBluePrints **********************");
+ ConfigModel configModel = null;
+ CbaContent cbaContent;
+ String version = "1.0";//TODO Read these information from metadata
+ String description = "Initial description for CBA archive " + cbaFileName;//TODO
+
+ List<String> serviceTemplateDirs = ConfigModelUtils.getBlueprintNames(cbaDirectory);
+ if (CollectionUtils.isNotEmpty(serviceTemplateDirs)) {
+ for (String fileName : serviceTemplateDirs) {
+ try {
+ String bluePrintPath = cbaDirectory.concat("/").concat(fileName);
+ log.debug("***** Loading service template : {}", bluePrintPath);
+ configModel = ConfigModelUtils.getConfigModel(bluePrintPath);
+
+ configModel = this.configModelCreateService.saveConfigModel(configModel);
+
+ log.info("Loaded service template successfully: {}", fileName);
+ } catch (Exception e) {
+ throw new BluePrintException("Load config model " + fileName + " error : "+e.getMessage());
+ }
+ }
+ } else {
+ throw new BluePrintException("Invalid structure. The unzipped file does not contains Blueprints");
+ }
+
+ byte[] file;
+ try {
+ file = Files.readAllBytes(cbaArchiveToSave);
+ } catch (IOException e) {
+ throw new BluePrintException("Fail to read the CBA to save in database.", e);
+ }
+
+ cbaContent = this.cbaContentService.saveCBAContent(cbaFileName, version, CbaStateEnum.DRAFT.getState(), description, file);
+ configModel.setConfigModelCBA(cbaContent);
+
+ return configModel;
+ }
+
+ /**
+ * This is a deleteConfigModel method
+ *
+ * @param id id
+ * @throws BluePrintException BluePrintException
+ */
+ public void deleteCBA(@NotNull Long id) throws BluePrintException {
+ Optional<ConfigModel> dbConfigModel = configModelRepository.findById(id);
+
+ //TODO: Delete CBA and COnfigModel
+
+ }
+
+ /**
+ * Get a list of the controller blueprint archives
+ * @return List<CbaContent> List with the controller blueprint archives
+ */
+ public List<CbaContent> listCBAFiles() {
+ return this.cbaContentService.getList();
+ }
+
+ /**
+ * Find a Controller Blueprint Archive by UUID
+ * @param uuID the User Identifier Controller Blueprint archive
+ * @return Optional<CbaContent> the Controller Blueprint archive
+ */
+ public Optional<CbaContent> findByUUID(String uuID) {
+ return this.cbaContentService.findByUUID(uuID);
+ }
+} \ No newline at end of file
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 fa8e32b6..f31a0ceb 100644..100755
--- 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
@@ -30,6 +30,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
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.ApplicationConstants;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.CbaContent;
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;
@@ -123,7 +124,7 @@ public class ConfigModelCreateService {
String artifactName = configModel.getArtifactName();
String artifactVersion = configModel.getArtifactVersion();
String author = configModel.getUpdatedBy();
-
+ CbaContent configModelCBA = configModel.getConfigModelCBA();
if (StringUtils.isBlank(author)) {
throw new BluePrintException("Artifact Author is missing in the Service Template");
@@ -181,7 +182,7 @@ public class ConfigModelCreateService {
addConfigModelContent(dbConfigModelId, configModel);
// Populate Content model types
- updateConfigModel = updateConfigModel(dbConfigModelId, artifactName, artifactVersion, author);
+ updateConfigModel = updateConfigModel(dbConfigModelId, artifactName, artifactVersion, author, configModelCBA);
return updateConfigModel;
@@ -220,7 +221,7 @@ public class ConfigModelCreateService {
}
private ConfigModel updateConfigModel(Long dbConfigModelId, String artifactName, String artifactVersion,
- String author) throws BluePrintException {
+ String author, CbaContent configModelCBA) throws BluePrintException {
ConfigModel dbConfigModel = configModelRepository.getOne(dbConfigModelId);
// Populate tags from metadata
@@ -234,6 +235,7 @@ public class ConfigModelCreateService {
dbConfigModel.setUpdatedBy(author);
dbConfigModel.setPublished(ApplicationConstants.ACTIVE_N);
dbConfigModel.setTags(tags);
+ dbConfigModel.setConfigModelCBA(configModelCBA);
configModelRepository.saveAndFlush(dbConfigModel);
log.info("Config model ({}) saved successfully.", dbConfigModel.getId());
return dbConfigModel;
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java
deleted file mode 100644
index 925a6c49..00000000
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service;
-
-import com.google.common.base.Preconditions;
-import org.apache.commons.lang3.StringUtils;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository;
-import org.onap.ccsdk.apps.controllerblueprints.service.validator.ModelTypeValidator;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.List;
-import java.util.Optional;
-
-/**
- * ModelTypeService.java Purpose: Provide ModelTypeService Service ModelTypeService
- *
- * @author Brinda Santh
- * @version 1.0
- */
-
-@Service
-@Transactional
-public class ModelTypeService {
-
- private ModelTypeRepository modelTypeRepository;
-
- /**
- * This is a ModelTypeService, used to save and get the model types stored in database
- *
- * @param modelTypeRepository modelTypeRepository
- */
- public ModelTypeService(ModelTypeRepository modelTypeRepository) {
- this.modelTypeRepository = modelTypeRepository;
- }
-
-
- /**
- * This is a getModelTypeByName service
- *
- * @param modelTypeName modelTypeName
- * @return ModelType
- */
- public ModelType getModelTypeByName(String modelTypeName) {
- ModelType modelType = null;
- Preconditions.checkArgument(StringUtils.isNotBlank(modelTypeName), "Model Name Information is missing.");
- Optional<ModelType> modelTypeOption = modelTypeRepository.findByModelName(modelTypeName);
- if (modelTypeOption.isPresent()) {
- modelType = modelTypeOption.get();
- }
- return modelType;
- }
-
-
- /**
- * This is a searchModelTypes service
- *
- * @param tags tags
- * @return List<ModelType>
- */
- public List<ModelType> searchModelTypes(String tags) {
- Preconditions.checkArgument(StringUtils.isNotBlank(tags), "No Search Information provide");
- return modelTypeRepository.findByTagsContainingIgnoreCase(tags);
- }
-
- /**
- * This is a saveModel service
- *
- * @param modelType modelType
- * @return ModelType
- * @throws BluePrintException BluePrintException
- */
- public ModelType saveModel(ModelType modelType) throws BluePrintException {
-
- Preconditions.checkNotNull(modelType, "Model Type Information is missing.");
-
- ModelTypeValidator.validateModelType(modelType);
-
- Optional<ModelType> dbModelType = modelTypeRepository.findByModelName(modelType.getModelName());
- if (dbModelType.isPresent()) {
- ModelType dbModel = dbModelType.get();
- dbModel.setDescription(modelType.getDescription());
- dbModel.setDefinition(modelType.getDefinition());
- dbModel.setDefinitionType(modelType.getDefinitionType());
- dbModel.setDerivedFrom(modelType.getDerivedFrom());
- dbModel.setTags(modelType.getTags());
- dbModel.setVersion(modelType.getVersion());
- dbModel.setUpdatedBy(modelType.getUpdatedBy());
- modelType = modelTypeRepository.save(dbModel);
- } else {
- modelType = modelTypeRepository.save(modelType);
- }
- return modelType;
- }
-
-
- /**
- * This is a deleteByModelName service
- *
- * @param modelName modelName
- */
- public void deleteByModelName(String modelName) {
- Preconditions.checkArgument(StringUtils.isNotBlank(modelName), "Model Name Information is missing.");
- modelTypeRepository.deleteByModelName(modelName);
-
- }
-
- /**
- * This is a getModelTypeByDefinitionType service
- *
- * @param definitionType definitionType
- * @return List<ModelType>
- */
- public List<ModelType> getModelTypeByDefinitionType(String definitionType) {
- Preconditions.checkArgument(StringUtils.isNotBlank(definitionType), "Model definitionType Information is missing.");
- return modelTypeRepository.findByDefinitionType(definitionType);
- }
-
- /**
- * This is a getModelTypeByDerivedFrom service
- *
- * @param derivedFrom derivedFrom
- * @return List<ModelType>
- */
- public List<ModelType> getModelTypeByDerivedFrom(String derivedFrom) {
- Preconditions.checkArgument(StringUtils.isNotBlank(derivedFrom), "Model derivedFrom Information is missing.");
- return modelTypeRepository.findByDerivedFrom(derivedFrom);
- }
-
-
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java
deleted file mode 100644
index eacc9025..00000000
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service;
-
-import com.google.common.base.Preconditions;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationService;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository;
-import org.onap.ccsdk.apps.controllerblueprints.service.validator.ResourceDictionaryValidator;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-import java.util.Optional;
-
-/**
- * ResourceDictionaryService.java Purpose: Provide DataDictionaryService Service
- * DataDictionaryService
- *
- * @author Brinda Santh
- * @version 1.0
- */
-@Service
-public class ResourceDictionaryService {
-
- private ResourceDictionaryRepository resourceDictionaryRepository;
-
- private ResourceDefinitionValidationService resourceDictionaryValidationService;
-
- /**
- * This is a DataDictionaryService, used to save and get the Resource Mapping stored in database
- *
- * @param dataDictionaryRepository dataDictionaryRepository
- * @param resourceDictionaryValidationService resourceDictionaryValidationService
- */
- public ResourceDictionaryService(ResourceDictionaryRepository dataDictionaryRepository,
- ResourceDefinitionValidationService resourceDictionaryValidationService) {
- this.resourceDictionaryRepository = dataDictionaryRepository;
- this.resourceDictionaryValidationService = resourceDictionaryValidationService;
- }
-
- /**
- * This is a getDataDictionaryByName service
- *
- * @param name name
- * @return DataDictionary
- * @throws BluePrintException BluePrintException
- */
- public ResourceDictionary getResourceDictionaryByName(String name) throws BluePrintException {
- Preconditions.checkArgument(StringUtils.isNotBlank(name), "Resource dictionary Name Information is missing.");
- Optional<ResourceDictionary> resourceDictionaryDb = resourceDictionaryRepository.findByName(name);
- if (resourceDictionaryDb.isPresent()) {
- return resourceDictionaryDb.get();
- } else {
- throw new BluePrintException(String.format("couldn't get resource dictionary for name (%s)", name));
- }
- }
-
- /**
- * This is a searchResourceDictionaryByNames service
- *
- * @param names names
- * @return List<ResourceDictionary>
- */
- public List<ResourceDictionary> searchResourceDictionaryByNames(List<String> names) {
- Preconditions.checkArgument(CollectionUtils.isNotEmpty(names), "No Search Information provide");
- return resourceDictionaryRepository.findByNameIn(names);
- }
-
- /**
- * This is a searchResourceDictionaryByTags service
- *
- * @param tags tags
- * @return List<ResourceDictionary>
- */
- public List<ResourceDictionary> searchResourceDictionaryByTags(String tags) {
- Preconditions.checkArgument(StringUtils.isNotBlank(tags), "No search tag information provide");
- return resourceDictionaryRepository.findByTagsContainingIgnoreCase(tags);
- }
-
- /**
- * This is a saveDataDictionary service
- *
- * @param resourceDictionary resourceDictionary
- * @return DataDictionary
- */
- public ResourceDictionary saveResourceDictionary(ResourceDictionary resourceDictionary) throws BluePrintException {
- Preconditions.checkNotNull(resourceDictionary, "Resource Dictionary information is missing");
- Preconditions.checkNotNull(resourceDictionary.getDefinition(), "Resource Dictionary definition information is missing");
-
- ResourceDefinition resourceDefinition = resourceDictionary.getDefinition();
- Preconditions.checkNotNull(resourceDefinition, "failed to get resource definition from content");
- // Validate the Resource Definitions
- resourceDictionaryValidationService.validate(resourceDefinition);
-
- resourceDictionary.setTags(resourceDefinition.getTags());
- resourceDefinition.setUpdatedBy(resourceDictionary.getUpdatedBy());
- // Set the Property Definitions
- PropertyDefinition propertyDefinition = resourceDefinition.getProperty();
- resourceDictionary.setDescription(propertyDefinition.getDescription());
- resourceDictionary.setDataType(propertyDefinition.getType());
- if (propertyDefinition.getEntrySchema() != null) {
- resourceDictionary.setEntrySchema(propertyDefinition.getEntrySchema().getType());
- }
-
- ResourceDictionaryValidator.validateResourceDictionary(resourceDictionary);
-
- Optional<ResourceDictionary> dbResourceDictionaryData =
- resourceDictionaryRepository.findByName(resourceDictionary.getName());
- if (dbResourceDictionaryData.isPresent()) {
- ResourceDictionary dbResourceDictionary = dbResourceDictionaryData.get();
-
- dbResourceDictionary.setName(resourceDictionary.getName());
- dbResourceDictionary.setDefinition(resourceDictionary.getDefinition());
- dbResourceDictionary.setDescription(resourceDictionary.getDescription());
- dbResourceDictionary.setTags(resourceDictionary.getTags());
- dbResourceDictionary.setUpdatedBy(resourceDictionary.getUpdatedBy());
- dbResourceDictionary.setDataType(resourceDictionary.getDataType());
- dbResourceDictionary.setEntrySchema(resourceDictionary.getEntrySchema());
- resourceDictionary = resourceDictionaryRepository.save(dbResourceDictionary);
- } else {
- resourceDictionary = resourceDictionaryRepository.save(resourceDictionary);
- }
-
- return resourceDictionary;
- }
-
- /**
- * This is a deleteResourceDictionary service
- *
- * @param name name
- */
- public void deleteResourceDictionary(String name) {
- Preconditions.checkArgument(StringUtils.isNotBlank(name), "Resource dictionary Name Information is missing.");
- resourceDictionaryRepository.deleteByName(name);
- }
-
- /**
- * This is a getResourceSourceMapping service
- */
- public ResourceSourceMapping getResourceSourceMapping() {
- return ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping();
- }
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/CbaContent.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/CbaContent.java
new file mode 100755
index 00000000..14ac6af1
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/CbaContent.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright © 2018 IBM 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.service.domain;
+
+import com.fasterxml.jackson.annotation.JsonManagedReference;
+import org.hibernate.annotations.Proxy;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * CbaContent.java Purpose: Provide Configuration Generator for CbaContent Entity
+ *
+ * @author Ruben Chang
+ * @version 1.0
+ */
+
+@EntityListeners({AuditingEntityListener.class})
+@Entity
+@Table(name = "CBA_CONTENT")
+@Proxy(lazy=false)
+public class CbaContent implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public CbaContent() {
+ this.cbaUUID = UUID.randomUUID().toString();
+ }
+
+ @Id
+ @Column(name = "cba_uuid", nullable = false)
+ private String cbaUUID;
+
+ @Lob
+ @Column(name = "cba_file")
+ private byte[] cbaFile;
+
+ @Column(name = "cba_name")
+ private String cbaName;
+
+ @Column(name = "cba_version")
+ private String cbaVersion;
+
+ @Column(name = "cba_state")
+ private int cbaState;
+
+ @Column(name="cba_description")
+ private String cbaDescription;
+
+ @OneToMany(mappedBy = "configModelCBA", fetch = FetchType.EAGER, orphanRemoval = true, cascade = CascadeType.ALL)
+ @JsonManagedReference
+ private List<ConfigModel> models = new ArrayList<>();
+
+ public String getCbaUUID() {
+ return cbaUUID;
+ }
+
+ public void setCbaUUID(String cbaUUID) {
+ this.cbaUUID = cbaUUID;
+ }
+
+ public String getCbaName() {
+ return cbaName;
+ }
+
+ public void setCbaName(String cbaName) {
+ this.cbaName = cbaName;
+ }
+
+ public String getCbaVersion() {
+ return cbaVersion;
+ }
+
+ public void setCbaVersion(String cbaVersion) {
+ this.cbaVersion = cbaVersion;
+ }
+
+ public List<ConfigModel> getModels() {
+ return models;
+ }
+
+ public void setModels(List<ConfigModel> models) { this.models = models; }
+
+ public int getCbaState() { return cbaState; }
+
+ public void setCbaState(int cbaState) { this.cbaState = cbaState; }
+
+ public String getCbaDescription() { return cbaDescription; }
+
+ public void setCbaDescription(String cbaDescription) { this.cbaDescription = cbaDescription; }
+
+ public byte[] getCbaFile() { return cbaFile; }
+
+ public void setCbaFile(byte[] cbaFile) { this.cbaFile = cbaFile; }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java
index 51c9a7c6..dea5757d 100644..100755
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java
@@ -119,6 +119,10 @@ public class ConfigModel implements Serializable {
@JsonManagedReference
private List<ConfigModelContent> configModelContents = new ArrayList<>();
+ @ManyToOne
+ @JoinColumn(name = "cba_content_uuid")
+ private CbaContent configModelCBA;
+
public Long getId() {
return id;
}
@@ -287,4 +291,12 @@ public class ConfigModel implements Serializable {
this.configModelContents = configModelContents;
}
+ public CbaContent getConfigModelCBA() {
+ return configModelCBA;
+ }
+
+ public void setConfigModelCBA(CbaContent configModelCBA) {
+ this.configModelCBA = configModelCBA;
+ }
+
}
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 33c7ae42..65a135c1 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
@@ -84,7 +84,7 @@ public class ModelType implements Serializable {
@Override
public String toString() {
- return "[" + ", modelName = " + modelName +
+ return "[" + "modelName = " + modelName +
", derivedFrom = " + derivedFrom +
", definitionType = " + definitionType +
", description = " + description +
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/BlueprintModelResponse.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/BlueprintModelResponse.java
new file mode 100755
index 00000000..1b67ed82
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/BlueprintModelResponse.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright © 2018 IBM Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.model;
+
+/**
+ * BlueprintModelResponse.java Purpose: Model response for Upload CBA service
+ *
+ */
+public class BlueprintModelResponse {
+ private Long id;
+ private String name;
+ private String version;
+ private String description;
+ private String cbaUUID;
+
+ public BlueprintModelResponse(Long id, String name, String version, String description, String cbaUUID) {
+ this.id = id;
+ this.name = name;
+ this.version = version;
+ this.description = description;
+ this.cbaUUID = cbaUUID;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getCbaUUID() {
+ return cbaUUID;
+ }
+
+ public void setCbaUUID(String cbaUUID) {
+ this.cbaUUID = cbaUUID;
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/ItemCbaResponse.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/ItemCbaResponse.java
new file mode 100755
index 00000000..0752df9b
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/model/ItemCbaResponse.java
@@ -0,0 +1,58 @@
+package org.onap.ccsdk.apps.controllerblueprints.service.model;
+
+/**
+ * CLass that would represent the response for the GET methods on the CBAService class
+ */
+public class ItemCbaResponse {
+
+ private String id;
+ private String description;
+ private String name;
+ private int state;
+ private String version;
+
+ public ItemCbaResponse() {
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getState() {
+ return state;
+ }
+
+ public void setState(int state) {
+ this.state = state;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/CBAContentRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/CBAContentRepository.java
new file mode 100755
index 00000000..273a19d6
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/CBAContentRepository.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright © 2018 IBM 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.service.repository;
+
+import org.jetbrains.annotations.NotNull;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.CbaContent;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * CBAContentRepository.java Purpose: Provide Configuration Generator CRUD methods for CBAContent table
+ *
+ * @author Ruben Chang
+ * @version 1.0
+ */
+@Repository
+public interface CBAContentRepository extends JpaRepository<CbaContent, String> {
+
+ /**
+ * This is a findAll method
+ * @return List<CbaContent>
+ */
+ @Override
+ List<CbaContent> findAll();
+
+ /**
+ * Returns a CbaContent based on the cbaUUID
+ * @param cbaUUID the CbaUUID
+ * @return Optional<CbaContent>
+ */
+ @Override
+ @NotNull
+ Optional<CbaContent> findById(@NotNull String cbaUUID);
+
+ /**
+ * This is a deleteById methid
+ * @param cbaUUID the user ID for a particular CBAFile
+ */
+ @Override
+ void deleteById(@NotNull String cbaUUID);
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/CbaRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/CbaRest.java
new file mode 100755
index 00000000..4608b175
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/CbaRest.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright © 2018 IBM Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.rs;
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.service.CbaService;
+import org.onap.ccsdk.apps.controllerblueprints.service.model.BlueprintModelResponse;
+import org.onap.ccsdk.apps.controllerblueprints.service.model.ItemCbaResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.Resource;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.http.codec.multipart.FilePart;
+import org.springframework.http.codec.multipart.Part;
+import org.springframework.web.bind.annotation.*;
+import reactor.core.publisher.Flux;
+
+import java.util.List;
+
+/**
+ * CbaRest.java Purpose: Provide a REST API to upload single and multiple CBA
+ *
+ * @author Steve Siani
+ * @version 1.0
+ */
+@RestController
+@RequestMapping(value = "/api/v1/cba")
+public class CbaRest {
+
+ @Autowired
+ private CbaService cbaService;
+
+ @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
+ public Flux<BlueprintModelResponse> uploadCBA(@RequestBody Flux<Part> parts) {
+ return parts.filter(part -> part instanceof FilePart) // only retain file parts
+ .ofType(FilePart.class) // convert the flux to FilePart
+ .flatMap(filePart -> cbaService.uploadCBAFile(filePart)); // save each file and flatmap it to a flux of results
+ }
+
+ @DeleteMapping(path = "/{id}")
+ public void deleteCBA(@PathVariable(value = "id") Long id) throws BluePrintException {
+ this.cbaService.deleteCBA(id);
+ }
+
+ @GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
+ public @ResponseBody
+ ItemCbaResponse getCBA(@PathVariable(value = "id") String id) {
+ return this.cbaService.findCBAByID(id);
+ }
+
+ @GetMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE)
+ public @ResponseBody
+ List<ItemCbaResponse> getAllCBA() {
+ return this.cbaService.findAllCBA();
+ }
+
+ @GetMapping(path = "/by-name/{name}/version/{version}", produces = MediaType.APPLICATION_JSON_VALUE)
+ public @ResponseBody
+ ItemCbaResponse getCBAByNameAndVersion(@PathVariable(value = "name") String name,
+ @PathVariable(value = "version") String version) throws BluePrintException {
+ return this.cbaService.findCBAByNameAndVersion(name, version);
+ }
+
+ @GetMapping(path = "/download/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
+ public @ResponseBody
+ ResponseEntity<Resource> downloadCBA(@PathVariable(value = "id") String id) {
+ return this.cbaService.downloadCBAFile(id);
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java
index 69c20925..12ed0a57 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java
@@ -18,8 +18,8 @@
package org.onap.ccsdk.apps.controllerblueprints.service.rs;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.service.ModelTypeService;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+import org.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@@ -29,18 +29,18 @@ import java.util.List;
* {@inheritDoc}
*/
@Deprecated
-@RestController
-@RequestMapping(value = "/api/v1/model-type")
+//@RestController
+//@RequestMapping(value = "/api/v1/model-type")
public class ModelTypeRest {
- private ModelTypeService modelTypeService;
+ private ModelTypeHandler modelTypeService;
/**
* This is a ModelTypeResourceImpl, used to save and get the model types stored in database
*
* @param modelTypeService Model Type Service
*/
- public ModelTypeRest(ModelTypeService modelTypeService) {
+ public ModelTypeRest(ModelTypeHandler modelTypeService) {
this.modelTypeService = modelTypeService;
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java
index 50442042..8b7a9577 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java
@@ -19,8 +19,8 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping;
-import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
+import org.onap.ccsdk.apps.controllerblueprints.service.handler.ResourceDictionaryHandler;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@@ -35,51 +35,51 @@ import java.util.List;
public class ResourceDictionaryRest {
- private ResourceDictionaryService resourceDictionaryService;
+ private ResourceDictionaryHandler resourceDictionaryHandler;
/**
* This is a DataDictionaryRestImpl, used to save and get the Resource Mapping stored in database
*
- * @param dataDictionaryService Data Dictionary Service
+ * @param resourceDictionaryHandler Data Dictionary Handler
*/
- public ResourceDictionaryRest(ResourceDictionaryService dataDictionaryService) {
- this.resourceDictionaryService = dataDictionaryService;
+ public ResourceDictionaryRest(ResourceDictionaryHandler resourceDictionaryHandler) {
+ this.resourceDictionaryHandler = resourceDictionaryHandler;
}
@PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary) throws BluePrintException {
- return resourceDictionaryService.saveResourceDictionary(dataDictionary);
+ return resourceDictionaryHandler.saveResourceDictionary(dataDictionary);
}
@DeleteMapping(path = "/{name}")
public void deleteResourceDictionaryByName(@PathVariable(value = "name") String name) {
- resourceDictionaryService.deleteResourceDictionary(name);
+ resourceDictionaryHandler.deleteResourceDictionary(name);
}
@GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
ResourceDictionary getResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException {
- return resourceDictionaryService.getResourceDictionaryByName(name);
+ return resourceDictionaryHandler.getResourceDictionaryByName(name);
}
@PostMapping(path = "/by-names", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
List<ResourceDictionary> searchResourceDictionaryByNames(@RequestBody List<String> names) {
- return resourceDictionaryService.searchResourceDictionaryByNames(names);
+ return resourceDictionaryHandler.searchResourceDictionaryByNames(names);
}
@GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
List<ResourceDictionary> searchResourceDictionaryByTags(@PathVariable(value = "tags") String tags) {
- return resourceDictionaryService.searchResourceDictionaryByTags(tags);
+ return resourceDictionaryHandler.searchResourceDictionaryByTags(tags);
}
@GetMapping(path = "/source-mapping", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
ResourceSourceMapping getResourceSourceMapping() {
- return resourceDictionaryService.getResourceSourceMapping();
+ return resourceDictionaryHandler.getResourceSourceMapping();
}
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/CbaStateEnum.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/CbaStateEnum.java
new file mode 100755
index 00000000..57785dd8
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/CbaStateEnum.java
@@ -0,0 +1,15 @@
+package org.onap.ccsdk.apps.controllerblueprints.service.utils;
+
+public enum CbaStateEnum {
+
+ DRAFT(0), VALIDATED(1), APPROVED(2);
+ int state;
+
+ CbaStateEnum(int state) {
+ this.state = state;
+ }
+
+ public int getState() {
+ return state;
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/CloseCondition.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/CloseCondition.java
new file mode 100755
index 00000000..d7b4aa93
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/CloseCondition.java
@@ -0,0 +1,36 @@
+package org.onap.ccsdk.apps.controllerblueprints.service.utils;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class CloseCondition {
+
+ AtomicInteger tasksSubmitted = new AtomicInteger(0);
+ AtomicInteger tasksCompleted = new AtomicInteger(0);
+ AtomicBoolean allTaskssubmitted = new AtomicBoolean(false);
+
+ /**
+ * notify all tasks have been subitted, determine of the file channel can be closed
+ * @return true if the asynchronous file stream can be closed
+ */
+ public boolean canCloseOnComplete() {
+ allTaskssubmitted.set(true);
+ return tasksCompleted.get() == tasksSubmitted.get();
+ }
+
+ /**
+ * notify a task has been submitted
+ */
+ public void onTaskSubmitted() {
+ tasksSubmitted.incrementAndGet();
+ }
+
+ /**
+ * notify a task has been completed
+ * @return true if the asynchronous file stream can be closed
+ */
+ public boolean onTaskCompleted() {
+ boolean allSubmittedClosed = tasksSubmitted.get() == tasksCompleted.incrementAndGet();
+ return allSubmittedClosed && allTaskssubmitted.get();
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt
index 50e19b2f..c818410f 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt
@@ -94,8 +94,8 @@ open class BluePrintRepoFileService(private val modelTypeRepository: ModelTypeRe
private fun getModelDefinition(modelName: String): JsonNode {
val modelDefinition: JsonNode
val modelTypeDb = modelTypeRepository.findByModelName(modelName)
- if (modelTypeDb.isPresent) {
- modelDefinition = modelTypeDb.get().definition
+ if (modelTypeDb != null) {
+ modelDefinition = modelTypeDb.definition
} else {
throw BluePrintException(String.format("failed to get model definition (%s) from repo", modelName))
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ModelTypeController.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ModelTypeController.kt
new file mode 100644
index 00000000..db82849e
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ModelTypeController.kt
@@ -0,0 +1,56 @@
+/*
+ * 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.service.controller
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType
+import org.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler
+import org.springframework.http.MediaType
+import org.springframework.web.bind.annotation.*
+
+@RestController
+@RequestMapping(value = arrayOf("/api/v1/model-type"))
+open class ModelTypeController(private val modelTypeHandler: ModelTypeHandler) {
+
+ @GetMapping(path = arrayOf("/{name}"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE))
+ fun getModelTypeByName(@PathVariable(value = "name") name: String): ModelType? {
+ return modelTypeHandler.getModelTypeByName(name)
+ }
+
+ @GetMapping(path = arrayOf("/search/{tags}"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE))
+ fun searchModelTypes(@PathVariable(value = "tags") tags: String): List<ModelType> {
+ return modelTypeHandler.searchModelTypes(tags)
+ }
+
+ @GetMapping(path = arrayOf("/by-definition/{definitionType}"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE))
+ @ResponseBody
+ fun getModelTypeByDefinitionType(@PathVariable(value = "definitionType") definitionType: String): List<ModelType> {
+ return modelTypeHandler.getModelTypeByDefinitionType(definitionType)
+ }
+
+ @PostMapping(path = arrayOf(""), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE), consumes = arrayOf(MediaType.APPLICATION_JSON_VALUE))
+ @ResponseBody
+ @Throws(BluePrintException::class)
+ fun saveModelType(@RequestBody modelType: ModelType): ModelType {
+ return modelTypeHandler.saveModel(modelType)
+ }
+
+ @DeleteMapping(path = arrayOf("/{name}"))
+ fun deleteModelTypeByName(@PathVariable(value = "name") name: String) {
+ modelTypeHandler.deleteByModelName(name)
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ModelTypeHandler.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ModelTypeHandler.kt
new file mode 100644
index 00000000..8099d07f
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ModelTypeHandler.kt
@@ -0,0 +1,116 @@
+/*
+ * 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.service.handler
+
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository
+import org.onap.ccsdk.apps.controllerblueprints.service.validator.ModelTypeValidator
+import org.springframework.stereotype.Service
+
+@Service
+open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository) {
+
+ private val log = EELFManager.getInstance().getLogger(ModelTypeHandler::class.java)!!
+
+ /**
+ * This is a getModelTypeByName service
+ *
+ * @param modelTypeName modelTypeName
+ * @return ModelType
+ */
+ fun getModelTypeByName(modelTypeName: String): ModelType? {
+ log.info("Searching : $modelTypeName")
+ check(modelTypeName.isNotBlank()) { "Model Name Information is missing." }
+ return modelTypeRepository.findByModelName(modelTypeName)
+ }
+
+
+ /**
+ * This is a searchModelTypes service
+ *
+ * @param tags tags
+ * @return List<ModelType>
+ </ModelType> */
+ fun searchModelTypes(tags: String): List<ModelType> {
+ check(tags.isNotBlank()) { "No Search Information provide" }
+ return modelTypeRepository.findByTagsContainingIgnoreCase(tags)
+ }
+
+ /**
+ * This is a saveModel service
+ *
+ * @param modelType modelType
+ * @return ModelType
+ * @throws BluePrintException BluePrintException
+ */
+ @Throws(BluePrintException::class)
+ open fun saveModel(modelType: ModelType): ModelType {
+ lateinit var dbModel: ModelType
+ ModelTypeValidator.validateModelType(modelType)
+ val dbModelType: ModelType? = modelTypeRepository.findByModelName(modelType.modelName)
+ if (dbModelType != null) {
+ dbModel = dbModelType
+ dbModel.description = modelType.description
+ dbModel.definition = modelType.definition
+ dbModel.definitionType = modelType.definitionType
+ dbModel.derivedFrom = modelType.derivedFrom
+ dbModel.tags = modelType.tags
+ dbModel.version = modelType.version
+ dbModel.updatedBy = modelType.updatedBy
+ dbModel = modelTypeRepository.save(dbModel)
+ } else {
+ dbModel = modelTypeRepository.save(modelType)
+ }
+ return dbModel
+ }
+
+
+ /**
+ * This is a deleteByModelName service
+ *
+ * @param modelName modelName
+ */
+ open fun deleteByModelName(modelName: String) {
+ check(modelName.isNotBlank()) { "Model Name Information is missing." }
+ modelTypeRepository.deleteByModelName(modelName)
+
+ }
+
+ /**
+ * This is a getModelTypeByDefinitionType service
+ *
+ * @param definitionType definitionType
+ * @return List<ModelType>
+ */
+ fun getModelTypeByDefinitionType(definitionType: String): List<ModelType> {
+ check(definitionType.isNotBlank()) { "Model definitionType Information is missing." }
+ return modelTypeRepository.findByDefinitionType(definitionType)
+ }
+
+ /**
+ * This is a getModelTypeByDerivedFrom service
+ *
+ * @param derivedFrom derivedFrom
+ * @return List<ModelType>
+ */
+ fun getModelTypeByDerivedFrom(derivedFrom: String): List<ModelType> {
+ check(derivedFrom.isNotBlank()) { "Model derivedFrom Information is missing." }
+ return modelTypeRepository.findByDerivedFrom(derivedFrom)
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt
new file mode 100644
index 00000000..c2493148
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt
@@ -0,0 +1,138 @@
+/*
+ * 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.service.handler
+
+import com.google.common.base.Preconditions
+import org.apache.commons.collections.CollectionUtils
+import org.apache.commons.lang3.StringUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationService
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository
+import org.onap.ccsdk.apps.controllerblueprints.service.validator.ResourceDictionaryValidator
+import org.springframework.stereotype.Service
+
+@Service
+class ResourceDictionaryHandler(private val resourceDictionaryRepository: ResourceDictionaryRepository,
+ private val resourceDictionaryValidationService: ResourceDefinitionValidationService) {
+
+
+ /**
+ * This is a getDataDictionaryByName service
+ *
+ * @param name name
+ * @return DataDictionary
+ * @throws BluePrintException BluePrintException
+ */
+ @Throws(BluePrintException::class)
+ fun getResourceDictionaryByName(name: String): ResourceDictionary {
+ Preconditions.checkArgument(StringUtils.isNotBlank(name), "Resource dictionary Name Information is missing.")
+ val resourceDictionaryDb = resourceDictionaryRepository.findByName(name)
+ return if (resourceDictionaryDb.isPresent) {
+ resourceDictionaryDb.get()
+ } else {
+ throw BluePrintException(String.format("couldn't get resource dictionary for name (%s)", name))
+ }
+ }
+
+ /**
+ * This is a searchResourceDictionaryByNames service
+ *
+ * @param names names
+ * @return List<ResourceDictionary>
+ </ResourceDictionary> */
+ fun searchResourceDictionaryByNames(names: List<String>): List<ResourceDictionary> {
+ Preconditions.checkArgument(CollectionUtils.isNotEmpty(names), "No Search Information provide")
+ return resourceDictionaryRepository.findByNameIn(names)
+ }
+
+ /**
+ * This is a searchResourceDictionaryByTags service
+ *
+ * @param tags tags
+ * @return List<ResourceDictionary>
+ </ResourceDictionary> */
+ fun searchResourceDictionaryByTags(tags: String): List<ResourceDictionary> {
+ Preconditions.checkArgument(StringUtils.isNotBlank(tags), "No search tag information provide")
+ return resourceDictionaryRepository.findByTagsContainingIgnoreCase(tags)
+ }
+
+ /**
+ * This is a saveDataDictionary service
+ *
+ * @param resourceDictionary resourceDictionary
+ * @return DataDictionary
+ */
+ @Throws(BluePrintException::class)
+ fun saveResourceDictionary(resourceDictionary: ResourceDictionary): ResourceDictionary {
+ var resourceDictionary = resourceDictionary
+
+ val resourceDefinition = resourceDictionary.definition
+ Preconditions.checkNotNull(resourceDefinition, "failed to get resource definition from content")
+ // Validate the Resource Definitions
+ resourceDictionaryValidationService.validate(resourceDefinition)
+
+ resourceDictionary.tags = resourceDefinition.tags
+ resourceDefinition.updatedBy = resourceDictionary.updatedBy
+ // Set the Property Definitions
+ val propertyDefinition = resourceDefinition.property
+ resourceDictionary.description = propertyDefinition.description
+ resourceDictionary.dataType = propertyDefinition.type
+ if (propertyDefinition.entrySchema != null) {
+ resourceDictionary.entrySchema = propertyDefinition.entrySchema!!.type
+ }
+
+ ResourceDictionaryValidator.validateResourceDictionary(resourceDictionary)
+
+ val dbResourceDictionaryData = resourceDictionaryRepository.findByName(resourceDictionary.name)
+ if (dbResourceDictionaryData.isPresent) {
+ val dbResourceDictionary = dbResourceDictionaryData.get()
+
+ dbResourceDictionary.name = resourceDictionary.name
+ dbResourceDictionary.definition = resourceDictionary.definition
+ dbResourceDictionary.description = resourceDictionary.description
+ dbResourceDictionary.tags = resourceDictionary.tags
+ dbResourceDictionary.updatedBy = resourceDictionary.updatedBy
+ dbResourceDictionary.dataType = resourceDictionary.dataType
+ dbResourceDictionary.entrySchema = resourceDictionary.entrySchema
+ resourceDictionary = resourceDictionaryRepository.save(dbResourceDictionary)
+ } else {
+ resourceDictionary = resourceDictionaryRepository.save(resourceDictionary)
+ }
+
+ return resourceDictionary
+ }
+
+ /**
+ * This is a deleteResourceDictionary service
+ *
+ * @param name name
+ */
+ fun deleteResourceDictionary(name: String) {
+ check(name.isNotBlank()) { "Resource dictionary name is missing." }
+ resourceDictionaryRepository.deleteByName(name)
+ }
+
+ /**
+ * This is a getResourceSourceMapping service
+ */
+ fun getResourceSourceMapping(): ResourceSourceMapping {
+ return ResourceSourceMappingFactory.getRegisterSourceMapping()
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt
index 31b1a16b..51bbca7d 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt
@@ -25,14 +25,14 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType
import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType
import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.onap.ccsdk.apps.controllerblueprints.service.ModelTypeService
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType
+import org.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler
import org.springframework.stereotype.Service
import java.io.File
import java.nio.charset.Charset
@Service
-open class ModelTypeLoadService(private val modelTypeService: ModelTypeService) {
+open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler) {
private val log = EELFManager.getInstance().getLogger(ModelTypeLoadService::class.java)
private val updateBySystem = "System"
@@ -100,7 +100,7 @@ open class ModelTypeLoadService(private val modelTypeService: ModelTypeService)
modelType.version = dataType.version
modelType.updatedBy = updateBySystem
modelType.tags = (dataKey + "," + dataType.derivedFrom + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
- modelTypeService.saveModel(modelType)
+ modelTypeHandler.saveModel(modelType)
log.trace("DataType(${file.name}) loaded successfully ")
} catch (e: Exception) {
errorBuilder.appendln("Couldn't load DataType(${file.name}: ${e.message}")
@@ -124,7 +124,7 @@ open class ModelTypeLoadService(private val modelTypeService: ModelTypeService)
modelType.version = artifactType.version
modelType.updatedBy = updateBySystem
modelType.tags = (dataKey + "," + artifactType.derivedFrom + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE)
- modelTypeService.saveModel(modelType)
+ modelTypeHandler.saveModel(modelType)
log.trace("ArtifactType(${file.name}) loaded successfully ")
} catch (e: Exception) {
errorBuilder.appendln("Couldn't load ArtifactType(${file.name}: ${e.message}")
@@ -148,7 +148,7 @@ open class ModelTypeLoadService(private val modelTypeService: ModelTypeService)
modelType.version = nodeType.version
modelType.updatedBy = updateBySystem
modelType.tags = (nodeKey + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE + "," + nodeType.derivedFrom)
- modelTypeService.saveModel(modelType)
+ modelTypeHandler.saveModel(modelType)
log.trace("NodeType(${file.name}) loaded successfully ")
} catch (e: Exception) {
errorBuilder.appendln("Couldn't load NodeType(${file.name}: ${e.message}")
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ResourceDictionaryLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ResourceDictionaryLoadService.kt
index 4bb8a2f3..8100cac3 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ResourceDictionaryLoadService.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ResourceDictionaryLoadService.kt
@@ -25,14 +25,14 @@ import org.apache.commons.lang3.text.StrBuilder
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.ResourceDefinition
-import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary
+import org.onap.ccsdk.apps.controllerblueprints.service.handler.ResourceDictionaryHandler
import org.springframework.stereotype.Service
import java.io.File
import java.nio.charset.Charset
@Service
-open class ResourceDictionaryLoadService(private val resourceDictionaryService: ResourceDictionaryService) {
+open class ResourceDictionaryLoadService(private val resourceDictionaryHandler: ResourceDictionaryHandler) {
private val log = EELFManager.getInstance().getLogger(ResourceDictionaryLoadService::class.java)
@@ -92,7 +92,7 @@ open class ResourceDictionaryLoadService(private val resourceDictionaryService:
} else {
resourceDictionary.tags = resourceDefinition.tags
}
- resourceDictionaryService.saveResourceDictionary(resourceDictionary)
+ resourceDictionaryHandler.saveResourceDictionary(resourceDictionary)
log.trace("Resource dictionary(${file.name}) loaded successfully ")
} else {
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.kt
index 27823ef3..990cc651 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.kt
@@ -1,107 +1,85 @@
-/*
- * 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.service.repository;
-
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Repository;
-
-import java.util.List;
-import java.util.Optional;
-
-
-/**
- * ModelTypeRepository.java Purpose: Provide Configuration Generator ModelTypeRepository
- *
- * @author Brinda Santh
- * @version 1.0
- */
-@Repository
-public interface ModelTypeRepository extends JpaRepository<ModelType, String> {
-
-
- /**
- * This is a findByModelName method
- *
- * @param modelName Model Name
- * @return Optional<ModelType>
- */
- Optional<ModelType> findByModelName(String modelName);
-
- /**
- * This is a findByModelNameIn method
- *
- * @param modelNames Model Names
- * @return List<ModelType>
- */
- List<ModelType> findByModelNameIn(List<String> modelNames);
-
- /**
- * This is a findByDerivedFrom method
- *
- * @param derivedFrom Derived From
- * @return List<ModelType>
- */
- List<ModelType> findByDerivedFrom(String derivedFrom);
-
-
- /**
- * This is a findByDerivedFromIn method
- *
- * @param derivedFroms Derived Froms
- * @return List<ModelType>
- */
- @SuppressWarnings("unused")
- List<ModelType> findByDerivedFromIn(List<String> derivedFroms);
-
- /**
- * This is a findByDefinitionType method
- *
- * @param definitionType Definition Type
- * @return List<ModelType>
- */
- List<ModelType> findByDefinitionType(String definitionType);
-
- /**
- * This is a findByDefinitionTypeIn method
- *
- * @param definitionTypes Definition Types
- * @return List<ModelType>
- */
- @SuppressWarnings("unused")
- List<ModelType> findByDefinitionTypeIn(List<String> definitionTypes);
-
-
- /**
- * This is a findByTagsContainingIgnoreCase method
- *
- * @param tags Tags
- * @return Optional<ModelType>
- */
- List<ModelType> findByTagsContainingIgnoreCase(String tags);
-
-
- /**
- * This is a deleteByModelName method
- *
- * @param modelName ModelName
- */
- void deleteByModelName(String modelName);
-
-
-
-}
+/*
+ * 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.service.repository
+
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType
+import org.springframework.data.jpa.repository.JpaRepository
+import org.springframework.stereotype.Repository
+import javax.transaction.Transactional
+
+@Repository
+interface ModelTypeRepository : JpaRepository<ModelType, String> {
+ /**
+ * This is a findByModelName method
+ *
+ * @param modelName Model Name
+ * @return Optional<ModelType>
+ */
+ fun findByModelName(modelName: String): ModelType?
+ /**
+ * This is a findByModelNameIn method
+ *
+ * @param modelNames Model Names
+ * @return List<ModelType>
+ */
+ fun findByModelNameIn(modelNames: List<String>): List<ModelType>
+ /**
+ * This is a findByDerivedFrom method
+ *
+ * @param derivedFrom Derived From
+ * @return List<ModelType>
+ */
+ fun findByDerivedFrom(derivedFrom: String): List<ModelType>
+ /**
+ * This is a findByDerivedFromIn method
+ *
+ * @param derivedFroms Derived Froms
+ * @return List<ModelType>
+ */
+ fun findByDerivedFromIn(derivedFroms: List<String>): List<ModelType>
+
+ /**
+ * This is a findByDefinitionType method
+ *
+ * @param definitionType Definition Type
+ * @return List<ModelType>
+ */
+ fun findByDefinitionType(definitionType: String): List<ModelType>
+ /**
+ * This is a findByDefinitionTypeIn method
+ *
+ * @param definitionTypes Definition Types
+ * @return List<ModelType>
+ */
+ fun findByDefinitionTypeIn(definitionTypes: List<String>): List<ModelType>
+
+ /**
+ * This is a findByTagsContainingIgnoreCase method
+ *
+ * @param tags Tags
+ * @return Optional<ModelType>
+ */
+ fun findByTagsContainingIgnoreCase(tags: String): List<ModelType>
+
+ /**
+ * This is a deleteByModelName method
+ *
+ * @param modelName ModelName
+ */
+ @Transactional
+ fun deleteByModelName(modelName: String)
+}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaFileManagementServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaFileManagementServiceTest.java
new file mode 100755
index 00000000..e3cea380
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaFileManagementServiceTest.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright © 2018 IBM Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service;
+import org.junit.*;
+import org.junit.runner.RunWith;
+import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.util.FileSystemUtils;
+import java.nio.file.Path;
+
+
+/**
+ * CbaFileManagementServiceTest.java Purpose: Test the decompressing method of CbaCompressionService
+ *
+ * @author Vinal Patel
+ * @version 1.0
+ */
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ContextConfiguration(classes = {TestApplication.class})
+public class CbaFileManagementServiceTest {
+
+ @Value("${controllerblueprints.loadBlueprintsExamplesPath}")
+ private String cbaPath;
+ private String zipfile;
+ private String directorypath;
+ private Path zipfilepath;
+
+ @Autowired
+ CbaFileManagementService cbaCompressionService;
+
+
+ /**
+ *
+ */
+ @Before
+ public void setUp() {
+ try {
+ zipfilepath = BluePrintFileUtils.Companion.getCbaStorageDirectory(cbaPath);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ zipfile = "CBA_Zip_Test.zip";
+ directorypath = zipfilepath.resolve(zipfile.substring(0,zipfile.lastIndexOf("."))).toAbsolutePath().toString();
+ }
+ @After
+ public void clenup() throws BluePrintException {
+
+ try {
+ //Delete the Zip file from the repository
+ FileSystemUtils.deleteRecursively(BluePrintFileUtils.Companion.getBluePrintFile(directorypath, zipfilepath));
+ }
+ catch (Exception ex){
+ throw new BluePrintException("Fail while cleaning up CBA saved!", ex);
+ }
+ }
+
+ /**
+ * @throws BluePrintException
+ * Test will get success if it is able to decompress CBA file and returns the folder path
+ */
+ @Test
+ public void testDecompressCBAFile_success() throws BluePrintException {
+ Assert.assertEquals(directorypath,cbaCompressionService.decompressCBAFile(zipfile,zipfilepath));
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java
index 8e258ab6..e2bb4c5f 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java
@@ -25,9 +25,11 @@ import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+import org.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler;
import org.onap.ccsdk.apps.controllerblueprints.service.rs.ModelTypeRestTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.test.annotation.Commit;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Propagation;
@@ -43,11 +45,12 @@ import java.util.List;
public class ModelTypeServiceTest {
private static EELFLogger log = EELFManager.getInstance().getLogger(ModelTypeRestTest.class);
@Autowired
- ModelTypeService modelTypeService;
+ private ModelTypeHandler modelTypeHandler;
String modelName = "test-datatype";
@Test
+ @Commit
public void test01SaveModelType() throws Exception {
log.info("**************** test01SaveModelType ********************");
@@ -62,18 +65,18 @@ public class ModelTypeServiceTest {
modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","
+ BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
modelType.setUpdatedBy("xxxxxx@xxx.com");
- modelType = modelTypeService.saveModel(modelType);
+ modelType = modelTypeHandler.saveModel(modelType);
log.info("Saved Mode {}", modelType.toString());
Assert.assertNotNull("Failed to get Saved ModelType", modelType);
Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.getModelName());
- ModelType dbModelType = modelTypeService.getModelTypeByName(modelType.getModelName());
+ ModelType dbModelType = modelTypeHandler.getModelTypeByName(modelType.getModelName());
Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType.getModelName() + ")",
dbModelType);
// Model Update
modelType.setUpdatedBy("bs2796@xxx.com");
- modelType = modelTypeService.saveModel(modelType);
+ modelType = modelTypeHandler.saveModel(modelType);
Assert.assertNotNull("Failed to get Saved ModelType", modelType);
Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.getUpdatedBy());
@@ -85,7 +88,7 @@ public class ModelTypeServiceTest {
String tags = "test-datatype";
- List<ModelType> dbModelTypes = modelTypeService.searchModelTypes(tags);
+ List<ModelType> dbModelTypes = modelTypeHandler.searchModelTypes(tags);
Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes);
Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.size() > 0);
@@ -94,17 +97,17 @@ public class ModelTypeServiceTest {
@Test
public void test03GetModelType() throws Exception {
log.info("************************* test03GetModelType *********************************");
- ModelType dbModelType = modelTypeService.getModelTypeByName(modelName);
+ ModelType dbModelType = modelTypeHandler.getModelTypeByName(modelName);
Assert.assertNotNull("Failed to get response for api call getModelByName ", dbModelType);
Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbModelType.getModelName());
List<ModelType> dbDatatypeModelTypes =
- modelTypeService.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
+ modelTypeHandler.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
Assert.assertNotNull("Failed to find getModelTypeByDefinitionType by tags", dbDatatypeModelTypes);
Assert.assertTrue("Failed to find getModelTypeByDefinitionType by count", dbDatatypeModelTypes.size() > 0);
List<ModelType> dbModelTypeByDerivedFroms =
- modelTypeService.getModelTypeByDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT);
+ modelTypeHandler.getModelTypeByDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT);
Assert.assertNotNull("Failed to find getModelTypeByDerivedFrom by tags", dbModelTypeByDerivedFroms);
Assert.assertTrue("Failed to find getModelTypeByDerivedFrom by count", dbModelTypeByDerivedFroms.size() > 0);
@@ -114,10 +117,10 @@ public class ModelTypeServiceTest {
public void test04DeleteModelType() throws Exception {
log.info(
"************************ test03DeleteModelType ***********************");
- ModelType dbResourceMapping = modelTypeService.getModelTypeByName(modelName);
+ ModelType dbResourceMapping = modelTypeHandler.getModelTypeByName(modelName);
Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping);
Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbResourceMapping.getModelName());
- modelTypeService.deleteByModelName(dbResourceMapping.getModelName());
+ modelTypeHandler.deleteByModelName(dbResourceMapping.getModelName());
}
} \ No newline at end of file
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 c7147490..d283377b 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
@@ -17,48 +17,37 @@
package org.onap.ccsdk.apps.controllerblueprints.service.rs;
-import org.apache.commons.io.FileUtils;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.junit.*;
import org.junit.runner.RunWith;
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.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.service.controller.ModelTypeController;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
-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;
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.test.annotation.Commit;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
-import java.io.File;
-import java.nio.charset.Charset;
import java.util.List;
@RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@DataJpaTest
@ContextConfiguration(classes = {TestApplication.class})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ModelTypeRestTest {
private static EELFLogger log = EELFManager.getInstance().getLogger(ModelTypeRestTest.class);
@Autowired
- ModelTypeRest modelTypeRest;
+ ModelTypeController modelTypeController;
String modelName = "test-datatype";
- @Before
- public void setUp() {
-
- }
-
-
- @After
- public void tearDown() {
- }
-
@Test
+ @Commit
public void test01SaveModelType() throws Exception {
log.info("**************** test01SaveModelType ********************");
@@ -73,18 +62,18 @@ public class ModelTypeRestTest {
modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","
+ BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
modelType.setUpdatedBy("xxxxxx@xxx.com");
- modelType = modelTypeRest.saveModelType(modelType);
+ modelType = modelTypeController.saveModelType(modelType);
log.info("Saved Mode {}", modelType.toString());
Assert.assertNotNull("Failed to get Saved ModelType", modelType);
Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.getModelName());
- ModelType dbModelType = modelTypeRest.getModelTypeByName(modelType.getModelName());
+ ModelType dbModelType = modelTypeController.getModelTypeByName(modelType.getModelName());
Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType.getModelName() + ")",
dbModelType);
// Model Update
modelType.setUpdatedBy("bs2796@xxx.com");
- modelType = modelTypeRest.saveModelType(modelType);
+ modelType = modelTypeController.saveModelType(modelType);
Assert.assertNotNull("Failed to get Saved ModelType", modelType);
Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.getUpdatedBy());
@@ -96,7 +85,7 @@ public class ModelTypeRestTest {
String tags = "test-datatype";
- List<ModelType> dbModelTypes = modelTypeRest.searchModelTypes(tags);
+ List<ModelType> dbModelTypes = modelTypeController.searchModelTypes(tags);
Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes);
Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.size() > 0);
@@ -105,25 +94,26 @@ public class ModelTypeRestTest {
@Test
public void test03GetModelType() throws Exception {
log.info("************************* test03GetModelType *********************************");
- ModelType dbModelType = modelTypeRest.getModelTypeByName(modelName);
- Assert.assertNotNull("Failed to get response for api call getModelByName ", dbModelType);
+ ModelType dbModelType = modelTypeController.getModelTypeByName(modelName);
+ Assert.assertNotNull("Failed to get response for api call getModelByName " + modelName, dbModelType);
Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbModelType.getModelName());
List<ModelType> dbDatatypeModelTypes =
- modelTypeRest.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
+ modelTypeController.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
Assert.assertNotNull("Failed to find getModelTypeByDefinitionType by tags", dbDatatypeModelTypes);
Assert.assertTrue("Failed to find getModelTypeByDefinitionType by count", dbDatatypeModelTypes.size() > 0);
}
@Test
+ @Commit
public void test04DeleteModelType() throws Exception {
log.info(
"************************ test03DeleteModelType ***********************");
- ModelType dbResourceMapping = modelTypeRest.getModelTypeByName(modelName);
+ ModelType dbResourceMapping = modelTypeController.getModelTypeByName(modelName);
Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping);
Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbResourceMapping.getModelName());
- modelTypeRest.deleteModelTypeByName(dbResourceMapping.getModelName());
+ modelTypeController.deleteModelTypeByName(dbResourceMapping.getModelName());
}
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 675d2c24..9c02d4cf 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
@@ -29,6 +29,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
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.controller.ModelTypeController;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
import com.att.eelf.configuration.EELFLogger;
@@ -52,7 +53,7 @@ public class ServiceTemplateRestTest {
private static EELFLogger log = EELFManager.getInstance().getLogger(ServiceTemplateRestTest.class);
@Autowired
- ModelTypeRest modelTypeRest;
+ ModelTypeController modelTypeRest;
@Autowired
private ServiceTemplateRest serviceTemplateRest;
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/application.properties b/ms/controllerblueprints/modules/service/src/test/resources/application.properties
index 718616bb..4e1bedf2 100644..100755
--- a/ms/controllerblueprints/modules/service/src/test/resources/application.properties
+++ b/ms/controllerblueprints/modules/service/src/test/resources/application.properties
@@ -32,4 +32,10 @@ controllerblueprints.loadBluePrintPaths=./../../../../components/model-catalog/b
controllerblueprints.loadModelType=false
controllerblueprints.loadModeTypePaths=./../../../../components/model-catalog/definition-type/starter-type
controllerblueprints.loadResourceDictionary=false
-controllerblueprints.loadResourceDictionaryPaths=./../../../../components/model-catalog/resource-dictionary/starter-dictionary \ No newline at end of file
+controllerblueprints.loadResourceDictionaryPaths=./../../../../components/model-catalog/resource-dictionary/starter-dictionary
+
+# CBA file extension
+controllerblueprints.loadCbaExtension=zip
+
+# CBA examples for tests cases
+controllerblueprints.loadBlueprintsExamplesPath=./../../../../components/model-catalog/blueprint-model/test-blueprints \ No newline at end of file
diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml
index b9134318..38a879ab 100644
--- a/ms/controllerblueprints/parent/pom.xml
+++ b/ms/controllerblueprints/parent/pom.xml
@@ -114,6 +114,11 @@
<version>${kotlin.couroutines.version}</version>
</dependency>
<dependency>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-reactor</artifactId>
+ <version>${kotlin.couroutines.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${kotlin.version}</version>