aboutsummaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
Diffstat (limited to 'ms')
-rw-r--r--ms/blueprintsprocessor/.gitignore1
-rw-r--r--ms/blueprintsprocessor/application/pom.xml4
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintGRPCServer.java64
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintHttpServer.java57
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/SwaggerConfig.java6
-rw-r--r--ms/blueprintsprocessor/application/src/main/resources/application.properties20
-rw-r--r--ms/blueprintsprocessor/application/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplicationTest.java7
-rw-r--r--ms/blueprintsprocessor/application/src/test/resources/application.properties27
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/pom.xml40
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt38
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/JsonParserService.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionConstants.kt)9
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt26
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfRpcService.kt27
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt80
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/logback-test.xml35
-rw-r--r--ms/blueprintsprocessor/functions/pom.xml1
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt44
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/JythonExecutionService.kt7
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.kt6
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt18
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/mock/MockInstanceConfiguration.kt32
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt54
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConfiguration.kt26
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt27
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt140
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DataBaseResourceAssignmentProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DataBaseResourceAssignmentProcessor.kt)7
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DefaultResourceAssignmentProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt)7
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/InputResourceAssignmentProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt)7
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/ResourceAssignmentProcessor.kt61
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/SimpleRestResourceAssignmentProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SimpleRestResourceAssignmentProcessor.kt)7
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt32
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt89
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt68
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt71
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.kt95
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json12
-rw-r--r--ms/blueprintsprocessor/modules/commons/core/pom.xml9
-rw-r--r--ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt49
-rw-r--r--ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt29
-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/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt51
-rw-r--r--ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/interfaces/BluePrintCatalogService.kt24
-rw-r--r--ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt47
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/pom.xml61
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt41
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibData.kt29
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibGenericService.kt28
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt85
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/service/PrimaryDBLibGenericService.kt38
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfigurationTest.kt44
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/application-test.properties24
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/logback-test.xml35
-rw-r--r--ms/blueprintsprocessor/modules/commons/pom.xml11
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml34
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt36
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt50
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt40
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt87
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt32
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt38
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt38
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties16
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestPropertyPlaceHolderConfigurationTest.kt57
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml35
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/pom.xml14
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/resource/api/ResourceResolutionController.java18
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml64
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintCatalogServiceImpl.kt33
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt63
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt44
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt52
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandlerTest.kt92
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt81
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt50
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/mock/SelfServiceApiMocks.kt46
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/application-test.properties17
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/execution-input/default-input.json23
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/execution-input/sample-payload.json10
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/logback.xml35
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zipbin0 -> 9189 bytes
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/pom.xml8
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt65
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionService.kt8
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt20
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionServiceTest.kt2
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt53
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt45
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/assign-activate-input.json23
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/default-input.json20
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/resource-assignment-input.json23
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/one-component.xml34
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/two-component.xml42
-rw-r--r--ms/blueprintsprocessor/parent/pom.xml20
-rw-r--r--ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java15
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java3
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java2
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java7
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java1
-rw-r--r--ms/controllerblueprints/parent/pom.xml29
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/Application.java2
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicySequence.java16
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperator.java1
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/rs/RestServiceImpl.java10
-rw-r--r--ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/PolicyEngineResponse.java3
104 files changed, 2870 insertions, 570 deletions
diff --git a/ms/blueprintsprocessor/.gitignore b/ms/blueprintsprocessor/.gitignore
index 983e231d..f72f78ad 100644
--- a/ms/blueprintsprocessor/.gitignore
+++ b/ms/blueprintsprocessor/.gitignore
@@ -25,6 +25,7 @@
**/.springBeans
**/.directory
+**/transaction.log
**/*versionsBackup
**/blackDuckHub*
**/*.jsonld \ No newline at end of file
diff --git a/ms/blueprintsprocessor/application/pom.xml b/ms/blueprintsprocessor/application/pom.xml
index 4e652d50..796cde63 100644
--- a/ms/blueprintsprocessor/application/pom.xml
+++ b/ms/blueprintsprocessor/application/pom.xml
@@ -46,6 +46,10 @@
<artifactId>selfservice-api</artifactId>
</dependency>
<dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<scope>test</scope>
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintGRPCServer.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintGRPCServer.java
new file mode 100644
index 00000000..86fdccd4
--- /dev/null
+++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintGRPCServer.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor;
+
+import io.grpc.Server;
+import io.grpc.ServerBuilder;
+import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.BluePrintManagementGRPCHandler;
+import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.BluePrintProcessingGRPCHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.stereotype.Component;
+
+@ConditionalOnProperty(name = "blueprintsprocessor.grpcEnable", havingValue = "true")
+@Component
+public class BlueprintGRPCServer implements ApplicationListener<ContextRefreshedEvent> {
+
+ private static Logger log = LoggerFactory.getLogger(BlueprintGRPCServer.class);
+
+ @Autowired
+ private BluePrintProcessingGRPCHandler bluePrintProcessingGRPCHandler;
+
+ @Autowired
+ private BluePrintManagementGRPCHandler bluePrintManagementGRPCHandler;
+
+ @Value("${blueprintsprocessor.grpcPort}")
+ private Integer grpcPort;
+
+ @Override
+ public void onApplicationEvent(ContextRefreshedEvent event) {
+ try {
+ log.info("Starting Blueprint Processor GRPC Starting..");
+ Server server = ServerBuilder
+ .forPort(grpcPort)
+ .addService(bluePrintProcessingGRPCHandler)
+ .addService(bluePrintManagementGRPCHandler)
+ .build();
+
+ server.start();
+ log.info("Blueprint Processor GRPC server started and ready to serve on port({})...", server.getPort());
+ server.awaitTermination();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintHttpServer.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintHttpServer.java
new file mode 100644
index 00000000..b00c4627
--- /dev/null
+++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintHttpServer.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
+import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
+import org.springframework.boot.web.server.WebServer;
+import org.springframework.http.server.reactive.HttpHandler;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+@ConditionalOnProperty(name = "blueprintsprocessor.grpcEnable", havingValue = "true")
+@Component
+public class BlueprintHttpServer {
+ private static Logger log = LoggerFactory.getLogger(BlueprintHttpServer.class);
+
+ @Value("${blueprintsprocessor.httpPort}")
+ private Integer httpPort;
+
+ @Autowired
+ HttpHandler httpHandler;
+
+ WebServer http;
+
+ @PostConstruct
+ public void start() {
+ ReactiveWebServerFactory factory = new NettyReactiveWebServerFactory(httpPort);
+ this.http = factory.getWebServer(this.httpHandler);
+ this.http.start();
+ }
+
+ @PreDestroy
+ public void stop() {
+ this.http.stop();
+ }
+}
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/SwaggerConfig.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/SwaggerConfig.java
index 3537a91d..810480e9 100644
--- a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/SwaggerConfig.java
+++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/SwaggerConfig.java
@@ -17,8 +17,7 @@
package org.onap.ccsdk.apps.blueprintsprocessor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
import org.springframework.context.annotation.Bean;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
@@ -27,10 +26,7 @@ import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
-import java.util.Arrays;
import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
/**
* SwaggerConfig
diff --git a/ms/blueprintsprocessor/application/src/main/resources/application.properties b/ms/blueprintsprocessor/application/src/main/resources/application.properties
index f30a7f12..fa1a1e6e 100644
--- a/ms/blueprintsprocessor/application/src/main/resources/application.properties
+++ b/ms/blueprintsprocessor/application/src/main/resources/application.properties
@@ -1,5 +1,5 @@
#
-# Copyright © 2017-2018 AT&T Intellectual Property.
+# 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.
@@ -12,4 +12,20 @@
# 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.
-# \ No newline at end of file
+#
+#logging.level.web=DEBUG
+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=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/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplicationTest.java b/ms/blueprintsprocessor/application/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplicationTest.java
index 3cba1f9e..8a4ebd0a 100644
--- a/ms/blueprintsprocessor/application/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplicationTest.java
+++ b/ms/blueprintsprocessor/application/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplicationTest.java
@@ -22,6 +22,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@@ -35,8 +36,8 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = BlueprintProcessorApplication.class)
-//@SpringBootTest(classes = BlueprintProcessorApplication.class,
-// webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@SpringBootTest(classes = BlueprintProcessorApplication.class,
+ webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class BlueprintProcessorApplicationTest {
@Autowired
@@ -48,7 +49,7 @@ public class BlueprintProcessorApplicationTest {
}
@Test
- public void testSample(){
+ public void testSample() {
Assert.assertNotNull("Failed to create Application Context ", context);
}
diff --git a/ms/blueprintsprocessor/application/src/test/resources/application.properties b/ms/blueprintsprocessor/application/src/test/resources/application.properties
new file mode 100644
index 00000000..f896ee05
--- /dev/null
+++ b/ms/blueprintsprocessor/application/src/test/resources/application.properties
@@ -0,0 +1,27 @@
+#
+# 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.
+#
+# 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:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE
+blueprintsprocessor.db.primary.username=sa
+blueprintsprocessor.db.primary.password=
+blueprintsprocessor.db.primary.driverClassName=org.h2.Driver
+blueprintsprocessor.db.primary.hibernateHbm2ddlAuto=create-drop
+blueprintsprocessor.db.primary.hibernateDDLAuto=update
+blueprintsprocessor.db.primary.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy
+blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.H2Dialect \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/pom.xml b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml
new file mode 100644
index 00000000..94103b59
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<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">
+ <parent>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>functions</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
+ <artifactId>netconf-executor</artifactId>
+ <name>Blueprints Processor Function - Netconf Executor</name>
+ <description>Blueprints Processor Function - Netconf Executor</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
+ <artifactId>python-executor</artifactId>
+ </dependency>
+ </dependencies>
+
+
+</project> \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt
new file mode 100644
index 00000000..e0fd7350
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt
@@ -0,0 +1,38 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.ComponentJythonExecutor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.PythonExecutorProperty
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Component
+
+@Component("component-netconf-executor")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class ComponentNetconfExecutor(private val netconfExecutorConfiguration: NetconfExecutorConfiguration,
+ private val pythonExecutorProperty: PythonExecutorProperty)
+ : ComponentJythonExecutor(pythonExecutorProperty) {
+
+ private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java)
+
+ override fun process(executionServiceInput: ExecutionServiceInput) {
+ super.process(executionServiceInput)
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionConstants.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/JsonParserService.kt
index e234d056..11173663 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionConstants.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/JsonParserService.kt
@@ -14,12 +14,11 @@
* limitations under the License.
*/
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor
-class ResourceResolutionConstants {
- companion object {
- const val PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR = "resource-assignment-processor-"
+import org.springframework.stereotype.Service
- }
+@Service("json-parser-service")
+class JsonParserService {
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt
new file mode 100644
index 00000000..267a49a7
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt
@@ -0,0 +1,26 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor
+
+import org.springframework.boot.context.properties.EnableConfigurationProperties
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+@ComponentScan
+@EnableConfigurationProperties
+open class NetconfExecutorConfiguration \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfRpcService.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfRpcService.kt
new file mode 100644
index 00000000..f4818106
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfRpcService.kt
@@ -0,0 +1,27 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor
+
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+
+@Service("netconf-rpc-service")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+class NetconfRpcService {
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt
new file mode 100644
index 00000000..05f6a2db
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt
@@ -0,0 +1,80 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ActionIdentifiers
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.CommonHeader
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.PythonExecutorProperty
+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.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [NetconfExecutorConfiguration::class, PythonExecutorProperty::class])
+@TestPropertySource(properties =
+["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints",
+ "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints"])
+class ComponentNetconfExecutorTest {
+
+ @Autowired
+ lateinit var componentNetconfExecutor: ComponentNetconfExecutor
+
+ @Test
+ fun testComponentNetconfExecutor() {
+
+ val executionServiceInput = ExecutionServiceInput()
+ val commonHeader = CommonHeader()
+ commonHeader.requestId = "1234"
+ executionServiceInput.commonHeader = commonHeader
+
+ val actionIdentifiers = ActionIdentifiers()
+ actionIdentifiers.blueprintName = "baseconfiguration"
+ actionIdentifiers.blueprintVersion = "1.0.0"
+ actionIdentifiers.actionName = "activate"
+ executionServiceInput.actionIdentifiers = actionIdentifiers
+
+
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(commonHeader.requestId,
+ "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+ componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService
+
+
+ val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "activate-jython")
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "JythonExecutorComponent")
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
+ // Set Step Inputs in Blueprint Runtime Service
+ bluePrintRuntimeService.put("activate-jython-step-inputs", stepMetaData.asJsonNode())
+
+ componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService
+ componentNetconfExecutor.stepName = "activate-jython"
+
+ componentNetconfExecutor.apply(executionServiceInput)
+
+ }
+}
+
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/logback-test.xml
new file mode 100644
index 00000000..f9ec9fe5
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/logback-test.xml
@@ -0,0 +1,35 @@
+<!--
+ ~ 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.test" level="warn"/>
+ <logger name="org.springframework" level="warn"/>
+ <logger name="org.hibernate" level="info"/>
+ <logger name="org.onap.ccsdk.apps.blueprintsprocessor" level="info"/>
+
+ <root level="warn">
+ <appender-ref ref="STDOUT"/>
+ </root>
+
+</configuration>
diff --git a/ms/blueprintsprocessor/functions/pom.xml b/ms/blueprintsprocessor/functions/pom.xml
index efd550dd..e4f8c844 100644
--- a/ms/blueprintsprocessor/functions/pom.xml
+++ b/ms/blueprintsprocessor/functions/pom.xml
@@ -32,6 +32,7 @@
<modules>
<module>resource-resolution</module>
<module>python-executor</module>
+ <module>netconf-executor</module>
</modules>
<dependencies>
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt
index 2965cb5d..166af0f7 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt
@@ -16,37 +16,39 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor
+import com.fasterxml.jackson.databind.node.ArrayNode
import org.apache.commons.io.FilenameUtils
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.utils.PythonExecutorUtils
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyNThrow
import org.onap.ccsdk.apps.controllerblueprints.core.data.OperationAssignment
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.ApplicationContext
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component
@Component("component-jython-executor")
-class ComponentJythonExecutor(private val pythonExecutorProperty: PythonExecutorProperty) : AbstractComponentFunction() {
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class ComponentJythonExecutor(private val pythonExecutorProperty: PythonExecutorProperty) : AbstractComponentFunction() {
private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java)
private var componentFunction: AbstractComponentFunction? = null
+ @Autowired
+ lateinit var applicationContext: ApplicationContext
- override fun process(executionServiceInput: ExecutionServiceInput) {
-
- log.info("Processing : ${executionServiceInput.metadata}")
- checkNotNull(bluePrintRuntimeService) { "failed to get bluePrintRuntimeService" }
-
+ fun populateJythonComponentInstance(executionServiceInput: ExecutionServiceInput) {
val bluePrintContext = bluePrintRuntimeService!!.bluePrintContext()
val operationAssignment: OperationAssignment = bluePrintContext
.nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName)
- val blueprintBasePath: String = bluePrintRuntimeService!!.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)?.asText()
- ?: throw BluePrintProcessorException("python execute path is missing for node template ($nodeTemplateName)")
+ val blueprintBasePath: String = bluePrintContext.rootPath
val artifactName: String = operationAssignment.implementation?.primary
?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
@@ -66,12 +68,30 @@ class ComponentJythonExecutor(private val pythonExecutorProperty: PythonExecutor
pythonPath.add(blueprintBasePath)
pythonPath.addAll(pythonExecutorProperty.modulePaths)
- val properties: MutableMap<String, Any> = hashMapOf()
- properties["log"] = log
+ val jythonInstances: MutableMap<String, Any> = hashMapOf()
+ jythonInstances["log"] = LoggerFactory.getLogger(nodeTemplateName)
+
+ val instanceDependenciesNode: ArrayNode = operationInputs[PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES] as? ArrayNode
+ ?: throw BluePrintProcessorException("Failed to get property(${PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES})")
+
+ instanceDependenciesNode.forEach { instanceName ->
+ jythonInstances[instanceName.textValue()] = applicationContext.getBean(instanceName.textValue())
+ }
componentFunction = PythonExecutorUtils.getPythonComponent(pythonExecutorProperty.executionPath,
- pythonPath, content, pythonClassName, properties)
+ pythonPath, content, pythonClassName, jythonInstances)
+ }
+
+
+ override fun process(executionServiceInput: ExecutionServiceInput) {
+
+ log.info("Processing : ${operationInputs}")
+ checkNotNull(bluePrintRuntimeService) { "failed to get bluePrintRuntimeService" }
+
+ // Populate Component Instance
+ populateJythonComponentInstance(executionServiceInput)
+ // Invoke Jython Component Script
componentFunction!!.process(executionServiceInput)
}
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/JythonExecutionService.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/JythonExecutionService.kt
index dc372af4..6618d13c 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/JythonExecutionService.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/JythonExecutionService.kt
@@ -33,10 +33,11 @@ class JythonExecutionService(private val pythonExecutorProperty: PythonExecutorP
lateinit var applicationContext: ApplicationContext
- fun processJythonNodeTemplate(pythonClassName: String, content: String, pythonPath: MutableList<String>,
- jythonContextInstance: MutableMap<String, Any>,
- dependencyInstanceNames: List<String>): AbstractComponentFunction {
+ fun getJythonComponentFunction(pythonClassName: String, content: String, pythonPath: MutableList<String>,
+ jythonContextInstance: MutableMap<String, Any>,
+ dependencyInstanceNames: List<String>): AbstractComponentFunction {
+ pythonPath.addAll(pythonExecutorProperty.modulePaths)
dependencyInstanceNames.forEach { instanceName ->
jythonContextInstance[instanceName] = applicationContext.getBean(instanceName)
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.kt
index dd80fb0a..be7374c5 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.kt
@@ -33,4 +33,10 @@ open class PythonExecutorProperty {
@Value("#{'\${blueprints.processor.functions.python.executor.modulePaths}'.split(',')}")
lateinit var modulePaths: List<String>
+}
+
+class PythonExecutorConstants {
+ companion object {
+ const val INPUT_INSTANCE_DEPENDENCIES = "instance-dependencies"
+ }
} \ No newline at end of file
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 1ce8d05b..07591a50 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
@@ -23,6 +23,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ActionIdentifiers
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.CommonHeader
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
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.springframework.beans.factory.annotation.Autowired
@@ -35,13 +36,11 @@ import org.springframework.test.context.junit4.SpringRunner
@TestPropertySource(properties =
["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints",
"blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints"])
-
class ComponentJythonExecutorTest {
@Autowired
lateinit var componentJythonExecutor: ComponentJythonExecutor
-
@Test
fun testPythonComponentInjection() {
@@ -60,15 +59,14 @@ class ComponentJythonExecutorTest {
val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(commonHeader.requestId,
"./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
- componentJythonExecutor.bluePrintRuntimeService = bluePrintRuntimeService
+ val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "activate-jython")
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "JythonExecutorComponent")
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
+ bluePrintRuntimeService.put("activate-jython-step-inputs", stepMetaData.asJsonNode())
-
- val metaData: MutableMap<String, JsonNode> = hashMapOf()
- metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_STEP, "resource-assignment-py")
- metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "resource-assignment-py")
- metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ResourceAssignmentComponent")
- metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
- executionServiceInput.metadata = metaData
+ componentJythonExecutor.bluePrintRuntimeService = bluePrintRuntimeService
+ componentJythonExecutor.stepName = "activate-jython"
componentJythonExecutor.apply(executionServiceInput)
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/mock/MockInstanceConfiguration.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/mock/MockInstanceConfiguration.kt
new file mode 100644
index 00000000..41250e0c
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/mock/MockInstanceConfiguration.kt
@@ -0,0 +1,32 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.mock
+
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+open class MockInstanceConfiguration {
+ @Bean(name = ["json-parser-service", "netconf-rpc-service"])
+ open fun createComponentFunction(): MockJythonService {
+ return MockJythonService()
+ }
+}
+
+class MockJythonService {
+
+} \ 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/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
new file mode 100644
index 00000000..e5feb257
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
@@ -0,0 +1,54 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.ApplicationContext
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Component
+
+@Component("component-resource-resolution")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class ResourceResolutionComponent(private val resourceResolutionService: ResourceResolutionService) : AbstractComponentFunction() {
+
+ @Autowired
+ private lateinit var applicationContext: ApplicationContext
+
+ override fun process(executionRequest: ExecutionServiceInput) {
+
+ val artifactPrefixNamesNode = getOperationInput(ResourceResolutionConstants.INPUT_ARTIFACT_PREFIX_NAMES)
+
+ val artifactPrefixNames = JacksonUtils.getListFromJsonNode(artifactPrefixNamesNode, String::class.java)
+ ?: throw BluePrintProcessorException("coundn't transform ${artifactPrefixNamesNode.asText()} to string array")
+
+ val resolvedParamContents = resourceResolutionService.resolveResources(bluePrintRuntimeService!!, nodeTemplateName, artifactPrefixNames)
+
+ // Set Output Attributes
+ bluePrintRuntimeService!!.setNodeTemplateAttributeValue(nodeTemplateName,
+ ResourceResolutionConstants.OUTPUT_ASSIGNMENT_PARAMS, resolvedParamContents.asJsonNode())
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+} \ 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/ResourceResolutionConfiguration.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConfiguration.kt
new file mode 100644
index 00000000..4c24ac69
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConfiguration.kt
@@ -0,0 +1,26 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
+
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+@ComponentScan
+open class ResourceResolutionConfiguration
+
+
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
new file mode 100644
index 00000000..3211d6e8
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
@@ -0,0 +1,27 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
+
+class ResourceResolutionConstants {
+ companion object {
+ const val PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR = "resource-assignment-processor-"
+ const val INPUT_ARTIFACT_PREFIX_NAMES = "artifact-prefix-names"
+ const val OUTPUT_ASSIGNMENT_PARAMS = "assignment-params"
+ const val FILE_NAME_RESOURCE_DICTIONARY_TYPES = "resources_dictionary_types.json"
+ }
+
+} \ 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/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
new file mode 100644
index 00000000..c3cf0097
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
@@ -0,0 +1,140 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
+
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.ResourceAssignmentProcessor
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+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.ResourceDefinition
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.context.ApplicationContext
+import org.springframework.stereotype.Service
+import java.io.File
+
+/**
+ * ResourceResolutionService
+ * @author Brinda Santh
+ * 8/14/2018
+ */
+
+@Service
+class ResourceResolutionService {
+
+ private val log = LoggerFactory.getLogger(ResourceResolutionService::class.java)
+
+ @Autowired
+ private lateinit var applicationContext: ApplicationContext
+
+ fun registeredResourceSources(): List<String> {
+ return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)
+ .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
+ .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
+ }
+
+
+ fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactNames: List<String>): MutableMap<String, String> {
+
+ val resolvedParams: MutableMap<String, String> = hashMapOf()
+ artifactNames.forEach { artifactName ->
+ val resolvedContent = resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactName)
+ resolvedParams[artifactName] = resolvedContent
+ }
+ return resolvedParams
+ }
+
+
+ fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String, artifactName: String): String {
+
+ var resolvedContent = ""
+ // Velocity Artifact Definition Name
+ val templateArtifactName = "$artifactName-template"
+ // Resource Assignment Artifact Definition Name
+ val mappingArtifactName = "$artifactName-mapping"
+
+ log.info("Resolving resource for template artifact($templateArtifactName) with resource assignment artifact($mappingArtifactName)")
+
+ val resourceAssignmentContent = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, mappingArtifactName)
+
+ val resourceAssignments: MutableList<ResourceAssignment> = JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment::class.java)
+ as? MutableList<ResourceAssignment>
+ ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
+
+ // Get the Resource Dictionary Name
+ val dictionaryFile = bluePrintRuntimeService.bluePrintContext().rootPath.plus(File.separator)
+ .plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR).plus(File.separator)
+ .plus(ResourceResolutionConstants.FILE_NAME_RESOURCE_DICTIONARY_TYPES)
+
+ val resourceDictionaries: MutableMap<String, ResourceDefinition> = JacksonUtils.getMapFromFile(dictionaryFile, ResourceDefinition::class.java)
+ ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
+
+ executeProcessors(bluePrintRuntimeService, resourceDictionaries, resourceAssignments)
+
+ // Check Template is there
+ val templateContent = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, mappingArtifactName)
+
+ // TODO ("Generate Param JSON from Resource Assignment")
+ val resolvedParamJsonContent = "{}"
+
+ if (templateContent.isNotEmpty()) {
+ // TODO ( "Mash Data and Content")
+ resolvedContent = "Mashed Content"
+
+ } else {
+ resolvedContent = resolvedParamJsonContent
+ }
+ return resolvedContent
+ }
+
+
+ fun executeProcessors(bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ resourceDictionaries: MutableMap<String, ResourceDefinition>,
+ resourceAssignments: MutableList<ResourceAssignment>) {
+
+ val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)
+
+ bulkSequenced.map { batchResourceAssignments ->
+ batchResourceAssignments.filter { it.name != "*" && it.name != "start" }
+ .map { resourceAssignment ->
+ val dictionarySource = resourceAssignment.dictionarySource
+ val processorInstanceName = ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR.plus(dictionarySource)
+
+ val resourceAssignmentProcessor = applicationContext.getBean(processorInstanceName) as? ResourceAssignmentProcessor
+ ?: throw BluePrintProcessorException("failed to get resource processor for instance name($processorInstanceName) " +
+ "for resource assignment(${resourceAssignment.name})")
+ try {
+ // Set BluePrint Runtime Service
+ resourceAssignmentProcessor.bluePrintRuntimeService = bluePrintRuntimeService
+ // Set Resource Dictionaries
+ resourceAssignmentProcessor.resourceDictionaries = resourceDictionaries
+ // Invoke Apply Method
+ resourceAssignmentProcessor.apply(resourceAssignment)
+ } catch (e: RuntimeException) {
+ resourceAssignmentProcessor.recover(e, resourceAssignment)
+ throw BluePrintProcessorException(e)
+ }
+ }
+ }
+ }
+
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DataBaseResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DataBaseResourceAssignmentProcessor.kt
index 66e43f1b..12120341 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DataBaseResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DataBaseResourceAssignmentProcessor.kt
@@ -15,10 +15,9 @@
* limitations under the License.
*/
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
/**
@@ -29,6 +28,10 @@ import org.springframework.stereotype.Service
@Service("resource-assignment-processor-db")
open class DataBaseResourceAssignmentProcessor : ResourceAssignmentProcessor(){
+ override fun getName(): String {
+ return "resource-assignment-processor-db"
+ }
+
override fun process(executionRequest: ResourceAssignment) {
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DefaultResourceAssignmentProcessor.kt
index e701e718..58c9e1d8 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DefaultResourceAssignmentProcessor.kt
@@ -15,10 +15,9 @@
* limitations under the License.
*/
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
/**
@@ -29,6 +28,10 @@ import org.springframework.stereotype.Service
@Service("resource-assignment-processor-default")
open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+ override fun getName(): String {
+ return "resource-assignment-processor-default"
+ }
+
override fun process(executionRequest: ResourceAssignment) {
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/InputResourceAssignmentProcessor.kt
index 9e177d46..10332484 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/InputResourceAssignmentProcessor.kt
@@ -15,10 +15,9 @@
* limitations under the License.
*/
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
/**
@@ -29,6 +28,10 @@ import org.springframework.stereotype.Service
@Service("resource-assignment-processor-input")
open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+ override fun getName(): String {
+ return "resource-assignment-processor-input"
+ }
+
override fun process(executionRequest: ResourceAssignment) {
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/ResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/ResourceAssignmentProcessor.kt
new file mode 100644
index 00000000..2b19c8b8
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/ResourceAssignmentProcessor.kt
@@ -0,0 +1,61 @@
+/*
+ * Copyright © 2018 IBM.
+ * Modifications Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
+import org.slf4j.LoggerFactory
+
+abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssignment, ResourceAssignment> {
+
+ private val log = LoggerFactory.getLogger(ResourceAssignmentProcessor::class.java)
+
+ var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null
+
+ var resourceDictionaries: Map<String, ResourceDefinition> = hashMapOf()
+
+
+ open fun resourceDefinition(name: String): ResourceDefinition {
+ return resourceDictionaries.get(name)
+ ?: throw BluePrintProcessorException("couldn't get resource definition($name)")
+ }
+
+ override fun prepareRequest(resourceAssignment: ResourceAssignment): ResourceAssignment {
+ log.info("prepareRequest for ${resourceAssignment.name}, dictionary(${resourceAssignment.dictionaryName})," +
+ "source(${resourceAssignment.dictionarySource})")
+ return resourceAssignment
+ }
+
+ override fun prepareResponse(): ResourceAssignment {
+ log.info("Preparing Response...")
+ return ResourceAssignment()
+ }
+
+ override fun apply(executionServiceInput: ResourceAssignment): ResourceAssignment {
+ prepareRequest(executionServiceInput)
+ process(executionServiceInput)
+ return prepareResponse()
+ }
+
+ override abstract fun process(executionRequest: ResourceAssignment)
+
+ override abstract fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment)
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SimpleRestResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/SimpleRestResourceAssignmentProcessor.kt
index e1b9a8ef..c6732627 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SimpleRestResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/SimpleRestResourceAssignmentProcessor.kt
@@ -15,10 +15,9 @@
* limitations under the License.
*/
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
/**
@@ -29,6 +28,10 @@ import org.springframework.stereotype.Service
@Service("resource-assignment-processor-mdsal")
open class SimpleRestResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+ override fun getName(): String {
+ return "resource-assignment-processor-mdsal"
+ }
+
override fun process(executionRequest: ResourceAssignment) {
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt
deleted file mode 100644
index a485fa62..00000000
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution
-
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
-import org.springframework.stereotype.Component
-
-@Component("component-resource-resolution")
-open class ResourceResolutionComponent : AbstractComponentFunction() {
- override fun process(executionRequest: ExecutionServiceInput) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt
deleted file mode 100644
index 9e735cf0..00000000
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution
-
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.context.ApplicationContext
-import org.springframework.stereotype.Service
-
-/**
- * ResourceResolutionService
- * @author Brinda Santh
- * 8/14/2018
- */
-
-@Service
-class ResourceResolutionService {
-
-
- @Autowired
- private lateinit var applicationContext: ApplicationContext
-
- fun resolveResource(resourceResolutionInput: ResourceResolutionInput): ResourceResolutionOutput {
- val resourceResolutionOutput = ResourceResolutionOutput()
- resourceResolutionOutput.actionIdentifiers = resourceResolutionInput.actionIdentifiers
- resourceResolutionOutput.commonHeader = resourceResolutionInput.commonHeader
- resourceResolutionOutput.resourceAssignments = resourceResolutionInput.resourceAssignments
-
- process(resourceResolutionOutput.resourceAssignments)
-
- val status = Status()
- status.code = 200
- status.message = "Success"
- resourceResolutionOutput.status = status
-
- return resourceResolutionOutput
- }
-
- fun registeredResourceSources(): List<String> {
- return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)
- .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
- .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
- }
-
- fun process(resourceAssignments: MutableList<ResourceAssignment>) {
-
- val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)
-
- bulkSequenced.map { batchResourceAssignments ->
- batchResourceAssignments.filter { it.name != "*" && it.name != "start" }
- .map { resourceAssignment ->
- val dictionarySource = resourceAssignment.dictionarySource
- val processorInstanceName = ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR.plus(dictionarySource)
-
- val resourceAssignmentProcessor = applicationContext.getBean(processorInstanceName) as? ResourceAssignmentProcessor
- ?: throw BluePrintProcessorException("failed to get resource processor for instance name($processorInstanceName) " +
- "for resource assignment(${resourceAssignment.name})")
- try {
- // Invoke Apply Method
- resourceAssignmentProcessor.apply(resourceAssignment)
- } catch (e: RuntimeException) {
- resourceAssignmentProcessor.recover(e, resourceAssignment)
- throw BluePrintProcessorException(e)
- }
- }
- }
- }
-}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
new file mode 100644
index 00000000..57217d0d
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
@@ -0,0 +1,68 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.utils.PayloadUtils
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DataBaseResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DefaultResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.InputResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.SimpleRestResourceAssignmentProcessor
+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.junit4.SpringRunner
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [ResourceResolutionComponent::class, ResourceResolutionService::class,
+ InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
+ DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class])
+class ResourceResolutionComponentTest {
+
+ @Autowired
+ lateinit var resourceResolutionComponent: ResourceResolutionComponent
+
+ @Test
+ fun testProcess() {
+
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java)!!
+
+ // Prepare Inputs
+ PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment")
+
+ val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "resource-assignment")
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ResourceAssignmentComponent")
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
+ bluePrintRuntimeService.put("resource-assignment-step-inputs", stepMetaData.asJsonNode())
+
+ resourceResolutionComponent.bluePrintRuntimeService = bluePrintRuntimeService
+ resourceResolutionComponent.stepName = "resource-assignment"
+ resourceResolutionComponent.apply(executionServiceInput)
+ }
+} \ 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
new file mode 100644
index 00000000..df560076
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
@@ -0,0 +1,71 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
+
+import org.junit.Assert
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DataBaseResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DefaultResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.InputResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.SimpleRestResourceAssignmentProcessor
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertNotNull
+import kotlin.test.assertTrue
+
+/**
+ * ResourceResolutionServiceTest
+ *
+ * @author Brinda Santh DATE : 8/15/2018
+ */
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [ResourceResolutionService::class,
+ InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
+ DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class])
+class ResourceResolutionServiceTest {
+
+ private val log = LoggerFactory.getLogger(ResourceResolutionServiceTest::class.java)
+
+ @Autowired
+ lateinit var resourceResolutionService: ResourceResolutionService
+
+
+ @Test
+ fun testRegisteredSource() {
+ val sources = resourceResolutionService.registeredResourceSources()
+ assertNotNull(sources, "failed to get registered sources")
+ assertTrue(sources.containsAll(arrayListOf("input", "default", "db", "mdsal")), "failed to get registered sources")
+ }
+
+ @Test
+ @Throws(Exception::class)
+ fun testResolveResource() {
+
+ Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
+
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+ resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", "baseconfig")
+
+ }
+
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.kt
deleted file mode 100644
index a7d573c6..00000000
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.kt
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution
-
-import com.fasterxml.jackson.databind.node.ObjectNode
-import org.apache.commons.collections.CollectionUtils
-import org.apache.commons.io.FileUtils
-import org.junit.Assert
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput
-import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.DataBaseResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.DefaultResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.InputResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.SimpleRestResourceAssignmentProcessor
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.slf4j.LoggerFactory
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.test.context.ContextConfiguration
-import org.springframework.test.context.junit4.SpringRunner
-import java.io.File
-import java.nio.charset.Charset
-import kotlin.test.assertNotNull
-import kotlin.test.assertTrue
-
-/**
- * ResourceResolutionServiceTest
- *
- * @author Brinda Santh DATE : 8/15/2018
- */
-@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [ResourceResolutionService::class, ResourceAssignmentProcessorFactory::class,
- InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
- DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class])
-class ResourceResolutionServiceTest {
-
- private val log = LoggerFactory.getLogger(ResourceResolutionServiceTest::class.java)
-
- @Autowired
- lateinit var resourceResolutionService: ResourceResolutionService
-
-
- @Test
- fun testRegisteredSource() {
- val sources = resourceResolutionService.registeredResourceSources()
- assertNotNull(sources, "failed to get registered sources")
- assertTrue(sources.containsAll(arrayListOf("input", "default", "db", "mdsal")), "failed to get registered sources")
- }
-
- @Test
- @Throws(Exception::class)
- fun testResolveResource() {
-
- Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
-
- val resourceResolutionInputContent = FileUtils.readFileToString(
- File("src/test/resources/payload/requests/sample-resourceresolution-request.json"), Charset.defaultCharset())
-
- val resourceResolutionInput = JacksonUtils.readValue(resourceResolutionInputContent, ResourceResolutionInput::class.java)
- Assert.assertNotNull("failed to populate resourceResolutionInput request ", resourceResolutionInput)
-
- val resourceAssignmentContent = FileUtils.readFileToString(
- File("src/test/resources/mapping/db/resource-assignments-simple.json"), Charset.defaultCharset())
- val batchResourceAssignment = JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment::class.java)
-
- Assert.assertTrue("failed to create ResourceAssignment from file", CollectionUtils.isNotEmpty(batchResourceAssignment))
- resourceResolutionInput!!.resourceAssignments = batchResourceAssignment as MutableList<ResourceAssignment>
-
- val inputContent = JacksonUtils.jsonNodeFromFile("src/test/resources/payload/inputs/input.json") as ObjectNode
- Assert.assertNotNull("failed to populate input payload ", inputContent)
- resourceResolutionInput.payload = inputContent
- log.info("ResourceResolutionInput : {}", JacksonUtils.getJson(resourceResolutionInput, true))
-
- val resourceResolutionOutput = resourceResolutionService.resolveResource(resourceResolutionInput)
- Assert.assertNotNull("failed to populate output", resourceResolutionOutput)
-
- }
-
-}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json
index e8830a8a..7889a7e4 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json
@@ -16,7 +16,13 @@
"timestamp": "2012-04-23T18:25:43.511Z"
},
"payload": {
- },
- "resourceAssignments": [
- ]
+ "resource-assignment-request": {
+ "resource-assignment-properties": {
+ "request-id": "1234",
+ "action-name": "assign-activate",
+ "scope-type": "vnf-type",
+ "hostname": "localhost"
+ }
+ }
+ }
}
diff --git a/ms/blueprintsprocessor/modules/commons/core/pom.xml b/ms/blueprintsprocessor/modules/commons/core/pom.xml
index 626a27a3..5e0c966d 100644
--- a/ms/blueprintsprocessor/modules/commons/core/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/core/pom.xml
@@ -29,15 +29,10 @@
<packaging>jar</packaging>
<name>Blueprints Processor Core</name>
<description>Blueprints Processor Core</description>
-
<dependencies>
<dependency>
- <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
- <artifactId>db-lib</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
- <artifactId>rest-lib</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
</dependencies>
</project>
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt
new file mode 100644
index 00000000..07e494a1
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt
@@ -0,0 +1,49 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.core
+
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.beans.factory.annotation.Value
+import org.springframework.boot.context.properties.bind.Binder
+import org.springframework.boot.context.properties.source.ConfigurationPropertySources
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import org.springframework.core.env.Environment
+
+
+@Configuration
+open class BluePrintCoreConfiguration {
+
+ @Value("\${blueprintsprocessor.blueprintDeployPath}")
+ lateinit var deployPath: String
+
+ @Value("\${blueprintsprocessor.blueprintArchivePath}")
+ lateinit var archivePath: String
+
+}
+
+@Configuration
+open class BlueprintPropertyConfiguration {
+ @Autowired
+ lateinit var environment: Environment
+
+ @Bean
+ open fun bluePrintPropertyBinder(): Binder {
+ val configurationPropertySource = ConfigurationPropertySources.get(environment)
+ return Binder(configurationPropertySource)
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt
new file mode 100644
index 00000000..10b8ceb5
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt
@@ -0,0 +1,29 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.core
+
+import org.springframework.boot.context.properties.bind.Bindable
+import org.springframework.boot.context.properties.bind.Binder
+import org.springframework.stereotype.Service
+
+@Service
+open class BluePrintProperties(var bluePrintPropertyBinder: Binder) {
+
+ fun <T> propertyBeanType(prefix: String, type: Class<T>): T {
+ return bluePrintPropertyBinder.bind(prefix, Bindable.of(type)).get()
+ }
+} \ No newline at end of file
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 427063e4..b0483dc3 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
@@ -18,10 +18,8 @@
package org.onap.ccsdk.apps.blueprintsprocessor.core.api.data
import com.fasterxml.jackson.annotation.JsonFormat
-import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.ObjectNode
import io.swagger.annotations.ApiModelProperty
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import java.util.*
/**
@@ -30,28 +28,6 @@ import java.util.*
* DATE : 8/15/2018
*/
-open class ResourceResolutionInput {
- @get:ApiModelProperty(required = true)
- lateinit var commonHeader: CommonHeader
- @get:ApiModelProperty(required = true)
- lateinit var actionIdentifiers: ActionIdentifiers
- @get:ApiModelProperty(required = true)
- lateinit var resourceAssignments: MutableList<ResourceAssignment>
- @get:ApiModelProperty(required = true)
- lateinit var payload: ObjectNode
-}
-
-open class ResourceResolutionOutput {
- @get:ApiModelProperty(required = true)
- lateinit var commonHeader: CommonHeader
- @get:ApiModelProperty(required = true)
- lateinit var actionIdentifiers: ActionIdentifiers
- @get:ApiModelProperty(required = true)
- lateinit var status: Status
- @get:ApiModelProperty(required = true)
- lateinit var resourceAssignments: MutableList<ResourceAssignment>
-}
-
open class ExecutionServiceInput {
@get:ApiModelProperty(required = true)
lateinit var commonHeader: CommonHeader
@@ -59,7 +35,6 @@ open class ExecutionServiceInput {
lateinit var actionIdentifiers: ActionIdentifiers
@get:ApiModelProperty(required = true)
lateinit var payload: ObjectNode
- var metadata: MutableMap<String, JsonNode> = hashMapOf()
}
open class ExecutionServiceOutput {
@@ -71,7 +46,6 @@ open class ExecutionServiceOutput {
var status: Status = Status()
@get:ApiModelProperty(required = true)
lateinit var payload: ObjectNode
- var metadata: MutableMap<String, JsonNode> = hashMapOf()
}
open class ActionIdentifiers {
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt
deleted file mode 100644
index 80ad0e67..00000000
--- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.core.factory
-
-import com.att.eelf.configuration.EELFManager
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
-import org.springframework.context.ApplicationContext
-import org.springframework.context.ApplicationContextAware
-import org.springframework.context.annotation.Configuration
-
-/**
- * ResourceAssignmentProcessorFactory
- *
- * @author Brinda Santh
- */
-@Configuration
-open class ResourceAssignmentProcessorFactory : ApplicationContextAware {
-
- private val log = EELFManager.getInstance().getLogger(ResourceAssignmentProcessorFactory::class.java)
-
- var resourceAssignmentProcessors: MutableMap<String, ResourceAssignmentProcessor> = hashMapOf()
-
- fun getInstance(instanceName: String): ResourceAssignmentProcessor? {
- log.trace("looking for Resource Assignment Processor : {}", instanceName)
- return resourceAssignmentProcessors.get(instanceName)
- }
-
- fun injectInstance(instanceName: String, resourceAssignmentProcessor: ResourceAssignmentProcessor) {
- this.resourceAssignmentProcessors[instanceName] = resourceAssignmentProcessor
- }
-
- override fun setApplicationContext(context: ApplicationContext) {
- resourceAssignmentProcessors = context.getBeansOfType(ResourceAssignmentProcessor::class.java)
- log.info("Injected Resource Assignment Processor : {}", resourceAssignmentProcessors)
- }
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/interfaces/BluePrintCatalogService.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/interfaces/BluePrintCatalogService.kt
new file mode 100644
index 00000000..64847964
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/interfaces/BluePrintCatalogService.kt
@@ -0,0 +1,24 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.core.interfaces
+
+interface BluePrintCatalogService {
+ /**
+ * Get the Blueprint from Data Base and Download it under working directory and return the path path
+ */
+ fun prepareBluePrint(name: String, version: String): String
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt
new file mode 100644
index 00000000..31dca33b
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt
@@ -0,0 +1,47 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.core.utils
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+
+
+class PayloadUtils {
+
+ companion object {
+
+ fun prepareInputsFromWorkflowPayload(bluePrintRuntimeService: BluePrintRuntimeService<*>, payload: JsonNode, workflowName: String) {
+ val input = payload.get("$workflowName-request")
+ bluePrintRuntimeService.assignWorkflowInputs(workflowName, input)
+ }
+
+ fun prepareDynamicInputsFromWorkflowPayload(bluePrintRuntimeService: BluePrintRuntimeService<*>, payload: JsonNode, workflowName: String) {
+ val input = payload.get("$workflowName-request")
+ val propertyFields = input.get("$workflowName-properties")
+ prepareDynamicInputsFromComponentPayload(bluePrintRuntimeService, propertyFields)
+ }
+
+ fun prepareDynamicInputsFromComponentPayload(bluePrintRuntimeService: BluePrintRuntimeService<*>, payload: JsonNode) {
+ payload.fields().forEach { property ->
+ val path = StringBuilder(BluePrintConstants.PATH_INPUTS)
+ .append(BluePrintConstants.PATH_DIVIDER).append(property.key).toString()
+ bluePrintRuntimeService.put(path, property.value)
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml
index 0139e74d..4b11f83f 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml
@@ -15,40 +15,45 @@
~ 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>commons</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- </parent>
+ 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>commons</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </parent>
- <artifactId>db-lib</artifactId>
- <packaging>jar</packaging>
- <name>Blueprints Processor DB Lib</name>
- <description>Blueprints Processor DB Lib</description>
+ <artifactId>db-lib</artifactId>
+ <packaging>jar</packaging>
+ <name>Blueprints Processor DB Lib</name>
+ <description>Blueprints Processor DB Lib</description>
- <dependencies>
-
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-data-jpa</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.validation</groupId>
- <artifactId>validation-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- </dependency>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mariadb.jdbc</groupId>
+ <artifactId>mariadb-java-client</artifactId>
+ </dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-testing</artifactId>
<scope>test</scope>
</dependency>
-
- </dependencies>
+ </dependencies>
</project>
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt
new file mode 100644
index 00000000..0bdee9be
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt
@@ -0,0 +1,41 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.db
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
+import org.springframework.boot.context.properties.EnableConfigurationProperties
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+@ComponentScan
+@EnableConfigurationProperties
+open class BluePrintDBLibConfiguration(private var bluePrintProperties: BluePrintProperties) {
+
+ @Bean("primary-database-properties")
+ open fun getPrimaryProperties(): PrimaryDataSourceProperties {
+ return bluePrintProperties.propertyBeanType(DBLibConstants.PREFIX_DB_PRIMARY,
+ PrimaryDataSourceProperties::class.java)
+ }
+}
+
+class DBLibConstants {
+ companion object {
+ const val PREFIX_DB_PRIMARY: String = "blueprintsprocessor.db.primary"
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibData.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibData.kt
new file mode 100644
index 00000000..a16e5565
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibData.kt
@@ -0,0 +1,29 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.db
+
+
+open class PrimaryDataSourceProperties {
+ lateinit var url: String
+ lateinit var username: String
+ lateinit var password: String
+ lateinit var driverClassName: String
+ lateinit var hibernateHbm2ddlAuto: String
+ lateinit var hibernateDDLAuto: String
+ lateinit var hibernateNamingStrategy: String
+ lateinit var hibernateDialect: String
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibGenericService.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibGenericService.kt
new file mode 100644
index 00000000..86420f9a
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibGenericService.kt
@@ -0,0 +1,28 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.db
+
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
+
+interface BluePrintDBLibGenericService {
+
+ fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate
+
+ fun query(sql: String, params: Map<String, Any>): List<Map<String, Any>>
+
+ fun update(sql: String, params: Map<String, Any>): Int
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt
new file mode 100644
index 00000000..bf76e213
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt
@@ -0,0 +1,85 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.db.primary
+
+import org.onap.ccsdk.apps.blueprintsprocessor.db.PrimaryDataSourceProperties
+import org.slf4j.LoggerFactory
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import org.springframework.context.annotation.Primary
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
+import org.springframework.jdbc.datasource.DriverManagerDataSource
+import org.springframework.orm.jpa.JpaTransactionManager
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
+import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter
+import org.springframework.transaction.PlatformTransactionManager
+import java.util.*
+import javax.sql.DataSource
+
+@Configuration
+@EnableJpaRepositories(
+ basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor.db.primary"],
+ entityManagerFactoryRef = "primaryEntityManager",
+ transactionManagerRef = "primaryTransactionManager"
+)
+open class PrimaryDatabaseConfiguration(private val primaryDataSourceProperties: PrimaryDataSourceProperties) {
+ val log = LoggerFactory.getLogger(PrimaryDatabaseConfiguration::class.java)!!
+
+ @Primary
+ @Bean("primaryEntityManager")
+ open fun primaryEntityManager(): LocalContainerEntityManagerFactoryBean {
+ val em = LocalContainerEntityManagerFactoryBean()
+ em.dataSource = primaryDataSource()
+ em.setPackagesToScan(
+ "org.onap.ccsdk.apps.blueprintsprocessor.db.primary")
+
+ val vendorAdapter = HibernateJpaVendorAdapter()
+ em.jpaVendorAdapter = vendorAdapter
+ val properties = HashMap<String, Any>()
+ properties["hibernate.hbm2ddl.auto"] = primaryDataSourceProperties.hibernateHbm2ddlAuto
+ properties["hibernate.dialect"] = primaryDataSourceProperties.hibernateDialect
+ em.jpaPropertyMap = properties
+ return em
+ }
+
+ @Primary
+ @Bean("primaryDataSource")
+ open fun primaryDataSource(): DataSource {
+ val dataSource = DriverManagerDataSource()
+ dataSource.setDriverClassName(primaryDataSourceProperties.driverClassName)
+ dataSource.url = primaryDataSourceProperties.url
+ dataSource.username = primaryDataSourceProperties.username
+ dataSource.password = primaryDataSourceProperties.password
+ return dataSource
+ }
+
+ @Primary
+ @Bean("primaryTransactionManager")
+ open fun primaryTransactionManager(): PlatformTransactionManager {
+ val transactionManager = JpaTransactionManager()
+ transactionManager.entityManagerFactory = primaryEntityManager().getObject()
+ log.info("Initialised Primary Transaction Manager for url ${primaryDataSourceProperties.url}")
+ return transactionManager
+ }
+
+ @Bean("primaryNamedParameterJdbcTemplate")
+ open fun primaryNamedParameterJdbcTemplate(primaryDataSource: DataSource): NamedParameterJdbcTemplate {
+ return NamedParameterJdbcTemplate(primaryDataSource)
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/service/PrimaryDBLibGenericService.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/service/PrimaryDBLibGenericService.kt
new file mode 100644
index 00000000..87f32ef2
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/service/PrimaryDBLibGenericService.kt
@@ -0,0 +1,38 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.db.primary.service
+
+import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibGenericService
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
+import org.springframework.stereotype.Service
+
+@Service
+class PrimaryDBLibGenericService(private val primaryNamedParameterJdbcTemplate: NamedParameterJdbcTemplate)
+ : BluePrintDBLibGenericService {
+
+ override fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate {
+ return primaryNamedParameterJdbcTemplate
+ }
+
+ override fun query(sql: String, params: Map<String, Any>): List<Map<String, Any>> {
+ return primaryNamedParameterJdbcTemplate.queryForList(sql, params)
+ }
+
+ override fun update(sql: String, params: Map<String, Any>): Int {
+ return primaryNamedParameterJdbcTemplate.update(sql, params)
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfigurationTest.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfigurationTest.kt
new file mode 100644
index 00000000..aa48c8e3
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfigurationTest.kt
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.db.primary
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfiguration
+import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibConfiguration
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import javax.sql.DataSource
+import kotlin.test.assertNotNull
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [BlueprintPropertyConfiguration::class, BluePrintProperties::class,
+ BluePrintDBLibConfiguration::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+class PrimaryDatabaseConfigurationTest {
+
+ @Autowired
+ lateinit var primaryDataSource: DataSource
+
+ @Test
+ fun testPrimaryDatabaseConfiguration() {
+ assertNotNull(primaryDataSource, " failed to create primary data source")
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/application-test.properties b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/application-test.properties
new file mode 100644
index 00000000..672ff80f
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/application-test.properties
@@ -0,0 +1,24 @@
+# suppress inspection "UnusedProperty" for whole file
+#
+# 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.
+#
+blueprintsprocessor.db.primary.url=jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE
+blueprintsprocessor.db.primary.username=sa
+blueprintsprocessor.db.primary.password=
+blueprintsprocessor.db.primary.driverClassName=org.h2.Driver
+blueprintsprocessor.db.primary.hibernateHbm2ddlAuto=create-drop
+blueprintsprocessor.db.primary.hibernateDDLAuto=update
+blueprintsprocessor.db.primary.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy
+blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.H2Dialect \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/logback-test.xml
new file mode 100644
index 00000000..f9ec9fe5
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/logback-test.xml
@@ -0,0 +1,35 @@
+<!--
+ ~ 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.test" level="warn"/>
+ <logger name="org.springframework" level="warn"/>
+ <logger name="org.hibernate" level="info"/>
+ <logger name="org.onap.ccsdk.apps.blueprintsprocessor" level="info"/>
+
+ <root level="warn">
+ <appender-ref ref="STDOUT"/>
+ </root>
+
+</configuration>
diff --git a/ms/blueprintsprocessor/modules/commons/pom.xml b/ms/blueprintsprocessor/modules/commons/pom.xml
index 7bfec58c..f38ccabf 100644
--- a/ms/blueprintsprocessor/modules/commons/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/pom.xml
@@ -38,6 +38,17 @@
<groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
<artifactId>resource-dict</artifactId>
</dependency>
+ <!-- Test Dependencies -->
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
index 6dfe111c..da6194ad 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
@@ -15,23 +15,23 @@
~ 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>commons</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- </parent>
+ 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>commons</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </parent>
- <artifactId>rest-lib</artifactId>
- <packaging>jar</packaging>
- <name>Blueprints Processor Rest Lib</name>
- <description>Blueprints Processor Rest Lib</description>
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-webflux</artifactId>
- </dependency>
- </dependencies>
+ <artifactId>rest-lib</artifactId>
+ <packaging>jar</packaging>
+ <name>Blueprints Processor Rest Lib</name>
+ <description>Blueprints Processor Rest Lib</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>core</artifactId>
+ </dependency>
+ </dependencies>
</project>
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
new file mode 100644
index 00000000..50d69aee
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
@@ -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.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.rest
+
+import org.springframework.boot.context.properties.EnableConfigurationProperties
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+@ComponentScan
+@EnableConfigurationProperties
+open class BluePrintRestLibConfiguration
+
+
+class RestLibConstants {
+ companion object {
+ const val TYPE_BASIC_AUTH = "basic-auth"
+ const val TYPE_SSL_BASIC_AUTH = "ssl-basic-auth"
+ const val TYPE_DME2_PROXY = "dme2-proxy"
+ const val TYPE_POLICY_MANAGER = "policy-manager"
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt
new file mode 100644
index 00000000..faf4fd4d
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt
@@ -0,0 +1,50 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.rest
+
+open class RestClientProperties {
+ lateinit var type: String
+ lateinit var url: String
+ lateinit var userId: String
+}
+
+open class BasicAuthRestClientProperties : RestClientProperties() {
+ var passwd: String? = null
+}
+
+open class SSLBasicAuthRestClientProperties : RestClientProperties() {
+ lateinit var sslTrust: String
+ lateinit var sslTrustPasswd: String
+ lateinit var sslKey: String
+ lateinit var sslKeyPasswd: String
+}
+
+open class DME2RestClientProperties : RestClientProperties() {
+ lateinit var service: String
+ lateinit var subContext: String
+ lateinit var version: String
+ lateinit var envContext: String
+ lateinit var routeOffer: String
+ var partner: String? = null
+ lateinit var appId: String
+}
+
+open class PolicyManagerRestClientProperties : RestClientProperties() {
+ lateinit var env: String
+ lateinit var clientAuth: String
+ lateinit var authorisation: String
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
new file mode 100644
index 00000000..b79034b4
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
@@ -0,0 +1,40 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
+
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
+import org.springframework.web.reactive.function.client.WebClient
+
+
+class BasicAuthRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService {
+
+ override fun webClient(): WebClient {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun <T> getResource(path: String, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
new file mode 100644
index 00000000..21d080d5
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
@@ -0,0 +1,87 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.*
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.springframework.stereotype.Service
+
+@Service
+open class BluePrintRestLibPropertyService(private var bluePrintProperties: BluePrintProperties) {
+
+ @Throws(BluePrintProcessorException::class)
+ fun restClientProperties(prefix: String): RestClientProperties {
+ val type = bluePrintProperties.propertyBeanType("$prefix.type", String::class.java)
+ return when (type) {
+ RestLibConstants.TYPE_BASIC_AUTH -> {
+ basicAuthRestClientProperties(prefix)
+ }
+ RestLibConstants.TYPE_SSL_BASIC_AUTH -> {
+ sslBasicAuthRestClientProperties(prefix)
+ }
+ RestLibConstants.TYPE_DME2_PROXY -> {
+ dme2ProxyClientProperties(prefix)
+ }
+ RestLibConstants.TYPE_POLICY_MANAGER -> {
+ policyManagerRestClientProperties(prefix)
+ }
+ else -> {
+ throw BluePrintProcessorException("Rest adaptor($type) is not supported")
+ }
+ }
+ }
+
+ @Throws(BluePrintProcessorException::class)
+ fun blueprintWebClientService(selector: String): BlueprintWebClientService {
+ val prefix = "blueprintsprocessor.restclient.$selector"
+ val beanProperties = restClientProperties(prefix)
+ when (beanProperties) {
+ is BasicAuthRestClientProperties -> {
+ return BasicAuthRestClientService(beanProperties)
+ }
+ is SSLBasicAuthRestClientProperties -> {
+ return SSLBasicAuthRestClientService(beanProperties)
+ }
+ is DME2RestClientProperties -> {
+ return DME2ProxyRestClientService(beanProperties)
+ }
+ else -> {
+ throw BluePrintProcessorException("couldn't get rest service for selector($selector)")
+ }
+ }
+
+ }
+
+ fun basicAuthRestClientProperties(prefix: String): BasicAuthRestClientProperties {
+ return bluePrintProperties.propertyBeanType(prefix, BasicAuthRestClientProperties::class.java)
+ }
+
+ fun sslBasicAuthRestClientProperties(prefix: String): SSLBasicAuthRestClientProperties {
+ return bluePrintProperties.propertyBeanType(prefix, SSLBasicAuthRestClientProperties::class.java)
+ }
+
+ fun dme2ProxyClientProperties(prefix: String): DME2RestClientProperties {
+ return bluePrintProperties.propertyBeanType(prefix, DME2RestClientProperties::class.java)
+ }
+
+ fun policyManagerRestClientProperties(prefix: String): PolicyManagerRestClientProperties {
+ return bluePrintProperties.propertyBeanType(prefix, PolicyManagerRestClientProperties::class.java)
+ }
+}
+
+
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
new file mode 100644
index 00000000..232f4bb0
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
@@ -0,0 +1,32 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
+
+import org.springframework.web.reactive.function.client.WebClient
+
+interface BlueprintWebClientService {
+
+ fun webClient(): WebClient
+
+ fun <T> getResource(path: String, responseType: Class<T>): T
+
+ fun <T> postResource(path: String, request: Any, responseType: Class<T>): T
+
+ fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T
+
+}
+
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt
new file mode 100644
index 00000000..bd46ced1
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt
@@ -0,0 +1,38 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
+
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
+import org.springframework.web.reactive.function.client.WebClient
+
+class DME2ProxyRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService {
+ override fun webClient(): WebClient {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun <T> getResource(path: String, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt
new file mode 100644
index 00000000..8b4add10
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt
@@ -0,0 +1,38 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
+
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
+import org.springframework.web.reactive.function.client.WebClient
+
+class SSLBasicAuthRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService {
+ override fun webClient(): WebClient {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun <T> getResource(path: String, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties
new file mode 100644
index 00000000..2ce87147
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties
@@ -0,0 +1,16 @@
+#
+# 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.
+#
+
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestPropertyPlaceHolderConfigurationTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestPropertyPlaceHolderConfigurationTest.kt
new file mode 100644
index 00000000..d5e27430
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestPropertyPlaceHolderConfigurationTest.kt
@@ -0,0 +1,57 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfiguration
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.BluePrintRestLibConfiguration
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertNotNull
+
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, BlueprintPropertyConfiguration::class, BluePrintProperties::class])
+@TestPropertySource(properties =
+["blueprintsprocessor.restclient.sample.type=basic-auth",
+ "blueprintsprocessor.restclient.sample.url=http://localhost:8080",
+ "blueprintsprocessor.restclient.sample.userId=sampleuser"])
+
+class RestPropertyPlaceHolderConfigurationTest {
+
+ @Autowired
+ lateinit var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService
+
+ @Test
+ fun testRestClientProperties() {
+ val properties = bluePrintRestLibPropertyService.restClientProperties("blueprintsprocessor.restclient.sample")
+ assertNotNull(properties, "failed to create property bean")
+ assertNotNull(properties.url, "failed to get url property in property bean")
+ }
+
+ @Test
+ fun testBlueprintWebClientService() {
+ val blueprintWebClientService = bluePrintRestLibPropertyService.blueprintWebClientService("sample")
+ assertNotNull(blueprintWebClientService, "failed to create blueprintWebClientService")
+ }
+
+}
+
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml
new file mode 100644
index 00000000..f9ec9fe5
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml
@@ -0,0 +1,35 @@
+<!--
+ ~ 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.test" level="warn"/>
+ <logger name="org.springframework" level="warn"/>
+ <logger name="org.hibernate" level="info"/>
+ <logger name="org.onap.ccsdk.apps.blueprintsprocessor" level="info"/>
+
+ <root level="warn">
+ <appender-ref ref="STDOUT"/>
+ </root>
+
+</configuration>
diff --git a/ms/blueprintsprocessor/modules/inbounds/pom.xml b/ms/blueprintsprocessor/modules/inbounds/pom.xml
index e26af0f0..91912c83 100644
--- a/ms/blueprintsprocessor/modules/inbounds/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/pom.xml
@@ -45,5 +45,19 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-test-junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito2</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/resource/api/ResourceResolutionController.java b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/resource/api/ResourceResolutionController.java
index 8aeb4153..fb833a57 100644
--- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/resource/api/ResourceResolutionController.java
+++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/resource/api/ResourceResolutionController.java
@@ -16,12 +16,12 @@
package org.onap.ccsdk.apps.blueprintsprocessor.resource.api;
-import io.swagger.annotations.ApiOperation;
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput;
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput;
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.ResourceResolutionService;
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionService;
import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
/**
@@ -45,12 +45,4 @@ public class ResourceResolutionController {
Mono<String> ping() {
return Mono.just("Success");
}
-
- @RequestMapping(path = "/resolve-mapping", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation(value = "Resolve Resource Mappings",
- notes = "Also returns a link to retrieve all students with rel - all-students")
- public @ResponseBody
- Mono<ResourceResolutionOutput> resolveResource(@RequestBody ResourceResolutionInput resourceResolutionInput) {
- return Mono.just(resourceResolutionService.resolveResource(resourceResolutionInput));
- }
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
index a4c7aaf0..f319ca41 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
@@ -15,17 +15,59 @@
~ 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.0-SNAPSHOT</version>
- </parent>
+ 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.0-SNAPSHOT</version>
+ </parent>
- <artifactId>selfservice-api</artifactId>
- <packaging>jar</packaging>
- <name>Blueprints Processor Selfservice API</name>
- <description>Blueprints Processor Selfservice API</description>
+ <artifactId>selfservice-api</artifactId>
+ <packaging>jar</packaging>
+ <name>Blueprints Processor Selfservice API</name>
+ <description>Blueprints Processor Selfservice API</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-testing</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>kr.motd.maven</groupId>
+ <artifactId>os-maven-plugin</artifactId>
+ <version>1.6.1</version>
+ </extension>
+ </extensions>
+ <plugins>
+ <plugin>
+ <groupId>org.xolstice.maven.plugins</groupId>
+ <artifactId>protobuf-maven-plugin</artifactId>
+ <version>0.6.1</version>
+ <configuration>
+ <protocArtifact>
+ com.google.protobuf:protoc:3.5.1-1:exe:${os.detected.classifier}
+ </protocArtifact>
+ <pluginId>grpc-java</pluginId>
+ <pluginArtifact>
+ io.grpc:protoc-gen-grpc-java:1.16.1:exe:${os.detected.classifier}
+ </pluginArtifact>
+ <protoSourceRoot>./../../../../../components/model-catalog/api-definition</protoSourceRoot>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ <goal>compile-custom</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintCatalogServiceImpl.kt
new file mode 100644
index 00000000..01c9a39e
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintCatalogServiceImpl.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.apps.blueprintsprocessor.core.interfaces.BluePrintCatalogService
+import org.springframework.stereotype.Service
+import java.io.File
+
+@Service
+class BluePrintCatalogServiceImpl(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration) : BluePrintCatalogService {
+
+ override fun prepareBluePrint(name: String, version: String): String {
+ //TODO("Get the Blueprint from the DB")
+ return bluePrintCoreConfiguration.deployPath.plus(File.separator)
+ .plus(name).plus(File.separator).plus(version)
+
+ }
+} \ 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/BluePrintManagementGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt
new file mode 100644
index 00000000..17191f31
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt
@@ -0,0 +1,63 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
+
+import io.grpc.stub.StreamObserver
+import org.apache.commons.io.FileUtils
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.apps.controllerblueprints.management.api.*
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+import java.io.File
+
+@Service
+class BluePrintManagementGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration)
+ : BluePrintManagementServiceGrpc.BluePrintManagementServiceImplBase() {
+
+ private val log = LoggerFactory.getLogger(BluePrintManagementGRPCHandler::class.java)
+
+ override fun uploadBlueprint(request: BluePrintUploadInput, responseObserver: StreamObserver<BluePrintUploadOutput>) {
+ val response = BluePrintUploadOutput.newBuilder().setCommonHeader(request.commonHeader).build()
+ try {
+ val blueprintName = request.blueprintName
+ val blueprintVersion = request.blueprintVersion
+ val filePath = "${bluePrintCoreConfiguration.archivePath}/$blueprintName/$blueprintVersion"
+ val blueprintDir = File(filePath)
+
+ log.info("Re-creating blueprint directory(${blueprintDir.absolutePath})")
+ FileUtils.deleteDirectory(blueprintDir)
+ FileUtils.forceMkdir(blueprintDir)
+
+ val file = File("${blueprintDir.absolutePath}/$blueprintName.zip")
+ log.info("Writing CBA File under :${file.absolutePath}")
+
+ val fileChunk = request.fileChunk
+
+ file.writeBytes(fileChunk.chunk.toByteArray()).apply {
+ log.info("CBA file(${file.absolutePath} written successfully")
+ }
+ } catch (e: Exception) {
+ log.error("failed to upload file ", e)
+ }
+ responseObserver.onNext(response)
+ responseObserver.onCompleted()
+ }
+
+ override fun removeBlueprint(request: BluePrintRemoveInput?, responseObserver: StreamObserver<BluePrintRemoveOutput>?) {
+ //TODO
+ }
+} \ 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/BluePrintProcessingGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt
new file mode 100644
index 00000000..2a5983d0
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
+
+import com.google.protobuf.util.JsonFormat
+import io.grpc.stub.StreamObserver
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
+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
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+
+@Service
+class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration)
+ : BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() {
+ private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandler::class.java)
+
+ override fun process(request: ExecutionServiceInput,
+ responseObserver: StreamObserver<ExecutionServiceOutput>) {
+
+ val json = JsonFormat.printer().print(request)
+
+ //log.info("Received GRPC request ${json}")
+ //TODO( Handle Processing Response")
+ val response = ExecutionServiceOutput.newBuilder().setCommonHeader(request.commonHeader).build()
+ responseObserver.onNext(response)
+ 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
new file mode 100644
index 00000000..aa44a060
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
@@ -0,0 +1,52 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.interfaces.BluePrintCatalogService
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintDGExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+
+@Service
+class ExecutionServiceHandler(private val bluePrintCatalogService: BluePrintCatalogService,
+ private val blueprintDGExecutionService: BlueprintDGExecutionService) {
+
+ private val log = LoggerFactory.getLogger(ExecutionServiceHandler::class.toString())
+
+ fun process(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
+
+ val requestId = executionServiceInput.commonHeader.requestId
+ log.info("processing request id $requestId")
+
+ val actionIdentifiers = executionServiceInput.actionIdentifiers
+
+ val blueprintName = actionIdentifiers.blueprintName
+ val blueprintVersion = actionIdentifiers.blueprintVersion
+
+ val basePath = bluePrintCatalogService.prepareBluePrint(blueprintName, blueprintVersion)
+ log.info("blueprint base path $basePath")
+
+ val blueprintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(requestId, basePath)
+
+ return blueprintDGExecutionService.executeDirectedGraph(blueprintRuntimeService, executionServiceInput)
+ }
+
+
+} \ 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
new file mode 100644
index 00000000..c870bf7f
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandlerTest.kt
@@ -0,0 +1,92 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.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.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.apps.controllerblueprints.management.api.BluePrintManagementServiceGrpc
+import org.onap.ccsdk.apps.controllerblueprints.management.api.BluePrintUploadInput
+import org.onap.ccsdk.apps.controllerblueprints.management.api.CommonHeader
+import org.onap.ccsdk.apps.controllerblueprints.management.api.FileChunk
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+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.assertNotNull
+import kotlin.test.assertTrue
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [BluePrintManagementGRPCHandler::class, BluePrintCoreConfiguration::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+class BluePrintManagementGRPCHandlerTest {
+
+ private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandlerTest::class.java)!!
+
+ @get:Rule
+ val grpcServerRule = GrpcServerRule().directExecutor()
+
+ @Autowired
+ lateinit var bluePrintManagementGRPCHandler: BluePrintManagementGRPCHandler
+
+ @BeforeTest
+ fun init() {
+ // Create a server, add service, start, and register for automatic graceful shutdown.
+ grpcServerRule.serviceRegistry.addService(bluePrintManagementGRPCHandler)
+ }
+
+ @AfterTest
+ fun cleanDir() {
+ FileUtils.deleteDirectory(File("./target/blueprints"))
+ }
+
+ @Test
+ fun testFileUpload() {
+ val blockingStub = BluePrintManagementServiceGrpc.newBlockingStub(grpcServerRule.channel)
+
+ val file = Paths.get("./src/test/resources/test-cba.zip").toFile()
+ assertTrue(file.exists(), "couldnt get file ${file.absolutePath}")
+
+ val commonHeader = CommonHeader.newBuilder()
+ .setTimestamp("2012-04-23T18:25:43.511Z")
+ .setOriginatorId("System")
+ .setRequestId("1234")
+ .setSubRequestId("1234-56").build()
+
+ val fileChunk = FileChunk.newBuilder().setChunk(ByteString.copyFrom(file.inputStream().readBytes()))
+ .build()
+
+ val input = BluePrintUploadInput.newBuilder()
+ .setCommonHeader(commonHeader)
+ .setBlueprintName("sample")
+ .setBlueprintVersion("1.0.0")
+ .setFileChunk(fileChunk)
+ .build()
+
+ val output = blockingStub.uploadBlueprint(input)
+ assertNotNull(output, "failed to get upload response")
+ }
+} \ 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
new file mode 100644
index 00000000..6d5d633c
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt
@@ -0,0 +1,81 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
+
+
+import com.google.protobuf.util.JsonFormat
+import io.grpc.testing.GrpcServerRule
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.processing.api.CommonHeader
+import org.onap.ccsdk.apps.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc
+import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.BeforeTest
+import kotlin.test.assertNotNull
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [BluePrintProcessingGRPCHandler::class, BluePrintCoreConfiguration::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+class BluePrintProcessingGRPCHandlerTest {
+
+ private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandlerTest::class.java)!!
+
+ @get:Rule
+ val grpcServerRule = GrpcServerRule().directExecutor()
+
+ @Autowired
+ lateinit var bluePrintProcessingGRPCHandler: BluePrintProcessingGRPCHandler
+
+ @BeforeTest
+ fun init() {
+ // Create a server, add service, start, and register for automatic graceful shutdown.
+ grpcServerRule.serviceRegistry.addService(bluePrintProcessingGRPCHandler)
+ }
+
+ @Test
+ fun testSelfServiceGRPCHandler() {
+
+ val blockingStub = BluePrintProcessingServiceGrpc.newBlockingStub(grpcServerRule.channel)
+
+ val commonHeader = CommonHeader.newBuilder()
+ .setTimestamp("2012-04-23T18:25:43.511Z")
+ .setOriginatorId("System")
+ .setRequestId("1234")
+ .setSubRequestId("1234-56").build()
+
+ val jsonContent = JacksonUtils.getClassPathFileContent("execution-input/sample-payload.json")
+ val payloadBuilder = ExecutionServiceInput.newBuilder().payloadBuilder
+ JsonFormat.parser().merge(jsonContent, payloadBuilder)
+
+ val input = ExecutionServiceInput.newBuilder()
+ .setCommonHeader(commonHeader)
+ .setPayload(payloadBuilder.build())
+ .build()
+
+ val response = blockingStub.process(input)
+ assertNotNull(response, "Response is null")
+ }
+
+} \ 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/ExecutionServiceHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt
new file mode 100644
index 00000000..e9e10307
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt
@@ -0,0 +1,50 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.mock.MockBluePrintCatalogService
+import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.mock.MockBlueprintDGExecutionService
+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.junit4.SpringRunner
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [MockBluePrintCatalogService::class,
+ MockBlueprintDGExecutionService::class, ExecutionServiceHandler::class])
+class ExecutionServiceHandlerTest {
+
+ @Autowired
+ lateinit var executionServiceHandler: ExecutionServiceHandler
+
+ @Test
+ fun testProcess() {
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/default-input.json", ExecutionServiceInput::class.java)!!
+ executionServiceHandler.process(executionServiceInput)
+
+ }
+
+}
+
+
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/mock/SelfServiceApiMocks.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/mock/SelfServiceApiMocks.kt
new file mode 100644
index 00000000..bc200f4c
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/mock/SelfServiceApiMocks.kt
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.mock
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.interfaces.BluePrintCatalogService
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintDGExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.stereotype.Service
+import kotlin.test.assertNotNull
+
+@Service
+class MockBlueprintDGExecutionService : BlueprintDGExecutionService {
+ override fun executeDirectedGraph(bluePrintRuntimeService: BluePrintRuntimeService<*>, executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
+
+ assertNotNull(executionServiceInput, "failed to get executionServiceInput")
+
+ val executionServiceOutput = ExecutionServiceOutput()
+ executionServiceOutput.commonHeader = executionServiceInput.commonHeader
+ return executionServiceOutput
+ }
+}
+
+@Service
+class MockBluePrintCatalogService : BluePrintCatalogService {
+ override fun prepareBluePrint(name: String, version: String): String {
+ assertNotNull(name, "failed to get blueprint Name")
+ assertNotNull(version, "failed to get blueprint version")
+ return "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration"
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/application-test.properties b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/application-test.properties
new file mode 100644
index 00000000..edb51022
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/application-test.properties
@@ -0,0 +1,17 @@
+#
+# 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.
+#
+blueprintsprocessor.blueprintDeployPath=./target/blueprints/deploy
+blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/execution-input/default-input.json b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/execution-input/default-input.json
new file mode 100644
index 00000000..47ace853
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/execution-input/default-input.json
@@ -0,0 +1,23 @@
+{
+ "commonHeader": {
+ "originatorId": "System",
+ "requestId": "1234",
+ "subRequestId": "1234-12234"
+ },
+ "actionIdentifiers": {
+ "blueprintName": "baseconfiguration",
+ "blueprintVersion": "1.0.0",
+ "actionName": "activate",
+ "mode": "sync"
+ },
+ "payload": {
+ "activate-request": {
+ "activate-properties": {
+ "request-id": "1234",
+ "action-name": "activate",
+ "scope-type": "vnf-type",
+ "hostname": "localhost"
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/execution-input/sample-payload.json b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/execution-input/sample-payload.json
new file mode 100644
index 00000000..07046aa3
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/execution-input/sample-payload.json
@@ -0,0 +1,10 @@
+{
+ "activate-request": {
+ "activate-properties": {
+ "request-id": "1234",
+ "action-name": "activate",
+ "scope-type": "vnf-type",
+ "hostname": "localhost"
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/logback.xml b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/logback.xml
new file mode 100644
index 00000000..a816a06c
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/logback.xml
@@ -0,0 +1,35 @@
+<!--
+ ~ 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="warn"/>
+ <logger name="org.hibernate" level="info"/>
+ <logger name="org.onap.ccsdk.apps.blueprintsprocessor" level="info"/>
+
+ <root level="warn">
+ <appender-ref ref="STDOUT"/>
+ </root>
+
+</configuration>
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zip b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zip
new file mode 100644
index 00000000..a62d4bfb
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zip
Binary files differ
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
index 4f0e6c0b..f9e51910 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
+++ b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
@@ -34,6 +34,14 @@
<artifactId>core</artifactId>
</dependency>
<dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>db-lib</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>rest-lib</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
<artifactId>resource-dict</artifactId>
</dependency>
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
index dfdf6259..87a925f9 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
@@ -17,9 +17,14 @@
package org.onap.ccsdk.apps.blueprintsprocessor.services.execution
+import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.node.JsonNodeFactory
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.apps.controllerblueprints.core.getAsString
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
@@ -30,6 +35,7 @@ import org.slf4j.LoggerFactory
* @author Brinda Santh
*/
abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServiceInput, ExecutionServiceOutput> {
+ @Transient
private val log = LoggerFactory.getLogger(AbstractComponentFunction::class.java)
var executionServiceInput: ExecutionServiceInput? = null
@@ -41,29 +47,67 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
var interfaceName: String = ""
var operationName: String = ""
var nodeTemplateName: String = ""
+ var operationInputs: MutableMap<String, JsonNode> = hashMapOf()
+ override fun getName(): String {
+ return stepName
+ }
override fun prepareRequest(executionServiceInput: ExecutionServiceInput): ExecutionServiceInput {
+ checkNotNull(bluePrintRuntimeService) { "failed to prepare blueprint runtime" }
+
+ check(stepName.isNotEmpty()) { "failed to assign step name" }
- this.executionServiceInput = this.executionServiceInput
+ this.executionServiceInput = executionServiceInput
processId = executionServiceInput.commonHeader.requestId
+ check(processId.isNotEmpty()) { "couldn't get process id for step($stepName)" }
+
workflowName = executionServiceInput.actionIdentifiers.actionName
+ check(workflowName.isNotEmpty()) { "couldn't get action name for step($stepName)" }
- val metadata = executionServiceInput.metadata
- stepName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_STEP)
- nodeTemplateName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE)
- interfaceName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_INTERFACE)
- operationName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_OPERATION)
+ log.info("preparing request id($processId) for workflow($workflowName) step($stepName)")
- checkNotNull(bluePrintRuntimeService) { "failed to prepare blueprint runtime" }
+ val operationInputs = bluePrintRuntimeService!!.get("$stepName-step-inputs")
+ ?: JsonNodeFactory.instance.objectNode()
+
+ operationInputs.fields().forEach {
+ this.operationInputs[it.key] = it.value
+ }
+
+ nodeTemplateName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE)
+ check(nodeTemplateName.isNotEmpty()) { "couldn't get NodeTemplate name for step($stepName)" }
+
+ interfaceName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_INTERFACE)
+ check(interfaceName.isNotEmpty()) { "couldn't get Interface name for step($stepName)" }
+
+ operationName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_OPERATION)
+ check(operationName.isNotEmpty()) { "couldn't get Operation name for step($stepName)" }
+
+
+ val operationResolvedProperties = bluePrintRuntimeService!!.resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)
+
+ this.operationInputs.putAll(operationResolvedProperties)
- log.info("prepareRequest...")
return executionServiceInput
}
override fun prepareResponse(): ExecutionServiceOutput {
log.info("Preparing Response...")
+ executionServiceOutput.commonHeader = executionServiceInput!!.commonHeader
+
+ // Resolve the Output Expression
+ val stepOutputs = bluePrintRuntimeService!!
+ .resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName)
+
+ bluePrintRuntimeService!!.put("$stepName-step-outputs", stepOutputs.asJsonNode())
+
+ // Populate Status
+ val status = Status()
+ status.eventType = "EVENT-COMPONENT-EXECUTED"
+ status.code = 200
+ status.message = BluePrintConstants.STATUS_SUCCESS
+ executionServiceOutput.status = status
return this.executionServiceOutput
}
@@ -72,4 +116,9 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
process(executionServiceInput)
return prepareResponse()
}
+
+ fun getOperationInput(key: String): JsonNode {
+ return operationInputs[key]
+ ?: throw BluePrintProcessorException("couldn't get the operation input($key) value.")
+ }
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionService.kt
index 993f10ee..9bb562b7 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionService.kt
@@ -19,7 +19,6 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.utils.SvcGraphUtils
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
@@ -55,14 +54,17 @@ class DefaultBlueprintDGExecutionService(val blueprintSvcLogicService: Blueprint
WorkflowServiceConstants.ARTIFACT_TYPE_DIRECTED_GRAPH)
// Populate the DG Path
- val dgFilePath = bluePrintRuntimeService.getAsString(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)
- .plus(File.separator).plus(artifactDefinition.file)
+ val dgFilePath = bluePrintContext.rootPath.plus(File.separator).plus(artifactDefinition.file)
log.info("Executing directed graph ($dgFilePath)")
// Create DG instance
val graph = SvcGraphUtils.getSvcGraphFromFile(dgFilePath)
+ // Assign Workflow inputs
+ val input = executionServiceInput.payload.get("$workflowName-request")
+ bluePrintRuntimeService.assignWorkflowInputs(workflowName, input)
+
// Execute the DG
return blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput) as ExecutionServiceOutput
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
index ace9f278..e514a1fb 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
@@ -16,9 +16,13 @@
package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor
+import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintSvcLogicContext
+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.sli.core.sli.SvcLogicContext
import org.onap.ccsdk.sli.core.sli.SvcLogicException
import org.onap.ccsdk.sli.core.sli.SvcLogicNode
@@ -57,13 +61,27 @@ open class ComponentExecuteNodeExecutor : ExecuteNodeExecutor() {
// Get the Component Name, NodeTemplate type is mapped to Component Name
val componentName = blueprintContext.nodeTemplateByName(nodeTemplateName).type
- log.info("executing node template($nodeTemplateName) component($componentName)")
+ val interfaceName = blueprintContext.nodeTemplateFirstInterfaceName(nodeTemplateName)
+
+ val operationName = blueprintContext.nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName)
+
+ log.info("executing node template($nodeTemplateName) component($componentName) interface($interfaceName) operation($operationName)")
// Get the Component Instance
val plugin = this.getComponentFunction(componentName)
// Set the Blueprint Service
plugin.bluePrintRuntimeService = ctx.getBluePrintService()
+ plugin.stepName = nodeTemplateName
val executionInput = ctx.getRequest() as ExecutionServiceInput
+
+ // Populate Step Meta Data
+ val stepInputs: MutableMap<String, JsonNode> = hashMapOf()
+ stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, nodeTemplateName)
+ stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, interfaceName)
+ stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, operationName)
+
+ plugin.bluePrintRuntimeService!!.put("$nodeTemplateName-step-inputs", stepInputs.asJsonNode())
+
// Get the Request from the Context and Set to the Function Input and Invoke the function
val executionOutput = plugin.apply(executionInput)
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionServiceTest.kt
index 46bb6f08..2d0dff53 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionServiceTest.kt
@@ -43,7 +43,7 @@ class BlueprintDGExecutionServiceTest {
val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
"./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
- val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/default-input.json", ExecutionServiceInput::class.java)!!
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
blueprintDGExecutionService.executeDirectedGraph(bluePrintRuntimeService, executionServiceInput)
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
index 341b6f84..7312d2de 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
@@ -20,13 +20,16 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor
-import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.utils.SvcGraphUtils
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.mock.PrototypeComponentFunction
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.mock.SingletonComponentFunction
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.context.ApplicationContext
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertEquals
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [WorkflowServiceConfiguration::class, ComponentExecuteNodeExecutor::class])
@@ -34,27 +37,57 @@ class BlueprintServiceLogicTest {
private val log = LoggerFactory.getLogger(BlueprintServiceLogicTest::class.java)
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
-
- val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/default-input.json", ExecutionServiceInput::class.java)!!
+ @Autowired
+ lateinit var applicationContext: ApplicationContext
@Autowired
- lateinit var blueprintSvcLogicService: BlueprintSvcLogicService
+ lateinit var blueprintDGExecutionService: BlueprintDGExecutionService
@Test
fun testExecuteGraphWithSingleComponent() {
- val graph = SvcGraphUtils.getSvcGraphFromClassPathFile("service-logic/one-component.xml")
- blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput)
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
+
+
+ blueprintDGExecutionService.executeDirectedGraph(bluePrintRuntimeService, executionServiceInput)
}
@Test
fun testExecuteGraphWithMultipleComponents() {
- val graph = SvcGraphUtils.getSvcGraphFromClassPathFile("service-logic/two-component.xml")
- blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput)
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/assign-activate-input.json", ExecutionServiceInput::class.java)!!
+
+ blueprintDGExecutionService.executeDirectedGraph(bluePrintRuntimeService, executionServiceInput)
+
+ }
+
+ @Test
+ fun testSingleton() {
+ val singleton1 = applicationContext.getBean(SingletonComponentFunction::class.java)
+ singleton1.stepName = "step1"
+ val singleton2 = applicationContext.getBean(SingletonComponentFunction::class.java)
+ assertEquals(singleton1.stepName, singleton2.stepName, " failed to get singleton data")
+ }
+
+ @Test
+ fun testProtoTypeFunction() {
+ val stepName1 = "step1"
+ val stepName2 = "step2"
+ val proto1 = applicationContext.getBean(PrototypeComponentFunction::class.java)
+ proto1.stepName = stepName1
+
+ val proto2 = applicationContext.getBean(PrototypeComponentFunction::class.java)
+ proto2.stepName = stepName2
+
+ assertEquals(stepName1, proto1.stepName, " Failed to match the step1 name")
+ assertEquals(stepName2, proto2.stepName, " Failed to match the step2 name")
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt
index 747be76c..1d738eef 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt
@@ -17,17 +17,19 @@
package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.mock
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
-import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Component
@Configuration
open class MockComponentConfiguration {
- @Bean(name = ["component-resource-assignment", "component-netconf-executor"])
+ @Bean(name = ["component-resource-assignment", "component-netconf-executor", "component-jython-executor"])
open fun createComponentFunction(): AbstractComponentFunction {
return MockComponentFunction()
}
@@ -35,12 +37,43 @@ open class MockComponentConfiguration {
class MockComponentFunction : AbstractComponentFunction() {
- private val log = LoggerFactory.getLogger(ComponentExecuteNodeExecutor::class.java)
+ private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
override fun process(executionRequest: ExecutionServiceInput) {
- log.info("Processing component..")
+ log.info("Processing component : ${operationInputs}")
- this.executionServiceOutput = ExecutionServiceOutput()
+ bluePrintRuntimeService!!.setNodeTemplateAttributeValue(nodeTemplateName,
+ "assignment-params", "params".asJsonPrimitive())
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ log.info("Recovering component..")
+ }
+}
+
+@Component("singleton-function")
+@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
+class SingletonComponentFunction : AbstractComponentFunction() {
+
+ private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
+
+ override fun process(executionRequest: ExecutionServiceInput) {
+ log.info("Processing component : ${operationInputs}")
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ log.info("Recovering component..")
+ }
+}
+
+@Component("prototype-function")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+class PrototypeComponentFunction : AbstractComponentFunction() {
+
+ private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
+
+ override fun process(executionRequest: ExecutionServiceInput) {
+ log.info("Processing component : ${operationInputs}")
}
override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/assign-activate-input.json b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/assign-activate-input.json
new file mode 100644
index 00000000..d63b1d31
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/assign-activate-input.json
@@ -0,0 +1,23 @@
+{
+ "commonHeader": {
+ "originatorId": "System",
+ "requestId": "1234",
+ "subRequestId": "1234-12234"
+ },
+ "actionIdentifiers": {
+ "blueprintName": "baseconfiguration",
+ "blueprintVersion": "1.0.0",
+ "actionName": "assign-activate",
+ "mode": "sync"
+ },
+ "payload": {
+ "assign-activate-request": {
+ "assign-activate-properties": {
+ "request-id": "1234",
+ "action-name": "assign-activate",
+ "scope-type": "vnf-type",
+ "hostname": "localhost"
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/default-input.json b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/default-input.json
deleted file mode 100644
index 20401fd1..00000000
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/default-input.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "commonHeader" : {
- "originatorId" : "System",
- "requestId" : "1234",
- "subRequestId" : "1234-12234"
- },
- "actionIdentifiers" : {
- "blueprintName" : "baseconfiguration",
- "blueprintVersion" : "1.0.0",
- "actionName" : "activate",
- "mode" : "sync"
- },
- "payload" : { },
- "metadata" : {
- "current-node-template" : "resource-assignment-py",
- "current-step" : "resource-assignment-py",
- "current-operation" : "process",
- "current-interface" : "ResourceAssignmentComponent"
- }
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/resource-assignment-input.json b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/resource-assignment-input.json
new file mode 100644
index 00000000..ce7bc8e5
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/resource-assignment-input.json
@@ -0,0 +1,23 @@
+{
+ "commonHeader": {
+ "originatorId": "System",
+ "requestId": "1234",
+ "subRequestId": "1234-12234"
+ },
+ "actionIdentifiers": {
+ "blueprintName": "baseconfiguration",
+ "blueprintVersion": "1.0.0",
+ "actionName": "resource-assignment",
+ "mode": "sync"
+ },
+ "payload": {
+ "resource-assignment-request": {
+ "resource-assignment-properties": {
+ "request-id": "1234",
+ "action-name": "resource-assignment",
+ "scope-type": "vnf-type",
+ "hostname": "localhost"
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/one-component.xml b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/one-component.xml
deleted file mode 100644
index 5ff26ad2..00000000
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/one-component.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<!--
- ~ Copyright © 2017-2018 AT&T Intellectual Property.
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<service-logic
- xmlns='http://www.onap.org/sdnc/svclogic'
- xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='CONFIG' version='1.0.0'>
- <method rpc='ActivateNetconf' mode='sync'>
- <block atomic="true">
- <execute plugin="resource-assignment" method="process">
- <outcome value='failure'>
- <return status="failure">
- </return>
- </outcome>
- <outcome value='success'>
- <return status='success'>
- </return>
- </outcome>
- </execute>
- </block>
- </method>
-</service-logic> \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/two-component.xml b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/two-component.xml
deleted file mode 100644
index 7de61db5..00000000
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/two-component.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<!--
- ~ Copyright © 2017-2018 AT&T Intellectual Property.
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<service-logic
- xmlns='http://www.onap.org/sdnc/svclogic'
- xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='CONFIG' version='1.0.0'>
- <method rpc='ResourceAssignAndActivate' mode='sync'>
- <block atomic="true">
- <execute plugin="resource-assignment" method="process">
- <outcome value='failure'>
- <return status="failure">
- </return>
- </outcome>
- <outcome value='success'>
- <execute plugin="resource-assignment-py" method="process">
- <outcome value='failure'>
- <return status="failure">
- </return>
- </outcome>
- <outcome value='success'>
- <return status='success'>
- </return>
- </outcome>
- </execute>
- </outcome>
- </execute>
- </block>
- </method>
-</service-logic> \ No newline at end of file
diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml
index 3ad3fef3..d8a47eff 100644
--- a/ms/blueprintsprocessor/parent/pom.xml
+++ b/ms/blueprintsprocessor/parent/pom.xml
@@ -36,6 +36,7 @@
<kotlin.maven.version>1.3.10</kotlin.maven.version>
<kotlin.couroutines.version>1.0.1</kotlin.couroutines.version>
<grpc.version>1.16.1</grpc.version>
+ <protobuff.java.utils.version>3.6.1</protobuff.java.utils.version>
<eelf.version>1.0.0</eelf.version>
<sli.version>0.3.1</sli.version>
<guava.version>26.0-jre</guava.version>
@@ -116,6 +117,11 @@
<artifactId>grpc-stub</artifactId>
<version>${grpc.version}</version>
</dependency>
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java-util</artifactId>
+ <version>${protobuff.java.utils.version}</version>
+ </dependency>
<!-- SLI Version -->
<dependency>
@@ -206,6 +212,16 @@
<artifactId>resource-resolution</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
+ <artifactId>python-executor</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
+ <artifactId>netconf-executor</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- Application Component Dependency -->
<dependency>
@@ -345,6 +361,10 @@
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java-util</artifactId>
+ </dependency>
</dependencies>
<build>
diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java
index b9c0bd19..f9dbf6d1 100644
--- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java
+++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,13 +17,20 @@
package org.onap.ccsdk.apps.controllerblueprints;
-import com.google.common.collect.Lists;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.jetbrains.annotations.NotNull;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMethod;
+
+import com.google.common.collect.Lists;
+
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.builders.ResponseMessageBuilder;
@@ -34,11 +42,6 @@ import springfox.documentation.service.ResponseMessage;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
/**
* SwaggerConfig
*
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
index 7ea81da0..aaa45e14 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
@@ -34,7 +34,6 @@ import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.BluePrintEnhanc
import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.ResourceAssignmentEnhancerService;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
-import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Service;
import java.util.HashMap;
@@ -48,7 +47,7 @@ import java.util.Map;
*/
@Service
-@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS)
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService {
private static EELFLogger log = EELFManager.getInstance().getLogger(BluePrintEnhancerService.class);
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java
index 3c92f7e9..1875a802 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java
@@ -127,7 +127,7 @@ public class ConfigModelCreateService {
String artifactName = configModel.getArtifactName();
String artifactVersion = configModel.getArtifactVersion();
String author = configModel.getUpdatedBy();
- // configModel.setTags(artifactName);
+
if (StringUtils.isBlank(author)) {
throw new BluePrintException("Artifact Author is missing in the Service Template");
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java
index a2f653c6..b2fff26e 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java
@@ -55,6 +55,7 @@ public class ConfigModelService {
private ConfigModelRepository configModelRepository;
private ConfigModelContentRepository configModelContentRepository;
private ConfigModelCreateService configModelCreateService;
+ private static final String CONFIG_MODEL_ID_FAILURE_MSG= "failed to get config model id(%d) from repo";
/**
* This is a ConfigModelService constructor.
@@ -174,7 +175,7 @@ public class ConfigModelService {
if (dbConfigModel.isPresent()) {
configModel = dbConfigModel.get();
} else {
- throw new BluePrintException(String.format("failed to get config model id(%d) from repo", id));
+ throw new BluePrintException(String.format(CONFIG_MODEL_ID_FAILURE_MSG, id));
}
return configModel;
@@ -232,7 +233,7 @@ public class ConfigModelService {
}
}
} else {
- throw new BluePrintException(String.format("failed to get config model id(%d) from repo", id));
+ throw new BluePrintException(String.format(CONFIG_MODEL_ID_FAILURE_MSG, id));
}
return cloneConfigModel;
@@ -252,7 +253,7 @@ public class ConfigModelService {
configModelContentRepository.deleteByConfigModel(dbConfigModel.get());
configModelRepository.delete(dbConfigModel.get());
} else {
- throw new BluePrintException(String.format("failed to get config model id(%d) from repo", id));
+ throw new BluePrintException(String.format(CONFIG_MODEL_ID_FAILURE_MSG, id));
}
}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java
index 2e58b53e..1ba32574 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java
@@ -20,7 +20,6 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import org.junit.Assert;
import org.junit.Before;
-import org.junit.Test;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils;
diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml
index 309b2283..b9134318 100644
--- a/ms/controllerblueprints/parent/pom.xml
+++ b/ms/controllerblueprints/parent/pom.xml
@@ -33,6 +33,8 @@
<kotlin.version>1.3.10</kotlin.version>
<kotlin.maven.version>1.3.10</kotlin.maven.version>
<kotlin.couroutines.version>1.0.1</kotlin.couroutines.version>
+ <grpc.version>1.16.1</grpc.version>
+ <protobuff.java.utils.version>3.6.1</protobuff.java.utils.version>
<eelf.version>1.0.0</eelf.version>
<guava.version>26.0-jre</guava.version>
<springfox.swagger2.version>2.9.2</springfox.swagger2.version>
@@ -127,6 +129,33 @@
<version>${kotlin.version}</version>
</dependency>
+ <!-- GRPC Dependencies -->
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-core</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-netty</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-protobuf</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-stub</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java-util</artifactId>
+ <version>${protobuff.java.utils.version}</version>
+ </dependency>
+
<!-- Database -->
<dependency>
<groupId>com.h2database</groupId>
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/Application.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/Application.java
index 1287a273..561273bf 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/Application.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/Application.java
@@ -3,6 +3,7 @@
* ONAP : CCSDK.apps
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -70,7 +71,6 @@ public class Application extends SpringBootServletInitializer {
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
- System.out.println(beanName);
log.info(beanName);
}
log.info("################################");
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicySequence.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicySequence.java
index 526f67c1..f70b0633 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicySequence.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicySequence.java
@@ -3,13 +3,14 @@
* ONAP : CCSDK.apps
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,15 +21,17 @@
package org.onap.ccsdk.apps.ms.neng.core.policy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Represents a sequence object in the policy, as a POJO.
*/
public class PolicySequence {
/**
- * The type of the policy sequence.
+ * The type of the policy sequence.
*/
- public enum Type {
- ALPHA, NUMERIC
+ public enum Type {
+ ALPHA, NUMERIC
}
private long startValue;
@@ -41,6 +44,8 @@ public class PolicySequence {
private String key;
private String value;
private Long lastReleaseSeqNumTried;
+ private Logger logger = LoggerFactory.getLogger(PolicySequence.class);
+
public long getStartValue() {
return startValue;
@@ -79,6 +84,7 @@ public class PolicySequence {
try {
this.maxValue = Long.valueOf(this.maxValueString, base);
} catch (Exception e) {
+ logger.error("Exception",e);
this.maxValue = null;
}
}
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperator.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperator.java
index 8fd30120..2a73a27e 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperator.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperator.java
@@ -128,7 +128,6 @@ public class PropertyOperator {
if (mapped == null) {
mapped = camelConverted(recipeItem);
}
- //String value = applyJavaOperation(null, recipeItem, mapped);
return applyJavaOperation(null, recipeItem, mapped);
}
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/rs/RestServiceImpl.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/rs/RestServiceImpl.java
index 3746756e..95afea21 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/rs/RestServiceImpl.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/rs/RestServiceImpl.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -43,7 +45,7 @@ public class RestServiceImpl implements RestService {
private static Logger log = Logger.getLogger(RestServiceImpl.class.getName());
private static final String INTERNAL_ERROR_MSG = "Internal error occured while processing the request.";
private static final String ERROR="error";
-
+ private static final String ERROR_500="err-0500";
@Autowired SpringService service;
@@ -73,7 +75,7 @@ public class RestServiceImpl implements RestService {
return buildErrorResponse(response);
} catch (Exception e) {
log.warning(e.getMessage());
- response.put(ERROR, buildErrorResponse("err-0500", INTERNAL_ERROR_MSG));
+ response.put(ERROR, buildErrorResponse(ERROR_500, INTERNAL_ERROR_MSG));
return buildErrorResponse(response);
}
}
@@ -94,7 +96,7 @@ public class RestServiceImpl implements RestService {
return buildErrorResponse(response);
} catch (Exception e) {
log.warning(e.getMessage());
- response.put(ERROR, buildErrorResponse("err-0500", INTERNAL_ERROR_MSG));
+ response.put(ERROR, buildErrorResponse(ERROR_500, INTERNAL_ERROR_MSG));
return buildErrorResponse(response);
}
}
@@ -122,7 +124,7 @@ public class RestServiceImpl implements RestService {
return buildResponse(response);
} catch (Exception e) {
log.warning(e.getMessage());
- response.put(ERROR, buildErrorResponse("err-0500", e.getMessage()));
+ response.put(ERROR, buildErrorResponse(ERROR_500, e.getMessage()));
return buildErrorResponse(response);
}
}
diff --git a/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/PolicyEngineResponse.java b/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/PolicyEngineResponse.java
index 0707cd34..96e9935b 100644
--- a/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/PolicyEngineResponse.java
+++ b/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/PolicyEngineResponse.java
@@ -1,5 +1,6 @@
/*******************************************************************************
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -64,7 +65,7 @@ public class PolicyEngineResponse implements Serializable {
private String property;
public PolicyEngineResponse() {
-
+ // this method does nothing
}
public String getPolicyConfigMessage() {