Add support for blueprintprocessor runtime DB
authorAlexis de Talhouët <adetalhouet89@gmail.com>
Mon, 7 Jan 2019 21:33:02 +0000 (16:33 -0500)
committerAlexis de Talhouët <alexis.de_talhouet@bell.ca>
Wed, 9 Jan 2019 22:11:43 +0000 (22:11 +0000)
- created db-resources module to store controller blueprint
related controller blueprint repository and entities. Also
create an abstract BlueprintCatalogServiceImpl so it can be
used both by controllerblueprint and blueprintprocessor
- created blueprint-validation to store the implementation
of the validation interface.
- change controllerblueprint service to levrage db-resources
- implement CatalogService for blueprintprocessor db-lib by
using db-resources.

Change-Id: I0539e414e4ff3b7a6edf0f6304d6cbc5e6eac404
Issue-ID: CCSDK-664
Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
22 files changed:
ms/controllerblueprints/modules/blueprint-validation/pom.xml [new file with mode: 0644]
ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintTypeValidatorServiceImpl.kt [moved from ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintTypeValidatorServiceImpl.kt with 97% similarity]
ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintValidatorDefaultService.kt [moved from ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt with 80% similarity]
ms/controllerblueprints/modules/db-resources/pom.xml [new file with mode: 0644]
ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt [new file with mode: 0644]
ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelContentRepository.kt [new file with mode: 0644]
ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelRepository.kt [new file with mode: 0644]
ms/controllerblueprints/modules/pom.xml
ms/controllerblueprints/modules/service/pom.xml
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BlueprintModelService.java
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java [deleted file]
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelContentRepository.java [deleted file]
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelRepository.java [deleted file]
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.java [moved from ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelSearchRepository.java with 87% similarity]
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/ControllerBluePrintCoreConfiguration.kt [moved from ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintCoreConfiguration.kt with 79% similarity]
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintLoadConfiguration.kt [deleted file]
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ControllerBlueprintCatalogServiceImpl.kt [moved from ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogServiceImpl.kt with 54% similarity]
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelContentRepository.kt [new file with mode: 0644]
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelRepository.kt [new file with mode: 0644]
ms/controllerblueprints/parent/pom.xml

diff --git a/ms/controllerblueprints/modules/blueprint-validation/pom.xml b/ms/controllerblueprints/modules/blueprint-validation/pom.xml
new file mode 100644 (file)
index 0000000..0cafc9a
--- /dev/null
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright © 2017-2018 AT&T Intellectual Property.
+  ~
+  ~ Modifications Copyright © 2018 IBM.
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+  xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+        <artifactId>modules</artifactId>
+        <version>0.4.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>blueprint-validation</artifactId>
+    <name>Controller Blueprints Validation Service</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+            <artifactId>core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+            <artifactId>resource-dict</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
  * limitations under the License.
  */
 
-package org.onap.ccsdk.apps.controllerblueprints.service.validator
+package org.onap.ccsdk.apps.controllerblueprints.blueprint.validation
 
 import com.att.eelf.configuration.EELFLogger
 import com.att.eelf.configuration.EELFManager
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService
 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
-import org.onap.ccsdk.apps.controllerblueprints.core.validation.*
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationServiceImpl
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintArtifactTypeValidatorImpl
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintAttributeDefinitionValidatorImpl
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintDataTypeValidatorImpl
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintNodeTemplateValidatorImpl
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintNodeTypeValidatorImpl
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintPropertyDefinitionValidatorImpl
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintServiceTemplateValidatorImpl
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintTopologyTemplateValidatorImpl
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintValidatorServiceImpl
+import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintWorkflowValidatorImpl
 import org.springframework.stereotype.Service
 import java.util.*
 
