aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor')
-rw-r--r--ms/blueprintsprocessor/.gitignore3
-rwxr-xr-xms/blueprintsprocessor/application/etc/logback.xml36
-rwxr-xr-xms/blueprintsprocessor/application/etc/run.source12
-rwxr-xr-xms/blueprintsprocessor/application/opt/app/onap/config/application.properties36
-rwxr-xr-xms/blueprintsprocessor/application/opt/app/onap/config/logback.xml36
-rwxr-xr-x[-rw-r--r--]ms/blueprintsprocessor/application/pom.xml85
-rwxr-xr-xms/blueprintsprocessor/application/src/main/resources/application-dev.properties36
-rwxr-xr-x[-rw-r--r--]ms/blueprintsprocessor/application/src/main/resources/application.properties7
-rw-r--r--ms/blueprintsprocessor/application/src/test/resources/application.properties2
-rwxr-xr-xms/blueprintsprocessor/distribution/pom.xml196
-rwxr-xr-xms/blueprintsprocessor/distribution/src/main/dc/docker-compose.yaml33
-rwxr-xr-xms/blueprintsprocessor/distribution/src/main/docker/Dockerfile20
-rwxr-xr-xms/blueprintsprocessor/distribution/src/main/docker/distribution.xml69
-rwxr-xr-xms/blueprintsprocessor/distribution/src/main/docker/startService.sh9
-rwxr-xr-x[-rw-r--r--]ms/blueprintsprocessor/functions/pom.xml0
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt8
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/resources/payload/requests/sample-activate-request.json (renamed from ms/blueprintsprocessor/functions/python-executor/src/test/resources/requests/sample-activate-request.json)0
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt32
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt87
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt134
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt26
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/pom.xml4
-rwxr-xr-x[-rw-r--r--]ms/blueprintsprocessor/modules/commons/pom.xml2
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml4
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml20
-rwxr-xr-x[-rw-r--r--]ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml9
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt18
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt22
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt7
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt168
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandlerTest.kt34
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt55
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappingTests.kt172
-rw-r--r--ms/blueprintsprocessor/modules/outbounds/pom.xml20
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/pom.xml4
-rwxr-xr-x[-rw-r--r--]ms/blueprintsprocessor/modules/services/pom.xml2
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/pom.xml4
-rwxr-xr-x[-rw-r--r--]ms/blueprintsprocessor/parent/pom.xml37
-rwxr-xr-x[-rw-r--r--]ms/blueprintsprocessor/pom.xml56
40 files changed, 1355 insertions, 152 deletions
diff --git a/ms/blueprintsprocessor/.gitignore b/ms/blueprintsprocessor/.gitignore
index f72f78ad..04f991d1 100644
--- a/ms/blueprintsprocessor/.gitignore
+++ b/ms/blueprintsprocessor/.gitignore
@@ -28,4 +28,5 @@
**/transaction.log
**/*versionsBackup
**/blackDuckHub*
-**/*.jsonld \ No newline at end of file
+**/*.jsonld
+/target-ide/
diff --git a/ms/blueprintsprocessor/application/etc/logback.xml b/ms/blueprintsprocessor/application/etc/logback.xml
new file mode 100755
index 00000000..a97bb8c3
--- /dev/null
+++ b/ms/blueprintsprocessor/application/etc/logback.xml
@@ -0,0 +1,36 @@
+<!--
+ ~ 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.
+ -->
+
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <!-- encoders are assigned the type
+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+
+ <logger name="org.springframework" level="info"/>
+ <logger name="org.springframework.web" level="info"/>
+ <logger name="org.hibernate" level="error"/>
+ <logger name="org.onap.ccsdk.apps" level="info"/>
+
+ <root level="warn">
+ <appender-ref ref="STDOUT"/>
+ </root>
+
+</configuration>
diff --git a/ms/blueprintsprocessor/application/etc/run.source b/ms/blueprintsprocessor/application/etc/run.source
new file mode 100755
index 00000000..7557ab12
--- /dev/null
+++ b/ms/blueprintsprocessor/application/etc/run.source
@@ -0,0 +1,12 @@
+java -classpath "/etc:${APP_HOME}/lib/*:/lib/*:/src:/schema:/generated-sources:${APP_CONFIG_HOME}:${APP_HOME}" \
+-DappName=${APPLICATIONNAME} -DappVersion=${BUNDLEVERSION} \
+-DrouteOffer=${ROUTEOFFER} \
+-DVERSION_ROUTEOFFER_ENVCONTEXT=${BUNDLEVERSION}/${STICKYSELECTORKEY}/${ENVCONTEXT} \
+-DSecurityFilePath=/etc \
+-DREST_NAME_NORMALIZER_PATTERN_FILE=/etc/PatternInputs.txt \
+-Dms_name=org.onap.ccsdk.apps.blueprintsprocessor \
+-Dlogging.config=${APP_CONFIG_HOME}/logback.xml \
+-Djava.security.egd=file:/dev/./urandom \
+-DAPPNAME=${APP_NAME} -DAPPENV=${APP_ENV} -DAPPVERSION=${APP_VERSION} -DNAMESPACE=${NAMESPACE} \
+-Dspring.config.location=${APP_CONFIG_HOME}/ \
+org.onap.ccsdk.apps.blueprintsprocessor.BlueprintProcessorApplication
diff --git a/ms/blueprintsprocessor/application/opt/app/onap/config/application.properties b/ms/blueprintsprocessor/application/opt/app/onap/config/application.properties
new file mode 100755
index 00000000..c4880b67
--- /dev/null
+++ b/ms/blueprintsprocessor/application/opt/app/onap/config/application.properties
@@ -0,0 +1,36 @@
+#
+# 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.
+#
+#logging.level.web=DEBUG
+
+# Web server config
+server.port=8080
+
+blueprintsprocessor.grpcEnable=false
+blueprintsprocessor.httpPort=8080
+blueprintsprocessor.grpcPort=9111
+# Blueprint Processor File Execution and Handling Properties
+blueprintsprocessor.blueprintDeployPath=/opt/app/onap/blueprints/deploy
+blueprintsprocessor.blueprintArchivePath=/opt/app/onap/blueprints/archive
+# Primary Database Configuration
+blueprintsprocessor.db.primary.url=jdbc:mysql://db:3306/sdnctl
+blueprintsprocessor.db.primary.username=sdnctl
+blueprintsprocessor.db.primary.password=sdnctl
+blueprintsprocessor.db.primary.driverClassName=org.mariadb.jdbc.Driver
+blueprintsprocessor.db.primary.hibernateHbm2ddlAuto=validate
+blueprintsprocessor.db.primary.hibernateDDLAuto=none
+blueprintsprocessor.db.primary.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy
+blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.MySQL5InnoDBDialect \ No newline at end of file
diff --git a/ms/blueprintsprocessor/application/opt/app/onap/config/logback.xml b/ms/blueprintsprocessor/application/opt/app/onap/config/logback.xml
new file mode 100755
index 00000000..a97bb8c3
--- /dev/null
+++ b/ms/blueprintsprocessor/application/opt/app/onap/config/logback.xml
@@ -0,0 +1,36 @@
+<!--
+ ~ 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.
+ -->
+
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <!-- encoders are assigned the type
+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+
+ <logger name="org.springframework" level="info"/>
+ <logger name="org.springframework.web" level="info"/>
+ <logger name="org.hibernate" level="error"/>
+ <logger name="org.onap.ccsdk.apps" level="info"/>
+
+ <root level="warn">
+ <appender-ref ref="STDOUT"/>
+ </root>
+
+</configuration>
diff --git a/ms/blueprintsprocessor/application/pom.xml b/ms/blueprintsprocessor/application/pom.xml
index 679a8b90..06752b79 100644..100755
--- a/ms/blueprintsprocessor/application/pom.xml
+++ b/ms/blueprintsprocessor/application/pom.xml
@@ -3,6 +3,7 @@
~ Copyright © 2017-2018 AT&T Intellectual Property.
~
~ Modifications Copyright © 2018 IBM.
+ ~ 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.
@@ -31,6 +32,10 @@
<dependencies>
<dependency>
+ <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+ <artifactId>core</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
@@ -69,13 +74,91 @@
<scope>test</scope>
</dependency>
</dependencies>
-
<build>
+ <resources>
+ <resource>
+ <!--config and resource files -->
+ <directory>${basedir}/etc</directory>
+ <targetPath>${basedir}/target/etc</targetPath>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ <resource>
+ <!--config and resource files -->
+ <directory>${basedir}/src/main/resources</directory>
+ <targetPath>${basedir}/target/src/main/resources</targetPath>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <execution>
+ <id>copy-dockerfile</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals><!-- here the phase you need -->
+ <phase>validate</phase>
+ <configuration>
+ <outputDirectory>${basedir}/target/docker-stage</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/docker</directory>
+ <includes>
+ <include>*</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>ant-test</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <fixcrlf srcdir="${basedir}" eol="unix" includes="**/*.sh, **/*.source"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <!-- <skip>${skip.compile}</skip>-->
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/ms/blueprintsprocessor/application/src/main/resources/application-dev.properties b/ms/blueprintsprocessor/application/src/main/resources/application-dev.properties
new file mode 100755
index 00000000..6bfa2407
--- /dev/null
+++ b/ms/blueprintsprocessor/application/src/main/resources/application-dev.properties
@@ -0,0 +1,36 @@
+#
+# Copyright � 2017-2018 AT&T Intellectual Property.
+# Modifications Copyright © 2019 IBM, 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.
+#
+#logging.level.web=DEBUG
+
+# Web server config
+server.port=8080
+
+blueprintsprocessor.grpcEnable=false
+blueprintsprocessor.httpPort=8080
+blueprintsprocessor.grpcPort=9111
+# Blueprint Processor File Execution and Handling Properties
+blueprintsprocessor.blueprintDeployPath=/opt/app/onap/blueprints/deploy
+blueprintsprocessor.blueprintArchivePath=/opt/app/onap/blueprints/archive
+# Primary Database Configuration
+blueprintsprocessor.db.primary.url=jdbc:mysql://localhost:3306/sdnctl
+blueprintsprocessor.db.primary.username=sdnctl
+blueprintsprocessor.db.primary.password=sdnctl
+blueprintsprocessor.db.primary.driverClassName=org.mariadb.jdbc.Driver
+blueprintsprocessor.db.primary.hibernateHbm2ddlAuto=update
+blueprintsprocessor.db.primary.hibernateDDLAuto=none
+blueprintsprocessor.db.primary.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy
+blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.MySQL5InnoDBDialect \ No newline at end of file
diff --git a/ms/blueprintsprocessor/application/src/main/resources/application.properties b/ms/blueprintsprocessor/application/src/main/resources/application.properties
index fa1a1e6e..62695207 100644..100755
--- a/ms/blueprintsprocessor/application/src/main/resources/application.properties
+++ b/ms/blueprintsprocessor/application/src/main/resources/application.properties
@@ -1,5 +1,6 @@
#
# Copyright � 2017-2018 AT&T Intellectual Property.
+# Modifications Copyright © 2019 IBM, Bell Canada.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -14,6 +15,10 @@
# limitations under the License.
#
#logging.level.web=DEBUG
+
+# Web server config
+server.port=8080
+
blueprintsprocessor.grpcEnable=false
blueprintsprocessor.httpPort=8080
blueprintsprocessor.grpcPort=9111
@@ -21,7 +26,7 @@ blueprintsprocessor.grpcPort=9111
blueprintsprocessor.blueprintDeployPath=/opt/app/onap/blueprints/deploy
blueprintsprocessor.blueprintArchivePath=/opt/app/onap/blueprints/archive
# Primary Database Configuration
-blueprintsprocessor.db.primary.url=jdbc:mysql://localhost:3306/sdnctl
+blueprintsprocessor.db.primary.url=jdbc:mysql://db:3306/sdnctl
blueprintsprocessor.db.primary.username=sdnctl
blueprintsprocessor.db.primary.password=sdnctl
blueprintsprocessor.db.primary.driverClassName=org.mariadb.jdbc.Driver
diff --git a/ms/blueprintsprocessor/application/src/test/resources/application.properties b/ms/blueprintsprocessor/application/src/test/resources/application.properties
index f896ee05..d21264c0 100644
--- a/ms/blueprintsprocessor/application/src/test/resources/application.properties
+++ b/ms/blueprintsprocessor/application/src/test/resources/application.properties
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+# Web server config
+server.port=8080
# Blueprint Processor File Execution and Handling Properties
blueprintsprocessor.blueprintDeployPath=/opt/app/onap/blueprints/deploy
blueprintsprocessor.blueprintArchivePath=/opt/app/onap/blueprints/archive
diff --git a/ms/blueprintsprocessor/distribution/pom.xml b/ms/blueprintsprocessor/distribution/pom.xml
new file mode 100755
index 00000000..fb5e3c12
--- /dev/null
+++ b/ms/blueprintsprocessor/distribution/pom.xml
@@ -0,0 +1,196 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright © 2019 IBM, 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>parent</artifactId>
+ <version>0.4.1-SNAPSHOT</version>
+ <relativePath>../parent</relativePath>
+ </parent>
+ <artifactId>distribution</artifactId>
+ <packaging>pom</packaging>
+ <name>Blueprints Processor Distribution</name>
+ <properties>
+ <assembly.id>maven</assembly.id>
+ <name.space>org.onap.ccsdk.apps</name.space> <!-- <name.space>${namespace}</name.space> -->
+ <serviceArtifactName>blueprintsprocessor</serviceArtifactName>
+ <image.name>onap/ccsdk-blueprintsprocessor</image.name>
+ <docker.buildArg.https_proxy>${https_proxy}</docker.buildArg.https_proxy>
+ <docker.push.phase>deploy</docker.push.phase>
+ <docker.verbose>true</docker.verbose>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>application</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <execution>
+ <id>copy-dockerfile</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals><!-- here the phase you need -->
+ <phase>validate</phase>
+ <configuration>
+ <outputDirectory>${basedir}/target/docker-stage</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/docker</directory>
+ <includes>
+ <include>*</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>ant-test</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <fixcrlf srcdir="${basedir}" eol="unix" includes="**/*.sh, **/*.source"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <!--build the final artifact for docker deployment -->
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>3.1.0</version>
+ <configuration>
+ <!-- <skipAssembly>${skip.assembly}</skipAssembly>-->
+ <outputDirectory>${basedir}/target/docker-stage</outputDirectory>
+ <descriptors>
+ <descriptor>src/main/docker/distribution.xml</descriptor>
+ </descriptors>
+ <tarLongFileMode>posix</tarLongFileMode>
+ </configuration>
+ <executions>
+ <execution>
+ <id>${assembly.id}</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.groovy.maven</groupId>
+ <artifactId>gmaven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <source>
+ println project.properties['ccsdk.project.version']
+ def versionArray
+ if (project.properties['ccsdk.project.version'] != null ) {
+ versionArray = project.properties['ccsdk.project.version'].split('\\.')
+ }
+
+ if (project.properties['ccsdk.project.version'].endsWith("-SNAPSHOT"))
+ {
+ project.properties['project.docker.latesttag.version']=versionArray[0] + '.' + versionArray[1] + "-STAGING-latest"
+ } else {
+ project.properties['project.docker.latesttag.version']=versionArray[0]+'.' + versionArray[1]+"-STAGING-latest"
+ }
+
+ println 'New Tag for docker:' + project.properties['project.docker.latesttag.version']
+ </source>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>docker</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.fabric8</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <version>0.26.1</version>
+ <inherited>false</inherited>
+ <configuration>
+ <images>
+ <image>
+ <name>${image.name}</name>
+ <build>
+ <cleanup>try</cleanup>
+ <dockerFileDir>${basedir}/target/docker-stage</dockerFileDir>
+ <tags>
+ <tag>${project.version}</tag>
+ <tag>${project.version}-STAGING-${maven.build.timestamp}</tag>
+ <tag>${project.docker.latesttag.version}</tag>
+ </tags>
+ </build>
+ </image>
+ </images>
+ <verbose>true</verbose>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate-images</id>
+ <phase>package</phase>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>push-images</id>
+ <phase>${docker.push.phase}</phase>
+ <goals>
+ <goal>build</goal>
+ <goal>push</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ </profiles>
+</project> \ No newline at end of file
diff --git a/ms/blueprintsprocessor/distribution/src/main/dc/docker-compose.yaml b/ms/blueprintsprocessor/distribution/src/main/dc/docker-compose.yaml
new file mode 100755
index 00000000..c0eade50
--- /dev/null
+++ b/ms/blueprintsprocessor/distribution/src/main/dc/docker-compose.yaml
@@ -0,0 +1,33 @@
+version: '3.3'
+
+services:
+ db:
+ image: mariadb:latest
+ container_name: ccsdk-mariadb
+ ports:
+ - "3306:3306"
+ volumes:
+ - ~/vm_mysql:/var/lib/mysql
+ restart: always
+ environment:
+ MYSQL_ROOT_PASSWORD: sdnctl
+ MYSQL_DATABASE: sdnctl
+ MYSQL_USER: sdnctl
+ MYSQL_PASSWORD: sdnctl
+ blueprints-processor:
+ depends_on:
+ - db
+ image: onap/ccsdk-blueprintsprocessor:latest
+ container_name: bp-rest
+ ports:
+ - "8000:8080"
+ restart: always
+ volumes:
+ - ~/share/vm_ms/blueprintsprocessor/config:/opt/app/onap/config
+ - ~/share/vm_ms/blueprintsprocessor/logs:/logs
+ environment:
+ APPLICATIONNAME: BlueprintsProcessor
+ BUNDLEVERSION: 1.0.0
+ APP_CONFIG_HOME: /opt/app/onap/config
+ STICKYSELECTORKEY:
+ ENVCONTEXT: dev \ No newline at end of file
diff --git a/ms/blueprintsprocessor/distribution/src/main/docker/Dockerfile b/ms/blueprintsprocessor/distribution/src/main/docker/Dockerfile
new file mode 100755
index 00000000..21362329
--- /dev/null
+++ b/ms/blueprintsprocessor/distribution/src/main/docker/Dockerfile
@@ -0,0 +1,20 @@
+FROM anapsix/alpine-java:8_jdk
+
+ENV HTTP_PROXY ${HTTP_PROXY}
+ENV HTTPS_PROXY ${HTTPS_PROXY}
+
+RUN apk add --no-cache curl
+
+COPY startService.sh /startService.sh
+RUN chmod 777 /startService.sh && dos2unix /startService.sh
+
+COPY @project.build.finalName@-@assembly.id@.tar.gz /source.tar.gz
+
+RUN (mkdir -p /source /opt/app/onap) && (tar -xzf /source.tar.gz -C /source) \
+&& (mv /source/@project.build.finalName@ /source/app) \
+&& (cp -rf /source/app/opt/app/onap/lib /opt/app/onap/) \
+&& (cp -rf /source/app/etc /) \
+&& (cp -rf /source/app/config /) \
+&& (rm -rf /source)
+
+ENTRYPOINT /startService.sh \ No newline at end of file
diff --git a/ms/blueprintsprocessor/distribution/src/main/docker/distribution.xml b/ms/blueprintsprocessor/distribution/src/main/docker/distribution.xml
new file mode 100755
index 00000000..b538b73b
--- /dev/null
+++ b/ms/blueprintsprocessor/distribution/src/main/docker/distribution.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright © 2018-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.
+ -->
+
+<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
+ <!-- create a tar.gz file containing the projects dependencies -->
+ <id>${assembly.id}</id>
+ <formats>
+ <format>tar.gz</format>
+ </formats>
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>/opt/app/onap/lib</outputDirectory>
+ <outputFileNameMapping>${artifact.groupId}-${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
+ <excludes>
+ </excludes>
+ </dependencySet>
+ </dependencySets>
+ <fileSets>
+ <fileSet>
+ <directory>${project.basedir}/../application/src/main/resources</directory>
+ <includes>
+ <include>application.properties</include>
+ <include>logback.xml</include>
+ </includes>
+ <outputDirectory>./</outputDirectory>
+ <useDefaultExcludes>true</useDefaultExcludes>
+ </fileSet>
+ <fileSet>
+ <directory>${project.basedir}/src/main/docker</directory>
+ <includes>
+ <include>Dockerfile</include>
+ <include>startService.sh</include>
+ </includes>
+ <outputDirectory>./</outputDirectory>
+ <useDefaultExcludes>true</useDefaultExcludes>
+ </fileSet>
+ <fileSet>
+ <directory>${project.basedir}/../application/src/main/resources</directory>
+ <outputDirectory>src/main/resources</outputDirectory>
+ <useDefaultExcludes>true</useDefaultExcludes>
+ </fileSet>
+ <fileSet>
+ <directory>${project.basedir}/../application/opt/app/onap/config</directory>
+ <outputDirectory>./config</outputDirectory>
+ <useDefaultExcludes>true</useDefaultExcludes>
+ </fileSet>
+ <fileSet>
+ <directory>${project.basedir}/../application/etc</directory>
+ <outputDirectory>./etc</outputDirectory>
+ <useDefaultExcludes>true</useDefaultExcludes>
+ </fileSet>
+ </fileSets>
+</assembly> \ No newline at end of file
diff --git a/ms/blueprintsprocessor/distribution/src/main/docker/startService.sh b/ms/blueprintsprocessor/distribution/src/main/docker/startService.sh
new file mode 100755
index 00000000..79bcbc06
--- /dev/null
+++ b/ms/blueprintsprocessor/distribution/src/main/docker/startService.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+nodeName=BlueprintsProcessor_1.0.0_$(cat /proc/self/cgroup | grep docker | sed s/\\//\\n/g | tail -1)
+
+echo "APP Config HOME : ${APP_CONFIG_HOME}"
+export APP_HOME=/opt/app/onap
+
+cp -rf /config /opt/app/onap/
+source /etc/run.source
diff --git a/ms/blueprintsprocessor/functions/pom.xml b/ms/blueprintsprocessor/functions/pom.xml
index 2a952f88..2a952f88 100644..100755
--- a/ms/blueprintsprocessor/functions/pom.xml
+++ b/ms/blueprintsprocessor/functions/pom.xml
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt
index 7684b2b0..83cf59c2 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt
@@ -27,6 +27,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
@@ -44,6 +45,7 @@ class ComponentJythonExecutorTest {
@Test
fun testPythonComponentInjection() {
+ /*
val executionServiceInput = ExecutionServiceInput()
executionServiceInput.payload = JsonNodeFactory.instance.objectNode()
@@ -57,8 +59,12 @@ class ComponentJythonExecutorTest {
actionIdentifiers.actionName = "activate"
executionServiceInput.actionIdentifiers = actionIdentifiers
+ */
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(commonHeader.requestId,
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-activate-request.json",
+ ExecutionServiceInput::class.java)!!
+
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
"./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/resources/requests/sample-activate-request.json b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/payload/requests/sample-activate-request.json
index 7142f045..7142f045 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/test/resources/requests/sample-activate-request.json
+++ b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/payload/requests/sample-activate-request.json
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt
index 1c5455fd..e389f362 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt
@@ -17,24 +17,50 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
+import com.fasterxml.jackson.databind.node.NullNode
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
/**
* DefaultResourceAssignmentProcessor
*
- * @author Brinda Santh
+ * @author Kapil Singal
*/
@Service("resource-assignment-processor-default")
open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+ private val logger = LoggerFactory.getLogger(DefaultResourceAssignmentProcessor::class.java)
+
override fun getName(): String {
return "resource-assignment-processor-default"
}
- override fun process(executionRequest: ResourceAssignment) {
+ override fun process(resourceAssignment: ResourceAssignment) {
+ try {
+ // Check if It has Input
+ var value: Any? = raRuntimeService.getInputValue(resourceAssignment.name)
+
+ // If value is null get it from default source
+ if (value == null || value is NullNode) {
+ logger.info("Looking for defaultValue as couldn't find value in input For template key (${resourceAssignment.name})")
+ value = resourceAssignment.property?.defaultValue
+ }
+
+ logger.info("For template key (${resourceAssignment.name}) setting value as ($value)")
+ ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
+
+ // Check the value has populated for mandatory case
+ ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment)
+ } catch (e: Exception) {
+ ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message)
+ throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}", e)
+ }
+
}
- override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
+ override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) {
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt
index 2b3270e6..94271830 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt
@@ -33,7 +33,7 @@ import java.util.*
/**
* PrimaryDataResourceAssignmentProcessor
*
- * @author Brinda Santh
+ * @author Kapil Singal
*/
@Service("resource-assignment-processor-primary-db")
open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGenericService: PrimaryDBLibGenericService)
@@ -54,27 +54,27 @@ open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGeneri
if (value != null && value !is NullNode) {
logger.info("primary-db source template key (${resourceAssignment.name}) found from input and value is ($value)")
ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
- return
- }
-
- val dName = resourceAssignment.dictionaryName
- val dSource = resourceAssignment.dictionarySource
- val resourceDefinition = resourceDictionaries[dName]
- ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dName")
- val resourceSource = resourceDefinition.sources[dSource]
- ?: throw BluePrintProcessorException("couldn't get resource definition $dName source($dSource)")
- val resourceSourceProperties = checkNotNull(resourceSource.properties) { "failed to get source properties for $dName " }
- val sourceProperties = JacksonUtils.getInstanceFromMap(resourceSourceProperties, DatabaseResourceSource::class.java)
- val sql = checkNotNull(sourceProperties.query) { "failed to get request query for $dName under $dSource properties" }
- val inputKeyMapping = checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
-
- logger.info("$dSource dictionary information : ($sql), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})")
-
- val rows = primaryDBLibGenericService.query(sql, populateNamedParameter(inputKeyMapping))
- if (rows.isNullOrEmpty()) {
- logger.warn("Failed to get $dSource result for dictionary name ($dName) the query ($sql)")
} else {
- processDBResults(resourceAssignment, sourceProperties, rows)
+ val dName = resourceAssignment.dictionaryName
+ val dSource = resourceAssignment.dictionarySource
+ val resourceDefinition = resourceDictionaries[dName]
+ ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dName")
+ val resourceSource = resourceDefinition.sources[dSource]
+ ?: throw BluePrintProcessorException("couldn't get resource definition $dName source($dSource)")
+ val resourceSourceProperties = checkNotNull(resourceSource.properties) { "failed to get source properties for $dName " }
+ val sourceProperties = JacksonUtils.getInstanceFromMap(resourceSourceProperties, DatabaseResourceSource::class.java)
+
+ val sql = checkNotNull(sourceProperties.query) { "failed to get request query for $dName under $dSource properties" }
+ val inputKeyMapping = checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
+
+ logger.info("$dSource dictionary information : ($sql), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})")
+
+ val rows = primaryDBLibGenericService.query(sql, populateNamedParameter(inputKeyMapping))
+ if (rows.isNullOrEmpty()) {
+ logger.warn("Failed to get $dSource result for dictionary name ($dName) the query ($sql)")
+ } else {
+ populateResource(resourceAssignment, sourceProperties, rows)
+ }
}
// Check the value has populated for mandatory case
@@ -106,7 +106,7 @@ open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGeneri
}
@Throws(BluePrintProcessorException::class)
- private fun processDBResults(resourceAssignment: ResourceAssignment, sourceProperties: DatabaseResourceSource, rows: List<Map<String, Any>>) {
+ private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: DatabaseResourceSource, rows: List<Map<String, Any>>) {
val dName = resourceAssignment.dictionaryName
val dSource = resourceAssignment.dictionarySource
val type = nullToEmpty(resourceAssignment.property?.type)
@@ -115,21 +115,17 @@ open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGeneri
logger.info("Response processing type($type)")
// Primitive Types
- if (BluePrintTypes.validPrimitiveTypes().contains(type)) {
- val dbColumnValue = rows[0][outputKeyMapping[dName]]
- ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, dbColumnValue)
- }
- // Array Types
- else if (BluePrintTypes.validCollectionTypes().contains(type)) {
- lateinit var entrySchemaType: String
- if (resourceAssignment.property?.entrySchema != null) {
- entrySchemaType = nullToEmpty(resourceAssignment.property?.entrySchema?.type)
+ when(type) {
+ in BluePrintTypes.validPrimitiveTypes() -> {
+ val dbColumnValue = rows[0][outputKeyMapping[dName]]
+ logger.info("For template key (${resourceAssignment.name}) setting value as ($dbColumnValue)")
+ ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, dbColumnValue)
}
-
- if (checkNotEmptyOrThrow(entrySchemaType, "Entry schema is not defined for dictionary ($dName) info")) {
- val arrayNode = JsonNodeFactory.instance.arrayNode()
+ in BluePrintTypes.validCollectionTypes() -> {
+ val entrySchemaType = returnNotEmptyOrThrow(resourceAssignment.property?.entrySchema?.type) { "Entry schema is not defined for dictionary ($dName) info" }
+ var arrayNode = JsonNodeFactory.instance.arrayNode()
rows.forEach {
- if (BluePrintTypes.validPrimitiveTypes().contains(entrySchemaType)) {
+ if (entrySchemaType in BluePrintTypes.validPrimitiveTypes()) {
val dbColumnValue = it[outputKeyMapping[dName]]
// Add Array JSON
JacksonUtils.populatePrimitiveValues(dbColumnValue!!, entrySchemaType, arrayNode)
@@ -143,19 +139,22 @@ open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGeneri
arrayNode.add(arrayChildNode)
}
}
+ logger.info("For template key (${resourceAssignment.name}) setting value as ($arrayNode)")
// Set the List of Complex Values
ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, arrayNode)
}
- } else {
- // Complex Types
- val row = rows[0]
- val objectNode = JsonNodeFactory.instance.objectNode()
- for (mapping in outputKeyMapping.entries) {
- val dbColumnValue = checkNotNull(row[mapping.key])
- val propertyTypeForDataType = ResourceAssignmentUtils.getPropertyType(raRuntimeService, type, mapping.key)
- JacksonUtils.populatePrimitiveValues(mapping.key, dbColumnValue, propertyTypeForDataType, objectNode)
+ else -> {
+ // Complex Types
+ val row = rows[0]
+ var objectNode = JsonNodeFactory.instance.objectNode()
+ for (mapping in outputKeyMapping.entries) {
+ val dbColumnValue = checkNotNull(row[mapping.key])
+ val propertyTypeForDataType = ResourceAssignmentUtils.getPropertyType(raRuntimeService, type, mapping.key)
+ JacksonUtils.populatePrimitiveValues(mapping.key, dbColumnValue, propertyTypeForDataType, objectNode)
+ }
+ logger.info("For template key (${resourceAssignment.name}) setting value as ($objectNode)")
+ ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, objectNode)
}
- ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, objectNode)
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt
index e05261d8..f1a4dbb0 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt
@@ -17,24 +17,146 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
+import com.fasterxml.jackson.databind.node.ArrayNode
+import com.fasterxml.jackson.databind.node.JsonNodeFactory
+import com.fasterxml.jackson.databind.node.NullNode
+import com.fasterxml.jackson.databind.node.ObjectNode
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.RestResourceSource
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
+import org.onap.ccsdk.apps.controllerblueprints.core.*
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
+import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
/**
* SimpleRestResourceAssignmentProcessor
*
- * @author Brinda Santh
+ * @author Kapil Singal
*/
-@Service("resource-assignment-processor-mdsal")
-open class SimpleRestResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+@Service("resource-assignment-processor-primary-config-data")
+open class SimpleRestResourceAssignmentProcessor(private val blueprintRestLibPropertyService: BluePrintRestLibPropertyService)
+ : ResourceAssignmentProcessor() {
+
+ private val logger = LoggerFactory.getLogger(SimpleRestResourceAssignmentProcessor::class.java)
override fun getName(): String {
- return "resource-assignment-processor-mdsal"
+ return "resource-assignment-processor-primary-config-data"
}
- override fun process(executionRequest: ResourceAssignment) {
+ override fun process(resourceAssignment: ResourceAssignment) {
+ try {
+ validate(resourceAssignment)
+
+ // Check if It has Input
+ val value = raRuntimeService.getInputValue(resourceAssignment.name)
+ if (value != null && value !is NullNode) {
+ logger.info("primary-db source template key (${resourceAssignment.name}) found from input and value is ($value)")
+ ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
+ } else {
+ val dName = resourceAssignment.dictionaryName
+ val dSource = resourceAssignment.dictionarySource
+ val resourceDefinition = resourceDictionaries[dName]
+ ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dName")
+ val resourceSource = resourceDefinition.sources[dSource]
+ ?: throw BluePrintProcessorException("couldn't get resource definition $dName source($dSource)")
+ val resourceSourceProperties = checkNotNull(resourceSource.properties) { "failed to get source properties for $dName " }
+ val sourceProperties = JacksonUtils.getInstanceFromMap(resourceSourceProperties, RestResourceSource::class.java)
+
+ val urlPath = checkNotNull(sourceProperties.urlPath) { "failed to get request urlPath for $dName under $dSource properties" }
+ val path = nullToEmpty(sourceProperties.path)
+ val inputKeyMapping = checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
+
+ logger.info("$dSource dictionary information : ($urlPath), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})")
+
+ val restClientService = blueprintRestLibPropertyService.blueprintWebClientService("primary-config-data")
+ val response = restClientService.getResource(urlPath, String::class.java)
+ if (response.isNotBlank()) {
+ logger.warn("Failed to get $dSource result for dictionary name ($dName) using urlPath ($urlPath)")
+ } else {
+ populateResource(resourceAssignment, sourceProperties, response, path)
+ }
+ }
+ // Check the value has populated for mandatory case
+ ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment)
+ } catch (e: Exception) {
+ ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message)
+ throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}", e)
+ }
}
- override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
+ @Throws(BluePrintProcessorException::class)
+ private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: RestResourceSource, restResponse: String, path: String) {
+ val dName = resourceAssignment.dictionaryName
+ val dSource = resourceAssignment.dictionarySource
+ val type = nullToEmpty(resourceAssignment.property?.type)
+ lateinit var entrySchemaType: String
+
+ val outputKeyMapping = checkNotNull(sourceProperties.outputKeyMapping) { "failed to get output-key-mappings for $dName under $dSource properties" }
+ logger.info("Response processing type($type)")
+
+ val responseNode = checkNotNull(JacksonUtils.jsonNode(restResponse).at(path)) { "Failed to find path ($path) in response ($restResponse)" }
+ logger.info("populating value for output mapping ($outputKeyMapping), from json ($responseNode)")
+
+
+ when (type) {
+ in BluePrintTypes.validPrimitiveTypes() -> {
+ logger.info("For template key (${resourceAssignment.name}) setting value as ($responseNode)")
+ ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, responseNode)
+ }
+ in BluePrintTypes.validCollectionTypes() -> {
+ // Array Types
+ entrySchemaType = returnNotEmptyOrThrow(resourceAssignment.property?.entrySchema?.type) { "Entry schema is not defined for dictionary ($dName) info" }
+ val arrayNode = responseNode as ArrayNode
+
+ if (entrySchemaType !in BluePrintTypes.validPrimitiveTypes()) {
+ val responseArrayNode = responseNode.toList()
+ for (responseSingleJsonNode in responseArrayNode) {
+ val arrayChildNode = JsonNodeFactory.instance.objectNode()
+ outputKeyMapping.map {
+ val responseKeyValue = responseSingleJsonNode.get(it.key)
+ val propertyTypeForDataType = ResourceAssignmentUtils.getPropertyType(raRuntimeService, entrySchemaType, it.key)
+ logger.info("For List Type Resource: key (${it.key}), value ($responseKeyValue), type ({$propertyTypeForDataType})")
+ JacksonUtils.populateJsonNodeValues(it.value, responseKeyValue, propertyTypeForDataType, arrayChildNode)
+ }
+ arrayNode.add(arrayChildNode)
+ }
+ }
+ logger.info("For template key (${resourceAssignment.name}) setting value as ($arrayNode)")
+ // Set the List of Complex Values
+ ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, arrayNode)
+ }
+ else -> {
+ // Complex Types
+ val objectNode = responseNode as ObjectNode
+ outputKeyMapping.map {
+ val responseKeyValue = responseNode.get(it.key)
+ val propertyTypeForDataType = ResourceAssignmentUtils.getPropertyType(raRuntimeService, entrySchemaType, it.key)
+ logger.info("For List Type Resource: key (${it.key}), value ($responseKeyValue), type ({$propertyTypeForDataType})")
+ JacksonUtils.populateJsonNodeValues(it.value, responseKeyValue, propertyTypeForDataType, objectNode)
+ }
+
+ logger.info("For template key (${resourceAssignment.name}) setting value as ($objectNode)")
+ // Set the List of Complex Values
+ ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, objectNode)
+ }
+ }
+ }
+
+ @Throws(BluePrintProcessorException::class)
+ private fun validate(resourceAssignment: ResourceAssignment) {
+ checkNotEmptyOrThrow(resourceAssignment.name, "resource assignment template key is not defined")
+ checkNotEmptyOrThrow(resourceAssignment.dictionaryName, "resource assignment dictionary name is not defined for template key (${resourceAssignment.name})")
+ checkEqualsOrThrow(ResourceDictionaryConstants.SOURCE_PRIMARY_CONFIG_DATA, resourceAssignment.dictionarySource) {
+ "resource assignment source is not ${ResourceDictionaryConstants.SOURCE_PRIMARY_CONFIG_DATA} but it is ${resourceAssignment.dictionarySource}"
+ }
+ checkNotEmptyOrThrow(resourceAssignment.dictionaryName, "resource assignment dictionary name is not defined for template key (${resourceAssignment.name})")
}
+
+ override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) {
+ }
+
+
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
index 9a846d69..ef69eb51 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
@@ -65,7 +65,7 @@ class ResourceResolutionServiceTest {
fun testRegisteredSource() {
val sources = resourceResolutionService.registeredResourceSources()
assertNotNull(sources, "failed to get registered sources")
- assertTrue(sources.containsAll(arrayListOf("input", "default", "primary-db", "mdsal")), "failed to get registered sources")
+ assertTrue(sources.containsAll(arrayListOf("input", "default", "primary-db", "primary-config-data")), "failed to get registered sources")
}
@Test
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
index 438e755c..41bbd1df 100644
--- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
+++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
@@ -95,3 +95,29 @@ open class Status {
@get:ApiModelProperty(required = true)
var message: String = "success"
}
+
+open class BluePrintManagementInput {
+ @get:ApiModelProperty(required = true)
+ lateinit var commonHeader: CommonHeader
+ @get:ApiModelProperty(required = false)
+ lateinit var blueprintName: String
+ @get:ApiModelProperty(required = false)
+ lateinit var blueprintVersion: String
+ @get:ApiModelProperty(required = true)
+ lateinit var fileChunk: FileChunk
+}
+
+open class FileChunk {
+ @get:ApiModelProperty(required = true)
+ lateinit var chunk: ByteArray
+}
+
+open class BluePrintManagementOutput {
+ @get:ApiModelProperty(required = true)
+ lateinit var commonHeader: CommonHeader
+ @get:ApiModelProperty(required = true)
+ var status: Status = Status()
+}
+
+
+
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml
index 53c9b185..590c87f0 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml
@@ -30,6 +30,10 @@
<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>
<version>${project.version}</version>
</dependency>
diff --git a/ms/blueprintsprocessor/modules/commons/pom.xml b/ms/blueprintsprocessor/modules/commons/pom.xml
index 4df89857..8d900a89 100644..100755
--- a/ms/blueprintsprocessor/modules/commons/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/pom.xml
@@ -2,6 +2,8 @@
<!--
~ 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
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
index 82e8cd73..773746b4 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
@@ -28,6 +28,10 @@
<description>Blueprints Processor Rest Lib</description>
<dependencies>
<dependency>
+ <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+ <artifactId>core</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
<artifactId>core</artifactId>
</dependency>
diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml
index 6395963b..dcf42c20 100644
--- a/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml
@@ -15,16 +15,16 @@
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
- <artifactId>inbounds</artifactId>
- <version>0.4.1-SNAPSHOT</version>
- </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>inbounds</artifactId>
+ <version>0.4.1-SNAPSHOT</version>
+ </parent>
- <artifactId>resource-api</artifactId>
- <packaging>jar</packaging>
- <name>Blueprints Processor Resource API</name>
- <description>Blueprints Processor Resource API</description>
+ <artifactId>resource-api</artifactId>
+ <packaging>jar</packaging>
+ <name>Blueprints Processor Resource API</name>
+ <description>Blueprints Processor Resource API</description>
</project>
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
index c510734d..818adf9d 100644..100755
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
@@ -2,6 +2,8 @@
<!--
~ 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
@@ -30,11 +32,16 @@
<dependencies>
<dependency>
- <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+ <groupId>org.onap.ccsdk.apps.components</groupId>
<artifactId>proto-definition</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+ <version>${project.version}</version>
+ <artifactId>core</artifactId>
+ </dependency>
+ <dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-testing</artifactId>
</dependency>
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt
index aa01f220..fb0bc567 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt
@@ -19,15 +19,14 @@ package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
import io.grpc.StatusException
import io.grpc.stub.StreamObserver
-import org.apache.commons.io.FileUtils
import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils.currentTimestamp
+import org.onap.ccsdk.apps.controllerblueprints.common.api.CommonHeader
+import org.onap.ccsdk.apps.controllerblueprints.common.api.Status
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintCatalogService
import org.onap.ccsdk.apps.controllerblueprints.management.api.BluePrintManagementInput
import org.onap.ccsdk.apps.controllerblueprints.management.api.BluePrintManagementOutput
import org.onap.ccsdk.apps.controllerblueprints.management.api.BluePrintManagementServiceGrpc
-import org.onap.ccsdk.apps.controllerblueprints.management.api.CommonHeader
-import org.onap.ccsdk.apps.controllerblueprints.management.api.Status
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
import java.io.File
@@ -79,15 +78,18 @@ class BluePrintManagementGRPCHandler(private val bluePrintCoreConfiguration: Blu
}
private fun saveToDisk(request: BluePrintManagementInput, blueprintDir: File) {
- log.debug("request(${request.commonHeader.requestId}): Writing CBA File under :${blueprintDir.absolutePath}")
+ log.info("request(${request.commonHeader.requestId}): Writing CBA File under :${blueprintDir.absolutePath}")
if (blueprintDir.exists()) {
- log.debug("request(${request.commonHeader.requestId}): Re-creating blueprint directory(${blueprintDir.absolutePath})")
- FileUtils.deleteDirectory(blueprintDir.parentFile)
+ log.info("request(${request.commonHeader.requestId}): Re-creating blueprint directory(${blueprintDir.absolutePath})")
+ //FileUtils.deleteDirectory(blueprintDir.parentFile)
+ blueprintDir.parentFile.deleteRecursively()
}
- FileUtils.forceMkdir(blueprintDir.parentFile)
+ blueprintDir.parentFile.mkdirs()
+ //FileUtils.forceMkdir(blueprintDir.parentFile)
blueprintDir.writeBytes(request.fileChunk.chunk.toByteArray()).apply {
- log.debug("request(${request.commonHeader.requestId}): CBA file(${blueprintDir.absolutePath} written successfully")
+ log.info("request(${request.commonHeader.requestId}): CBA file(${blueprintDir.absolutePath} written successfully")
}
+
}
private fun successStatus(message: String, header: CommonHeader): BluePrintManagementOutput =
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt
index 4ca0cfa9..453306de 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt
@@ -18,6 +18,8 @@ package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
import io.grpc.stub.StreamObserver
import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils.toJava
+import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils.toProto
import org.onap.ccsdk.apps.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc
import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput
import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput
@@ -30,27 +32,29 @@ class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration: Blu
: BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() {
private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandler::class.java)
-
override fun process(responseObserver: StreamObserver<ExecutionServiceOutput>?): StreamObserver<ExecutionServiceInput> {
return object : StreamObserver<ExecutionServiceInput> {
-
override fun onNext(executionServiceInput: ExecutionServiceInput) {
- TODO("Handle Processing Response")
-// executionServiceHandler.process(executionServiceInput)
-// responseObserver.onNext(executionServiceOuput)
+ try {
+ val output = executionServiceHandler.process(executionServiceInput.toJava())
+ .toProto(executionServiceInput.payload)
+ responseObserver?.onNext(output)
+ } catch (e: Exception) {
+ onError(e)
+ }
}
override fun onError(error: Throwable) {
- log.warn("Fail to process message", error)
+ log.debug("Fail to process message", error)
+ responseObserver?.onError(io.grpc.Status.INTERNAL
+ .withDescription(error.message)
+ .asException())
}
override fun onCompleted() {
responseObserver?.onCompleted()
}
}
-
}
-
-
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
index 0b361d8a..ec605c1d 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
@@ -66,11 +66,11 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC
response(executionServiceInput)
}
executionServiceInput.actionIdentifiers.mode == ACTION_MODE_SYNC -> doProcess(executionServiceInput)
- else -> response(executionServiceInput, true)
+ else -> response(executionServiceInput, "Failed to process request, 'actionIdentifiers.mode' not specified. Valid value are: 'sync' or 'async'.", true)
}
}
- fun doProcess(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
+ private fun doProcess(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
val requestId = executionServiceInput.commonHeader.requestId
log.info("processing request id $requestId")
@@ -87,13 +87,14 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC
return blueprintDGExecutionService.executeDirectedGraph(blueprintRuntimeService, executionServiceInput)
}
- fun response(executionServiceInput: ExecutionServiceInput, failure: Boolean = false): ExecutionServiceOutput {
+ fun response(executionServiceInput: ExecutionServiceInput, errorMessage: String = "", failure: Boolean = false): ExecutionServiceOutput {
val executionServiceOutput = ExecutionServiceOutput()
executionServiceOutput.commonHeader = executionServiceInput.commonHeader
executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers
executionServiceOutput.payload = executionServiceInput.payload
val status = Status()
+ status.errorMessage = errorMessage
if (failure) {
status.eventType = "EVENT-COMPONENT-FAILURE"
status.code = 500
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt
new file mode 100644
index 00000000..220a6fd6
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt
@@ -0,0 +1,168 @@
+/*
+ * 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.blueprintsprocessor.selfservice.api.utils
+
+import com.fasterxml.jackson.databind.node.JsonNodeFactory
+import com.fasterxml.jackson.databind.node.ObjectNode
+import com.google.common.base.Strings
+import com.google.protobuf.Struct
+import com.google.protobuf.Value
+import org.onap.ccsdk.apps.controllerblueprints.common.api.ActionIdentifiers
+import org.onap.ccsdk.apps.controllerblueprints.common.api.CommonHeader
+import org.onap.ccsdk.apps.controllerblueprints.common.api.Flag
+import org.onap.ccsdk.apps.controllerblueprints.common.api.Status
+import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput
+import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput
+import java.text.SimpleDateFormat
+import java.util.*
+
+private val formatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+
+// STRUCT
+
+fun Struct.toJava(): ObjectNode {
+ val objectNode = JsonNodeFactory.instance.objectNode()
+ return getNode(objectNode)
+}
+
+fun Struct.getNode(objectNode: ObjectNode): ObjectNode {
+ this.fieldsMap.forEach {
+ when (it.value.kindCase.name) {
+ "BOOL_VALUE" -> objectNode.put(it.key, it.value.boolValue)
+ "KIND_NOT_SET" -> objectNode.put(it.key, it.value.toByteArray())
+ "LIST_VALUE" -> {
+ val arrayNode = JsonNodeFactory.instance.arrayNode()
+ it.value.listValue.valuesList.forEach { arrayNode.addPOJO(it.getValue()) }
+ objectNode.put(it.key, arrayNode)
+ }
+ "NULL_VALUE" -> objectNode.put(it.key, JsonNodeFactory.instance.nullNode())
+ "NUMBER_VALUE" -> objectNode.put(it.key, it.value.numberValue)
+ "STRING_VALUE" -> objectNode.put(it.key, it.value.stringValue)
+ "STRUCT_VALUE" -> objectNode.put(it.key, it.value.structValue.getNode(JsonNodeFactory.instance.objectNode()))
+ }
+ }
+ return objectNode
+}
+
+fun Value.getValue(): Any {
+ return when (this.kindCase.name) {
+ "BOOL_VALUE" -> this.boolValue
+ "KIND_NOT_SET" -> this.toByteArray()
+ "LIST_VALUE" -> listOf(this.listValue.valuesList.forEach { it.getValue() })
+ "NULL_VALUE" -> JsonNodeFactory.instance.nullNode()
+ "NUMBER_VALUE" -> this.numberValue
+ "STRING_VALUE" -> this.stringValue
+ "STRUCT_VALUE" -> this.structValue.getNode(JsonNodeFactory.instance.objectNode())
+ else -> {
+ "undefined"
+ }
+ }
+}
+
+// ACTION IDENTIFIER
+
+fun org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ActionIdentifiers.toProto(): ActionIdentifiers {
+ val actionIdentifier = ActionIdentifiers.newBuilder()
+ actionIdentifier.actionName = this.actionName
+ actionIdentifier.blueprintName = this.blueprintName
+ actionIdentifier.blueprintVersion = this.blueprintVersion
+ actionIdentifier.mode = this.mode
+ return actionIdentifier.build()
+}
+
+fun ActionIdentifiers.toJava(): org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ActionIdentifiers {
+ val actionIdentifier = org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ActionIdentifiers()
+ actionIdentifier.actionName = this.actionName
+ actionIdentifier.blueprintName = this.blueprintName
+ actionIdentifier.blueprintVersion = this.blueprintVersion
+ actionIdentifier.mode = this.mode
+ return actionIdentifier
+}
+
+// COMMON HEADER
+
+fun org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.CommonHeader.toProto(): CommonHeader {
+ val commonHeader = CommonHeader.newBuilder()
+ commonHeader.originatorId = this.originatorId
+ commonHeader.requestId = this.requestId
+ commonHeader.subRequestId = this.subRequestId
+ commonHeader.timestamp = this.timestamp.toString()
+ commonHeader.flag = this.flags?.toProto()
+ return commonHeader.build()
+}
+
+fun CommonHeader.toJava(): org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.CommonHeader {
+ val commonHeader = org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.CommonHeader()
+ commonHeader.originatorId = this.originatorId
+ commonHeader.requestId = this.requestId
+ commonHeader.subRequestId = this.subRequestId
+ commonHeader.timestamp = if (!Strings.isNullOrEmpty(this.timestamp)) {
+ formatter.parse(this.timestamp)
+ } else {
+ Date()
+ }
+ commonHeader.flags = this.flag?.toJava()
+ return commonHeader
+}
+
+// FLAG
+
+fun org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Flags.toProto(): Flag {
+ val flag = Flag.newBuilder()
+ flag.isForce = this.isForce
+ flag.ttl = this.ttl
+ return flag.build()
+}
+
+fun Flag.toJava(): org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Flags {
+ val flag = org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Flags()
+ flag.isForce = this.isForce
+ flag.ttl = this.ttl
+ return flag
+}
+
+// STATUS
+
+fun org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status.toProto(): Status {
+ val status = Status.newBuilder()
+ status.code = this.code
+ status.errorMessage = this.errorMessage
+ status.message = this.message
+ status.timestamp = this.timestamp.toString()
+ status.eventType = this.eventType
+ return status.build()
+}
+
+// EXECUTION INPUT
+
+fun ExecutionServiceInput.toJava(): org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput {
+ val executionServiceInput = org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput()
+ executionServiceInput.actionIdentifiers = this.actionIdentifiers.toJava()
+ executionServiceInput.commonHeader = this.commonHeader.toJava()
+ executionServiceInput.payload = this.payload.toJava()
+ return executionServiceInput
+}
+
+// EXECUTION OUPUT
+
+fun org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput.toProto(payload: Struct): ExecutionServiceOutput {
+ val executionServiceOuput = ExecutionServiceOutput.newBuilder()
+ executionServiceOuput.actionIdentifiers = this.actionIdentifiers.toProto()
+ executionServiceOuput.commonHeader = this.commonHeader.toProto()
+ executionServiceOuput.status = this.status.toProto()
+ executionServiceOuput.payload = payload
+ return executionServiceOuput.build()
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandlerTest.kt
index a48e699c..264e2aea 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandlerTest.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandlerTest.kt
@@ -19,13 +19,12 @@ package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
import com.google.protobuf.ByteString
import io.grpc.testing.GrpcServerRule
-import org.apache.commons.io.FileUtils
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.controllerblueprints.common.api.CommonHeader
import org.onap.ccsdk.apps.controllerblueprints.management.api.BluePrintManagementInput
import org.onap.ccsdk.apps.controllerblueprints.management.api.BluePrintManagementServiceGrpc
-import org.onap.ccsdk.apps.controllerblueprints.management.api.CommonHeader
import org.onap.ccsdk.apps.controllerblueprints.management.api.FileChunk
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
@@ -34,7 +33,6 @@ import org.springframework.test.annotation.DirtiesContext
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
import java.io.File
-import java.nio.file.Paths
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.assertEquals
@@ -61,14 +59,19 @@ class BluePrintManagementGRPCHandlerTest {
@AfterTest
fun cleanDir() {
- FileUtils.deleteDirectory(File("./target/blueprints"))
+ //TODO It's giving fluctuating results, need to look for another way to cleanup
+ // works sometimes otherwise results IO Exception
+ // Most probably bufferReader stream is not getting closed when cleanDir is getting invoked
+ File("./target/blueprints").deleteRecursively()
}
@Test
fun `test upload blueprint`() {
val blockingStub = BluePrintManagementServiceGrpc.newBlockingStub(grpcServerRule.channel)
- val id = "123"
- val output = blockingStub.uploadBlueprint(createInputRequest(id))
+ val id = "123_upload"
+ val req = createInputRequest(id)
+ val output = blockingStub.uploadBlueprint(req)
+
assertEquals(200, output.status.code)
assertTrue(output.status.message.contains("Successfully uploaded blueprint sample:1.0.0 with id("))
assertEquals(id, output.commonHeader.requestId)
@@ -77,17 +80,24 @@ class BluePrintManagementGRPCHandlerTest {
@Test
fun `test delete blueprint`() {
val blockingStub = BluePrintManagementServiceGrpc.newBlockingStub(grpcServerRule.channel)
- val id = "123"
+ val id = "123_delete"
val req = createInputRequest(id)
- blockingStub.uploadBlueprint(req)
- blockingStub.removeBlueprint(req)
+
+ var output = blockingStub.uploadBlueprint(req)
+ assertEquals(200, output.status.code)
+ assertTrue(output.status.message.contains("Successfully uploaded blueprint sample:1.0.0 with id("))
+ assertEquals(id, output.commonHeader.requestId)
+
+ output = blockingStub.removeBlueprint(req)
+ assertEquals(200, output.status.code)
}
private fun createInputRequest(id: String): BluePrintManagementInput {
- val file = Paths.get("./src/test/resources/test-cba.zip").toFile()
+ val file = File("./src/test/resources/test-cba.zip")
assertTrue(file.exists(), "couldnt get file ${file.absolutePath}")
- val commonHeader = CommonHeader.newBuilder()
+ val commonHeader = CommonHeader
+ .newBuilder()
.setTimestamp("2012-04-23T18:25:43.511Z")
.setOriginatorId("System")
.setRequestId(id)
@@ -103,4 +113,4 @@ class BluePrintManagementGRPCHandlerTest {
.setFileChunk(fileChunk)
.build()
}
-} \ No newline at end of file
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt
index 280227d0..01984b21 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt
@@ -19,15 +19,20 @@ package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
import com.google.protobuf.util.JsonFormat
+import io.grpc.stub.StreamObserver
import io.grpc.testing.GrpcServerRule
+import org.junit.Assert
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.controllerblueprints.common.api.ActionIdentifiers
+import org.onap.ccsdk.apps.controllerblueprints.common.api.CommonHeader
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc
-import org.onap.ccsdk.apps.controllerblueprints.processing.api.CommonHeader
import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput
+import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput
+import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.context.annotation.ComponentScan
@@ -43,6 +48,7 @@ import kotlin.test.BeforeTest
@ComponentScan(basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor", "org.onap.ccsdk.apps.controllerblueprints"])
@TestPropertySource(locations = ["classpath:application-test.properties"])
class BluePrintProcessingGRPCHandlerTest {
+ private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandlerTest::class.java)
@get:Rule
val grpcServerRule = GrpcServerRule().directExecutor()
@@ -50,17 +56,35 @@ class BluePrintProcessingGRPCHandlerTest {
@Autowired
lateinit var bluePrintProcessingGRPCHandler: BluePrintProcessingGRPCHandler
+ lateinit var requestObs: StreamObserver<ExecutionServiceInput>
+
@BeforeTest
fun init() {
- // Create a server, add service, start, and register for automatic graceful shutdown.
grpcServerRule.serviceRegistry.addService(bluePrintProcessingGRPCHandler)
+
+ val blockingStub = BluePrintProcessingServiceGrpc.newStub(grpcServerRule.channel)
+
+ requestObs = blockingStub.process(object : StreamObserver<ExecutionServiceOutput> {
+ override fun onNext(executionServiceOuput: ExecutionServiceOutput) {
+ log.debug("onNext {}", executionServiceOuput)
+ if ("1234".equals(executionServiceOuput.commonHeader.requestId)) {
+ Assert.assertEquals("Failed to process request, \'actionIdentifiers.mode\' not specified. Valid value are: \'sync\' or \'async\'.", executionServiceOuput.status.errorMessage)
+ }
+ }
+
+ override fun onError(error: Throwable) {
+ log.debug("Fail to process message", error)
+ Assert.assertEquals("INTERNAL: Could not find blueprint : from database", error.message)
+ }
+
+ override fun onCompleted() {
+ log.info("Done")
+ }
+ })
}
@Test
fun testSelfServiceGRPCHandler() {
-
- val blockingStub = BluePrintProcessingServiceGrpc.newBlockingStub(grpcServerRule.channel)
-
val commonHeader = CommonHeader.newBuilder()
.setTimestamp("2012-04-23T18:25:43.511Z")
.setOriginatorId("System")
@@ -76,8 +100,25 @@ class BluePrintProcessingGRPCHandlerTest {
.setPayload(payloadBuilder.build())
.build()
-// val response = blockingStub.process(input)
-// assertNotNull(response, "Response is null")
+ requestObs.onNext(input)
+
+ val commonHeader2 = CommonHeader.newBuilder()
+ .setTimestamp("2012-04-23T18:25:43.511Z")
+ .setOriginatorId("System")
+ .setRequestId("2345")
+ .setSubRequestId("1234-56").build()
+
+ val actionIdentifier = ActionIdentifiers.newBuilder().setMode("sync").build()
+
+ val input2 = ExecutionServiceInput.newBuilder()
+ .setCommonHeader(commonHeader2)
+ .setActionIdentifiers(actionIdentifier)
+ .setPayload(payloadBuilder.build())
+ .build()
+
+ requestObs.onNext(input2)
+
+ requestObs.onCompleted()
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappingTests.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappingTests.kt
new file mode 100644
index 00000000..2e4ba275
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappingTests.kt
@@ -0,0 +1,172 @@
+package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils
+
+import com.fasterxml.jackson.databind.ObjectMapper
+import com.google.protobuf.ListValue
+import com.google.protobuf.NullValue
+import com.google.protobuf.Struct
+import com.google.protobuf.Value
+import com.google.protobuf.util.JsonFormat
+import org.junit.Assert
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Flags
+import org.onap.ccsdk.apps.controllerblueprints.common.api.ActionIdentifiers
+import org.onap.ccsdk.apps.controllerblueprints.common.api.CommonHeader
+import org.onap.ccsdk.apps.controllerblueprints.common.api.Flag
+import org.springframework.test.context.junit4.SpringRunner
+import java.text.SimpleDateFormat
+
+@RunWith(SpringRunner::class)
+class BluePrintMappingsTest {
+
+ val formatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ val dateString = "2019-01-16T18:25:43.511Z"
+ val dateForTest = formatter.parse(dateString)
+
+ val flag = Flag.newBuilder().setIsForce(false).setTtl(1).build()
+
+ fun createFlag(): Flags {
+ val flag = Flags()
+ flag.isForce = false
+ flag.ttl = 1
+ return flag
+ }
+
+ @Test
+ fun flagToJavaTest() {
+ val flag2 = flag.toJava()
+
+ Assert.assertEquals(flag.isForce, flag2.isForce)
+ Assert.assertEquals(flag.ttl, flag2.ttl)
+ }
+
+ @Test
+ fun flagToProtoTest() {
+ val flag = createFlag()
+ val flag2 = flag.toProto()
+
+ Assert.assertEquals(flag.isForce, flag2.isForce)
+ Assert.assertEquals(flag.ttl, flag2.ttl)
+ }
+
+ fun createStatus(): org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status {
+ val status = org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status()
+ status.code = 400
+ status.errorMessage = "Concurrent modification exception"
+ status.eventType = "Update"
+ status.message = "Error uploading data"
+ status.timestamp = dateForTest
+ return status
+ }
+
+ @Test
+ fun statusToProtoTest() {
+ val status = createStatus()
+ val status2 = status.toProto()
+
+ Assert.assertEquals(status.code, status2.code)
+ Assert.assertEquals(status.errorMessage, status2.errorMessage)
+ Assert.assertEquals(status.eventType, status2.eventType)
+ Assert.assertEquals(status.message, status2.message)
+ Assert.assertEquals(status.timestamp.toString(), status2.timestamp)
+ }
+
+ @Test
+ fun commonHeaderToJavaTest() {
+ val flag = Flag.newBuilder().setIsForce(true).setTtl(2).build()
+
+ val commonHeader = CommonHeader.newBuilder().setOriginatorId("Origin").setRequestId("requestID").setSubRequestId("subRequestID").setTimestamp(dateString).setFlag(flag).build()
+ val commonHeader2 = commonHeader.toJava()
+
+ Assert.assertEquals(commonHeader.originatorId, commonHeader2.originatorId)
+ Assert.assertEquals(commonHeader.requestId, commonHeader2.requestId)
+ Assert.assertEquals(commonHeader.subRequestId, commonHeader2.subRequestId)
+ Assert.assertEquals(commonHeader.timestamp, formatter.format(commonHeader2.timestamp))
+ }
+
+ fun createCommonHeader(): org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.CommonHeader {
+ val commonHeader = org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.CommonHeader()
+ commonHeader.flags = createFlag()
+ commonHeader.originatorId = "1234"
+ commonHeader.requestId = "2345"
+ commonHeader.subRequestId = "0123"
+ commonHeader.timestamp = dateForTest
+ return commonHeader
+ }
+
+ @Test
+ fun commonHeaderToProtoTest() {
+ val commonHeader = createCommonHeader()
+ val commonHeader2 = commonHeader.toProto()
+ Assert.assertEquals(commonHeader.originatorId, commonHeader2.originatorId)
+ Assert.assertEquals(commonHeader.requestId, commonHeader2.requestId)
+ Assert.assertEquals(commonHeader.subRequestId, commonHeader2.subRequestId)
+ Assert.assertEquals(commonHeader.timestamp.toString(), commonHeader2.timestamp)
+ }
+
+ @Test
+ fun actionIdentifierToJavaTest() {
+ val actionIdentifiers = ActionIdentifiers.newBuilder().setActionName("Process Action").setBlueprintName("BlueprintName").setBlueprintVersion("3.0").setMode("Execution").build()
+ val actionIdentifiers2 = actionIdentifiers.toJava()
+
+ Assert.assertEquals(actionIdentifiers.actionName, actionIdentifiers2.actionName)
+ Assert.assertEquals(actionIdentifiers.blueprintName, actionIdentifiers2.blueprintName)
+ Assert.assertEquals(actionIdentifiers.blueprintVersion, actionIdentifiers2.blueprintVersion)
+ Assert.assertEquals(actionIdentifiers.mode, actionIdentifiers2.mode)
+ }
+
+ fun createActionIdentifier(): org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ActionIdentifiers {
+ val ac = org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ActionIdentifiers()
+ ac.mode = "mode"
+ ac.blueprintVersion = "version"
+ ac.blueprintName = "name"
+ ac.actionName = "action"
+ return ac
+ }
+
+ @Test
+ fun actionIdentifierToProtoTest() {
+ val actionIdentifiers = createActionIdentifier()
+ val actionIdentifiers2 = actionIdentifiers.toProto()
+
+ Assert.assertEquals(actionIdentifiers.actionName, actionIdentifiers2.actionName)
+ Assert.assertEquals(actionIdentifiers.blueprintName, actionIdentifiers2.blueprintName)
+ Assert.assertEquals(actionIdentifiers.blueprintVersion, actionIdentifiers2.blueprintVersion)
+ Assert.assertEquals(actionIdentifiers.mode, actionIdentifiers2.mode)
+ }
+
+ @Test
+ fun testStructToJava() {
+ val struct = Struct.newBuilder().putAllFields(createValues()).build()
+ val struct2 = struct.toJava()
+
+ val mapper = ObjectMapper()
+
+ Assert.assertEquals(JsonFormat.printer().print(struct).replace(" ", "").replace("\r",""),
+ mapper.writerWithDefaultPrettyPrinter().writeValueAsString(struct2).replace(" ", "").replace("\r",""))
+ }
+
+ fun createValues(): Map<String, Value> {
+ val map = mutableMapOf<String, Value>()
+
+ val boolValue = Value.newBuilder().setBoolValue(true).build()
+ val stringValue = Value.newBuilder().setStringValue("string").build()
+ val doubleValue = Value.newBuilder().setNumberValue(Double.MAX_VALUE).build()
+ val jsonValue = Value.newBuilder().setStringValue("{\"bblah\": \"bbblo\"}").build()
+ val listValue = Value.newBuilder().setListValue(ListValue.newBuilder().addValues(boolValue).addValues(boolValue).build()).build()
+ val nullValue = Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build()
+
+ map.put("bool", boolValue)
+ map.put("string", stringValue)
+ map.put("doublbe", doubleValue)
+ map.put("json", jsonValue)
+ map.put("list", listValue)
+ map.put("null", nullValue)
+
+ val structValue = Value.newBuilder().setStructValue(Struct.newBuilder().putAllFields(map).build()).build()
+
+ map.put("struct", structValue)
+
+ return map
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/outbounds/pom.xml b/ms/blueprintsprocessor/modules/outbounds/pom.xml
index e957c881..b6c26e67 100644
--- a/ms/blueprintsprocessor/modules/outbounds/pom.xml
+++ b/ms/blueprintsprocessor/modules/outbounds/pom.xml
@@ -15,16 +15,16 @@
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
- <artifactId>modules</artifactId>
- <version>0.4.1-SNAPSHOT</version>
- </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>modules</artifactId>
+ <version>0.4.1-SNAPSHOT</version>
+ </parent>
- <artifactId>outbounds</artifactId>
- <packaging>pom</packaging>
- <name>Blueprints Processor Outbounds POM</name>
- <description>Blueprints Processor Outbounds</description>
+ <artifactId>outbounds</artifactId>
+ <packaging>pom</packaging>
+ <name>Blueprints Processor Outbounds POM</name>
+ <description>Blueprints Processor Outbounds</description>
</project>
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
index 035f14d9..96bb09f2 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
+++ b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
@@ -29,6 +29,10 @@
<dependencies>
<dependency>
+ <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+ <artifactId>core</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
<artifactId>core</artifactId>
</dependency>
diff --git a/ms/blueprintsprocessor/modules/services/pom.xml b/ms/blueprintsprocessor/modules/services/pom.xml
index 8cb3c6f1..469899d0 100644..100755
--- a/ms/blueprintsprocessor/modules/services/pom.xml
+++ b/ms/blueprintsprocessor/modules/services/pom.xml
@@ -2,6 +2,8 @@
<!--
~ 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
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml b/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml
index 6e3dade6..cc2a0e66 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml
@@ -28,6 +28,10 @@
<dependencies>
<dependency>
+ <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+ <artifactId>core</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
<artifactId>execution-service</artifactId>
</dependency>
diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml
index f694ac12..472b466b 100644..100755
--- a/ms/blueprintsprocessor/parent/pom.xml
+++ b/ms/blueprintsprocessor/parent/pom.xml
@@ -3,6 +3,7 @@
~ Copyright © 2017-2018 AT&T Intellectual Property.
~
~ Modifications Copyright © 2018 IBM.
+ ~ 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.
@@ -30,12 +31,12 @@
<name>Blueprints Processor Parent</name>
<description>Blueprints Processor Parent</description>
<properties>
- <spring.boot.version>2.1.1.RELEASE</spring.boot.version>
- <spring.version>5.1.3.RELEASE</spring.version>
- <kotlin.version>1.3.11</kotlin.version>
- <kotlin.maven.version>1.3.11</kotlin.maven.version>
- <kotlin.couroutines.version>1.1.0</kotlin.couroutines.version>
- <grpc.version>1.17.1</grpc.version>
+ <spring.boot.version>2.1.2.RELEASE</spring.boot.version>
+ <spring.version>5.1.4.RELEASE</spring.version>
+ <kotlin.version>1.3.20</kotlin.version>
+ <kotlin.maven.version>1.3.20</kotlin.maven.version>
+ <kotlin.couroutines.version>1.1.1</kotlin.couroutines.version>
+ <grpc.version>1.18.0</grpc.version>
<protobuff.java.utils.version>3.6.1</protobuff.java.utils.version>
<eelf.version>1.0.0</eelf.version>
<sli.version>0.4.1-SNAPSHOT</sli.version>
@@ -126,14 +127,26 @@
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-stdlib-common</artifactId>
+ <version>${kotlin.version}</version>
+ </dependency>
+ <!--Use kotlin-compiler-embeddable instead koltin-compiler wrap-->
+ <!--guava dependency inside kotlin-compiler creating classpath issues at runtime-->
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-scripting-jvm-host</artifactId>
<version>${kotlin.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-compile</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-compiler-embeddable</artifactId>
<version>${kotlin.version}</version>
- <scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
@@ -247,6 +260,11 @@
<!-- Application Module Dependencies -->
<dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>application</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
<artifactId>db-lib</artifactId>
<version>${project.version}</version>
</dependency>
@@ -304,6 +322,11 @@
<artifactId>resource-dict</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+ <artifactId>core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- Database -->
<dependency>
diff --git a/ms/blueprintsprocessor/pom.xml b/ms/blueprintsprocessor/pom.xml
index df4932cd..774e177e 100644..100755
--- a/ms/blueprintsprocessor/pom.xml
+++ b/ms/blueprintsprocessor/pom.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
@@ -15,34 +16,35 @@
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.ccsdk.apps</groupId>
- <artifactId>ccsdk-apps-ms</artifactId>
- <version>0.4.1-SNAPSHOT</version>
- </parent>
- <artifactId>blueprintsprocessor</artifactId>
- <packaging>pom</packaging>
- <name>Blueprints Processor Root</name>
- <description>Blueprints Processor Root</description>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.ccsdk.apps</groupId>
+ <artifactId>ccsdk-apps-ms</artifactId>
+ <version>0.4.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>blueprintsprocessor</artifactId>
+ <packaging>pom</packaging>
+ <name>Blueprints Processor Root</name>
+ <description>Blueprints Processor Root</description>
- <properties>
- <service.name>BlueprintsProcessor</service.name>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
- <build.number>${maven.build.timestamp}</build.number>
- <java.version>1.8</java.version>
- <maven.compiler.target>1.8</maven.compiler.target>
- <maven.compiler.source>1.8</maven.compiler.source>
- <ccsdk.project.version>${project.version}</ccsdk.project.version>
- </properties>
+ <properties>
+ <service.name>BlueprintsProcessor</service.name>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
+ <build.number>${maven.build.timestamp}</build.number>
+ <java.version>1.8</java.version>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <ccsdk.project.version>${project.version}</ccsdk.project.version>
+ </properties>
- <modules>
- <module>parent</module>
- <module>modules</module>
- <module>functions</module>
- <module>application</module>
- </modules>
+ <modules>
+ <module>parent</module>
+ <module>modules</module>
+ <module>functions</module>
+ <module>application</module>
+ <module>distribution</module>
+ </modules>
</project>