diff options
Diffstat (limited to 'ms/controllerblueprints')
72 files changed, 432 insertions, 340 deletions
diff --git a/ms/controllerblueprints/application/pom.xml b/ms/controllerblueprints/application/pom.xml index 3bb7fde9a..ddefb2787 100644 --- a/ms/controllerblueprints/application/pom.xml +++ b/ms/controllerblueprints/application/pom.xml @@ -52,6 +52,12 @@ <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> + <exclusions> + <exclusion> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-logging</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/ControllerBlueprintsApplication.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/ControllerBlueprintsApplication.java index 29d2eb7c7..df979c6b3 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/ControllerBlueprintsApplication.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/ControllerBlueprintsApplication.java @@ -16,8 +16,8 @@ package org.onap.ccsdk.cds.controllerblueprints; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -32,7 +32,7 @@ import org.springframework.web.reactive.config.EnableWebFlux; @ComponentScan(basePackages = {"org.onap.ccsdk.cds.controllerblueprints"}) @EnableAutoConfiguration public class ControllerBlueprintsApplication { - private static EELFLogger log = EELFManager.getInstance().getLogger(ControllerBlueprintsApplication.class); + private static Logger log = LoggerFactory.getLogger(ControllerBlueprintsApplication.class); public static void main(String[] args) { log.info("****** Starting Controlled Blueprints Application ******"); diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java index 131ff015d..d992dd945 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java @@ -16,8 +16,8 @@ package org.onap.ccsdk.cds.controllerblueprints.security; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity; @@ -37,7 +37,7 @@ public class ApplicationSecurityConfigurerAdapter { @Value("${basic-auth.hashed-pwd}") private String userHashedPassword; - private static EELFLogger log = EELFManager.getInstance().getLogger(ApplicationSecurityConfigurerAdapter.class); + private static Logger log = LoggerFactory.getLogger(ApplicationSecurityConfigurerAdapter.class); @Bean public SecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http) throws Exception { diff --git a/ms/controllerblueprints/application/src/main/resources/application-dev.properties b/ms/controllerblueprints/application/src/main/resources/application-dev.properties index 7282d75c4..46218d6d2 100755 --- a/ms/controllerblueprints/application/src/main/resources/application-dev.properties +++ b/ms/controllerblueprints/application/src/main/resources/application-dev.properties @@ -53,7 +53,7 @@ resourceSourceMappings=processor-db=source-processor-db,input=source-input,defau # Controller Blueprints Core Configuration controllerblueprints.blueprintDeployPath=/etc/blueprints/deploy controllerblueprints.blueprintArchivePath=/etc/blueprints/archive -controllerblueprints.blueprintEnrichmentPath=/etc/blueprints/enrichment +controllerblueprints.blueprintWorkingPath=/etc/blueprints/work # Controller Blueprint Load Configurations controllerblueprints.loadInitialData=true controllerblueprints.loadBluePrint=false diff --git a/ms/controllerblueprints/application/src/main/resources/application.properties b/ms/controllerblueprints/application/src/main/resources/application.properties index 5877ea55a..b9c1d4f4e 100755 --- a/ms/controllerblueprints/application/src/main/resources/application.properties +++ b/ms/controllerblueprints/application/src/main/resources/application.properties @@ -57,7 +57,7 @@ resourceSourceMappings=processor-db=source-processor-db,input=source-input,defau # Controller Blueprints Core Configuration controllerblueprints.blueprintDeployPath=/etc/blueprints/deploy controllerblueprints.blueprintArchivePath=/etc/blueprints/archive -controllerblueprints.blueprintEnrichmentPath=/etc/blueprints/enrichment +controllerblueprints.blueprintWorkingPath=/etc/blueprints/work # Controller Blueprint Load Configurations # blueprints.load.initial-data may be overridden by ENV variables controllerblueprints.loadInitialData=true diff --git a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/VersionSplitTest.java b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/VersionSplitTest.java index 71597afc4..9688b26b1 100644 --- a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/VersionSplitTest.java +++ b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/VersionSplitTest.java @@ -16,11 +16,11 @@ package org.onap.ccsdk.cds.controllerblueprints;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
import org.apache.commons.lang3.StringUtils;
import org.junit.Assert;
import org.junit.Test;
+import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
/**
@@ -29,7 +29,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; * @author Brinda Santh
*/
public class VersionSplitTest {
- private static EELFLogger log = EELFManager.getInstance().getLogger(VersionSplitTest.class);
+ private static Logger log = LoggerFactory.getLogger(VersionSplitTest.class); @Test
public void testVersionSplit() {
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctions.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctions.kt index 6744b625e..bda60ea73 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctions.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctions.kt @@ -84,6 +84,14 @@ fun normalizedPathName(path: String, vararg more: String?): String { return normalizedPath(path, *more).toString() } +suspend fun File.reCreateNBDirs(): File = withContext(Dispatchers.IO) { + reCreateDirs() +} + +suspend fun deleteNBDir(path: String, vararg more: String?) = withContext(Dispatchers.IO) { + normalizedFile(path, *more).deleteRecursively() +} + suspend fun File.readNBText(): String = withContext(Dispatchers.IO) { readText(Charset.defaultCharset()) } diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/config/BluePrintLoadConfiguration.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/config/BluePrintLoadConfiguration.kt index 2815bad4c..8674c4d40 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/config/BluePrintLoadConfiguration.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/config/BluePrintLoadConfiguration.kt @@ -16,12 +16,15 @@ package org.onap.ccsdk.cds.controllerblueprints.core.config -open class BluePrintLoadConfiguration { +open class BluePrintPathConfiguration { lateinit var blueprintDeployPath: String lateinit var blueprintArchivePath: String - lateinit var blueprintEnrichmentPath: String + lateinit var blueprintWorkingPath: String +} + +open class BluePrintLoadConfiguration : BluePrintPathConfiguration() { var loadInitialData: Boolean = false var loadBluePrint: Boolean = false var loadBluePrintPaths: String? = null diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintCatalogService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintCatalogService.kt index d71569ea2..9b4f6b56e 100755 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintCatalogService.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintCatalogService.kt @@ -16,8 +16,6 @@ package org.onap.ccsdk.cds.controllerblueprints.core.interfaces -import org.jetbrains.annotations.NotNull -import org.jetbrains.annotations.Nullable import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import java.io.File import java.nio.file.Path @@ -26,14 +24,14 @@ interface BluePrintCatalogService { /** * Save the CBA to database. + * @param processingId Processing Id * @param blueprintFile Either a directory, or an archive * @param validate whether to validate blueprint content. Default true. * @return The unique blueprint identifier * @throws BluePrintException if process failed */ - @NotNull @Throws(BluePrintException::class) - fun saveToDatabase(@NotNull blueprintFile: File, @Nullable validate: Boolean = true): String + suspend fun saveToDatabase(processingId: String, blueprintFile: File, validate: Boolean = true): String /** * Retrieve the CBA from database either archived or extracted. @@ -43,9 +41,9 @@ interface BluePrintCatalogService { * @return Path where CBA is located * @throws BluePrintException if process failed */ - @NotNull + @Throws(BluePrintException::class) - fun getFromDatabase(@NotNull name: String, @NotNull version: String, @Nullable extract: Boolean = true): Path + suspend fun getFromDatabase(name: String, version: String, extract: Boolean = true): Path /** * Delete the CBA from database. @@ -53,7 +51,7 @@ interface BluePrintCatalogService { * @param version Version of the blueprint * @throws BluePrintException if process failed */ - @NotNull + @Throws(BluePrintException::class) - fun deleteFromDatabase(@NotNull name: String, @NotNull version: String) + suspend fun deleteFromDatabase(name: String, version: String) }
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContext.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContext.kt index f0a3bcc0f..26181bb19 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContext.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContext.kt @@ -18,8 +18,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import com.fasterxml.jackson.databind.JsonNode import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException @@ -33,7 +32,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils */ class BluePrintContext(val serviceTemplate: ServiceTemplate) { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + private val log= LoggerFactory.getLogger(this::class.toString()) /** * Blueprint CBA extracted file location diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt index a126d64d4..32cb6ac77 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt @@ -17,8 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.ArrayNode import com.fasterxml.jackson.databind.node.ObjectNode @@ -34,7 +33,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.* * @author Brinda Santh */ object BluePrintExpressionService { - val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + val log= LoggerFactory.getLogger(this::class.toString()) @JvmStatic fun checkContainsExpression(propertyAssignmentNode: JsonNode): Boolean { diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileService.kt index 8562287d1..4b02492da 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileService.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileService.kt @@ -16,8 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.data.* @@ -26,7 +25,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoService { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRepoFileService::class.toString()) + private val log= LoggerFactory.getLogger(BluePrintRepoFileService::class.toString()) private val dataTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) private val nodeTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE) diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt index 37ab7171e..8f39a5a5c 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt @@ -18,8 +18,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode import com.fasterxml.jackson.databind.node.ObjectNode @@ -134,7 +133,7 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl : BluePrintRuntimeService<MutableMap<String, JsonNode>> { @Transient - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRuntimeService::class.toString()) + private val log= LoggerFactory.getLogger(BluePrintRuntimeService::class.toString()) private var store: MutableMap<String, JsonNode> = hashMapOf() diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintValidatorService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintValidatorService.kt index 03fdc22fa..e74a8e9cc 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintValidatorService.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintValidatorService.kt @@ -17,8 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import com.fasterxml.jackson.databind.JsonNode import com.google.common.base.Preconditions import org.apache.commons.lang3.StringUtils @@ -44,7 +43,7 @@ interface BluePrintValidatorService : Serializable { @Deprecated("Decomposed implementation moved to blueprint-validation module") open class BluePrintValidatorDefaultService : BluePrintValidatorService { - val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorDefaultService::class.toString()) + val log= LoggerFactory.getLogger(BluePrintValidatorDefaultService::class.toString()) lateinit var bluePrintContext: BluePrintContext lateinit var serviceTemplate: ServiceTemplate diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt index 6080f52bb..931d31e9d 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt @@ -18,8 +18,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants @@ -37,7 +36,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.ResourceResolverUtils * @author Brinda Santh */ class PropertyAssignmentService(var bluePrintRuntimeService: BluePrintRuntimeService<MutableMap<String, JsonNode>>) { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + private val log= LoggerFactory.getLogger(this::class.toString()) private var bluePrintContext: BluePrintContext = bluePrintRuntimeService.bluePrintContext() diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtils.kt index 25867769e..5f9725f10 100755 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtils.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtils.kt @@ -17,8 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import kotlinx.coroutines.runBlocking import org.apache.commons.io.FileUtils import org.apache.commons.lang3.StringUtils @@ -39,7 +38,7 @@ import java.nio.file.StandardOpenOption class BluePrintFileUtils { companion object { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + private val log= LoggerFactory.getLogger(this::class.toString()) fun createEmptyBluePrint(basePath: String) { diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt index bc0103958..c51f48290 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt @@ -18,8 +18,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import com.fasterxml.jackson.databind.JsonNode import kotlinx.coroutines.runBlocking import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants @@ -36,7 +35,7 @@ import java.util.* class BluePrintMetadataUtils { companion object { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + private val log= LoggerFactory.getLogger(this::class.toString()) suspend fun toscaMetaData(basePath: String): ToscaMetaData { diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt index 2e3211ef9..3dd756763 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt @@ -16,8 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants @@ -29,7 +28,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext * @author Brinda Santh */ object BluePrintRuntimeUtils { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + private val log= LoggerFactory.getLogger(this::class.toString()) fun assignInputsFromFile(bluePrintContext: BluePrintContext, fileName: String, context: MutableMap<String, JsonNode>) { val jsonNode: JsonNode = JacksonUtils.jsonNodeFromFile(fileName) diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtils.kt index a7136a59c..9fbc38507 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtils.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtils.kt @@ -17,8 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import com.fasterxml.jackson.databind.JsonNode import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext @@ -30,7 +29,7 @@ import java.nio.charset.Charset class JacksonReactorUtils { companion object { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + private val log= LoggerFactory.getLogger(this::class.toString()) suspend fun getContent(fileName: String): String { //log.info("Reading File($fileName)") diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt index 7ac79e2f1..7b5f181da 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt @@ -1,6 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Modifications Copyright © 2018-2019 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import kotlinx.coroutines.withContext import org.apache.commons.io.IOUtils import org.onap.ccsdk.cds.controllerblueprints.core.* import java.io.File +import java.io.InputStream import java.nio.charset.Charset /** @@ -42,10 +43,17 @@ class JacksonUtils { inline fun <reified T : Any> readValue(content: String): T = objectMapper.readValue(content, T::class.java) + inline fun <reified T : Any> readValue(stream: InputStream): T = + objectMapper.readValue(stream, T::class.java) + fun <T> readValue(content: String, valueType: Class<T>): T? { return objectMapper.readValue(content, valueType) } + fun <T> readValue(stream: InputStream, valueType: Class<T>): T? { + return objectMapper.readValue(stream, valueType) + } + fun <T> readValue(node: JsonNode, valueType: Class<T>): T? { return objectMapper.treeToValue(node, valueType) } diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ResourceResolverUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ResourceResolverUtils.kt index 90e4ff80f..f26e7ae20 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ResourceResolverUtils.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ResourceResolverUtils.kt @@ -17,8 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty import java.io.File @@ -30,7 +29,7 @@ import java.net.URL * @author Brinda Santh */ object ResourceResolverUtils { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + private val log= LoggerFactory.getLogger(this::class.toString()) fun getFileContent(filename: String, basePath: String?): String { log.trace("file ({}), basePath ({}) ", filename, basePath) diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctionTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctionTest.kt new file mode 100644 index 000000000..9a0da6905 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctionTest.kt @@ -0,0 +1,34 @@ +/* + * Copyright © 2019 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.cds.controllerblueprints.core + +import org.junit.Test +import kotlin.test.assertTrue + +class FileExtensionFunctionTest { + val blueprintBasePath = "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" + + @Test + fun testCompress() { + val blueprintFile = normalizedFile(blueprintBasePath) + val targetZip = normalizedFile("target", "compress.zip") + targetZip.deleteRecursively() + blueprintFile.compress(targetZip) + assertTrue(blueprintFile.exists(), "failed to create compressed file(${targetZip.absolutePath} ") + } + +}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContextTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContextTest.kt index ac21f132c..2c6561f23 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContextTest.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContextTest.kt @@ -18,8 +18,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.junit.Test import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils @@ -32,7 +31,7 @@ import kotlin.test.assertNotNull */ class BluePrintContextTest { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + private val log= LoggerFactory.getLogger(this::class.toString()) val blueprintBasePath: String = ("./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt index 3c573c483..4c207fbe1 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -17,8 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode import org.junit.Test @@ -37,7 +36,7 @@ import kotlin.test.assertNotNull * @author Brinda Santh */ class BluePrintRuntimeServiceTest { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + private val log= LoggerFactory.getLogger(this::class.toString()) @Test fun `test Resolve NodeTemplate Properties`() { diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt index 8812816ba..d0e971ad7 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt @@ -16,14 +16,13 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import kotlinx.coroutines.runBlocking import org.junit.Test class JacksonReactorUtilsTest { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + private val log= LoggerFactory.getLogger(this::class.toString()) @Test fun testJsonNodeFromClassPathFile() { diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtilsTest.kt index 3d1721384..faa198faf 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtilsTest.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtilsTest.kt @@ -17,8 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.junit.Test import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import kotlin.test.assertNotNull @@ -31,7 +30,7 @@ import kotlin.test.assertTrue */ class JacksonUtilsTest { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + private val log= LoggerFactory.getLogger(this::class.toString()) @Test fun testJsonNodeFromClassPathFile() { diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt index 297bf432a..182c22ce9 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt @@ -16,8 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.validation -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition @@ -35,7 +34,7 @@ import java.io.File open class BluePrintArtifactDefinitionValidatorImpl( private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintArtifactDefinitionValidator { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintArtifactDefinitionValidatorImpl::class.toString()) + private val log= LoggerFactory.getLogger(BluePrintArtifactDefinitionValidatorImpl::class.toString()) lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> lateinit var bluePrintContext: BluePrintContext diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt index 0d16f9b74..3cec5af7b 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt @@ -17,8 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.validation -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeDefinition @@ -35,7 +34,7 @@ import org.springframework.stereotype.Service open class BluePrintAttributeDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintAttributeDefinitionValidator { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) + private val log= LoggerFactory.getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt index 72fb7ac13..c67a9bc0c 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt @@ -17,8 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.validation -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeValidatorService @@ -39,7 +38,7 @@ open class BluePrintDesignTimeValidatorService(private val bluePrintTypeValidato private val resourceDefinitionValidator: ResourceDefinitionValidator) : BluePrintValidatorService { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintDesignTimeValidatorService::class.toString()) + private val log= LoggerFactory.getLogger(BluePrintDesignTimeValidatorService::class.toString()) override fun validateBluePrints(basePath: String): Boolean { diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt index fb466f7c3..48f1b2155 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt @@ -17,9 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.validation -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.onap.ccsdk.cds.controllerblueprints.validation.utils.PropertyAssignmentValidationUtils +import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.data.* @@ -27,6 +25,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintNodeTemp import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeValidatorService import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.validation.utils.PropertyAssignmentValidationUtils import org.springframework.beans.factory.config.ConfigurableBeanFactory import org.springframework.context.annotation.Scope import org.springframework.stereotype.Service @@ -36,7 +35,7 @@ import org.springframework.stereotype.Service @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTemplateValidator { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateValidatorImpl::class.toString()) + private val log= LoggerFactory.getLogger(BluePrintNodeTemplateValidatorImpl::class.toString()) lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> lateinit var bluePrintContext: BluePrintContext @@ -44,7 +43,7 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator var paths: MutableList<String> = arrayListOf() override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) { - log.info("Validating NodeTemplate($name)") + log.debug("Validating NodeTemplate($name)") this.bluePrintRuntimeService = bluePrintRuntimeService this.bluePrintContext = bluePrintRuntimeService.bluePrintContext() @@ -132,7 +131,8 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator @Throws(BluePrintException::class) open fun validateRequirementAssignment(nodeTemplateName: String, requirementAssignmentName: String, requirementDefinition: RequirementDefinition, requirementAssignment: RequirementAssignment) { - log.info("Validating NodeTemplate({}) requirement assignment ({}) ", nodeTemplateName, requirementAssignmentName) + log.debug("Validating NodeTemplate({}) requirement assignment ({}) ", nodeTemplateName, + requirementAssignmentName) val requirementNodeTemplateName = requirementAssignment.node!! val capabilityName = requirementAssignment.capability val relationship = requirementAssignment.relationship!! @@ -197,7 +197,8 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator val operationDefinition = interfaceDefinition.operations?.get(operationAssignmentName) ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) operation definition ($operationAssignmentName)") - log.info("Validation NodeTemplate($nodeTemplateName) Interface($interfaceAssignmentName) Operation ($operationAssignmentName)") + log.debug("Validation NodeTemplate($nodeTemplateName) Interface($interfaceAssignmentName) Operation " + + "($operationAssignmentName)") val inputs = operationAssignments.inputs val outputs = operationAssignments.outputs diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt index 3085140dc..10804e48d 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt @@ -17,8 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.validation -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmptyOrThrow @@ -36,7 +35,7 @@ import org.springframework.stereotype.Service @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTypeValidator { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) + private val log= LoggerFactory.getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> lateinit var bluePrintContext: BluePrintContext diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt index 6808b8e1e..c2c80d7f7 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt @@ -17,8 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.validation -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition @@ -34,7 +33,7 @@ import org.springframework.stereotype.Service @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) open class BluePrintPropertyDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintPropertyDefinitionValidator { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) + private val log= LoggerFactory.getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintServiceTemplateValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintServiceTemplateValidatorImpl.kt index cb9873c8a..0e76be49e 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintServiceTemplateValidatorImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintServiceTemplateValidatorImpl.kt @@ -16,8 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.validation -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import com.google.common.base.Preconditions import org.apache.commons.lang3.StringUtils import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants @@ -34,7 +33,7 @@ import org.springframework.stereotype.Service @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintServiceTemplateValidator { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) + private val log= LoggerFactory.getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> lateinit var error: BluePrintError diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintTopologyTemplateValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintTopologyTemplateValidatorImpl.kt index f88105473..406f8dec0 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintTopologyTemplateValidatorImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintTopologyTemplateValidatorImpl.kt @@ -17,8 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.validation -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition @@ -35,7 +34,7 @@ import org.springframework.stereotype.Service @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) open class BluePrintTopologyTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintTopologyTemplateValidator { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) + private val log= LoggerFactory.getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt index 13307fdfa..e705808c9 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt @@ -17,8 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.validation -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.validation.utils.PropertyAssignmentValidationUtils import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow @@ -33,7 +32,7 @@ import org.springframework.stereotype.Service @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintWorkflowValidator { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) + private val log= LoggerFactory.getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> var paths: MutableList<String> = arrayListOf() diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt index 0c3cef2e7..03183e624 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt @@ -16,8 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.validation.extension -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintArtifactDefinitionValidator import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeValidatorService @@ -32,7 +31,7 @@ import java.io.File open class ArtifactMappingResourceValidator(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintArtifactDefinitionValidator { - private val log: EELFLogger = EELFManager.getInstance().getLogger(ArtifactMappingResourceValidator::class.toString()) + private val log= LoggerFactory.getLogger(ArtifactMappingResourceValidator::class.toString()) override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactDefinition: ArtifactDefinition) { diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/extension/ResourceDefinitionValidation.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/extension/ResourceDefinitionValidation.kt index 6439ee824..608de4f0c 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/extension/ResourceDefinitionValidation.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/extension/ResourceDefinitionValidation.kt @@ -16,8 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.validation.extension -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeValidatorService import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidator import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService @@ -32,7 +31,7 @@ interface ResourceDefinitionValidator : BluePrintValidator<ResourceDefinition> @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) open class ResourceDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : ResourceDefinitionValidator { - private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDefinitionValidatorImpl::class.java) + private val log= LoggerFactory.getLogger(ResourceDefinitionValidatorImpl::class.java) override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, resourceDefinition: ResourceDefinition) { diff --git a/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt b/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt index 3be56480f..9780bbd31 100644 --- a/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt +++ b/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt @@ -18,69 +18,70 @@ package org.onap.ccsdk.cds.controllerblueprints.db.resources -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.cds.controllerblueprints.core.* +import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintPathConfiguration import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintArchiveUtils -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils +import org.slf4j.LoggerFactory import java.io.File import java.nio.file.Path -import java.util.* import javax.persistence.MappedSuperclass @MappedSuperclass -abstract class BlueprintCatalogServiceImpl(private val blueprintValidator: BluePrintValidatorService) - : BluePrintCatalogService { +abstract class BlueprintCatalogServiceImpl( + private val bluePrintPathConfiguration: BluePrintPathConfiguration, + private val blueprintValidator: BluePrintValidatorService) : BluePrintCatalogService { - override fun saveToDatabase(blueprintFile: File, validate: Boolean): String { - val extractedDirectory: File - val archivedDirectory: File - val toDeleteDirectory: File - val blueprintId = UUID.randomUUID().toString() + private val log = LoggerFactory.getLogger(BlueprintCatalogServiceImpl::class.java)!! + + override suspend fun saveToDatabase(processingId: String, blueprintFile: File, validate: Boolean): String { + + var archiveFile: File? = null + var workingDir: String? = null if (blueprintFile.isDirectory) { - extractedDirectory = blueprintFile - archivedDirectory = File("$blueprintFile.zip") - toDeleteDirectory = archivedDirectory + log.info("Save processing($processingId) Working Dir(${blueprintFile.absolutePath})") + workingDir = blueprintFile.absolutePath + archiveFile = normalizedFile(bluePrintPathConfiguration.blueprintArchivePath, processingId, "cba.zip") - if (!BluePrintArchiveUtils.compress(blueprintFile, archivedDirectory, true)) { + if (!BluePrintArchiveUtils.compress(blueprintFile, archiveFile, true)) { throw BluePrintException("Fail to compress blueprint") } } else { - val targetDir = "${blueprintFile.parent}/${BluePrintFileUtils.stripFileExtension(blueprintFile.name)}" - - extractedDirectory = BluePrintArchiveUtils.deCompress(blueprintFile, targetDir) - archivedDirectory = blueprintFile - toDeleteDirectory = extractedDirectory + // Compressed File + log.info("Save processing($processingId) CBA(${blueprintFile.absolutePath})") + workingDir = normalizedPathName(bluePrintPathConfiguration.blueprintWorkingPath, processingId) + archiveFile = blueprintFile + // Decompress the CBA file to working Directory + blueprintFile.deCompress(workingDir) } var valid = BluePrintConstants.FLAG_N if (validate) { - blueprintValidator.validateBluePrints(extractedDirectory.path) + blueprintValidator.validateBluePrints(workingDir!!) valid = BluePrintConstants.FLAG_Y } - val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(blueprintId, extractedDirectory.path) + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(processingId, workingDir!!) val metadata = bluePrintRuntimeService.bluePrintContext().metadata!! - metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = blueprintId + metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = processingId metadata[BluePrintConstants.PROPERTY_BLUEPRINT_VALID] = valid - save(metadata, archivedDirectory) - - toDeleteDirectory.deleteRecursively() + save(metadata, archiveFile) - return blueprintId + return processingId } - override fun getFromDatabase(name: String, version: String, extract: Boolean): Path = get(name, version, extract) + override suspend fun getFromDatabase(name: String, version: String, extract: Boolean): Path = get(name, version, + extract) ?: throw BluePrintException("Could not find blueprint $name:$version from database") - override fun deleteFromDatabase(name: String, version: String) = delete(name, version) + override suspend fun deleteFromDatabase(name: String, version: String) = delete(name, version) - abstract fun save(metadata: MutableMap<String, String>, archiveFile: File) - abstract fun get(name: String, version: String, extract: Boolean): Path? - abstract fun delete(name: String, version: String) + abstract suspend fun save(metadata: MutableMap<String, String>, archiveFile: File) + abstract suspend fun get(name: String, version: String, extract: Boolean): Path? + abstract suspend fun delete(name: String, version: String) }
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/pom.xml b/ms/controllerblueprints/modules/pom.xml index 9147862eb..c4d1b1d37 100644 --- a/ms/controllerblueprints/modules/pom.xml +++ b/ms/controllerblueprints/modules/pom.xml @@ -38,6 +38,10 @@ </modules> <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-logging</artifactId> + </dependency> <!-- Test Dependencies --> <dependency> <groupId>io.mockk</groupId> diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt index a7e87b6ea..08b9d0560 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt @@ -17,8 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.resource.dict.service -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.apache.commons.collections.CollectionUtils import org.apache.commons.lang3.StringUtils import org.apache.commons.lang3.text.StrBuilder @@ -44,7 +43,7 @@ interface ResourceAssignmentValidationService : Serializable { * @author Brinda Santh */ open class ResourceAssignmentValidationServiceImpl : ResourceAssignmentValidationService { - private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationServiceImpl::class.java) + private val log= LoggerFactory.getLogger(ResourceAssignmentValidationServiceImpl::class.java) open var resourceAssignmentMap: Map<String, ResourceAssignment> = hashMapOf() open val validationMessage = StrBuilder() diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt index 42bde8517..dbd5b7dfe 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt @@ -16,11 +16,10 @@ package org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils -import com.att.eelf.configuration.EELFLogger import org.apache.commons.collections.CollectionUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.TopologicalSortingUtils import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import java.util.ArrayList /** * BulkResourceSequencingUtils. @@ -28,7 +27,7 @@ import java.util.ArrayList * @author Brinda Santh */ object BulkResourceSequencingUtils { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BulkResourceSequencingUtils::class.java) + private val log= LoggerFactory.getLogger(BulkResourceSequencingUtils::class.java) @JvmStatic fun process(resourceAssignments: MutableList<ResourceAssignment>): List<List<ResourceAssignment>> { diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt index f6159188c..cd5470953 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt @@ -16,8 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode import org.apache.commons.collections.MapUtils @@ -34,7 +33,7 @@ import java.io.File object ResourceDictionaryUtils { - private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDictionaryUtils::class.java) + private val log= LoggerFactory.getLogger(ResourceDictionaryUtils::class.java) @JvmStatic fun populateSourceMapping(resourceAssignment: ResourceAssignment, diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinitionTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinitionTest.java index db949d45f..b8185c46a 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinitionTest.java +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinitionTest.java @@ -20,11 +20,11 @@ package org.onap.ccsdk.cds.controllerblueprints.resource.dict; import org.junit.Assert; import org.junit.Test; import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ResourceDefinitionTest { - private EELFLogger log = EELFManager.getInstance().getLogger(ResourceDefinitionTest.class); + private Logger log = LoggerFactory.getLogger(ResourceDefinitionTest.class); private String basePath = "load/resource_dictionary"; @Test diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt index f21ff4093..b891f9ec6 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt @@ -16,15 +16,14 @@ package org.onap.ccsdk.cds.controllerblueprints.resource.dict.service -import com.att.eelf.configuration.EELFLogger import org.junit.Assert import org.junit.Test import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment -import com.att.eelf.configuration.EELFManager import org.junit.Before import org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils.ResourceDictionaryTestUtils +import org.slf4j.LoggerFactory /** * ResourceAssignmentValidationServiceTest. @@ -32,7 +31,7 @@ import org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils.ResourceDicti * @author Brinda Santh */ class ResourceAssignmentValidationServiceTest { - private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationServiceTest::class.java) + private val log = LoggerFactory.getLogger(ResourceAssignmentValidationServiceTest::class.java) @Before fun setUp() { // Setup dummy Source Instance Mapping diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java index fccc4f5fa..93c42445f 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java @@ -27,18 +27,19 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils; import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment; import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition; import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDictionaryConstants; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; import java.util.HashMap; import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * ResourceDictionaryUtilsTest. * * @author Brinda Santh */ public class ResourceDictionaryUtilsTest { - private static final EELFLogger log = EELFManager.getInstance().getLogger(ResourceDictionaryUtilsTest.class); + private static final Logger log = LoggerFactory.getLogger(ResourceDictionaryUtilsTest.class); @Test public void testPopulateSourceMapping() { diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/ApplicationRegistrationService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/ApplicationRegistrationService.java index 1e7109262..51484ff6c 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/ApplicationRegistrationService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/ApplicationRegistrationService.java @@ -17,10 +17,10 @@ package org.onap.ccsdk.cds.controllerblueprints.service; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; import org.apache.commons.collections.CollectionUtils; import org.onap.ccsdk.cds.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -30,7 +30,7 @@ import java.util.List; @Component @SuppressWarnings("unused") public class ApplicationRegistrationService { - private static EELFLogger log = EELFManager.getInstance().getLogger(ApplicationRegistrationService.class); + private static Logger log = LoggerFactory.getLogger(ApplicationRegistrationService.class); @Value("#{'${resourceSourceMappings}'.split(',')}") private List<String> resourceSourceMappings; diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/AutoResourceMappingService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/AutoResourceMappingService.java index c04c0dcf4..b9eff7624 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/AutoResourceMappingService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/AutoResourceMappingService.java @@ -17,8 +17,6 @@ package org.onap.ccsdk.cds.controllerblueprints.service; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; import com.google.common.base.Preconditions; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -30,6 +28,8 @@ import org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils.ResourceDicti import org.onap.ccsdk.cds.controllerblueprints.service.domain.ResourceDictionary; import org.onap.ccsdk.cds.controllerblueprints.service.model.AutoMapResponse; import org.onap.ccsdk.cds.controllerblueprints.service.repository.ResourceDictionaryRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -48,7 +48,7 @@ import java.util.Map; @SuppressWarnings("unused") public class AutoResourceMappingService { - private static EELFLogger log = EELFManager.getInstance().getLogger(AutoResourceMappingService.class); + private static Logger log = LoggerFactory.getLogger(AutoResourceMappingService.class); private ResourceDictionaryRepository dataDictionaryRepository; diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/SchemaGeneratorService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/SchemaGeneratorService.java index 6c09ef8cd..7d4d93b3d 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/SchemaGeneratorService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/SchemaGeneratorService.java @@ -16,8 +16,6 @@ package org.onap.ccsdk.cds.controllerblueprints.service; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; import com.google.common.base.Preconditions; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -29,6 +27,8 @@ import org.onap.ccsdk.cds.controllerblueprints.service.common.SwaggerGenerator; import java.util.HashMap; import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * SchemaGeneratorService.java Purpose: Provide Service to generate service template input schema definition and Sample @@ -39,7 +39,7 @@ import java.util.Map; */ @Deprecated public class SchemaGeneratorService { - private static EELFLogger log = EELFManager.getInstance().getLogger(SchemaGeneratorService.class); + private static Logger log = LoggerFactory.getLogger(SchemaGeneratorService.class); private Map<String, DataType> dataTypes; diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/ControllerBluePrintCoreConfiguration.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/ControllerBluePrintCoreConfiguration.kt index 8a7c01851..790c61ebc 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/ControllerBluePrintCoreConfiguration.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/ControllerBluePrintCoreConfiguration.kt @@ -34,7 +34,7 @@ open class ControllerBluePrintCoreConfiguration(private val bluePrintProperties: } @Bean - open fun controlelrBlueprintLoadConfiguration(): BluePrintLoadConfiguration { + open fun bluePrintLoadConfiguration(): BluePrintLoadConfiguration { return bluePrintProperties .propertyBeanType(PREFIX_BLUEPRINT_LOAD_CONFIGURATION, BluePrintLoadConfiguration::class.java) } @@ -53,7 +53,7 @@ open class ControllerBlueprintPropertyConfiguration { } @Service -open class ControllerBlueprintProperties(var bluePrintPropertyBinder: Binder) { +open class ControllerBlueprintProperties(private var bluePrintPropertyBinder: Binder) { fun <T> propertyBeanType(prefix: String, type: Class<T>): T { return bluePrintPropertyBinder.bind(prefix, Bindable.of(type)).get() } diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/BlueprintModelController.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/BlueprintModelController.kt index 0ea753fd1..a214f961e 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/BlueprintModelController.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/BlueprintModelController.kt @@ -26,7 +26,6 @@ import org.springframework.http.MediaType import org.springframework.http.ResponseEntity import org.springframework.http.codec.multipart.FilePart import org.springframework.web.bind.annotation.* -import reactor.core.publisher.Mono /** * BlueprintModelController Purpose: Handle controllerBlueprint API request @@ -41,8 +40,8 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint @PostMapping("", produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType.MULTIPART_FORM_DATA_VALUE]) @ResponseBody @Throws(BluePrintException::class) - fun saveBlueprint(@RequestPart("file") file: FilePart): Mono<BlueprintModelSearch> { - return bluePrintModelHandler.saveBlueprintModel(file) + fun saveBlueprint(@RequestPart("file") filePart: FilePart): BlueprintModelSearch = runBlocking { + bluePrintModelHandler.saveBlueprintModel(filePart) } @GetMapping("", produces = [MediaType.APPLICATION_JSON_VALUE]) diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt index b49fc46b5..c6f821f99 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt @@ -16,8 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.service.enhancer -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive @@ -43,7 +42,7 @@ open class BluePrintArtifactDefinitionEnhancerImpl(private val bluePrintRepoServ } - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintArtifactDefinitionEnhancerImpl::class.toString()) + private val log= LoggerFactory.getLogger(BluePrintArtifactDefinitionEnhancerImpl::class.toString()) lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> lateinit var bluePrintContext: BluePrintContext diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt index e4861e1fc..cad523e25 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt @@ -17,8 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.service.enhancer -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintEnhancerService import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService @@ -33,7 +32,7 @@ import java.util.* open class BluePrintEnhancerServiceImpl(private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService, private val resourceDefinitionEnhancerService: ResourceDefinitionEnhancerService) : BluePrintEnhancerService { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintEnhancerServiceImpl::class.toString()) + private val log= LoggerFactory.getLogger(BluePrintEnhancerServiceImpl::class.toString()) override suspend fun enhance(basePath: String, enrichedBasePath: String): BluePrintContext { diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt index 639b6ee1a..0e53c2130 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt @@ -17,8 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.service.enhancer -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintNodeTemplateEnhancer import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService @@ -36,7 +35,7 @@ open class BluePrintNodeTemplateEnhancerImpl(private val bluePrintRepoService: B private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) : BluePrintNodeTemplateEnhancer { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateEnhancerImpl::class.toString()) + private val log= LoggerFactory.getLogger(BluePrintNodeTemplateEnhancerImpl::class.toString()) lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> lateinit var bluePrintContext: BluePrintContext diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt index f248c315a..2b5d007ed 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt @@ -16,8 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.service.enhancer -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.data.InterfaceDefinition @@ -38,7 +37,7 @@ import org.springframework.stereotype.Service open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService, private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) : BluePrintNodeTypeEnhancer { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTypeEnhancerImpl::class.toString()) + private val log= LoggerFactory.getLogger(BluePrintNodeTypeEnhancerImpl::class.toString()) lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> lateinit var bluePrintContext: BluePrintContext diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt index ef460ec9e..a6acf0be0 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt @@ -16,8 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.service.enhancer -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintServiceTemplateEnhancer import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService @@ -31,7 +30,7 @@ import org.springframework.stereotype.Service @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) : BluePrintServiceTemplateEnhancer { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateEnhancerImpl::class.toString()) + private val log= LoggerFactory.getLogger(BluePrintServiceTemplateEnhancerImpl::class.toString()) lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt index 02e1052b9..8ea23136c 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt @@ -17,8 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.service.enhancer -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException @@ -43,7 +42,7 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService, private val resourceAssignmentEnhancerService: ResourceAssignmentEnhancerService) : BluePrintWorkflowEnhancer { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintWorkflowEnhancerImpl::class.toString()) + private val log= LoggerFactory.getLogger(BluePrintWorkflowEnhancerImpl::class.toString()) companion object { const val ARTIFACT_TYPE_MAPPING_SOURCE: String = "artifact-mapping-resource" diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt index 7d4244cda..b51d88085 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt @@ -16,8 +16,7 @@ package org.onap.ccsdk.cds.controllerblueprints.service.enhancer -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService @@ -53,7 +52,7 @@ interface ResourceAssignmentEnhancerService { @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionRepoService: ResourceDefinitionRepoService) : ResourceAssignmentEnhancerService { - private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentEnhancerServiceImpl::class.java) + private val log= LoggerFactory.getLogger(ResourceAssignmentEnhancerServiceImpl::class.java) /** * Get the defined source instance from the ResourceAssignment, diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt index 6f4527abc..df499b26d 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt @@ -17,8 +17,7 @@ package org.onap.ccsdk.cds.controllerblueprints.service.enhancer -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.slf4j.LoggerFactory import kotlinx.coroutines.Deferred import kotlinx.coroutines.async import kotlinx.coroutines.runBlocking @@ -44,7 +43,7 @@ interface ResourceDefinitionEnhancerService { class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoService: ResourceDefinitionRepoService) : ResourceDefinitionEnhancerService { - private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDefinitionEnhancerService::class.toString()) + private val log= LoggerFactory.getLogger(ResourceDefinitionEnhancerService::class.toString()) companion object { const val ARTIFACT_TYPE_MAPPING_SOURCE: String = "artifact-mapping-resource" diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/BluePrintModelHandler.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/BluePrintModelHandler.kt index 72c27adc1..c54bf87fe 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/BluePrintModelHandler.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/BluePrintModelHandler.kt @@ -18,19 +18,18 @@ package org.onap.ccsdk.cds.controllerblueprints.service.handler -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.cds.controllerblueprints.core.* import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintEnhancerService -import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModel import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModelSearch import org.onap.ccsdk.cds.controllerblueprints.service.repository.ControllerBlueprintModelContentRepository import org.onap.ccsdk.cds.controllerblueprints.service.repository.ControllerBlueprintModelRepository import org.onap.ccsdk.cds.controllerblueprints.service.repository.ControllerBlueprintModelSearchRepository import org.onap.ccsdk.cds.controllerblueprints.service.utils.BluePrintEnhancerUtils +import org.slf4j.LoggerFactory import org.springframework.core.io.ByteArrayResource import org.springframework.core.io.Resource import org.springframework.http.HttpHeaders @@ -39,7 +38,6 @@ import org.springframework.http.ResponseEntity import org.springframework.http.codec.multipart.FilePart import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional -import reactor.core.publisher.Mono import java.io.File import java.io.IOException import java.util.* @@ -59,6 +57,8 @@ open class BluePrintModelHandler(private val bluePrintCatalogService: BluePrintC private val blueprintModelContentRepository: ControllerBlueprintModelContentRepository, private val bluePrintEnhancerService: BluePrintEnhancerService) { + private val log = LoggerFactory.getLogger(BluePrintModelHandler::class.java)!! + /** * This is a getAllBlueprintModel method to retrieve all the BlueprintModel in Database * @@ -76,23 +76,28 @@ open class BluePrintModelHandler(private val bluePrintCatalogService: BluePrintC * @throws BluePrintException BluePrintException </BlueprintModelSearch> */ @Throws(BluePrintException::class) - open fun saveBlueprintModel(filePart: FilePart): Mono<BlueprintModelSearch> { + open suspend fun saveBlueprintModel(filePart: FilePart): BlueprintModelSearch { + val saveId = UUID.randomUUID().toString() + val blueprintArchive = normalizedPathName(bluePrintLoadConfiguration.blueprintArchivePath, saveId) try { - val cbaLocation = BluePrintFileUtils.getCbaStorageDirectory(bluePrintLoadConfiguration.blueprintArchivePath) - return BluePrintEnhancerUtils.saveCBAFile(filePart, cbaLocation).map { fileName -> - var blueprintId: String? = null - try { - blueprintId = bluePrintCatalogService.saveToDatabase(cbaLocation.resolve(fileName).toFile(), false) - } catch (e: BluePrintException) { - // FIXME handle expection - } - blueprintModelSearchRepository.findById(blueprintId!!).get() - } + //Recreate the Dir + normalizedFile(bluePrintLoadConfiguration.blueprintArchivePath, saveId).reCreateDirs() + val deCompressedFile = normalizedFile(blueprintArchive, "cba.zip") + // Copy the File Part to Local File + BluePrintEnhancerUtils.copyFromFilePart(filePart, deCompressedFile) + // Save the Copied file to Database + val blueprintId = bluePrintCatalogService.saveToDatabase(saveId, deCompressedFile, false) + // Check and Return the Saved File + val blueprintModelSearch = blueprintModelSearchRepository.findById(blueprintId).get() + log.info("Save($saveId) successful for blueprint(${blueprintModelSearch.artifactName}) " + + "version(${blueprintModelSearch.artifactVersion})") + return blueprintModelSearch } catch (e: IOException) { throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value, - String.format("I/O Error while uploading the CBA file: %s", e.message), e) + "Error in Save CBA: ${e.message}", e) + } finally { + deleteDir(blueprintArchive) } - } @@ -277,20 +282,20 @@ open class BluePrintModelHandler(private val bluePrintCatalogService: BluePrintC open suspend fun enrichBlueprint(filePart: FilePart): ResponseEntity<Resource> { val enhanceId = UUID.randomUUID().toString() val blueprintArchive = normalizedPathName(bluePrintLoadConfiguration.blueprintArchivePath, enhanceId) - val blueprintEnrichmentDir = normalizedPathName(bluePrintLoadConfiguration.blueprintEnrichmentPath, enhanceId) + val blueprintWorkingDir = normalizedPathName(bluePrintLoadConfiguration.blueprintWorkingPath, enhanceId) try { - BluePrintEnhancerUtils.decompressFilePart(filePart, blueprintArchive, blueprintEnrichmentDir) + BluePrintEnhancerUtils.decompressFilePart(filePart, blueprintArchive, blueprintWorkingDir) // Enhance the Blue Prints - bluePrintEnhancerService.enhance(blueprintEnrichmentDir) + bluePrintEnhancerService.enhance(blueprintWorkingDir) - return BluePrintEnhancerUtils.compressToFilePart(blueprintEnrichmentDir, blueprintArchive) + return BluePrintEnhancerUtils.compressToFilePart(blueprintWorkingDir, blueprintArchive) } catch (e: IOException) { throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value, "Error in Enriching CBA: ${e.message}", e) } finally { - BluePrintEnhancerUtils.cleanEnhancer(blueprintArchive, blueprintEnrichmentDir) + BluePrintEnhancerUtils.cleanEnhancer(blueprintArchive, blueprintWorkingDir) } } @@ -305,12 +310,12 @@ open class BluePrintModelHandler(private val bluePrintCatalogService: BluePrintC open suspend fun publishBlueprint(filePart: FilePart): BlueprintModelSearch { val publishId = UUID.randomUUID().toString() val blueprintArchive = bluePrintLoadConfiguration.blueprintArchivePath.plus(File.separator).plus(publishId) - val blueprintEnrichmentDir = bluePrintLoadConfiguration.blueprintEnrichmentPath.plus(File.separator).plus(publishId) + val blueprintWorkingDir = bluePrintLoadConfiguration.blueprintWorkingPath.plus(File.separator).plus(publishId) try { val compressedFilePart = BluePrintEnhancerUtils - .extractCompressFilePart(filePart, blueprintArchive, blueprintEnrichmentDir) + .extractCompressFilePart(filePart, blueprintArchive, blueprintWorkingDir) - val blueprintId = bluePrintCatalogService.saveToDatabase(compressedFilePart, true) + val blueprintId = bluePrintCatalogService.saveToDatabase(publishId, compressedFilePart, true) return blueprintModelSearchRepository.findById(blueprintId).get() @@ -318,7 +323,7 @@ open class BluePrintModelHandler(private val bluePrintCatalogService: BluePrintC throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value, "Error in Publishing CBA: ${e.message}", e) } finally { - BluePrintEnhancerUtils.cleanEnhancer(blueprintArchive, blueprintEnrichmentDir) + BluePrintEnhancerUtils.cleanEnhancer(blueprintArchive, blueprintWorkingDir) } } diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ModelTypeHandler.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ModelTypeHandler.kt index f602437ed..d68fdd025 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ModelTypeHandler.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ModelTypeHandler.kt @@ -17,17 +17,17 @@ package org.onap.ccsdk.cds.controllerblueprints.service.handler -import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType import org.onap.ccsdk.cds.controllerblueprints.service.repository.ModelTypeRepository import org.onap.ccsdk.cds.controllerblueprints.service.validator.ModelTypeValidator +import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @Service open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository) { - private val log = EELFManager.getInstance().getLogger(ModelTypeHandler::class.java)!! + private val log = LoggerFactory.getLogger(ModelTypeHandler::class.java)!! /** * This is a getModelTypeByName service diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintCatalogLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintCatalogLoadService.kt index eca7ce1bf..58e89d8d2 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintCatalogLoadService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintCatalogLoadService.kt @@ -17,39 +17,54 @@ package org.onap.ccsdk.cds.controllerblueprints.service.load -import com.att.eelf.configuration.EELFManager +import kotlinx.coroutines.Deferred +import kotlinx.coroutines.async +import kotlinx.coroutines.runBlocking +import org.apache.commons.lang.text.StrBuilder import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile +import org.slf4j.LoggerFactory import org.springframework.stereotype.Service import java.io.File +import java.util.* @Service open class BluePrintCatalogLoadService(private val bluePrintCatalogService: BluePrintCatalogService) { - private val log = EELFManager.getInstance().getLogger(BluePrintCatalogLoadService::class.java) + private val log = LoggerFactory.getLogger(BluePrintCatalogLoadService::class.java) - open suspend fun loadPathsBluePrintModelCatalog(paths: List<String>) { + open fun loadPathsBluePrintModelCatalog(paths: List<String>) { paths.forEach { loadPathBluePrintModelCatalog(it) } } - open suspend fun loadPathBluePrintModelCatalog(path: String) { + open fun loadPathBluePrintModelCatalog(path: String) { - val files = normalizedFile(path).listFiles() - val errors = mutableListOf<String>() - files.forEach { - loadBluePrintModelCatalog(errors, it) - } - if (!errors.isEmpty()) { - log.error(errors.joinToString("\n")) + val files = File(path).listFiles() + runBlocking { + val errorBuilder = StrBuilder() + val deferredResults = mutableListOf<Deferred<Unit>>() + + for (file in files) { + deferredResults += async { + loadBluePrintModelCatalog(errorBuilder, file) + } + } + + for (deferredResult in deferredResults) { + deferredResult.await() + } + + if (!errorBuilder.isEmpty) { + log.error(errorBuilder.toString()) + } } } - open suspend fun loadBluePrintModelCatalog(errorBuilder: MutableList<String>, file: File) { + open suspend fun loadBluePrintModelCatalog(errorBuilder: StrBuilder, file: File) { try { - log.info("loading blueprint cba(${file.absolutePath})") - bluePrintCatalogService.saveToDatabase(file) + bluePrintCatalogService.saveToDatabase(UUID.randomUUID().toString(), file) } catch (e: Exception) { - errorBuilder.add("Couldn't load BlueprintModel(${file.name}: ${e.message}") + errorBuilder.appendln("Couldn't load BlueprintModel(${file.name}: ${e.message}") } } diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt index 4a3168d65..11c91ab77 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt @@ -17,9 +17,9 @@ package org.onap.ccsdk.cds.controllerblueprints.service.load -import com.att.eelf.configuration.EELFManager import kotlinx.coroutines.runBlocking import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration +import org.slf4j.LoggerFactory import org.springframework.boot.context.event.ApplicationReadyEvent import org.springframework.context.event.EventListener import org.springframework.stereotype.Service @@ -30,7 +30,7 @@ open class BluePrintDatabaseLoadService(private val bluePrintLoadConfiguration: private val resourceDictionaryLoadService: ResourceDictionaryLoadService, private val bluePrintCatalogLoadService: BluePrintCatalogLoadService) { - private val log = EELFManager.getInstance().getLogger(BluePrintDatabaseLoadService::class.java) + private val log = LoggerFactory.getLogger(BluePrintDatabaseLoadService::class.java) @EventListener(ApplicationReadyEvent::class) diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ControllerBlueprintCatalogServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ControllerBlueprintCatalogServiceImpl.kt index 358a4654a..3d6e134d4 100755 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ControllerBlueprintCatalogServiceImpl.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ControllerBlueprintCatalogServiceImpl.kt @@ -23,7 +23,9 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.common.ApplicationConstants import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode +import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService +import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPath import org.onap.ccsdk.cds.controllerblueprints.db.resources.BlueprintCatalogServiceImpl import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModel import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModelContent @@ -34,7 +36,7 @@ import org.springframework.stereotype.Service import java.io.File import java.nio.file.Files import java.nio.file.Path -import java.nio.file.Paths +import java.util.* /** * Similar implementation in [org.onap.ccsdk.cds.blueprintsprocessor.db.BlueprintProcessorCatalogServiceImpl] @@ -43,7 +45,7 @@ import java.nio.file.Paths class ControllerBlueprintCatalogServiceImpl(bluePrintValidatorService: BluePrintValidatorService, private val bluePrintLoadConfiguration: BluePrintLoadConfiguration, private val blueprintModelRepository: ControllerBlueprintModelRepository) - : BlueprintCatalogServiceImpl(bluePrintValidatorService) { + : BlueprintCatalogServiceImpl(bluePrintLoadConfiguration, bluePrintValidatorService) { private val log = LoggerFactory.getLogger(ControllerBlueprintCatalogServiceImpl::class.toString()) @@ -52,13 +54,18 @@ class ControllerBlueprintCatalogServiceImpl(bluePrintValidatorService: BluePrint log.info("BlueprintProcessorCatalogServiceImpl initialized") } - override fun delete(name: String, version: String) = blueprintModelRepository.deleteByArtifactNameAndArtifactVersion(name, version) + override suspend fun delete(name: String, version: String) { + // Cleaning Deployed Blueprint + deleteDir(bluePrintLoadConfiguration.blueprintDeployPath, name, version) + // Cleaning Data Base + blueprintModelRepository.deleteByArtifactNameAndArtifactVersion(name, version) + } - override fun get(name: String, version: String, extract: Boolean): Path? { + override suspend fun get(name: String, version: String, extract: Boolean): Path? { val path = if (extract) { - Paths.get("${bluePrintLoadConfiguration.blueprintDeployPath}/$name/$version") + normalizedPath(bluePrintLoadConfiguration.blueprintDeployPath, name, version) } else { - Paths.get("${bluePrintLoadConfiguration.blueprintArchivePath}/$name/$version.zip") + normalizedPath(bluePrintLoadConfiguration.blueprintArchivePath, UUID.randomUUID().toString(), "cba.zip") } blueprintModelRepository.findByArtifactNameAndArtifactVersion(name, version)?.also { it.blueprintModelContent.run { @@ -70,11 +77,14 @@ class ControllerBlueprintCatalogServiceImpl(bluePrintValidatorService: BluePrint return null } - override fun save(metadata: MutableMap<String, String>, archiveFile: File) { + override suspend fun save(metadata: MutableMap<String, String>, archiveFile: File) { val artifactName = metadata[BluePrintConstants.METADATA_TEMPLATE_NAME] val artifactVersion = metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION] + check(archiveFile.isFile && !archiveFile.isDirectory) { + throw BluePrintException("Not a valid Archive file(${archiveFile.absolutePath})") + } blueprintModelRepository.findByArtifactNameAndArtifactVersion(artifactName!!, artifactVersion!!)?.let { log.info("Overwriting blueprint model :$artifactName::$artifactVersion") diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ModelTypeLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ModelTypeLoadService.kt index ff87ad465..f7875efde 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ModelTypeLoadService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ModelTypeLoadService.kt @@ -17,7 +17,6 @@ package org.onap.ccsdk.cds.controllerblueprints.service.load -import com.att.eelf.configuration.EELFManager import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.coroutineScope @@ -31,13 +30,14 @@ import org.onap.ccsdk.cds.controllerblueprints.core.readNBText import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType import org.onap.ccsdk.cds.controllerblueprints.service.handler.ModelTypeHandler +import org.slf4j.LoggerFactory import org.springframework.stereotype.Service import java.io.File @Service open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler) { - private val log = EELFManager.getInstance().getLogger(ModelTypeLoadService::class.java) + private val log = LoggerFactory.getLogger(ModelTypeLoadService::class.java) private val updateBySystem = "System" open suspend fun loadPathsModelType(modelTypePaths: List<String>) { diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ResourceDictionaryLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ResourceDictionaryLoadService.kt index 69b7c643c..ce979f60e 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ResourceDictionaryLoadService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ResourceDictionaryLoadService.kt @@ -17,7 +17,6 @@ package org.onap.ccsdk.cds.controllerblueprints.service.load -import com.att.eelf.configuration.EELFManager import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.coroutineScope @@ -30,13 +29,14 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition import org.onap.ccsdk.cds.controllerblueprints.service.domain.ResourceDictionary import org.onap.ccsdk.cds.controllerblueprints.service.handler.ResourceDictionaryHandler +import org.slf4j.LoggerFactory import org.springframework.stereotype.Service import java.io.File @Service open class ResourceDictionaryLoadService(private val resourceDictionaryHandler: ResourceDictionaryHandler) { - private val log = EELFManager.getInstance().getLogger(ResourceDictionaryLoadService::class.java) + private val log = LoggerFactory.getLogger(ResourceDictionaryLoadService::class.java) open suspend fun loadPathsResourceDictionary(paths: List<String>) { paths.forEach { diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt index 166a2b283..d4753e194 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt @@ -84,7 +84,7 @@ class BluePrintEnhancerUtils { return artifactType } - private suspend fun copyFromFilePart(filePart: FilePart, targetFile: File): File { + suspend fun copyFromFilePart(filePart: FilePart, targetFile: File): File { // Delete the Directory targetFile.deleteRecursively() return filePart.transferTo(targetFile) diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/cds/controllerblueprints/service/common/SchemaGeneratorServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/cds/controllerblueprints/service/common/SchemaGeneratorServiceTest.java index 56a92fe0a..f17d637e6 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/cds/controllerblueprints/service/common/SchemaGeneratorServiceTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/cds/controllerblueprints/service/common/SchemaGeneratorServiceTest.java @@ -16,8 +16,6 @@ package org.onap.ccsdk.cds.controllerblueprints.service.common; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; import org.apache.commons.io.FileUtils; import org.junit.Assert; import org.junit.FixMethodOrder; @@ -27,12 +25,14 @@ import org.onap.ccsdk.cds.controllerblueprints.service.SchemaGeneratorService; import java.io.File; import java.nio.charset.Charset; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class SchemaGeneratorServiceTest { - private static EELFLogger log = EELFManager.getInstance().getLogger(SchemaGeneratorServiceTest.class); + private static Logger log = LoggerFactory.getLogger(SchemaGeneratorServiceTest.class); @Test public void test01GenerateSwaggerData() throws Exception { diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/ModelTypeServiceTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/ModelTypeServiceTest.kt index 741431840..e55f2a511 100644 --- a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/ModelTypeServiceTest.kt +++ b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/ModelTypeServiceTest.kt @@ -16,7 +16,6 @@ package org.onap.ccsdk.cds.controllerblueprints.service -import com.att.eelf.configuration.EELFManager import kotlinx.coroutines.runBlocking import org.junit.Assert import org.junit.FixMethodOrder @@ -28,6 +27,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType import org.onap.ccsdk.cds.controllerblueprints.service.handler.ModelTypeHandler +import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest import org.springframework.test.annotation.Commit @@ -48,7 +48,7 @@ class ModelTypeServiceTest { internal var modelName = "test-datatype" - private val log = EELFManager.getInstance().getLogger(ModelTypeServiceTest::class.java) + private val log = LoggerFactory.getLogger(ModelTypeServiceTest::class.java) @Test @Commit diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/BlueprintModelControllerTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/BlueprintModelControllerTest.kt index d61e64251..64bd3ff3e 100644 --- a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/BlueprintModelControllerTest.kt +++ b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/BlueprintModelControllerTest.kt @@ -17,9 +17,9 @@ package org.onap.ccsdk.cds.controllerblueprints.service.controller -import com.google.gson.Gson +import kotlinx.coroutines.reactive.awaitSingle +import kotlinx.coroutines.runBlocking import org.json.JSONException -import org.json.JSONObject import org.junit.After import org.junit.Before import org.junit.FixMethodOrder @@ -27,26 +27,31 @@ import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.MethodSorters import org.onap.ccsdk.cds.controllerblueprints.TestApplication -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintArchiveUtils +import org.onap.ccsdk.cds.controllerblueprints.core.* +import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintPathConfiguration +import org.onap.ccsdk.cds.controllerblueprints.service.ControllerBluePrintCoreConfiguration import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModelSearch +import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired -import org.springframework.beans.factory.annotation.Value import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.boot.test.context.SpringBootTest import org.springframework.context.annotation.ComponentScan import org.springframework.core.io.ByteArrayResource import org.springframework.http.HttpMethod import org.springframework.http.HttpStatus +import org.springframework.http.client.MultipartBodyBuilder import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.junit4.SpringRunner import org.springframework.test.web.reactive.server.WebTestClient +import org.springframework.test.web.reactive.server.returnResult import org.springframework.util.Base64Utils import org.springframework.web.reactive.function.BodyInserters import java.io.File -import java.io.IOException import java.nio.charset.StandardCharsets.UTF_8 -import java.nio.file.Files import java.nio.file.Paths +import kotlin.test.assertEquals +import kotlin.test.assertNotNull +import kotlin.test.assertTrue /** * BlueprintModelControllerTest Purpose: Integration test at API level @@ -57,109 +62,142 @@ import java.nio.file.Paths @RunWith(SpringRunner::class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ContextConfiguration(classes = [TestApplication::class]) +@ContextConfiguration(classes = [TestApplication::class, ControllerBluePrintCoreConfiguration::class]) @ComponentScan(basePackages = ["org.onap.ccsdk.cds.controllerblueprints"]) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @EnableAutoConfiguration class BlueprintModelControllerTest { - companion object { + private val log = LoggerFactory.getLogger(BlueprintModelControllerTest::class.java)!! - private var id: String? = null - private var name: String? = null - private var version: String? = null - private var tag: String? = null - private var result: String? = null + companion object { + private var bp: BlueprintModelSearch? = null } - @Value("\${controllerblueprints.loadBluePrintPaths}") - private val loadBluePrintPaths: String? = null - @Autowired - private val webTestClient: WebTestClient? = null + lateinit var webTestClient: WebTestClient + + private var bluePrintLoadConfiguration: BluePrintPathConfiguration? = null - @Value("\${controllerblueprints.loadBlueprintsExamplesPath}") - private val blueprintArchivePath: String? = null + private val blueprintDir = "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" + private var zipBlueprintFileName: String? = null + + private var testZipFile: File? = null - private val filename = "test.zip" - private var blueprintFile: File? = null - private var zipBlueprintFile: File? = null @Before - @Throws(Exception::class) fun setUp() { - blueprintFile = File(loadBluePrintPaths+"/baseconfiguration") - if (blueprintFile!!.isDirectory) { - zipBlueprintFile = File(Paths.get(blueprintArchivePath).resolve(filename).toString()) - BluePrintArchiveUtils.compress(blueprintFile!!, zipBlueprintFile!!, true) + assertNotNull(webTestClient, " Failed to create WebTestClient") + + bluePrintLoadConfiguration = BluePrintPathConfiguration().apply { + blueprintArchivePath = "./target/blueprints/archive" + blueprintWorkingPath = "./target/blueprints/work" + blueprintDeployPath = "./target/blueprints/deploy" } + zipBlueprintFileName = normalizedPathName(bluePrintLoadConfiguration!!.blueprintArchivePath, "test.zip") + + val archiveDir = normalizedFile(bluePrintLoadConfiguration!!.blueprintArchivePath).reCreateDirs() + assertTrue(archiveDir.exists(), "failed to create archiveDir(${archiveDir.absolutePath}") + + val blueprintFile = Paths.get(blueprintDir).toFile().normalize() + testZipFile = blueprintFile.compress(zipBlueprintFileName!!) + assertNotNull(testZipFile, "test zip is null") + assertTrue(testZipFile!!.exists(), "Failed to create blueprint test zip(${testZipFile!!.absolutePath}") } @After - @Throws(Exception::class) fun tearDown() { - zipBlueprintFile!!.delete() + deleteDir(bluePrintLoadConfiguration!!.blueprintArchivePath) + deleteDir(bluePrintLoadConfiguration!!.blueprintWorkingPath) } @Test - @Throws(IOException::class, JSONException::class) - fun test1_saveBluePrint() { - webTestClient(HttpMethod.POST, - BodyInserters.fromMultipartData("file", object : ByteArrayResource(Files.readAllBytes(zipBlueprintFile!!.toPath())) { - override fun getFilename(): String? { + fun test01_saveBluePrint() { + bp = runBlocking { + val body = MultipartBodyBuilder().apply { + part("file", object : ByteArrayResource(testZipFile!!.readBytes()) { + override fun getFilename(): String { return "test.zip" } - }), - "/api/v1/blueprint-model", - HttpStatus.OK, true) + }) + }.build() + + val saveBP = webTestClient + .post() + .uri("/api/v1/blueprint-model") + .body(BodyInserters.fromMultipartData(body)) + .exchange() + .expectStatus().isOk + .returnResult<BlueprintModelSearch>() + .responseBody + .awaitSingle() + + assertNotNull(saveBP, "failed to get response") + assertEquals("baseconfiguration", saveBP.artifactName, "mismatch artifact name") + assertEquals("1.0.0", saveBP.artifactVersion, "mismatch artifact version") + assertEquals("N", saveBP.published, "mismatch publish") + saveBP + } } @Test @Throws(JSONException::class) - fun test2_getBluePrintByNameAndVersion() { - webTestClient(HttpMethod.GET, null, "/api/v1/blueprint-model/by-name/$name/version/$version", HttpStatus.OK, false) + fun test02_getBluePrintByNameAndVersion() { + webTestClient(HttpMethod.GET, null, + "/api/v1/blueprint-model/by-name/${bp!!.artifactName}/version/${bp!!.artifactVersion}", + HttpStatus.OK, false) } @Test @Throws(JSONException::class) - fun test3_getBlueprintModel() { - webTestClient(HttpMethod.GET, null, "/api/v1/blueprint-model/$id", HttpStatus.OK, false) + fun test03_getBlueprintModel() { + webTestClient(HttpMethod.GET, null, + "/api/v1/blueprint-model/${bp!!.id}", + HttpStatus.OK, false) } @Test @Throws(JSONException::class) - fun test4_getAllBlueprintModel() { + fun test04_getAllBlueprintModel() { webTestClient(HttpMethod.GET, null, "/api/v1/blueprint-model", HttpStatus.OK, false) } @Test @Throws(JSONException::class) - fun test5_downloadBluePrint() { - webTestClient(HttpMethod.GET, null, "/api/v1/blueprint-model/download/$id", HttpStatus.OK, false) + fun test05_downloadBluePrint() { + webTestClient(HttpMethod.GET, null, + "/api/v1/blueprint-model/download/${bp!!.id}", + HttpStatus.OK, false) + } + + @Test + fun test06_enrichBlueprintModel() { } @Test - fun test6_publishBlueprintModel() { + fun test07_publishBlueprintModel() { } @Test @Throws(JSONException::class) - fun test7_searchBlueprintModels() { - webTestClient(HttpMethod.GET, null, "/api/v1/blueprint-model/search/$name", HttpStatus.OK, false) + fun test08_searchBlueprintModels() { + webTestClient(HttpMethod.GET, null, + "/api/v1/blueprint-model/search/${bp!!.artifactName}", + HttpStatus.OK, false) } @Test @Throws(JSONException::class) - fun test8_downloadBlueprintByNameAndVersion() { - webTestClient(HttpMethod.GET, null, "/api/v1/blueprint-model/download/by-name/$name/version/$version", HttpStatus.OK, false) + fun test09_downloadBlueprintByNameAndVersion() { + webTestClient(HttpMethod.GET, null, + "/api/v1/blueprint-model/download/by-name/${bp!!.artifactName}/version/${bp!!.artifactVersion}", + HttpStatus.OK, false) } @Test - fun test9_deleteBluePrint() { - //TODO: Use webTestClient function - //webTestClient(HttpMethod.DELETE, null, "/api/v1/blueprint-model/" + id, HttpStatus.OK, false); - webTestClient!!.delete().uri("/api/v1/blueprint-model/$id") + fun test10_deleteBluePrint() { + webTestClient.delete().uri("/api/v1/blueprint-model/${bp!!.id}") .header("Authorization", "Basic " + Base64Utils .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8))) .exchange() @@ -167,27 +205,20 @@ class BlueprintModelControllerTest { } @Throws(JSONException::class) - private fun webTestClient(requestMethod: HttpMethod, body: BodyInserters.MultipartInserter?, uri: String, expectedResponceStatus: HttpStatus, setParam: Boolean) { + private fun webTestClient(requestMethod: HttpMethod, body: BodyInserters.MultipartInserter?, uri: String, + expectedResponceStatus: HttpStatus, setParam: Boolean) { - result = String(webTestClient!!.method(requestMethod).uri(uri) + log.info("Requesting($uri): Method(${requestMethod.name})") + + webTestClient.method(requestMethod).uri(uri) .header("Authorization", "Basic " + Base64Utils .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8))) .body(body) .exchange() .expectStatus().isEqualTo(expectedResponceStatus) .expectBody() - .returnResult().responseBody!!) - - if (setParam) { - val jsonResponse = JSONObject(result) - val blueprintModelSearchJSON = jsonResponse.getJSONObject("blueprintModel") - val gson = Gson() - val blueprintModelSearch = gson.fromJson(blueprintModelSearchJSON.toString(), BlueprintModelSearch::class.java) - id = blueprintModelSearch.id - name = blueprintModelSearch.artifactName - version = blueprintModelSearch.artifactVersion - tag = blueprintModelSearch.tags - } + .returnResult().responseBody!! + } }
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ModelTypeControllerTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ModelTypeControllerTest.kt index 610c9d033..4af8851a5 100644 --- a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ModelTypeControllerTest.kt +++ b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ModelTypeControllerTest.kt @@ -16,7 +16,6 @@ package org.onap.ccsdk.cds.controllerblueprints.service.controller -import com.att.eelf.configuration.EELFManager import org.junit.Assert import org.junit.FixMethodOrder import org.junit.Test @@ -26,6 +25,7 @@ import org.onap.ccsdk.cds.controllerblueprints.TestApplication import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType +import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest import org.springframework.test.annotation.Commit @@ -38,7 +38,7 @@ import org.springframework.test.context.junit4.SpringRunner @FixMethodOrder(MethodSorters.NAME_ASCENDING) class ModelTypeControllerTest { - private val log = EELFManager.getInstance().getLogger(ModelTypeControllerTest::class.java)!! + private val log = LoggerFactory.getLogger(ModelTypeControllerTest::class.java)!! @Autowired internal var modelTypeController: ModelTypeController? = null diff --git a/ms/controllerblueprints/modules/service/src/test/resources/application.properties b/ms/controllerblueprints/modules/service/src/test/resources/application.properties index 011bad32c..19430ad08 100755 --- a/ms/controllerblueprints/modules/service/src/test/resources/application.properties +++ b/ms/controllerblueprints/modules/service/src/test/resources/application.properties @@ -24,7 +24,7 @@ resourceSourceMappings=processor-db=source-processor-db,input=source-input,defau # Controller Blueprints Core Configuration controllerblueprints.blueprintDeployPath=./target/blueprints/deploy controllerblueprints.blueprintArchivePath=./target/blueprints/archive -controllerblueprints.blueprintEnrichmentPath=./target/blueprints/enrichment +controllerblueprints.blueprintWorkingPath=./target/blueprints/work # Controller Blueprint Load Configurations controllerblueprints.loadInitialData=false controllerblueprints.loadBluePrint=false diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index 3fc5084ff..50cfae197 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -56,14 +56,9 @@ </dependency> <dependency> - <groupId>com.att.eelf</groupId> - <artifactId>eelf-core</artifactId> - <version>${eelf.version}</version> - </dependency> - <dependency> - <groupId>org.onap.logging-analytics</groupId> - <artifactId>logging-slf4j</artifactId> - <version>${onap.logger.slf4j}</version> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-logging</artifactId> + <version>${spring.boot.version}</version> </dependency> <!--Swagger Dependencies --> @@ -71,6 +66,12 @@ <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>${springfox.swagger2.version}</version> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>io.springfox</groupId> @@ -282,14 +283,6 @@ <dependencies> <dependency> - <groupId>com.att.eelf</groupId> - <artifactId>eelf-core</artifactId> - </dependency> - <dependency> - <groupId>org.onap.logging-analytics</groupId> - <artifactId>logging-slf4j</artifactId> - </dependency> - <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency> @@ -308,6 +301,12 @@ <dependency> <groupId>com.jayway.jsonpath</groupId> <artifactId>json-path</artifactId> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>com.google.guava</groupId> @@ -316,6 +315,12 @@ <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>io.springfox</groupId> |