Add extension validation framework
authorMuthuramalingam, Brinda Santh <brindasanth@in.ibm.com>
Fri, 22 Feb 2019 15:14:24 +0000 (10:14 -0500)
committerMuthuramalingam, Brinda Santh <brindasanth@in.ibm.com>
Mon, 25 Feb 2019 21:11:52 +0000 (16:11 -0500)
Change-Id: I5674e8da70cc4d20899f6fe2163a595b28861036
Issue-ID: CCSDK-1103
Signed-off-by: Muthuramalingam, Brinda Santh <brindasanth@in.ibm.com>
ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt
ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip
ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintDesignTimeRuntimeValidatorService.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zip
ms/blueprintsprocessor/parent/pom.xml

index 33d0d96..e94bcff 100755 (executable)
@@ -1,6 +1,7 @@
 /*
  * Copyright © 2017-2018 AT&T Intellectual Property.
  * Modifications Copyright © 2019 Bell Canada.
+ * 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.
@@ -40,10 +41,10 @@ import java.nio.file.Paths
  * Similar/Duplicate implementation in [org.onap.ccsdk.apps.controllerblueprints.service.load.ControllerBlueprintCatalogServiceImpl]
  */
 @Service
-class BlueprintProcessorCatalogServiceImpl(bluePrintValidatorService: BluePrintValidatorService,
+class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: BluePrintValidatorService,
                                            private val blueprintConfig: BluePrintCoreConfiguration,
                                            private val blueprintModelRepository: BlueprintProcessorModelRepository)
-    : BlueprintCatalogServiceImpl(bluePrintValidatorService) {
+    : BlueprintCatalogServiceImpl(bluePrintRuntimeValidatorService) {
 
     private val log = LoggerFactory.getLogger(BlueprintProcessorCatalogServiceImpl::class.toString())
 
index a62d4bf..9074824 100644 (file)
Binary files a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip and b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip differ
index 4a30535..c05b84a 100755 (executable)
         </dependency>
         <dependency>
             <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
-            <version>${project.version}</version>
             <artifactId>blueprint-core</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+            <artifactId>blueprint-validation</artifactId>
+        </dependency>
         <dependency>
             <groupId>io.grpc</groupId>
             <artifactId>grpc-testing</artifactId>
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintDesignTimeRuntimeValidatorService.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintDesignTimeRuntimeValidatorService.kt
new file mode 100644 (file)
index 0000000..08d2c3b
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ *  Copyright © 2018 IBM.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.validation
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.validation.BluePrintDesignTimeValidatorService
+import org.springframework.stereotype.Service
+
+@Service
+open class BluePrintRuntimeValidatorService(
+        private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintDesignTimeValidatorService(bluePrintTypeValidatorService) {
+
+    override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean {
+
+        bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template",
+                bluePrintRuntimeService.bluePrintContext().serviceTemplate)
+        if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) {
+            throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}")
+        }
+        return true
+    }
+}
\ No newline at end of file
index a62d4bf..9074824 100644 (file)
Binary files a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zip and b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zip differ
index ab418f4..51eae8b 100755 (executable)
                 <artifactId>blueprint-scripts</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+                <artifactId>blueprint-validation</artifactId>
+                <version>${project.version}</version>
+            </dependency>
 
             <!-- Database -->
             <dependency>