aboutsummaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
Diffstat (limited to 'ms')
-rwxr-xr-xms/blueprintsprocessor/application/pom.xml8
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintGRPCServer.java13
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintHttpServer.java8
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplication.java5
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/WebConfig.java47
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/AuthenticationManager.java40
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/BasicAuthServerInterceptor.java97
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/SecurityConfiguration.java59
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/SecurityContextRepository.java75
-rwxr-xr-xms/blueprintsprocessor/application/src/main/resources/application.properties3
-rw-r--r--ms/blueprintsprocessor/application/src/test/resources/application.properties6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt58
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt11
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt)37
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt)26
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt)13
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt)80
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt10
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt)28
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt12
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt9
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt)20
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json4
-rwxr-xr-xms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt5
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zipbin9189 -> 9302 bytes
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml76
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/DmaapEventPublisher.kt181
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EnvironmentContext.kt56
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EventPublisher.kt39
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/event.properties26
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/producer.properties52
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/apps/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt118
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/resources/logback-test.xml40
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/resources/preferredRoute.txt22
-rwxr-xr-xms/blueprintsprocessor/modules/commons/pom.xml1
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt33
-rwxr-xr-xms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml11
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt5
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt7
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt5
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt9
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt48
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintDesignTimeRuntimeValidatorService.kt38
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt3
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappingTests.kt46
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zipbin9189 -> 9302 bytes
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/pom.xml7
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt3
-rwxr-xr-xms/blueprintsprocessor/parent/pom.xml10
51 files changed, 1279 insertions, 239 deletions
diff --git a/ms/blueprintsprocessor/application/pom.xml b/ms/blueprintsprocessor/application/pom.xml
index 83dc7061f..f42cdfade 100755
--- a/ms/blueprintsprocessor/application/pom.xml
+++ b/ms/blueprintsprocessor/application/pom.xml
@@ -17,7 +17,8 @@
~ 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">
+<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>
@@ -40,6 +41,11 @@
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-security</artifactId>
+ </dependency>
+
<!-- North Bound -->
<dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
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
index 86fdccd4b..3ac1a6e62 100644
--- 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
@@ -18,6 +18,7 @@ package org.onap.ccsdk.apps.blueprintsprocessor;
import io.grpc.Server;
import io.grpc.ServerBuilder;
+import org.onap.ccsdk.apps.blueprintsprocessor.security.BasicAuthServerInterceptor;
import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.BluePrintManagementGRPCHandler;
import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.BluePrintProcessingGRPCHandler;
import org.slf4j.Logger;
@@ -37,9 +38,10 @@ public class BlueprintGRPCServer implements ApplicationListener<ContextRefreshed
@Autowired
private BluePrintProcessingGRPCHandler bluePrintProcessingGRPCHandler;
-
@Autowired
private BluePrintManagementGRPCHandler bluePrintManagementGRPCHandler;
+ @Autowired
+ private BasicAuthServerInterceptor authInterceptor;
@Value("${blueprintsprocessor.grpcPort}")
private Integer grpcPort;
@@ -49,10 +51,11 @@ public class BlueprintGRPCServer implements ApplicationListener<ContextRefreshed
try {
log.info("Starting Blueprint Processor GRPC Starting..");
Server server = ServerBuilder
- .forPort(grpcPort)
- .addService(bluePrintProcessingGRPCHandler)
- .addService(bluePrintManagementGRPCHandler)
- .build();
+ .forPort(grpcPort)
+ .intercept(authInterceptor)
+ .addService(bluePrintProcessingGRPCHandler)
+ .addService(bluePrintManagementGRPCHandler)
+ .build();
server.start();
log.info("Blueprint Processor GRPC server started and ready to serve on port({})...", server.getPort());
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
index b00c4627c..9561b78d4 100644
--- 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
@@ -16,23 +16,21 @@
package org.onap.ccsdk.apps.blueprintsprocessor;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
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}")
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplication.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplication.java
index 241d920a5..3f8dc375c 100644
--- a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplication.java
+++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplication.java
@@ -21,7 +21,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
-import org.springframework.web.reactive.config.EnableWebFlux;
/**
* BlueprintProcessorApplication
@@ -30,10 +29,10 @@ import org.springframework.web.reactive.config.EnableWebFlux;
*/
@SpringBootApplication
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
-@EnableWebFlux
@ComponentScan(basePackages = {"org.onap.ccsdk.apps.controllerblueprints",
- "org.onap.ccsdk.apps.blueprintsprocessor"})
+ "org.onap.ccsdk.apps.blueprintsprocessor"})
public class BlueprintProcessorApplication {
+
public static void main(String[] args) {
SpringApplication.run(BlueprintProcessorApplication.class, args);
}
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/WebConfig.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/WebConfig.java
index 796a2d794..47c7b7225 100644
--- a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/WebConfig.java
+++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/WebConfig.java
@@ -17,8 +17,17 @@
package org.onap.ccsdk.apps.blueprintsprocessor;
+import org.onap.ccsdk.apps.blueprintsprocessor.security.AuthenticationManager;
+import org.onap.ccsdk.apps.blueprintsprocessor.security.SecurityContextRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.web.reactive.config.*;
+import org.springframework.http.HttpMethod;
+import org.springframework.security.config.web.server.ServerHttpSecurity;
+import org.springframework.security.web.server.SecurityWebFilterChain;
+import org.springframework.web.reactive.config.CorsRegistry;
+import org.springframework.web.reactive.config.ResourceHandlerRegistry;
+import org.springframework.web.reactive.config.WebFluxConfigurationSupport;
/**
* WebConfig
@@ -27,21 +36,43 @@ import org.springframework.web.reactive.config.*;
*/
@Configuration
public class WebConfig extends WebFluxConfigurationSupport {
- @Override
+
+ @Autowired
+ private AuthenticationManager authenticationManager;
+
+ @Autowired
+ private SecurityContextRepository securityContextRepository;
+
+ @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
- .addResourceLocations("classpath:/META-INF/resources/");
+ .addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
- .addResourceLocations("classpath:/META-INF/resources/webjars/");
+ .addResourceLocations("classpath:/META-INF/resources/webjars/");
}
@Override
public void addCorsMappings(CorsRegistry corsRegistry) {
corsRegistry.addMapping("/**")
- .allowedOrigins("*")
- .allowedMethods("*")
- .allowedHeaders("DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range")
- .maxAge(3600);
+ .allowedOrigins("*")
+ .allowedMethods("*")
+ .allowedHeaders("*")
+ .maxAge(3600);
+ }
+
+
+ @Bean
+ public SecurityWebFilterChain securitygWebFilterChain(ServerHttpSecurity http) {
+ return http.csrf().disable()
+ .formLogin().disable()
+ .httpBasic().disable()
+ .authenticationManager(authenticationManager)
+ .securityContextRepository(securityContextRepository)
+ .authorizeExchange()
+ .pathMatchers(HttpMethod.OPTIONS).permitAll()
+ .anyExchange().authenticated()
+ .and().build();
+
}
}
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/AuthenticationManager.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/AuthenticationManager.java
new file mode 100644
index 000000000..726be2ce7
--- /dev/null
+++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/AuthenticationManager.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+* limitations under the License.
+ */
+package org.onap.ccsdk.apps.blueprintsprocessor.security;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.authentication.AuthenticationProvider;
+import org.springframework.security.authentication.ReactiveAuthenticationManager;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.AuthenticationException;
+import reactor.core.publisher.Mono;
+
+@Configuration
+public class AuthenticationManager implements ReactiveAuthenticationManager {
+
+ @Autowired
+ private AuthenticationProvider authenticationProvider;
+
+ @Override
+ public Mono<Authentication> authenticate(Authentication authentication) {
+ try {
+ return Mono.just(authenticationProvider.authenticate(authentication));
+ } catch (AuthenticationException e) {
+ return Mono.error(e);
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/BasicAuthServerInterceptor.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/BasicAuthServerInterceptor.java
new file mode 100644
index 000000000..db0bfce46
--- /dev/null
+++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/BasicAuthServerInterceptor.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.apps.blueprintsprocessor.security;
+
+import com.google.common.base.Strings;
+import io.grpc.Metadata;
+import io.grpc.ServerCall;
+import io.grpc.ServerCallHandler;
+import io.grpc.ServerInterceptor;
+import io.grpc.Status;
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.authentication.BadCredentialsException;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.stereotype.Component;
+
+@Component
+public class BasicAuthServerInterceptor implements ServerInterceptor {
+
+ private static Logger log = LoggerFactory.getLogger(BasicAuthServerInterceptor.class);
+
+ @Autowired
+ private AuthenticationManager authenticationManager;
+
+
+ @Override
+ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
+ ServerCall<ReqT, RespT> call,
+ Metadata headers,
+ ServerCallHandler<ReqT, RespT> next) {
+ String authHeader = headers.get(Metadata.Key.of("Authorization", Metadata.ASCII_STRING_MARSHALLER));
+
+ if (Strings.isNullOrEmpty(authHeader)) {
+ throw Status.UNAUTHENTICATED.withDescription("Missing required authentication").asRuntimeException();
+
+ }
+
+ try {
+ String[] tokens = decodeBasicAuth(authHeader);
+ String username = tokens[0];
+
+ log.info("Basic Authentication Authorization header found for user: {}", username);
+
+ Authentication authRequest = new UsernamePasswordAuthenticationToken(username, tokens[1]);
+ Authentication authResult = authenticationManager.authenticate(authRequest).block();
+
+ log.info("Authentication success: {}", authResult);
+
+ SecurityContextHolder.getContext().setAuthentication(authResult);
+
+ } catch (AuthenticationException e) {
+ SecurityContextHolder.clearContext();
+
+ log.info("Authentication request failed: {}", e.getMessage());
+
+ throw Status.UNAUTHENTICATED.withDescription(e.getMessage()).withCause(e).asRuntimeException();
+ }
+
+ return next.startCall(call, headers);
+ }
+
+ private String[] decodeBasicAuth(String authHeader) {
+ String basicAuth;
+ try {
+ basicAuth = new String(Base64.getDecoder().decode(authHeader.substring(6).getBytes(StandardCharsets.UTF_8)),
+ StandardCharsets.UTF_8);
+ } catch (IllegalArgumentException | IndexOutOfBoundsException e) {
+ throw new BadCredentialsException("Failed to decode basic authentication token");
+ }
+
+ int delim = basicAuth.indexOf(':');
+ if (delim == -1) {
+ throw new BadCredentialsException("Failed to decode basic authentication token");
+ }
+
+ return new String[]{basicAuth.substring(0, delim), basicAuth.substring(delim + 1)};
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/SecurityConfiguration.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/SecurityConfiguration.java
new file mode 100644
index 000000000..7ddc42ccd
--- /dev/null
+++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/SecurityConfiguration.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.apps.blueprintsprocessor.security;
+
+import java.util.Collections;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.authentication.AuthenticationProvider;
+import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.security.core.userdetails.User;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.security.provisioning.InMemoryUserDetailsManager;
+
+@Configuration
+public class SecurityConfiguration {
+
+ @Value("${security.user.name}")
+ private String username;
+
+ @Value("${security.user.password}")
+ private String password;
+
+ @Bean
+ public UserDetailsService inMemoryUserService() {
+ UserDetails user = new User(username, password,
+ Collections.singletonList(new SimpleGrantedAuthority("USER")));
+ return new InMemoryUserDetailsManager(user);
+ }
+
+ @Bean
+ public PasswordEncoder passwordEncoder() {
+ return new BCryptPasswordEncoder();
+ }
+
+ @Bean
+ public AuthenticationProvider inMemoryAuthenticationProvider() {
+ DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
+ provider.setUserDetailsService(inMemoryUserService());
+ return provider;
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/SecurityContextRepository.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/SecurityContextRepository.java
new file mode 100644
index 000000000..f9e184a11
--- /dev/null
+++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/SecurityContextRepository.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.apps.blueprintsprocessor.security;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.security.authentication.BadCredentialsException;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContext;
+import org.springframework.security.core.context.SecurityContextImpl;
+import org.springframework.security.web.server.context.ServerSecurityContextRepository;
+import org.springframework.stereotype.Component;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
+
+@Component
+public class SecurityContextRepository implements ServerSecurityContextRepository {
+
+ @Autowired
+ private AuthenticationManager authenticationManager;
+
+ @Override
+ public Mono<Void> save(ServerWebExchange swe, SecurityContext sc) {
+ throw new UnsupportedOperationException("Not supported.");
+ }
+
+ @Override
+ public Mono<SecurityContext> load(ServerWebExchange swe) {
+ ServerHttpRequest request = swe.getRequest();
+ String authHeader = request.getHeaders().getFirst(HttpHeaders.AUTHORIZATION);
+ if (authHeader != null && authHeader.startsWith("Basic")) {
+ String[] tokens = decodeBasicAuth(authHeader);
+ String username = tokens[0];
+ String password = tokens[1];
+ Authentication auth = new UsernamePasswordAuthenticationToken(username, password);
+ return this.authenticationManager.authenticate(auth).map(SecurityContextImpl::new);
+ } else {
+ return Mono.empty();
+ }
+ }
+
+ private String[] decodeBasicAuth(String authHeader) {
+ String basicAuth;
+ try {
+ basicAuth = new String(Base64.getDecoder().decode(authHeader.substring(6).getBytes(StandardCharsets.UTF_8)),
+ StandardCharsets.UTF_8);
+ } catch (IllegalArgumentException | IndexOutOfBoundsException e) {
+ throw new BadCredentialsException("Failed to decode basic authentication token");
+ }
+
+ int delim = basicAuth.indexOf(':');
+ if (delim == -1) {
+ throw new BadCredentialsException("Failed to decode basic authentication token");
+ }
+
+ return new String[]{basicAuth.substring(0, delim), basicAuth.substring(delim + 1)};
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/application/src/main/resources/application.properties b/ms/blueprintsprocessor/application/src/main/resources/application.properties
index cfef4f82f..e955c97c3 100755
--- a/ms/blueprintsprocessor/application/src/main/resources/application.properties
+++ b/ms/blueprintsprocessor/application/src/main/resources/application.properties
@@ -36,3 +36,6 @@ blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.MySQL5Inno
# Python executor
blueprints.processor.functions.python.executor.executionPath=/opt/app/onap/scripts/jython/ccsdk_blueprints
blueprints.processor.functions.python.executor.modulePaths=/opt/app/onap/scripts/jython/ccsdk_blueprints,/opt/app/onap/scripts/jython/ccsdk_netconf
+
+security.user.password: {bcrypt}$2a$10$duaUzVUVW0YPQCSIbGEkQOXwafZGwQ/b32/Ys4R1iwSSawFgz7QNu
+security.user.name: ccsdkapps
diff --git a/ms/blueprintsprocessor/application/src/test/resources/application.properties b/ms/blueprintsprocessor/application/src/test/resources/application.properties
index 2b5bea109..393024516 100644
--- a/ms/blueprintsprocessor/application/src/test/resources/application.properties
+++ b/ms/blueprintsprocessor/application/src/test/resources/application.properties
@@ -17,6 +17,9 @@
#
# Web server config
server.port=8080
+blueprintsprocessor.grpcEnable=false
+blueprintsprocessor.httpPort=8080
+blueprintsprocessor.grpcPort=9111
# Blueprint Processor File Execution and Handling Properties
blueprintsprocessor.blueprintDeployPath=/opt/app/onap/blueprints/deploy
blueprintsprocessor.blueprintArchivePath=/opt/app/onap/blueprints/archive
@@ -32,3 +35,6 @@ blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.H2Dialect
# Python executor
blueprints.processor.functions.python.executor.executionPath=/opt/app/onap/scripts/jython
blueprints.processor.functions.python.executor.modulePaths=/opt/app/onap/scripts/jython
+
+security.user.password: {bcrypt}$2a$10$duaUzVUVW0YPQCSIbGEkQOXwafZGwQ/b32/Ys4R1iwSSawFgz7QNu
+security.user.name: ccsdkapps
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
index 5765609b7..ca92e96dc 100644
--- 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
@@ -20,7 +20,7 @@ class ResourceResolutionConstants {
companion object {
const val SERVICE_RESOURCE_RESOLUTION = "resource-resolution-service"
- const val PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR = "resource-assignment-processor-"
+ const val PREFIX_RESOURCE_RESOLUTION_PROCESSOR = "rr-processor-"
const val INPUT_ARTIFACT_PREFIX_NAMES = "artifact-prefix-names"
const val OUTPUT_ASSIGNMENT_PARAMS = "assignment-params"
const val FILE_NAME_RESOURCE_DEFINITION_TYPES = "resources_definition_types.json"
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
index 24401ccfc..48415efa4 100644
--- 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
@@ -21,6 +21,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.pro
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintTemplateService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
@@ -59,8 +60,8 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
override 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) }
+ .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
+ .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
}
override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
@@ -123,6 +124,11 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
return resolvedContent
}
+ /**
+ * Iterate the Batch, get the Resource Assignment, dictionary Name, Look for the Resource definition for the
+ * name, then get the type of the Resource Definition, Get the instance for the Resource Type and process the
+ * request.
+ */
override fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
resourceDictionaries: MutableMap<String, ResourceDefinition>,
resourceAssignments: MutableList<ResourceAssignment>,
@@ -133,12 +139,17 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
bulkSequenced.map { batchResourceAssignments ->
batchResourceAssignments.filter { it.name != "*" && it.name != "start" }
- .map { resourceAssignment ->
+ .forEach { resourceAssignment ->
+ val dictionaryName = resourceAssignment.dictionaryName
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) " +
+ /**
+ * Get the Processor name
+ */
+ val processorName = processorName(dictionaryName!!, dictionarySource!!,
+ resourceDictionaries)
+
+ val resourceAssignmentProcessor = applicationContext.getBean(processorName) as? ResourceAssignmentProcessor
+ ?: throw BluePrintProcessorException("failed to get resource processor for name($processorName) " +
"for resource assignment(${resourceAssignment.name})")
try {
// Set BluePrint Runtime Service
@@ -155,4 +166,37 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
}
}
+
+ /**
+ * If the Source instance is "input", then it is not mandatory to have source Resource Definition, So it can
+ * derive the default input processor.
+ */
+ private fun processorName(dictionaryName: String, dictionarySource: String,
+ resourceDictionaries: MutableMap<String, ResourceDefinition>): String {
+ var processorName: String? = null
+ when (dictionarySource) {
+ "input" -> {
+ processorName = "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-input"
+ }
+ "default" -> {
+ processorName = "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-default"
+ }
+ else -> {
+ val resourceDefinition = resourceDictionaries[dictionaryName]
+ ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dictionaryName")
+
+ val resourceSource = resourceDefinition.sources[dictionarySource]
+ ?: throw BluePrintProcessorException("couldn't get resource definition $dictionaryName source($dictionarySource)")
+
+ processorName = ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
+ .plus(resourceSource.type)
+ }
+ }
+ checkNotEmptyOrThrow(processorName,
+ "couldn't get processor name for resource dictionary definition($dictionaryName) source" +
+ "($dictionarySource)")
+
+ return processorName
+
+ }
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
index 0f1267cbb..1c3574461 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
@@ -36,6 +36,8 @@ open class DefaultResourceSource : ResourceSourceProperties() {
open class DatabaseResourceSource : ResourceSourceProperties() {
lateinit var type: String
+ @get:JsonProperty("endpoint-selector")
+ var endpointSelector: String? = null
lateinit var query: String
@get:JsonProperty("input-key-mapping")
var inputKeyMapping: MutableMap<String, String>? = null
@@ -47,6 +49,8 @@ open class DatabaseResourceSource : ResourceSourceProperties() {
open class RestResourceSource : ResourceSourceProperties() {
lateinit var type: String
+ @get:JsonProperty("endpoint-selector")
+ var endpointSelector: String? = null
@get:JsonProperty("url-path")
lateinit var urlPath: String
lateinit var path: String
@@ -61,9 +65,10 @@ open class RestResourceSource : ResourceSourceProperties() {
}
open class CapabilityResourceSource : ResourceSourceProperties() {
- lateinit var type: String
- @get:JsonProperty("instance-name")
- lateinit var instanceName: String
+ @get:JsonProperty("script-type")
+ lateinit var scriptType: String
+ @get:JsonProperty("script-class-reference")
+ lateinit var scriptClassReference: String
@get:JsonProperty("instance-dependencies")
var instanceDependencies: List<String>? = null
@get:JsonProperty("key-dependencies")
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
index 489645fd6..c6b7d77e5 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
@@ -18,30 +18,27 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintScriptsService
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.config.ConfigurableBeanFactory
import org.springframework.context.ApplicationContext
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
import java.io.File
-@Service("resource-assignment-processor-capability")
-open class CapabilityResourceAssignmentProcessor(private var applicationContext: ApplicationContext,
+@Service("rr-processor-source-capability")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class CapabilityResourceResolutionProcessor(private var applicationContext: ApplicationContext,
private val bluePrintScriptsService: BluePrintScriptsService,
private val bluePrintJythonService: BlueprintJythonService) :
ResourceAssignmentProcessor() {
- companion object {
- const val CAPABILITY_TYPE_KOTLIN_COMPONENT = "KOTLIN-COMPONENT"
- const val CAPABILITY_TYPE_JAVA_COMPONENT = "JAVA-COMPONENT"
- const val CAPABILITY_TYPE_JYTHON_COMPONENT = "JYTHON-COMPONENT"
- }
-
override fun getName(): String {
return "resource-assignment-processor-capability"
}
@@ -62,28 +59,28 @@ open class CapabilityResourceAssignmentProcessor(private var applicationContext:
val capabilityResourceSourceProperty = JacksonUtils
.getInstanceFromMap(resourceSourceProps, CapabilityResourceSource::class.java)
- val instanceType = capabilityResourceSourceProperty.type
- val instanceName = capabilityResourceSourceProperty.instanceName
+ val scriptType = capabilityResourceSourceProperty.scriptType
+ val scriptClassReference = capabilityResourceSourceProperty.scriptClassReference
var componentResourceAssignmentProcessor: ResourceAssignmentProcessor? = null
- when (instanceType) {
- CAPABILITY_TYPE_KOTLIN_COMPONENT -> {
- componentResourceAssignmentProcessor = getKotlinResourceAssignmentProcessorInstance(instanceName,
+ when (scriptType) {
+ BluePrintConstants.SCRIPT_KOTLIN -> {
+ componentResourceAssignmentProcessor = getKotlinResourceAssignmentProcessorInstance(scriptClassReference,
capabilityResourceSourceProperty.instanceDependencies)
}
- CAPABILITY_TYPE_JAVA_COMPONENT -> {
+ BluePrintConstants.SCRIPT_INTERNAL -> {
// Initialize Capability Resource Assignment Processor
- componentResourceAssignmentProcessor = applicationContext.getBean(instanceName, ResourceAssignmentProcessor::class.java)
+ componentResourceAssignmentProcessor = applicationContext.getBean(scriptClassReference, ResourceAssignmentProcessor::class.java)
}
- CAPABILITY_TYPE_JYTHON_COMPONENT -> {
- val content = getJythonContent(instanceName)
- componentResourceAssignmentProcessor = getJythonResourceAssignmentProcessorInstance(instanceName,
+ BluePrintConstants.SCRIPT_JYTHON -> {
+ val content = getJythonContent(scriptClassReference)
+ componentResourceAssignmentProcessor = getJythonResourceAssignmentProcessorInstance(scriptClassReference,
content, capabilityResourceSourceProperty.instanceDependencies)
}
}
- checkNotNull(componentResourceAssignmentProcessor) { "failed to get capability resource assignment processor($instanceName)" }
+ checkNotNull(componentResourceAssignmentProcessor) { "failed to get capability resource assignment processor($scriptClassReference)" }
// Assign Current Blueprint runtime and ResourceDictionaries
componentResourceAssignmentProcessor.raRuntimeService = raRuntimeService
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
index e389f362a..a8e0ad80e 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
@@ -17,34 +17,37 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
-import com.fasterxml.jackson.databind.node.NullNode
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
/**
- * DefaultResourceAssignmentProcessor
+ * DefaultResourceResolutionProcessor
*
* @author Kapil Singal
*/
-@Service("resource-assignment-processor-default")
-open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+@Service("rr-processor-source-default")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class DefaultResourceResolutionProcessor : ResourceAssignmentProcessor() {
- private val logger = LoggerFactory.getLogger(DefaultResourceAssignmentProcessor::class.java)
+ private val logger = LoggerFactory.getLogger(DefaultResourceResolutionProcessor::class.java)
override fun getName(): String {
- return "resource-assignment-processor-default"
+ return "rr-processor-source-default"
}
override fun process(resourceAssignment: ResourceAssignment) {
try {
// Check if It has Input
- var value: Any? = raRuntimeService.getInputValue(resourceAssignment.name)
-
- // If value is null get it from default source
- if (value == null || value is NullNode) {
+ var value: Any?
+ try {
+ value = raRuntimeService.getInputValue(resourceAssignment.name)
+ } catch (e: BluePrintProcessorException) {
+ // If value is null get it from default source
logger.info("Looking for defaultValue as couldn't find value in input For template key (${resourceAssignment.name})")
value = resourceAssignment.property?.defaultValue
}
@@ -56,7 +59,8 @@ open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() {
ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment)
} catch (e: Exception) {
ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message)
- throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}", e)
+ throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}",
+ e)
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt
index 5757de2af..ed6b09fcd 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt
@@ -23,20 +23,23 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmpty
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
/**
- * InputResourceAssignmentProcessor
+ * InputResourceResolutionProcessor
*
* @author Kapil Singal
*/
-@Service("resource-assignment-processor-input")
-open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+@Service("rr-processor-source-input")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class InputResourceResolutionProcessor : ResourceAssignmentProcessor() {
- private val logger = LoggerFactory.getLogger(InputResourceAssignmentProcessor::class.java)
+ private val logger = LoggerFactory.getLogger(InputResourceResolutionProcessor::class.java)
override fun getName(): String {
- return "resource-assignment-processor-input"
+ return "rr-processor-source-input"
}
override fun process(resourceAssignment: ResourceAssignment) {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceResolutionProcessor.kt
index 876c75faf..3922c3760 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceResolutionProcessor.kt
@@ -18,32 +18,38 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
import com.fasterxml.jackson.databind.node.JsonNodeFactory
-import com.fasterxml.jackson.databind.node.MissingNode
-import com.fasterxml.jackson.databind.node.NullNode
import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.PrimaryDBLibGenericService
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.DatabaseResourceSource
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
-import org.onap.ccsdk.apps.controllerblueprints.core.*
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.apps.controllerblueprints.core.checkEqualsOrThrow
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
+import org.onap.ccsdk.apps.controllerblueprints.core.nullToEmpty
+import org.onap.ccsdk.apps.controllerblueprints.core.returnNotEmptyOrThrow
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
import java.util.*
/**
- * PrimaryDataResourceAssignmentProcessor
+ * PrimaryDataResourceResolutionProcessor
*
* @author Kapil Singal
*/
-@Service("resource-assignment-processor-primary-db")
-open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGenericService: PrimaryDBLibGenericService)
+@Service("rr-processor-source-primary-db")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class PrimaryDataResourceResolutionProcessor(private val primaryDBLibGenericService: PrimaryDBLibGenericService)
: ResourceAssignmentProcessor() {
- private val logger = LoggerFactory.getLogger(PrimaryDataResourceAssignmentProcessor::class.java)
+ private val logger = LoggerFactory.getLogger(PrimaryDataResourceResolutionProcessor::class.java)
override fun getName(): String {
- return "resource-assignment-processor-primary-db"
+ return "rr-processor-source-primary-db"
}
override fun process(resourceAssignment: ResourceAssignment) {
@@ -51,22 +57,27 @@ open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGeneri
validate(resourceAssignment)
// Check if It has Input
- val value = raRuntimeService.getInputValue(resourceAssignment.name)
- if (value !is NullNode && value !is MissingNode) {
+ try {
+ val value = raRuntimeService.getInputValue(resourceAssignment.name)
logger.info("primary-db source template key (${resourceAssignment.name}) found from input and value is ($value)")
ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
- } else {
+ } catch (e: BluePrintProcessorException) {
+ // Else, get from DB
val dName = resourceAssignment.dictionaryName
val dSource = resourceAssignment.dictionarySource
val resourceDefinition = resourceDictionaries[dName]
- ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dName")
+ ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dName")
val resourceSource = resourceDefinition.sources[dSource]
- ?: throw BluePrintProcessorException("couldn't get resource definition $dName source($dSource)")
- val resourceSourceProperties = checkNotNull(resourceSource.properties) { "failed to get source properties for $dName " }
- val sourceProperties = JacksonUtils.getInstanceFromMap(resourceSourceProperties, DatabaseResourceSource::class.java)
+ ?: throw BluePrintProcessorException("couldn't get resource definition $dName source($dSource)")
+ val resourceSourceProperties =
+ checkNotNull(resourceSource.properties) { "failed to get source properties for $dName " }
+ val sourceProperties =
+ JacksonUtils.getInstanceFromMap(resourceSourceProperties, DatabaseResourceSource::class.java)
- val sql = checkNotNull(sourceProperties.query) { "failed to get request query for $dName under $dSource properties" }
- val inputKeyMapping = checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
+ val sql =
+ checkNotNull(sourceProperties.query) { "failed to get request query for $dName under $dSource properties" }
+ val inputKeyMapping =
+ checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
logger.info("$dSource dictionary information : ($sql), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})")
@@ -82,14 +93,16 @@ open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGeneri
ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment)
} catch (e: Exception) {
ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message)
- throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}", e)
+ throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}",
+ e)
}
}
@Throws(BluePrintProcessorException::class)
private fun validate(resourceAssignment: ResourceAssignment) {
checkNotEmptyOrThrow(resourceAssignment.name, "resource assignment template key is not defined")
- checkNotEmptyOrThrow(resourceAssignment.dictionaryName, "resource assignment dictionary name is not defined for template key (${resourceAssignment.name})")
+ checkNotEmptyOrThrow(resourceAssignment.dictionaryName,
+ "resource assignment dictionary name is not defined for template key (${resourceAssignment.name})")
checkEqualsOrThrow(ResourceDictionaryConstants.SOURCE_PRIMARY_DB, resourceAssignment.dictionarySource) {
"resource assignment source is not ${ResourceDictionaryConstants.SOURCE_PRIMARY_DB} but it is ${resourceAssignment.dictionarySource}"
}
@@ -100,30 +113,33 @@ open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGeneri
inputKeyMapping.forEach {
val expressionValue = raRuntimeService.getDictionaryStore(it.value)
logger.trace("Reference dictionary key (${it.key}) resulted in value ($expressionValue)")
- namedParameters[it.key] = expressionValue
+ namedParameters[it.key] = expressionValue.asText()
}
logger.info("Parameter information : ({})", namedParameters)
return namedParameters
}
@Throws(BluePrintProcessorException::class)
- private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: DatabaseResourceSource, rows: List<Map<String, Any>>) {
+ private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: DatabaseResourceSource,
+ rows: List<Map<String, Any>>) {
val dName = resourceAssignment.dictionaryName
val dSource = resourceAssignment.dictionarySource
val type = nullToEmpty(resourceAssignment.property?.type)
- val outputKeyMapping = checkNotNull(sourceProperties.outputKeyMapping) { "failed to get output-key-mappings for $dName under $dSource properties" }
+ val outputKeyMapping =
+ checkNotNull(sourceProperties.outputKeyMapping) { "failed to get output-key-mappings for $dName under $dSource properties" }
logger.info("Response processing type($type)")
// Primitive Types
- when(type) {
+ when (type) {
in BluePrintTypes.validPrimitiveTypes() -> {
val dbColumnValue = rows[0][outputKeyMapping[dName]]
logger.info("For template key (${resourceAssignment.name}) setting value as ($dbColumnValue)")
ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, dbColumnValue)
}
in BluePrintTypes.validCollectionTypes() -> {
- val entrySchemaType = returnNotEmptyOrThrow(resourceAssignment.property?.entrySchema?.type) { "Entry schema is not defined for dictionary ($dName) info" }
+ val entrySchemaType =
+ returnNotEmptyOrThrow(resourceAssignment.property?.entrySchema?.type) { "Entry schema is not defined for dictionary ($dName) info" }
var arrayNode = JsonNodeFactory.instance.arrayNode()
rows.forEach {
if (entrySchemaType in BluePrintTypes.validPrimitiveTypes()) {
@@ -134,8 +150,12 @@ open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGeneri
val arrayChildNode = JsonNodeFactory.instance.objectNode()
for (mapping in outputKeyMapping.entries) {
val dbColumnValue = checkNotNull(it[mapping.key])
- val propertyTypeForDataType = ResourceAssignmentUtils.getPropertyType(raRuntimeService, entrySchemaType, mapping.key)
- JacksonUtils.populatePrimitiveValues(mapping.key, dbColumnValue, propertyTypeForDataType, arrayChildNode)
+ val propertyTypeForDataType =
+ ResourceAssignmentUtils.getPropertyType(raRuntimeService, entrySchemaType, mapping.key)
+ JacksonUtils.populatePrimitiveValues(mapping.key,
+ dbColumnValue,
+ propertyTypeForDataType,
+ arrayChildNode)
}
arrayNode.add(arrayChildNode)
}
@@ -150,8 +170,12 @@ open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGeneri
var objectNode = JsonNodeFactory.instance.objectNode()
for (mapping in outputKeyMapping.entries) {
val dbColumnValue = checkNotNull(row[mapping.key])
- val propertyTypeForDataType = ResourceAssignmentUtils.getPropertyType(raRuntimeService, type, mapping.key)
- JacksonUtils.populatePrimitiveValues(mapping.key, dbColumnValue, propertyTypeForDataType, objectNode)
+ val propertyTypeForDataType =
+ ResourceAssignmentUtils.getPropertyType(raRuntimeService, type, mapping.key)
+ JacksonUtils.populatePrimitiveValues(mapping.key,
+ dbColumnValue,
+ propertyTypeForDataType,
+ objectNode)
}
logger.info("For template key (${resourceAssignment.name}) setting value as ($objectNode)")
ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, objectNode)
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
index b07155a32..9b7c70aa4 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
@@ -57,9 +57,13 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
return ResourceAssignment()
}
- override fun apply(executionServiceInput: ResourceAssignment): ResourceAssignment {
- prepareRequest(executionServiceInput)
- process(executionServiceInput)
+ override fun apply(resourceAssignment: ResourceAssignment): ResourceAssignment {
+ try {
+ prepareRequest(resourceAssignment)
+ process(resourceAssignment)
+ } catch (runtimeException: RuntimeException) {
+ recover(runtimeException, resourceAssignment)
+ }
return prepareResponse()
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
index a264ba504..4daa46e52 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
@@ -24,26 +24,30 @@ import com.fasterxml.jackson.databind.node.ObjectNode
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.RestResourceSource
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BlueprintWebClientService
import org.onap.ccsdk.apps.controllerblueprints.core.*
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
/**
- * SimpleRestResourceAssignmentProcessor
+ * RestResourceResolutionProcessor
*
* @author Kapil Singal
*/
-@Service("resource-assignment-processor-primary-config-data")
-open class SimpleRestResourceAssignmentProcessor(private val blueprintRestLibPropertyService: BluePrintRestLibPropertyService)
+@Service("rr-processor-source-rest")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyService: BluePrintRestLibPropertyService)
: ResourceAssignmentProcessor() {
- private val logger = LoggerFactory.getLogger(SimpleRestResourceAssignmentProcessor::class.java)
+ private val logger = LoggerFactory.getLogger(RestResourceResolutionProcessor::class.java)
override fun getName(): String {
- return "resource-assignment-processor-primary-config-data"
+ return "rr-processor-source-rest"
}
override fun process(resourceAssignment: ResourceAssignment) {
@@ -70,8 +74,8 @@ open class SimpleRestResourceAssignmentProcessor(private val blueprintRestLibPro
val inputKeyMapping = checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
logger.info("$dSource dictionary information : ($urlPath), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})")
- // TODO("Dynamic Rest Client Service, call (blueprintDynamicWebClientService || blueprintWebClientService")
- val restClientService = blueprintRestLibPropertyService.blueprintWebClientService("primary-config-data")
+ // Get the Rest Client Service
+ val restClientService = blueprintWebClientService(resourceAssignment, sourceProperties)
val response = restClientService.getResource(urlPath, String::class.java)
if (response.isNotBlank()) {
logger.warn("Failed to get $dSource result for dictionary name ($dName) using urlPath ($urlPath)")
@@ -87,6 +91,16 @@ open class SimpleRestResourceAssignmentProcessor(private val blueprintRestLibPro
}
}
+ open fun blueprintWebClientService(resourceAssignment: ResourceAssignment,
+ restResourceSource: RestResourceSource): BlueprintWebClientService {
+ return if (checkNotEmpty(restResourceSource.endpointSelector)) {
+ val restPropertiesJson = raRuntimeService.resolveDSLExpression(restResourceSource.endpointSelector!!)
+ blueprintRestLibPropertyService.blueprintWebClientService(restPropertiesJson)
+ } else {
+ blueprintRestLibPropertyService.blueprintWebClientService(resourceAssignment.dictionarySource!!)
+ }
+ }
+
@Throws(BluePrintProcessorException::class)
private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: RestResourceSource, restResponse: String, path: String) {
val dName = resourceAssignment.dictionaryName
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
index 93b93fecb..1c9a905fd 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
@@ -23,7 +23,13 @@ import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.node.NullNode
import com.fasterxml.jackson.databind.node.ObjectNode
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
-import org.onap.ccsdk.apps.controllerblueprints.core.*
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmpty
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
+import org.onap.ccsdk.apps.controllerblueprints.core.nullToEmpty
+import org.onap.ccsdk.apps.controllerblueprints.core.returnNotEmptyOrThrow
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
@@ -41,13 +47,13 @@ class ResourceAssignmentUtils {
val resourceProp = checkNotNull(resourceAssignment.property) { "Failed in setting resource value for resource mapping $resourceAssignment" }
checkNotEmptyOrThrow(resourceAssignment.name, "Failed in setting resource value for resource mapping $resourceAssignment")
- if (checkNotEmpty(resourceAssignment.dictionaryName)) {
+ if (resourceAssignment.dictionaryName.isNullOrEmpty()) {
resourceAssignment.dictionaryName = resourceAssignment.name
logger.warn("Missing dictionary key, setting with template key (${resourceAssignment.name}) as dictionary key (${resourceAssignment.dictionaryName})")
}
try {
- if (checkNotEmpty(resourceProp.type)) {
+ if (resourceProp.type.isNotEmpty()) {
val convertedValue = convertResourceValue(resourceProp.type, value)
logger.info("Setting Resource Value ($convertedValue) for Resource Name (${resourceAssignment.dictionaryName}) of type (${resourceProp.type})")
setResourceValue(resourceAssignment, raRuntimeService, convertedValue)
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
index fbecb55c3..c3b101840 100644
--- 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
@@ -42,9 +42,9 @@ import org.springframework.test.context.junit4.SpringRunner
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [ResourceResolutionServiceImpl::class,
- InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
- PrimaryDataResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class,
- CapabilityResourceAssignmentProcessor::class, PrimaryDBLibGenericService::class,
+ InputResourceResolutionProcessor::class, DefaultResourceResolutionProcessor::class,
+ PrimaryDataResourceResolutionProcessor::class, RestResourceResolutionProcessor::class,
+ CapabilityResourceResolutionProcessor::class, PrimaryDBLibGenericService::class,
BlueprintPropertyConfiguration::class, BluePrintProperties::class,
BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class])
@TestPropertySource(locations = ["classpath:application-test.properties"])
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
index d0d3a13fe..6d2d3f2df 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
@@ -47,9 +47,9 @@ import kotlin.test.assertTrue
*/
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [ResourceResolutionServiceImpl::class,
- InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
- PrimaryDataResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class,
- CapabilityResourceAssignmentProcessor::class, PrimaryDBLibGenericService::class,
+ InputResourceResolutionProcessor::class, DefaultResourceResolutionProcessor::class,
+ PrimaryDataResourceResolutionProcessor::class, RestResourceResolutionProcessor::class,
+ CapabilityResourceResolutionProcessor::class, PrimaryDBLibGenericService::class,
BlueprintPropertyConfiguration::class, BluePrintProperties::class,
BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class])
@TestPropertySource(locations = ["classpath:application-test.properties"])
@@ -66,7 +66,8 @@ class ResourceResolutionServiceTest {
fun testRegisteredSource() {
val sources = resourceResolutionService.registeredResourceSources()
assertNotNull(sources, "failed to get registered sources")
- assertTrue(sources.containsAll(arrayListOf("input", "default", "primary-db", "primary-config-data")), "failed to get registered sources")
+ assertTrue(sources.containsAll(arrayListOf("source-input", "source-default", "source-primary-db",
+ "source-rest")), "failed to get registered sources")
}
@Test
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
index 0dbd0f6e3..f779054e9 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
@@ -20,9 +20,9 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.pr
import org.junit.Test
import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.PythonExecutorProperty
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
@@ -36,15 +36,15 @@ import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [CapabilityResourceAssignmentProcessor::class, BluePrintScriptsServiceImpl::class,
+@ContextConfiguration(classes = [CapabilityResourceResolutionProcessor::class, BluePrintScriptsServiceImpl::class,
BlueprintJythonService::class, PythonExecutorProperty::class, MockCapabilityService::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 CapabilityResourceAssignmentProcessorTest {
+class CapabilityResourceResolutionProcessorTest {
@Autowired
- lateinit var capabilityResourceAssignmentProcessor: CapabilityResourceAssignmentProcessor
+ lateinit var capabilityResourceResolutionProcessor: CapabilityResourceResolutionProcessor
@Test
fun `test kotlin capability`() {
@@ -54,15 +54,15 @@ class CapabilityResourceAssignmentProcessorTest {
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
- capabilityResourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
- capabilityResourceAssignmentProcessor.resourceDictionaries = hashMapOf()
+ capabilityResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
+ capabilityResourceResolutionProcessor.resourceDictionaries = hashMapOf()
val scriptPropertyInstances: MutableMap<String, Any> = mutableMapOf()
scriptPropertyInstances["mock-service1"] = MockCapabilityService()
scriptPropertyInstances["mock-service2"] = MockCapabilityService()
- val resourceAssignmentProcessor = capabilityResourceAssignmentProcessor
+ val resourceAssignmentProcessor = capabilityResourceResolutionProcessor
.getKotlinResourceAssignmentProcessorInstance(
"ResourceAssignmentProcessor_cba\$ScriptResourceAssignmentProcessor", scriptPropertyInstances)
@@ -90,14 +90,14 @@ class CapabilityResourceAssignmentProcessorTest {
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
- capabilityResourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
+ capabilityResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
val resourceDefinition = JacksonUtils
.readValueFromClassPathFile("mapping/capability/jython-resource-definitions.json",
ResourceDefinition::class.java)!!
val resourceDefinitions: MutableMap<String, ResourceDefinition> = mutableMapOf()
resourceDefinitions[resourceDefinition.name] = resourceDefinition
- capabilityResourceAssignmentProcessor.resourceDictionaries = resourceDefinitions
+ capabilityResourceResolutionProcessor.resourceDictionaries = resourceDefinitions
val resourceAssignment = ResourceAssignment().apply {
name = "service-instance-id"
@@ -108,7 +108,7 @@ class CapabilityResourceAssignmentProcessorTest {
}
}
- val processorName = capabilityResourceAssignmentProcessor.apply(resourceAssignment)
+ val processorName = capabilityResourceResolutionProcessor.apply(resourceAssignment)
assertNotNull(processorName, "couldn't get Jython script resource assignment processor name")
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json
index d3780e0a0..fe89291c1 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json
@@ -10,8 +10,8 @@
"capability": {
"type": "source-capability",
"properties": {
- "type": "JYTHON-COMPONENT",
- "instance-name": "SampleRAProcessor",
+ "script-type": "jython",
+ "script-class-reference": "SampleRAProcessor",
"instance-dependencies": []
}
}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt
index 33d0d96d4..e94bcff52 100755
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt
@@ -1,6 +1,7 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
* Modifications Copyright © 2019 Bell Canada.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,10 +41,10 @@ import java.nio.file.Paths
* Similar/Duplicate implementation in [org.onap.ccsdk.apps.controllerblueprints.service.load.ControllerBlueprintCatalogServiceImpl]
*/
@Service
-class BlueprintProcessorCatalogServiceImpl(bluePrintValidatorService: BluePrintValidatorService,
+class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: BluePrintValidatorService,
private val blueprintConfig: BluePrintCoreConfiguration,
private val blueprintModelRepository: BlueprintProcessorModelRepository)
- : BlueprintCatalogServiceImpl(bluePrintValidatorService) {
+ : BlueprintCatalogServiceImpl(bluePrintRuntimeValidatorService) {
private val log = LoggerFactory.getLogger(BlueprintProcessorCatalogServiceImpl::class.toString())
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip
index a62d4bfbb..907482400 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip
Binary files differ
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml
new file mode 100644
index 000000000..0dd3da350
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ ============LICENSE_START=======================================================
+ ~ ONAP - CDS
+ ~ ================================================================================
+ ~ Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ ~ ================================================================================
+ ~ 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.
+ ~ ============LICENSE_END=========================================================
+ -->
+<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.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>dmaap-lib</artifactId>
+ <packaging>jar</packaging>
+ <name>Blueprints Processor Dmaap Lib</name>
+ <description>Blueprints Processor Dmaap Lib</description>
+
+ <properties>
+ <dmaap.client.version>1.1.5</dmaap.client.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.dmaap.messagerouter.dmaapclient</groupId>
+ <artifactId>dmaapClient</artifactId>
+ <version>${dmaap.client.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-webflux</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.inject</groupId>
+ <artifactId>jersey-hk2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ <version>2.1-m07</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-test-junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/DmaapEventPublisher.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/DmaapEventPublisher.kt
new file mode 100644
index 000000000..7c686f089
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/DmaapEventPublisher.kt
@@ -0,0 +1,181 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CDS
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.dmaap
+
+import com.att.nsa.mr.client.MRBatchingPublisher
+import com.att.nsa.mr.client.MRClientFactory
+import com.att.nsa.mr.client.MRPublisher
+import org.slf4j.LoggerFactory
+import org.springframework.boot.context.properties.bind.Binder
+import org.springframework.boot.context.properties.source.ConfigurationPropertySources
+import org.springframework.context.annotation.Configuration
+import org.springframework.context.annotation.PropertySource
+import org.springframework.context.annotation.PropertySources
+import org.springframework.core.env.ConfigurableEnvironment
+import org.springframework.core.env.Environment
+import org.springframework.core.io.support.ResourcePropertySource
+import java.io.IOException
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+/**
+ * Representation of DMaap event publisher, to create a session with the
+ * message router and send messages when asked for. The producer.properties
+ * is used for creating a session. In order to overwrite the parameters such
+ * as host, topic, username and password, the event.properties can be used.
+ *
+ * compName : Name of the component appended in the event.properties file
+ * to overwrite.
+ * (E.g., so.topic=cds_so : In this "so" is the component name)
+ */
+@Configuration
+@PropertySources(PropertySource("classpath:event.properties",
+ "classpath:producer.properties"))
+open class DmaapEventPublisher(compName: String = ""): EventPublisher {
+
+ /**
+ * Static variable for logging.
+ */
+ companion object {
+ var log = LoggerFactory.getLogger(DmaapEventPublisher::class.java)!!
+ }
+
+ /**
+ * The component name used in defining the event.properties file.
+ */
+ private var cName:String? = null
+
+ /**
+ * List of topics for a given message to be sent.
+ */
+ var topics = mutableListOf<String>()
+
+ /**
+ * List of clients formed for the list of topics where the messages has to
+ * be sent.
+ */
+ var clients = mutableListOf<MRBatchingPublisher>()
+
+ /**
+ * The populated values from producer.properties which are overwritten
+ * by the event.properties values according to the component information.
+ */
+ var prodProps: Properties = Properties()
+
+
+ init {
+ cName = compName
+ }
+
+ /**
+ * Loads the producer.properties file and populates all the parameters
+ * and then loads the event.properties file and populates the finalized
+ * parameters such as host, topic, username and password if available for
+ * the specified component. With this updated producer.properties, for
+ * each topic a client will be created.
+ */
+ private fun loadPropertiesInfo() {
+ if (prodProps.isEmpty) {
+ parseEventProps(cName!!)
+ addClients()
+ }
+ }
+
+ /**
+ * Adds clients for each topic into a client list.
+ */
+ private fun addClients() {
+ for (topic in topics) {
+ prodProps.setProperty("topic", topic)
+ val client = MRClientFactory.createBatchingPublisher(prodProps)
+ clients.add(client)
+ }
+ }
+
+ /**
+ * Parses the event.properties file and update it into the producer
+ * .properties, where both the files are loaded and stored.
+ */
+ private fun parseEventProps(cName: String) {
+ val env = EnvironmentContext.env as Environment
+ val propSrc = ConfigurationPropertySources.get(env)
+ val proProps = (env as ConfigurableEnvironment).propertySources.get(
+ "class path resource [producer.properties]")
+
+ if (proProps != null) {
+ val entries = (proProps as ResourcePropertySource).source.entries
+ for (e in entries) {
+ prodProps.put(e.key, e.value)
+ }
+ } else {
+ log.info("Unable to load the producer.properties file")
+ }
+
+ val eProps = Binder(propSrc).bind(cName, Properties::class.java).get()
+ val top = eProps.get("topic").toString()
+ if (top != "") {
+ topics.addAll(top.split(","))
+ }
+ prodProps.putAll(eProps)
+ }
+
+ /**
+ * Sends message to the sessions created by the information provided in
+ * the producer.properties file.
+ */
+ override fun sendMessage(partition: String , messages: Collection<String>):
+ Boolean {
+ loadPropertiesInfo()
+ var success = true
+ val dmaapMsgs = mutableListOf<MRPublisher.message>()
+ for (m in messages) {
+ dmaapMsgs.add(MRPublisher.message(partition, m))
+ }
+ for (client in clients) {
+ log.info("Sending messages to the DMaap Server")
+ try {
+ client.send(dmaapMsgs)
+ } catch (e: IOException) {
+ log.error(e.message, e)
+ success = false
+ }
+ }
+ return success
+ }
+
+ /**
+ * Closes the opened session that was used for sending messages.
+ */
+ override fun close(timeout: Long) {
+ log.debug("Closing the DMaap producer clients")
+ if (!clients.isEmpty()) {
+ for (client in clients) {
+ try {
+ client.close(timeout, TimeUnit.SECONDS)
+ } catch (e : IOException) {
+ log.warn("Unable to cleanly close the connection from " +
+ "the client $client", e)
+ }
+ }
+ }
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EnvironmentContext.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EnvironmentContext.kt
new file mode 100644
index 000000000..1d2a28ce8
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EnvironmentContext.kt
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CDS
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.dmaap
+
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.core.env.Environment
+import org.springframework.stereotype.Component
+import javax.annotation.PostConstruct
+
+/**
+ * Abstraction of environment context information component.
+ */
+@Component
+class EnvironmentContext {
+
+ /**
+ * Environment information.
+ */
+ companion object {
+ var env: Environment? = null
+ }
+
+ /**
+ * Environment auto-wired information.
+ */
+ @Autowired
+ var environment: Environment? = null
+
+ /**
+ * Initiates the static variable after the instantiation takes place to
+ * the auto-wired variable.
+ */
+ @PostConstruct
+ private fun initStaticContext() {
+ env = environment
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EventPublisher.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EventPublisher.kt
new file mode 100644
index 000000000..7d02e806c
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EventPublisher.kt
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CDS
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.dmaap
+
+/**
+ * Abstraction of a publisher, to send messages with the given partition in a
+ * session and closing the same.
+ */
+interface EventPublisher {
+
+ /**
+ * Sends messages through a session on a given partition.
+ */
+ fun sendMessage(partition: String, messages: Collection<String>): Boolean
+
+ /**
+ * Closes the session with the given time.
+ */
+ fun close(timeout: Long)
+
+}
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/event.properties b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/event.properties
new file mode 100644
index 000000000..be764d841
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/event.properties
@@ -0,0 +1,26 @@
+#
+# ============LICENSE_START=======================================================
+# ONAP - CDS
+# ================================================================================
+# Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+# ================================================================================
+# 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.
+# ============LICENSE_END=========================================================
+#
+
+
+so.topic=cds_so
+so.username=admin
+so.password=admin
+so.host=10.12.6.236:30226
+
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/producer.properties b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/producer.properties
new file mode 100644
index 000000000..c3c228ba3
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/producer.properties
@@ -0,0 +1,52 @@
+#
+# ============LICENSE_START=======================================================
+# ONAP - CDS
+# ================================================================================
+# Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+# ================================================================================
+# 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.
+# ============LICENSE_END=========================================================
+#
+
+#TransportType-Specify which way user want to use. I.e. <HTTPAAF,DME2,HTTPAUTH >
+TransportType=HTTPNOAUTH
+Latitude =50.000000
+Longitude =-100.000000
+Version =3.1
+ServiceName =dmaap-v1.dev.dmaap.dt.saat.acsi.att.com/events
+Environment =TEST
+Partner=BOT_R
+routeOffer=MR1
+SubContextPath =/
+Protocol =http
+MethodType =POST
+username =admin
+password =admin
+contenttype = application/json
+authKey=01234567890abcde:01234567890abcdefghijklmn
+authDate=2016-07-20T11:30:56-0700
+host=10.12.6.236:30227
+topic=org.onap.appc.UNIT-TEST
+partition=1
+maxBatchSize=100
+maxAgeMs=250
+AFT_DME2_EXCHANGE_REQUEST_HANDLERS=com.att.nsa.test.PreferredRouteRequestHandler
+AFT_DME2_EXCHANGE_REPLY_HANDLERS=com.att.nsa.test.PreferredRouteReplyHandler
+AFT_DME2_REQ_TRACE_ON=true
+AFT_ENVIRONMENT=AFTUAT
+AFT_DME2_EP_CONN_TIMEOUT=15000
+AFT_DME2_ROUNDTRIP_TIMEOUT_MS=240000
+AFT_DME2_EP_READ_TIMEOUT_MS=50000
+sessionstickinessrequired=NO
+DME2preferredRouterFilePath=src/test/resources/preferredRoute.txt
+MessageSentThreadOccurance=50
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/apps/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/apps/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt
new file mode 100644
index 000000000..ac8882187
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/apps/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt
@@ -0,0 +1,118 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - CDS
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.ccsdk.apps.blueprintprocessor.dmaap
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.dmaap.DmaapEventPublisher
+import org.onap.ccsdk.apps.blueprintsprocessor.dmaap.EnvironmentContext
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.http.HttpStatus
+import org.springframework.http.ResponseEntity
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import org.springframework.web.bind.annotation.PathVariable
+import org.springframework.web.bind.annotation.PostMapping
+import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.RestController
+import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
+
+/**
+ * Unit test cases for DMaap publisher code.
+ */
+@RunWith(SpringRunner::class)
+@EnableAutoConfiguration(exclude = [DataSourceAutoConfiguration::class])
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
+@ContextConfiguration(classes = [EnvironmentContext::class, TestController::class,
+ DmaapEventPublisher::class])
+@TestPropertySource(properties = ["server.port=9111","aai.topic=cds_aai",
+ "aai.username=admin","aai.password=admin","aai.host=127.0.0.1:9111",
+ "mul.topic=cds_mul_1,cds_mul_2", "mul.username=admin","mul.password=admin",
+ "mul.host=127.0.0.1:9111"])
+class TestDmaapEventPublisher {
+
+ /**
+ * Tests the event properties being set properly and sent as request.
+ */
+ @Test
+ fun testEventProperties() {
+ val strList = mutableListOf<String>()
+ val pub = DmaapEventPublisher(compName = "aai")
+ strList.add("{\n" +
+ " \"a\" : \"hello\"\n" +
+ "}")
+ pub.sendMessage("1", strList)
+ pub.close(2)
+ pub.prodProps
+ assertNotNull(pub.prodProps, "The property file updation failed")
+ assertEquals(pub.prodProps.get("topic"), "cds_aai")
+ assertEquals(pub.prodProps.get("username"), "admin")
+ assertEquals(pub.prodProps.get("password"), "admin")
+ assertEquals(pub.prodProps.get("host"), "127.0.0.1:9111")
+ }
+
+ /**
+ * Tests the event properties with multiple topics.
+ */
+ @Test
+ fun testMultiTopicProperties() {
+ val strList = mutableListOf<String>()
+ val pub = DmaapEventPublisher(compName = "mul")
+ strList.add("{\n" +
+ " \"a\" : \"hello\"\n" +
+ "}")
+ pub.sendMessage("1", strList)
+ pub.close(2)
+ var tops = pub.topics
+ assertNotNull(pub.prodProps, "The property file updation failed")
+ assertEquals(tops[0], "cds_mul_1")
+ assertEquals(tops[1], "cds_mul_2")
+ //assertEquals(pub.topics.contains("cds_mul_2`"), true)
+ assertEquals(pub.prodProps.get("username"), "admin")
+ assertEquals(pub.prodProps.get("password"), "admin")
+ assertEquals(pub.prodProps.get("host"), "127.0.0.1:9111")
+ }
+}
+
+/**
+ * Rest controller for testing the client request that is sent.
+ */
+@RestController
+@RequestMapping(path = ["/events"])
+open class TestController {
+
+ /**
+ * Accepts request for a topic and sends a message as response.
+ */
+ @PostMapping(path = ["/{topic}"])
+ fun postTopic(@PathVariable(value = "topic") topic : String):
+ ResponseEntity<Any> {
+ var a = "{\n" +
+ " \"message\" : \"The message is published into $topic " +
+ "topic\"\n" +
+ "}"
+ return ResponseEntity(a, HttpStatus.OK)
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/resources/logback-test.xml
new file mode 100644
index 000000000..0f76057ad
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/resources/logback-test.xml
@@ -0,0 +1,40 @@
+<!--
+ ~ ============LICENSE_START=======================================================
+ ~ ONAP - CDS
+ ~ ================================================================================
+ ~ Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ ~ ================================================================================
+ ~ 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.
+ ~ ============LICENSE_END=========================================================
+ -->
+
+
+<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/dmaap-lib/src/test/resources/preferredRoute.txt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/resources/preferredRoute.txt
new file mode 100644
index 000000000..7e6ed8bdf
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/resources/preferredRoute.txt
@@ -0,0 +1,22 @@
+# ============LICENSE_START==========================================
+# ONAP : APPC
+# ===================================================================
+# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the License);
+# you may not use this software 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.
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# ============LICENSE_END============================================
+preferredRouteKey=MR1
diff --git a/ms/blueprintsprocessor/modules/commons/pom.xml b/ms/blueprintsprocessor/modules/commons/pom.xml
index 8d900a895..9d5dc51c4 100755
--- a/ms/blueprintsprocessor/modules/commons/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/pom.xml
@@ -33,6 +33,7 @@
<module>db-lib</module>
<module>rest-lib</module>
<module>core</module>
+ <module>dmaap-lib</module>
</modules>
<dependencies>
<dependency>
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
index 47577b39e..705caa2e2 100644
--- 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
@@ -17,15 +17,16 @@
package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
+import com.fasterxml.jackson.databind.JsonNode
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.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.springframework.stereotype.Service
@Service(RestLibConstants.SERVICE_BLUEPRINT_REST_LIB_PROPERTY)
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) {
@@ -47,19 +48,39 @@ open class BluePrintRestLibPropertyService(private var bluePrintProperties: Blue
}
}
- @Throws(BluePrintProcessorException::class)
+ fun restClientProperties(jsonNode: JsonNode): RestClientProperties {
+ val type = jsonNode.get("type").textValue()
+ return when (type) {
+ RestLibConstants.TYPE_BASIC_AUTH -> {
+ JacksonUtils.readValue(jsonNode, BasicAuthRestClientProperties::class.java)!!
+ }
+ RestLibConstants.TYPE_SSL_BASIC_AUTH -> {
+ JacksonUtils.readValue(jsonNode, SSLBasicAuthRestClientProperties::class.java)!!
+ }
+ RestLibConstants.TYPE_DME2_PROXY -> {
+ JacksonUtils.readValue(jsonNode, DME2RestClientProperties::class.java)!!
+ }
+ RestLibConstants.TYPE_POLICY_MANAGER -> {
+ JacksonUtils.readValue(jsonNode, PolicyManagerRestClientProperties::class.java)!!
+ }
+ else -> {
+ throw BluePrintProcessorException("Rest adaptor($type) is not supported")
+ }
+ }
+ }
+
+
fun blueprintWebClientService(selector: String): BlueprintWebClientService {
val prefix = "blueprintsprocessor.restclient.$selector"
val restClientProperties = restClientProperties(prefix)
return blueprintWebClientService(restClientProperties)
}
-
- fun blueprintDynamicWebClientService(sourceType: String, selector: String): BlueprintWebClientService {
- TODO()
+ fun blueprintWebClientService(jsonNode: JsonNode): BlueprintWebClientService {
+ val restClientProperties = restClientProperties(jsonNode)
+ return blueprintWebClientService(restClientProperties)
}
- @Throws(BluePrintProcessorException::class)
fun blueprintWebClientService(restClientProperties: RestClientProperties): BlueprintWebClientService {
when (restClientProperties) {
is BasicAuthRestClientProperties -> {
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
index 4a3053587..f538a152d 100755
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
@@ -32,6 +32,12 @@
<description>Blueprints Processor Selfservice API</description>
<dependencies>
+
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-core</artifactId>
+ </dependency>
+
<dependency>
<groupId>org.onap.ccsdk.apps.components</groupId>
<artifactId>proto-definition</artifactId>
@@ -39,10 +45,13 @@
</dependency>
<dependency>
<groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
- <version>${project.version}</version>
<artifactId>blueprint-core</artifactId>
</dependency>
<dependency>
+ <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+ <artifactId>blueprint-validation</artifactId>
+ </dependency>
+ <dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-testing</artifactId>
</dependency>
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt
index fb0bc5678..d689187e8 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt
@@ -28,16 +28,18 @@ import org.onap.ccsdk.apps.controllerblueprints.management.api.BluePrintManageme
import org.onap.ccsdk.apps.controllerblueprints.management.api.BluePrintManagementOutput
import org.onap.ccsdk.apps.controllerblueprints.management.api.BluePrintManagementServiceGrpc
import org.slf4j.LoggerFactory
+import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.stereotype.Service
import java.io.File
@Service
-class BluePrintManagementGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration,
+open class BluePrintManagementGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration,
private val bluePrintCatalogService: BluePrintCatalogService)
: BluePrintManagementServiceGrpc.BluePrintManagementServiceImplBase() {
private val log = LoggerFactory.getLogger(BluePrintManagementGRPCHandler::class.java)
+ @PreAuthorize("hasRole('USER')")
override fun uploadBlueprint(request: BluePrintManagementInput, responseObserver: StreamObserver<BluePrintManagementOutput>) {
val blueprintName = request.blueprintName
val blueprintVersion = request.blueprintVersion
@@ -61,6 +63,7 @@ class BluePrintManagementGRPCHandler(private val bluePrintCoreConfiguration: Blu
}
}
+ @PreAuthorize("hasRole('USER')")
override fun removeBlueprint(request: BluePrintManagementInput, responseObserver: StreamObserver<BluePrintManagementOutput>) {
val blueprintName = request.blueprintName
val blueprintVersion = request.blueprintVersion
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt
index cf6776c55..aadbec83a 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt
@@ -23,22 +23,23 @@ import org.onap.ccsdk.apps.controllerblueprints.processing.api.BluePrintProcessi
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.security.access.prepost.PreAuthorize
import org.springframework.stereotype.Service
@Service
-class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration,
+open class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration,
private val executionServiceHandler: ExecutionServiceHandler)
: BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() {
private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandler::class.java)
+ @PreAuthorize("hasRole('USER')")
override fun process(
responseObserver: StreamObserver<ExecutionServiceOutput>): StreamObserver<ExecutionServiceInput> {
return object : StreamObserver<ExecutionServiceInput> {
override fun onNext(executionServiceInput: ExecutionServiceInput) {
try {
- val inputPayload = executionServiceInput.payload
- executionServiceHandler.process(executionServiceInput.toJava(), responseObserver, inputPayload)
+ executionServiceHandler.process(executionServiceInput.toJava(), responseObserver)
} catch (e: Exception) {
onError(e)
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
index 6477c0678..16f0fa869 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
@@ -23,6 +23,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOut
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.MediaType
import org.springframework.http.codec.multipart.FilePart
+import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
@@ -34,7 +35,7 @@ import reactor.core.publisher.Mono
@RestController
@RequestMapping("/api/v1/execution-service")
-class ExecutionServiceController {
+open class ExecutionServiceController {
@Autowired
lateinit var executionServiceHandler: ExecutionServiceHandler
@@ -48,6 +49,7 @@ class ExecutionServiceController {
@PostMapping(path = ["/upload"], consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
@ApiOperation(value = "Upload CBA", notes = "Takes a File and load it in the runtime database")
@ResponseBody
+ @PreAuthorize("hasRole('USER')")
fun upload(@RequestPart("file") parts: Mono<FilePart>): Mono<String> {
return parts
.filter { it is FilePart }
@@ -59,6 +61,7 @@ class ExecutionServiceController {
@ApiOperation(value = "Resolve Resource Mappings",
notes = "Takes the blueprint information and process as per the payload")
@ResponseBody
+ @PreAuthorize("hasRole('USER')")
fun process(@RequestBody executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
if (executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC) {
throw IllegalStateException("Can't process async request through the REST endpoint. Use gRPC for async processing.")
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
index 4447dd4bf..5278c17ed 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
@@ -17,7 +17,6 @@
package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
import com.fasterxml.jackson.databind.node.JsonNodeFactory
-import com.google.protobuf.Struct
import io.grpc.stub.StreamObserver
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
@@ -31,6 +30,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status
import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils.saveCBAFile
import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils.toProto
import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintDGExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.common.api.EventType
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintCatalogService
@@ -61,8 +61,7 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC
}
fun process(executionServiceInput: ExecutionServiceInput,
- responseObserver: StreamObserver<org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput>,
- inputPayload: Struct) {
+ responseObserver: StreamObserver<org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput>) {
when {
executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC -> {
GlobalScope.launch(Dispatchers.Default) {
@@ -114,11 +113,11 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC
val status = Status()
status.errorMessage = errorMessage
if (failure) {
- status.eventType = "EVENT-COMPONENT-FAILURE"
+ status.eventType = EventType.EVENT_COMPONENT_FAILURE.name
status.code = 500
status.message = BluePrintConstants.STATUS_FAILURE
} else {
- status.eventType = "EVENT-COMPONENT-PROCESSING"
+ status.eventType = EventType.EVENT_COMPONENT_PROCESSING.name
status.code = 200
status.message = BluePrintConstants.STATUS_PROCESSING
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt
index b261c41b0..c344ca00a 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt
@@ -15,14 +15,13 @@
*/
package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils
-import com.fasterxml.jackson.databind.node.JsonNodeFactory
import com.fasterxml.jackson.databind.node.ObjectNode
import com.google.common.base.Strings
import com.google.protobuf.Struct
-import com.google.protobuf.Value
import com.google.protobuf.util.JsonFormat
import org.onap.ccsdk.apps.controllerblueprints.common.api.ActionIdentifiers
import org.onap.ccsdk.apps.controllerblueprints.common.api.CommonHeader
+import org.onap.ccsdk.apps.controllerblueprints.common.api.EventType
import org.onap.ccsdk.apps.controllerblueprints.common.api.Flag
import org.onap.ccsdk.apps.controllerblueprints.common.api.Status
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
@@ -33,47 +32,6 @@ import java.util.*
private val formatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
-// STRUCT
-
-fun Struct.toJava(): ObjectNode {
- val objectNode = JsonNodeFactory.instance.objectNode()
- return getNode(objectNode)
-}
-
-fun Struct.getNode(objectNode: ObjectNode): ObjectNode {
- this.fieldsMap.forEach {
- when (it.value.kindCase.name) {
- "BOOL_VALUE" -> objectNode.put(it.key, it.value.boolValue)
- "KIND_NOT_SET" -> objectNode.put(it.key, it.value.toByteArray())
- "LIST_VALUE" -> {
- val arrayNode = JsonNodeFactory.instance.arrayNode()
- it.value.listValue.valuesList.forEach { arrayNode.addPOJO(it.getValue()) }
- objectNode.put(it.key, arrayNode)
- }
- "NULL_VALUE" -> objectNode.put(it.key, JsonNodeFactory.instance.nullNode())
- "NUMBER_VALUE" -> objectNode.put(it.key, it.value.numberValue)
- "STRING_VALUE" -> objectNode.put(it.key, it.value.stringValue)
- "STRUCT_VALUE" -> objectNode.put(it.key, it.value.structValue.getNode(JsonNodeFactory.instance.objectNode()))
- }
- }
- return objectNode
-}
-
-fun Value.getValue(): Any {
- return when (this.kindCase.name) {
- "BOOL_VALUE" -> this.boolValue
- "KIND_NOT_SET" -> this.toByteArray()
- "LIST_VALUE" -> listOf(this.listValue.valuesList.forEach { it.getValue() })
- "NULL_VALUE" -> JsonNodeFactory.instance.nullNode()
- "NUMBER_VALUE" -> this.numberValue
- "STRING_VALUE" -> this.stringValue
- "STRUCT_VALUE" -> this.structValue.getNode(JsonNodeFactory.instance.objectNode())
- else -> {
- "undefined"
- }
- }
-}
-
// ACTION IDENTIFIER
fun org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ActionIdentifiers.toProto(): ActionIdentifiers {
@@ -144,7 +102,7 @@ fun org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status.toProto(): Stat
status.errorMessage = this.errorMessage ?: ""
status.message = this.message
status.timestamp = this.timestamp.toString()
- status.eventType = this.eventType
+ status.eventType = EventType.valueOf(this.eventType)
return status.build()
}
@@ -154,7 +112,7 @@ fun ExecutionServiceInput.toJava(): org.onap.ccsdk.apps.blueprintsprocessor.core
val executionServiceInput = org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput()
executionServiceInput.actionIdentifiers = this.actionIdentifiers.toJava()
executionServiceInput.commonHeader = this.commonHeader.toJava()
- executionServiceInput.payload = this.payload.toJava()
+ executionServiceInput.payload = JacksonUtils.jsonNode(JsonFormat.printer().print(this.payload)) as ObjectNode
return executionServiceInput
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintDesignTimeRuntimeValidatorService.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintDesignTimeRuntimeValidatorService.kt
new file mode 100644
index 000000000..08d2c3b5b
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintDesignTimeRuntimeValidatorService.kt
@@ -0,0 +1,38 @@
+/*
+ * Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.validation
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.validation.BluePrintDesignTimeValidatorService
+import org.springframework.stereotype.Service
+
+@Service
+open class BluePrintRuntimeValidatorService(
+ private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintDesignTimeValidatorService(bluePrintTypeValidatorService) {
+
+ override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean {
+
+ bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template",
+ bluePrintRuntimeService.bluePrintContext().serviceTemplate)
+ if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) {
+ throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}")
+ }
+ return true
+ }
+} \ No newline at end of file
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
index de1201488..b730472e8 100644
--- 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
@@ -24,6 +24,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInp
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintCatalogService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.autoconfigure.security.SecurityProperties
import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest
import org.springframework.context.annotation.ComponentScan
import org.springframework.core.io.ByteArrayResource
@@ -39,7 +40,7 @@ import kotlin.test.assertTrue
@RunWith(SpringRunner::class)
@WebFluxTest
-@ContextConfiguration(classes = [ExecutionServiceHandler::class, BluePrintCoreConfiguration::class, BluePrintCatalogService::class])
+@ContextConfiguration(classes = [ExecutionServiceHandler::class, BluePrintCoreConfiguration::class, BluePrintCatalogService::class, SecurityProperties::class])
@ComponentScan(basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor", "org.onap.ccsdk.apps.controllerblueprints"])
@TestPropertySource(locations = ["classpath:application-test.properties"])
class ExecutionServiceHandlerTest {
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappingTests.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappingTests.kt
index 2e4ba2755..770e4a9b3 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappingTests.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappingTests.kt
@@ -1,17 +1,12 @@
package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils
-import com.fasterxml.jackson.databind.ObjectMapper
-import com.google.protobuf.ListValue
-import com.google.protobuf.NullValue
-import com.google.protobuf.Struct
-import com.google.protobuf.Value
-import com.google.protobuf.util.JsonFormat
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Flags
import org.onap.ccsdk.apps.controllerblueprints.common.api.ActionIdentifiers
import org.onap.ccsdk.apps.controllerblueprints.common.api.CommonHeader
+import org.onap.ccsdk.apps.controllerblueprints.common.api.EventType
import org.onap.ccsdk.apps.controllerblueprints.common.api.Flag
import org.springframework.test.context.junit4.SpringRunner
import java.text.SimpleDateFormat
@@ -53,7 +48,7 @@ class BluePrintMappingsTest {
val status = org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status()
status.code = 400
status.errorMessage = "Concurrent modification exception"
- status.eventType = "Update"
+ status.eventType = EventType.EVENT_COMPONENT_PROCESSING.name
status.message = "Error uploading data"
status.timestamp = dateForTest
return status
@@ -66,7 +61,7 @@ class BluePrintMappingsTest {
Assert.assertEquals(status.code, status2.code)
Assert.assertEquals(status.errorMessage, status2.errorMessage)
- Assert.assertEquals(status.eventType, status2.eventType)
+ Assert.assertEquals(status.eventType, status2.eventType.name)
Assert.assertEquals(status.message, status2.message)
Assert.assertEquals(status.timestamp.toString(), status2.timestamp)
}
@@ -134,39 +129,4 @@ class BluePrintMappingsTest {
Assert.assertEquals(actionIdentifiers.blueprintVersion, actionIdentifiers2.blueprintVersion)
Assert.assertEquals(actionIdentifiers.mode, actionIdentifiers2.mode)
}
-
- @Test
- fun testStructToJava() {
- val struct = Struct.newBuilder().putAllFields(createValues()).build()
- val struct2 = struct.toJava()
-
- val mapper = ObjectMapper()
-
- Assert.assertEquals(JsonFormat.printer().print(struct).replace(" ", "").replace("\r",""),
- mapper.writerWithDefaultPrettyPrinter().writeValueAsString(struct2).replace(" ", "").replace("\r",""))
- }
-
- fun createValues(): Map<String, Value> {
- val map = mutableMapOf<String, Value>()
-
- val boolValue = Value.newBuilder().setBoolValue(true).build()
- val stringValue = Value.newBuilder().setStringValue("string").build()
- val doubleValue = Value.newBuilder().setNumberValue(Double.MAX_VALUE).build()
- val jsonValue = Value.newBuilder().setStringValue("{\"bblah\": \"bbblo\"}").build()
- val listValue = Value.newBuilder().setListValue(ListValue.newBuilder().addValues(boolValue).addValues(boolValue).build()).build()
- val nullValue = Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build()
-
- map.put("bool", boolValue)
- map.put("string", stringValue)
- map.put("doublbe", doubleValue)
- map.put("json", jsonValue)
- map.put("list", listValue)
- map.put("null", nullValue)
-
- val structValue = Value.newBuilder().setStructValue(Struct.newBuilder().putAllFields(map).build()).build()
-
- map.put("struct", structValue)
-
- return map
- }
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zip b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zip
index a62d4bfbb..907482400 100644
--- 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
Binary files differ
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
index 283a8a66c..df68b9528 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
+++ b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
@@ -15,7 +15,8 @@
~ 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">
+<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>
@@ -57,6 +58,10 @@
<groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
<artifactId>resource-dict</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.components</groupId>
+ <artifactId>proto-definition</artifactId>
+ </dependency>
<dependency>
<groupId>org.onap.ccsdk.sli.core</groupId>
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 7086ebbce..a67e006a6 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
@@ -23,6 +23,7 @@ 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.common.api.EventType
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
@@ -113,7 +114,7 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
// Populate Status
val status = Status()
- status.eventType = "EVENT-COMPONENT-EXECUTED"
+ status.eventType = EventType.EVENT_COMPONENT_EXECUTED.name
status.code = 200
status.message = BluePrintConstants.STATUS_SUCCESS
executionServiceOutput.status = status
diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml
index ab418f479..cad5a4b36 100755
--- a/ms/blueprintsprocessor/parent/pom.xml
+++ b/ms/blueprintsprocessor/parent/pom.xml
@@ -212,6 +212,11 @@
<artifactId>protobuf-java-util</artifactId>
<version>${protobuff.java.utils.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.components</groupId>
+ <artifactId>proto-definition</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- SLI Version -->
<dependency>
@@ -339,6 +344,11 @@
<artifactId>blueprint-scripts</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+ <artifactId>blueprint-validation</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- Database -->
<dependency>