@@ -91,13 +97,4 @@ class DefaulBluePrintPropertyDefinitionValidator(bluePrintTypeValidatorService:
 
 @Service
 class DefaultBluePrintAttributeDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
-    : BluePrintAttributeDefinitionValidatorImpl(bluePrintTypeValidatorService)
-
-// Resource Dictionary Validation Services
-
-@Service
-class DefaultResourceAssignmentValidationService : ResourceAssignmentValidationServiceImpl()
-
-@Service
-class DefalutResourceDefinitionValidationService(bluePrintRepoService: BluePrintRepoService)
-    : ResourceDefinitionValidationServiceImpl(bluePrintRepoService)
\ No newline at end of file
+    : BluePrintAttributeDefinitionValidatorImpl(bluePrintTypeValidatorService)
\ No newline at end of file
diff --git a/ms/controllerblueprints/modules/db-resources/pom.xml b/ms/controllerblueprints/modules/db-resources/pom.xml
new file mode 100644 (file)
index 0000000..69e322e
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright © 2017-2018 AT&T Intellectual Property.
+  ~
+  ~ Modifications Copyright © 2018 IBM.
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+  xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+        <artifactId>modules</artifactId>
+        <version>0.4.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>db-resources</artifactId>
+    <name>Controller Blueprints DB Resources</name>
+
+    <properties>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+            <artifactId>core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt b/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt
new file mode 100644 (file)
index 0000000..881e3bc
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.db.resources
+
+import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintCatalogService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintArchiveUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils
+import java.io.File
+import javax.persistence.MappedSuperclass
+
+@MappedSuperclass
+abstract class BlueprintCatalogServiceImpl(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration) : BluePrintCatalogService {
+
+    override fun uploadToDataBase(file: String, validate: Boolean): String {
+        // The file name provided here is unique as we transform to UUID before storing
+        val blueprintFile = File(file)
+        val fileName = blueprintFile.name
+        val id = BluePrintFileUtils.stripFileExtension(fileName)
+        // If the file is directory
+        if (blueprintFile.isDirectory) {
+
+            val zipFile = File("${bluePrintLoadConfiguration.blueprintArchivePath}/$fileName")
+            // zip the directory
+            BluePrintArchiveUtils.compress(blueprintFile, zipFile, true)
+
+            // Upload to the Data Base
+            saveToDataBase(blueprintFile, id, zipFile)
+
+            // After Upload to Database delete the zip file
+            zipFile.delete()
+
+        } else {
+            // If the file is ZIP
+            // unzip the CBA file to validate before store in database
+            val targetDir = "${bluePrintLoadConfiguration.blueprintDeployPath}/$id/"
+            val extractedDirectory = BluePrintArchiveUtils.deCompress(blueprintFile, targetDir)
+
+            // Upload to the Data Base
+            saveToDataBase(extractedDirectory, id, blueprintFile)
+
+            // After Upload to Database delete the zip file
+            blueprintFile.delete()
+            extractedDirectory.delete()
+        }
+
+        return id
+    }
+
+    override fun downloadFromDataBase(name: String, version: String, path: String): String {
+        // If path ends with zip, then compress otherwise download as extracted folder
+
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun downloadFromDataBase(uuid: String, path: String): String {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun prepareBluePrint(name: String, version: String): String {
+        val preparedPath = "${bluePrintLoadConfiguration.blueprintDeployPath}/$name/$version"
+        downloadFromDataBase(name, version, preparedPath)
+        return preparedPath
+    }
+
+    abstract fun saveToDataBase(extractedDirectory: File, id: String, archiveFile: File, checkValidity: Boolean? = false)
+}
\ No newline at end of file
diff --git a/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelContentRepository.kt b/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelContentRepository.kt
new file mode 100644 (file)
index 0000000..4965677
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.db.resources.repository
+
+import org.jetbrains.annotations.NotNull
+import java.util.Optional
+import org.springframework.data.jpa.repository.JpaRepository
+import org.springframework.data.repository.NoRepositoryBean
+
+/**
+ * @param <T> Model
+ * @param <B> ModelContent
+ */
+@NoRepositoryBean
+interface ModelContentRepository<T, B> : JpaRepository<B, String> {
+
+    /**
+     * This is a findById method
+     *
+     * @param id id
+     * @return Optional<T>
+     */
+    @NotNull
+    override fun findById(@NotNull id: String): Optional<B>
+
+    /**
+     * This is a findTopByBlueprintModelAndContentType method
+     *
+     * @param blueprintModel blueprintModel
+     * @param contentType contentType
+     * @return Optional<B>
+     */
+    fun findTopByBlueprintModelAndContentType(blueprintModel: T,
+                                              contentType: String): Optional<B>
+
+    /**
+     * This is a findByBlueprintModelAndContentType method
+     *
+     * @param blueprintModel blueprintModel
+     * @param contentType contentType
+     * @return Optional<BlueprintModelContent>
+     */
+    fun findByBlueprintModelAndContentType(blueprintModel: T, contentType: String): List<B>
+
+    /**
+     * This is a findByBlueprintModel method
+     *
+     * @param blueprintModel B
+     * @return Optional<T>
+     */
+    fun findByBlueprintModel(blueprintModel: T): List<B>
+
+    /**
+     * This is a findByBlueprintModelAndContentTypeAndName method
+     *
+     * @param blueprintModel blueprintModel
+     * @param contentType contentType
+     * @param name name
+     * @return Optional<B>
+     */
+    fun findByBlueprintModelAndContentTypeAndName(blueprintModel: T,
+                                                  contentType: String, name: String): Optional<B>
+
+    /**
+     * This is a deleteByMdeleteByBlueprintModelodelName method
+     *
+     * @param blueprintModel B
+     */
+    fun deleteByBlueprintModel(blueprintModel: T)
+
+    /**
+     * This is a deleteById method
+     *
+     * @param id id
+     */
+    override fun deleteById(@NotNull id: String)
+
+}
\ No newline at end of file
diff --git a/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelRepository.kt b/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelRepository.kt
new file mode 100644 (file)
index 0000000..c31f009
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.db.resources.repository
+
+import org.jetbrains.annotations.NotNull
+import java.util.Optional
+import org.springframework.data.jpa.repository.JpaRepository
+import org.springframework.data.repository.NoRepositoryBean
+
+/**
+ * @param <T> Model
+ */
+@NoRepositoryBean
+interface ModelRepository<T> : JpaRepository<T, String> {
+
+    /**
+     * This is a findById method
+     *
+     * @param id id
+     * @return Optional<T>
+     */
+    @NotNull
+    override fun findById(@NotNull id: String): Optional<T>
+
+    /**
+     * This is a findByArtifactNameAndArtifactVersion method
+     *
+     * @param artifactName artifactName
+     * @param artifactVersion artifactVersion
+     * @return Optional<T>
+     */
+    fun findByArtifactNameAndArtifactVersion(artifactName: String, artifactVersion: String): Optional<T>
+
+    /**
+     * This is a findTopByArtifactNameOrderByArtifactIdDesc method
+     *
+     * @param artifactName artifactName
+     * @return Optional<T>
+     */
+    fun findTopByArtifactNameOrderByArtifactVersionDesc(artifactName: String): Optional<T>
+
+    /**
+     * This is a findTopByArtifactName method
+     *
+     * @param artifactName artifactName
+     * @return Optional<T>
+     */
+    fun findTopByArtifactName(artifactName: String): List<T>
+
+    /**
+     * This is a findByTagsContainingIgnoreCase method
+     *
+     * @param tags tags
+     * @return Optional<ModelType>
+     */
+    fun findByTagsContainingIgnoreCase(tags: String): List<T>
+
+    /**
+     * This is a deleteByArtifactNameAndArtifactVersion method
+     *
+     * @param artifactName artifactName
+     * @param artifactVersion artifactVersion
+     */
+    fun deleteByArtifactNameAndArtifactVersion(artifactName: String, artifactVersion: String)
+
+    /**
+     * This is a deleteById method
+     *
+     * @param id id
+     */
+    override fun deleteById(@NotNull id: String)
+
+}
index eff2429..9a53eeb 100644 (file)
@@ -16,9 +16,9 @@
   -->\r
 \r
 <project\r
-        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"\r
-        xmlns="http://maven.apache.org/POM/4.0.0"\r
-        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"\r
+  xmlns="http://maven.apache.org/POM/4.0.0"\r
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
     <modelVersion>4.0.0</modelVersion>\r
     <parent>\r
         <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>\r
@@ -32,6 +32,8 @@
 \r
     <modules>\r
         <module>service</module>\r
+        <module>blueprint-validation</module>\r
+        <module>db-resources</module>\r
     </modules>\r
 \r
     <build>\r
index 017cfde..91a9eab 100644 (file)
@@ -1,84 +1,96 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-  ~ Copyright © 2017-2018 AT&T Intellectual Property.\r
-  ~\r
-  ~ Modifications Copyright © 2018 IBM.\r
-  ~\r
-  ~ Licensed under the Apache License, Version 2.0 (the "License");\r
-  ~ you may not use this file except in compliance with the License.\r
-  ~ You may obtain a copy of the License at\r
-  ~\r
-  ~     http://www.apache.org/licenses/LICENSE-2.0\r
-  ~\r
-  ~ Unless required by applicable law or agreed to in writing, software\r
-  ~ distributed under the License is distributed on an "AS IS" BASIS,\r
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-  ~ See the License for the specific language governing permissions and\r
-  ~ limitations under the License.\r
-  -->\r
-\r
-<project\r
-        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"\r
-        xmlns="http://maven.apache.org/POM/4.0.0"\r
-        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
-    <modelVersion>4.0.0</modelVersion>\r
-    <parent>\r
-        <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>\r
-        <artifactId>modules</artifactId>\r
-        <version>0.4.0-SNAPSHOT</version>\r
-    </parent>\r
-    <artifactId>service</artifactId>\r
-    <name>Controller Blueprints Service</name>\r
-\r
-    <properties>\r
-    </properties>\r
-\r
-    <dependencies>\r
-        <dependency>\r
-            <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>\r
-            <artifactId>resource-dict</artifactId>\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>org.apache.velocity</groupId>\r
-            <artifactId>velocity</artifactId>\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>org.springframework.boot</groupId>\r
-            <artifactId>spring-boot-starter-webflux</artifactId>\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>org.springframework.boot</groupId>\r
-            <artifactId>spring-boot-starter-data-jpa</artifactId>\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>com.h2database</groupId>\r
-            <artifactId>h2</artifactId>\r
-            <scope>runtime</scope>\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>org.mariadb.jdbc</groupId>\r
-            <artifactId>mariadb-java-client</artifactId>\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>org.powermock</groupId>\r
-            <artifactId>powermock-api-mockito2</artifactId>\r
-            <scope>test</scope>\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>org.springframework.boot</groupId>\r
-            <artifactId>spring-boot-starter-test</artifactId>\r
-            <scope>test</scope>\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>org.jetbrains.kotlin</groupId>\r
-            <artifactId>kotlin-test-junit</artifactId>\r
-            <scope>test</scope>\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>io.projectreactor</groupId>\r
-            <artifactId>reactor-test</artifactId>\r
-            <scope>test</scope>\r
-        </dependency>\r
-    </dependencies>\r
-</project>\r
-\r
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright © 2017-2018 AT&T Intellectual Property.
+  ~
+  ~ Modifications Copyright © 2018 IBM.
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+  xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+        <artifactId>modules</artifactId>
+        <version>0.4.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>service</artifactId>
+    <name>Controller Blueprints Service</name>
+
+    <properties>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+            <artifactId>core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+            <artifactId>db-resources</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+            <artifactId>blueprint-validation</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+            <artifactId>resource-dict</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.velocity</groupId>
+            <artifactId>velocity</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-webflux</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mariadb.jdbc</groupId>
+            <artifactId>mariadb-java-client</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.powermock</groupId>
+            <artifactId>powermock-api-mockito2</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.jetbrains.kotlin</groupId>
+            <artifactId>kotlin-test-junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>io.projectreactor</groupId>
+            <artifactId>reactor-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
+
index ba27742..ca0e243 100644 (file)
@@ -21,14 +21,14 @@ import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;\r
 import org.jetbrains.annotations.NotNull;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
+import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintCatalogService;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils;\r
 import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel;\r
 import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelSearch;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.load.BluePrintLoadConfiguration;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelContentRepository;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelRepository;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelSearchRepository;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ControllerBlueprintModelContentRepository;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ControllerBlueprintModelRepository;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ControllerBlueprintModelSearchRepository;\r
 import org.onap.ccsdk.apps.controllerblueprints.service.utils.BluePrintEnhancerUtils;\r
 import org.springframework.beans.factory.annotation.Autowired;\r
 import org.springframework.core.io.ByteArrayResource;\r
@@ -65,17 +65,17 @@ public class BlueprintModelService {
     private BluePrintCatalogService bluePrintCatalogService;\r
 \r
     @Autowired\r
-    private BlueprintModelSearchRepository blueprintModelSearchRepository;\r
+    private ControllerBlueprintModelSearchRepository blueprintModelSearchRepository;\r
 \r
     @Autowired\r
-    private BlueprintModelRepository blueprintModelRepository;\r
+    private ControllerBlueprintModelRepository blueprintModelRepository;\r
 \r
     @Autowired\r
-    private BlueprintModelContentRepository blueprintModelContentRepository;\r
+    private ControllerBlueprintModelContentRepository blueprintModelContentRepository;\r
 \r
     private static final String BLUEPRINT_MODEL_ID_FAILURE_MSG = "failed to get blueprint model id(%d) from repo";\r
     private static final String BLUEPRINT_MODEL_NAME_VERSION_FAILURE_MSG = "failed to get blueprint model by name(%d)" +\r
-                                                                    " and version(%d) from repo";\r
+        " and version(%d) from repo";\r
 \r
     /**\r
      * This is a saveBlueprintModel method\r
@@ -86,10 +86,12 @@ public class BlueprintModelService {
      */\r
     public Mono<BlueprintModelSearch> saveBlueprintModel(FilePart filePart) throws BluePrintException {\r
         try {\r
-            Path cbaLocation = BluePrintFileUtils.Companion.getCbaStorageDirectory(bluePrintLoadConfiguration.blueprintArchivePath);\r
+            Path cbaLocation = BluePrintFileUtils.Companion\r
+                .getCbaStorageDirectory(bluePrintLoadConfiguration.blueprintArchivePath);\r
             return BluePrintEnhancerUtils.Companion.saveCBAFile(filePart, cbaLocation).map(fileName -> {\r
-                        String blueprintId =   bluePrintCatalogService.uploadToDataBase(cbaLocation.resolve(fileName).toString(), false);\r
-                        return blueprintModelSearchRepository.findById(blueprintId).get();\r
+                String blueprintId = bluePrintCatalogService\r
+                    .uploadToDataBase(cbaLocation.resolve(fileName).toString(), false);\r
+                return blueprintModelSearchRepository.findById(blueprintId).get();\r
             });\r
 \r
         } catch (IOException | BluePrintException e) {\r
@@ -122,14 +124,15 @@ public class BlueprintModelService {
     /**\r
      * This is a getBlueprintModelByNameAndVersion method\r
      *\r
-     * @param name    name\r
+     * @param name name\r
      * @param version version\r
      * @return BlueprintModelSearch\r
      */\r
-    public BlueprintModelSearch getBlueprintModelByNameAndVersion(@NotNull String name, @NotNull String version) throws BluePrintException {\r
+    public BlueprintModelSearch getBlueprintModelByNameAndVersion(@NotNull String name, @NotNull String version)\r
+        throws BluePrintException {\r
         BlueprintModelSearch blueprintModelSearch;\r
         Optional<BlueprintModelSearch> dbBlueprintModel = blueprintModelSearchRepository\r
-                                                            .findByArtifactNameAndArtifactVersion(name, version);\r
+            .findByArtifactNameAndArtifactVersion(name, version);\r
         if (dbBlueprintModel.isPresent()) {\r
             blueprintModelSearch = dbBlueprintModel.get();\r
         } else {\r
@@ -142,7 +145,6 @@ public class BlueprintModelService {
     /**\r
      * This is a downloadBlueprintModelFile method to find the target file to download and return a file resource using MONO\r
      *\r
-     * @param (id)\r
      * @return ResponseEntity<Resource>\r
      */\r
     public ResponseEntity<Resource> downloadBlueprintModelFile(@NotNull String id) throws BluePrintException {\r
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java
deleted file mode 100644 (file)
index d16f1b1..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.common;\r
-\r
-/**\r
- * ApplicationConstants.java Purpose: Provide ControllerBluprintsApplication Constant Information\r
- *\r
- * @author Brinda Santh\r
- * @version 1.0\r
- */\r
-public final class ApplicationConstants {\r
-    public static final String ACTIVE_Y = "Y";\r
-    public static final String ACTIVE_N = "N";\r
-    public static final String ASDC_ARTIFACT_TYPE_SDNC_MODEL = "SDNC_MODEL";\r
-    \r
-    private ApplicationConstants() {\r
-\r
-    }\r
-\r
-}\r
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelContentRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelContentRepository.java
deleted file mode 100644 (file)
index 7940c94..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2019 Bell Canada.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.repository;\r
-\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelContent;\r
-import org.springframework.data.jpa.repository.JpaRepository;\r
-import org.springframework.stereotype.Repository;\r
-\r
-import javax.validation.constraints.NotNull;\r
-import java.util.List;\r
-import java.util.Optional;\r
-\r
-/**\r
- * BlueprintModelContentRepository.java Purpose: Provide BlueprintModelContentRepository of Repository\r
- *\r
- * @author Brinda Santh\r
- * @version 1.0\r
- */\r
-@Repository\r
-public interface BlueprintModelContentRepository extends JpaRepository<BlueprintModelContent, String> {\r
-\r
-    /**\r
-     * This is a findById method\r
-     * \r
-     * @param id id\r
-     * @return Optional<AsdcArtifacts>\r
-     */\r
-    @NotNull\r
-    Optional<BlueprintModelContent> findById(@NotNull String id);\r
-\r
-    /**\r
-     * This is a findTopByBlueprintModelAndContentType method\r
-     * \r
-     * @param blueprintModel  blueprintModel\r
-     * @param contentType contentType\r
-     * @return Optional<BlueprintModelContent>\r
-     */\r
-    @SuppressWarnings("unused")\r
-    Optional<BlueprintModelContent> findTopByBlueprintModelAndContentType(BlueprintModel blueprintModel, String contentType);\r
-\r
-    /**\r
-     * This is a findByBlueprintModelAndContentType method\r
-     * \r
-     * @param blueprintModel blueprintModel\r
-     * @param contentType contentType\r
-     * @return Optional<BlueprintModelContent>\r
-     */\r
-    @SuppressWarnings("unused")\r
-    List<BlueprintModelContent> findByBlueprintModelAndContentType(BlueprintModel blueprintModel, String contentType);\r
-\r
-    /**\r
-     * This is a findByBlueprintModel method\r
-     * \r
-     * @param blueprintModel blueprintModel\r
-     * @return Optional<BlueprintModelContent>\r
-     */\r
-    @SuppressWarnings("unused")\r
-    List<BlueprintModelContent> findByBlueprintModel(BlueprintModel blueprintModel);\r
-\r
-    /**\r
-     * This is a findByBlueprintModelAndContentTypeAndName method\r
-     * \r
-     * @param blueprintModel blueprintModel\r
-     * @param contentType contentType\r
-     * @param name name\r
-     * @return Optional<BlueprintModelContent>\r
-     */\r
-    @SuppressWarnings("unused")\r
-    Optional<BlueprintModelContent> findByBlueprintModelAndContentTypeAndName(BlueprintModel blueprintModel,\r
-                                                                           String contentType, String name);\r
-\r
-    /**\r
-     * This is a deleteByMdeleteByBlueprintModelodelName method\r
-     * \r
-     * @param blueprintModel blueprintModel\r
-     */\r
-    void deleteByBlueprintModel(BlueprintModel blueprintModel);\r
-\r
-    /**\r
-     * This is a deleteById method\r
-     * \r
-     * @param  id id\r
-     */\r
-    void deleteById(@NotNull String id);\r
-\r
-}\r
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelRepository.java
deleted file mode 100644 (file)
index 4131604..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2019 Bell Canada.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.repository;\r
-\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel;\r
-import org.springframework.data.jpa.repository.JpaRepository;\r
-import org.springframework.stereotype.Repository;\r
-\r
-import javax.validation.constraints.NotNull;\r
-import java.util.List;\r
-import java.util.Optional;\r
-\r
-/**\r
- * AsdcArtifactsRepository.java Purpose: Provide Configuration Generator AsdcArtifactsRepository\r
- *\r
- * @author Brinda Santh\r
- * @version 1.0\r
- */\r
-@Repository\r
-public interface BlueprintModelRepository extends JpaRepository<BlueprintModel, String> {\r
-    /**\r
-     * This is a findById method\r
-     * \r
-     * @param id id\r
-     * @return Optional<AsdcArtifacts>\r
-     */\r
-    @NotNull\r
-    Optional<BlueprintModel> findById(@NotNull String id);\r
-\r
-    /**\r
-     * This is a findByArtifactNameAndArtifactVersion method\r
-     * \r
-     * @param artifactName artifactName\r
-     * @param artifactVersion artifactVersion\r
-     * @return Optional<AsdcArtifacts>\r
-     */\r
-    Optional<BlueprintModel> findByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion);\r
-\r
-    /**\r
-     * This is a findTopByArtifactNameOrderByArtifactIdDesc method\r
-     * \r
-     * @param artifactName artifactName\r
-     * @return Optional<AsdcArtifacts>\r
-     */\r
-    Optional<BlueprintModel> findTopByArtifactNameOrderByArtifactVersionDesc(String artifactName);\r
-\r
-    /**\r
-     * This is a findTopByArtifactName method\r
-     * \r
-     * @param artifactName artifactName\r
-     * @return Optional<AsdcArtifacts>\r
-     */\r
-    @SuppressWarnings("unused")\r
-    List<BlueprintModel> findTopByArtifactName(String artifactName);\r
-\r
-    /**\r
-     * This is a findByTagsContainingIgnoreCase method\r
-     * \r
-     * @param tags tags\r
-     * @return Optional<ModelType>\r
-     */\r
-    List<BlueprintModel> findByTagsContainingIgnoreCase(String tags);\r
-\r
-    /**\r
-     * This is a deleteByArtifactNameAndArtifactVersion method\r
-     * \r
-     * @param artifactName artifactName\r
-     * @param artifactVersion artifactVersion\r
-     */\r
-    @SuppressWarnings("unused")\r
-    void deleteByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion);\r
-\r
-    /**\r
-     * This is a deleteById method\r
-     * \r
-     * @param id id\r
-     */\r
-    @SuppressWarnings("unused")\r
-    void deleteById(@NotNull String id);\r
-\r
-}\r
@@ -1,69 +1,69 @@
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2019 Bell Canada.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.repository;\r
-\r
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelSearch;\r
-import org.springframework.data.jpa.repository.JpaRepository;\r
-import org.springframework.stereotype.Repository;\r
-\r
-import javax.validation.constraints.NotNull;\r
-import java.util.List;\r
-import java.util.Optional;\r
-\r
-/**\r
- * BlueprintModelSearchRepository.java Purpose: Provide Configuration Generator AsdcArtifactsRepository\r
- *\r
- * @author Brinda Santh\r
- * @version 1.0\r
- */\r
-@Repository\r
-public interface BlueprintModelSearchRepository extends JpaRepository<BlueprintModelSearch, Long> {\r
-\r
-    /**\r
-     * This is a findById method\r
-     *\r
-     * @param id id\r
-     * @return Optional<BlueprintModelSearch>\r
-     */\r
-    @NotNull\r
-    Optional<BlueprintModelSearch> findById(@NotNull String id);\r
-\r
-    /**\r
-     * This is a findAll method\r
-     * @return List<BlueprintModelSearch>\r
-     */\r
-    @Override\r
-    List<BlueprintModelSearch> findAll();\r
-\r
-    /**\r
-     * This is a findByArtifactNameAndArtifactVersion method\r
-     *\r
-     * @param artifactName artifactName\r
-     * @param artifactVersion artifactVersion\r
-     * @return Optional<AsdcArtifacts>\r
-     */\r
-    Optional<BlueprintModelSearch> findByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion);\r
-\r
-    /**\r
-     * This is a findByTagsContainingIgnoreCase method\r
-     * \r
-     * @param tags\r
-     * @return Optional<BlueprintModelSearch>\r
-     */\r
-    List<BlueprintModelSearch> findByTagsContainingIgnoreCase(String tags);\r
-}\r
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.repository;
+
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelSearch;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import javax.validation.constraints.NotNull;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * ControllerBlueprintModelSearchRepository.java Purpose: Provide Configuration Generator AsdcArtifactsRepository
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Repository
+public interface ControllerBlueprintModelSearchRepository extends JpaRepository<BlueprintModelSearch, Long> {
+
+    /**
+     * This is a findById method
+     *
+     * @param id id
+     * @return Optional<BlueprintModelSearch>
+     */
+    @NotNull
+    Optional<BlueprintModelSearch> findById(@NotNull String id);
+
+    /**
+     * This is a findAll method
+     * @return List<BlueprintModelSearch>
+     */
+    @Override
+    List<BlueprintModelSearch> findAll();
+
+    /**
+     * This is a findByArtifactNameAndArtifactVersion method
+     *
+     * @param artifactName artifactName
+     * @param artifactVersion artifactVersion
+     * @return Optional<AsdcArtifacts>
+     */
+    Optional<BlueprintModelSearch> findByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion);
+
+    /**
+     * This is a findByTagsContainingIgnoreCase method
+     * 
+     * @param tags
+     * @return Optional<BlueprintModelSearch>
+     */
+    List<BlueprintModelSearch> findByTagsContainingIgnoreCase(String tags);
+}
index c818410..f856b9e 100644 (file)
@@ -24,10 +24,21 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.*
 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationServiceImpl
 import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository
 import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository
 import org.springframework.stereotype.Service
 
+// Resource Dictionary Validation Services
+
+@Service
+class DefaultResourceAssignmentValidationService : ResourceAssignmentValidationServiceImpl()
+
+@Service
+class DefalutResourceDefinitionValidationService(bluePrintRepoService: BluePrintRepoService)
+    : ResourceDefinitionValidationServiceImpl(bluePrintRepoService)
+
 interface ResourceDefinitionRepoService : BluePrintRepoService {
 
     @Throws(BluePrintException::class)
@@ -16,7 +16,7 @@
 
 package org.onap.ccsdk.apps.controllerblueprints.service
 
-import org.onap.ccsdk.apps.controllerblueprints.service.load.BluePrintLoadConfiguration
+import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.boot.context.properties.bind.Bindable
 import org.springframework.boot.context.properties.bind.Binder
@@ -27,33 +27,33 @@ import org.springframework.core.env.Environment
 import org.springframework.stereotype.Service
 
 @Configuration
-open class BluePrintCoreConfiguration(private val bluePrintProperties: BluePrintProperties) {
+open class ControllerBluePrintCoreConfiguration(private val bluePrintProperties: ControllerBlueprintProperties) {
 
     companion object {
         const val PREFIX_BLUEPRINT_LOAD_CONFIGURATION = "controllerblueprints"
     }
 
     @Bean
-    open fun bluePrintLoadConfiguration(): BluePrintLoadConfiguration {
+    open fun controlelrBlueprintLoadConfiguration(): BluePrintLoadConfiguration {
         return bluePrintProperties
                 .propertyBeanType(PREFIX_BLUEPRINT_LOAD_CONFIGURATION, BluePrintLoadConfiguration::class.java)
     }
 }
 
 @Configuration
-open class BlueprintPropertyConfiguration {
+open class ControllerBlueprintPropertyConfiguration {
     @Autowired
     lateinit var environment: Environment
 
     @Bean
-    open fun bluePrintPropertyBinder(): Binder {
+    open fun controllerBluePrintPropertyBinder(): Binder {
         val configurationPropertySource = ConfigurationPropertySources.get(environment)
         return Binder(configurationPropertySource)
     }
 }
 
 @Service
-open class BluePrintProperties(var bluePrintPropertyBinder: Binder) {
+open class ControllerBlueprintProperties(var bluePrintPropertyBinder: Binder) {
     fun <T> propertyBeanType(prefix: String, type: Class<T>): T {
         return bluePrintPropertyBinder.bind(prefix, Bindable.of(type)).get()
     }
index eeea97c..8b6e54a 100644 (file)
@@ -17,6 +17,7 @@
 package org.onap.ccsdk.apps.controllerblueprints.service.load
 
 import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration
 import org.springframework.boot.context.event.ApplicationReadyEvent
 import org.springframework.context.event.EventListener
 import org.springframework.stereotype.Service
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintLoadConfiguration.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintLoadConfiguration.kt
deleted file mode 100644 (file)
index cf36a3e..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.load
-
-open class BluePrintLoadConfiguration {
-
-    lateinit var blueprintDeployPath: String
-    lateinit var blueprintArchivePath: String
-    lateinit var blueprintEnrichmentPath: String
-
-    var loadInitialData: Boolean = false
-    var loadBluePrint: Boolean = false
-    var loadBluePrintPaths: String? = null
-
-    var loadModelType: Boolean = false
-    var loadModeTypePaths: String? = null
-
-    var loadResourceDictionary: Boolean = false
-    var loadResourceDictionaryPaths: String? = null
-}
\ No newline at end of file
 package org.onap.ccsdk.apps.controllerblueprints.service.load
 
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintCatalogService
+import org.onap.ccsdk.apps.controllerblueprints.core.common.ApplicationConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration
 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintArchiveUtils
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
-import org.onap.ccsdk.apps.controllerblueprints.service.common.ApplicationConstants
+import org.onap.ccsdk.apps.controllerblueprints.db.resources.BlueprintCatalogServiceImpl
 import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel
 import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelContent
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelContentRepository
-import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelRepository
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ControllerBlueprintModelContentRepository
+import org.onap.ccsdk.apps.controllerblueprints.service.repository.ControllerBlueprintModelRepository
 import org.springframework.stereotype.Service
 import java.io.File
 import java.nio.file.Files
 
+/**
+Similar implementation in [org.onap.ccsdk.apps.blueprintsprocessor.db.BlueprintProcessorCatalogServiceImpl]
+ */
 @Service
-class BluePrintCatalogServiceImpl(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
-                                  private val bluePrintValidatorService: BluePrintValidatorService,
-                                  private val blueprintModelContentRepository: BlueprintModelContentRepository,
-                                  private val blueprintModelRepository: BlueprintModelRepository) : BluePrintCatalogService {
-
-    override fun uploadToDataBase(file: String, validate: Boolean): String {
-        // The file name provided here is unique as we transform to UUID before storing
-        val blueprintFile = File(file)
-        val fileName = blueprintFile.name
-        val id = BluePrintFileUtils.stripFileExtension(fileName)
-        // If the file is directory
-        if (blueprintFile.isDirectory) {
-
-            val zipFile = File("${bluePrintLoadConfiguration.blueprintArchivePath}/$fileName")
-            // zip the directory
-            BluePrintArchiveUtils.compress(blueprintFile, zipFile, true)
-
-            // Upload to the Data Base
-            saveToDataBase(blueprintFile, id, zipFile)
-
-            // After Upload to Database delete the zip file
-            zipFile.delete()
-
-        } else {
-            // If the file is ZIP
-            // unzip the CBA file to validate before store in database
-            val targetDir = "${bluePrintLoadConfiguration.blueprintDeployPath}/$id/"
-            val extractedDirectory = BluePrintArchiveUtils.deCompress(blueprintFile, targetDir)
-
-            // Upload to the Data Base
-            saveToDataBase(extractedDirectory, id, blueprintFile)
-
-            // After Upload to Database delete the zip file
-            blueprintFile.delete()
-            extractedDirectory.delete()
-        }
-
-        return id
-    }
-
-    override fun downloadFromDataBase(name: String, version: String, path: String): String {
-        // If path ends with zip, then compress otherwise download as extracted folder
-
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
-    }
-
-    override fun downloadFromDataBase(uuid: String, path: String): String {
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
-    }
-
-    override fun prepareBluePrint(name: String, version: String): String {
-        val preparedPath = "${bluePrintLoadConfiguration.blueprintDeployPath}/$name/$version"
-        downloadFromDataBase(name, version, preparedPath)
-        return preparedPath
-    }
+class ControllerBlueprintCatalogServiceImpl(bluePrintLoadConfiguration: BluePrintLoadConfiguration,
+                                            private val bluePrintValidatorService: BluePrintValidatorService,
+                                            private val blueprintModelContentRepository: ControllerBlueprintModelContentRepository,
+                                            private val blueprintModelRepository: ControllerBlueprintModelRepository)
+    : BlueprintCatalogServiceImpl(bluePrintLoadConfiguration) {
 
-    private fun saveToDataBase(extractedDirectory: File, id: String, archiveFile: File, checkValidity: Boolean? = false) {
-        // Upload to the Data Base
-        //val id = "save-$uuid"
+    override fun saveToDataBase(extractedDirectory: File, id: String, archiveFile: File, checkValidity: Boolean?) {
         var valid = false
         val firstItem = BluePrintArchiveUtils.getFirstItemInDirectory(extractedDirectory)
         val blueprintBaseDirectory = extractedDirectory.absolutePath + "/" + firstItem
@@ -108,7 +59,7 @@ class BluePrintCatalogServiceImpl(private val bluePrintLoadConfiguration: BluePr
             // FIXME("Check Duplicate for Artifact Name and Artifact Version")
             val blueprintModel = BlueprintModel()
             blueprintModel.id = id
-            blueprintModel.artifactType =  ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL
+            blueprintModel.artifactType = ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL
             blueprintModel.published = ApplicationConstants.ACTIVE_N
             blueprintModel.artifactName = metaData[BluePrintConstants.METADATA_TEMPLATE_NAME]
             blueprintModel.artifactVersion = metaData[BluePrintConstants.METADATA_TEMPLATE_VERSION]
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelContentRepository.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelContentRepository.kt
new file mode 100644 (file)
index 0000000..7cda727
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.apps.controllerblueprints.service.repository
+
+import org.onap.ccsdk.apps.controllerblueprints.db.resources.repository.ModelContentRepository
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelContent
+
+interface ControllerBlueprintModelContentRepository : ModelContentRepository<BlueprintModel, BlueprintModelContent>
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelRepository.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelRepository.kt
new file mode 100644 (file)
index 0000000..ec11750
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.apps.controllerblueprints.service.repository
+
+import org.onap.ccsdk.apps.controllerblueprints.db.resources.repository.ModelRepository
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel
+
+interface ControllerBlueprintModelRepository : ModelRepository<BlueprintModel>
index 38a879a..ec6f252 100644 (file)
                 <artifactId>resource-dict</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+                <artifactId>db-resources</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+                <artifactId>blueprint-validation</artifactId>
+                <version>${project.version}</version>
+            </dependency>
 
             <!-- Testing Dependencies -->
             <dependency>