aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/BasicAuthServerInterceptor.kt2
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/MessagePrioritizationRepositories.kt12
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/PrioritizationMessageEntity.kt3
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/service/MessagePrioritizationStateService.kt7
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessagePrioritizationSample.kt1
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibConfiguration.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyService.kt27
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt5
8 files changed, 57 insertions, 2 deletions
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/BasicAuthServerInterceptor.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/BasicAuthServerInterceptor.kt
index f821462af..a0a4ae297 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/BasicAuthServerInterceptor.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/security/BasicAuthServerInterceptor.kt
@@ -49,7 +49,7 @@ class BasicAuthServerInterceptor(private val authenticationManager: Authenticati
log.info("Basic Authentication Authorization header found for user: {}", username)
val authRequest = UsernamePasswordAuthenticationToken(username, tokens[1])
- val authResult = authenticationManager!!.authenticate(authRequest).block()
+ val authResult = authenticationManager.authenticate(authRequest).block()
log.info("Authentication success: {}", authResult)
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/MessagePrioritizationRepositories.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/MessagePrioritizationRepositories.kt
index 69c81079d..5c2495fd7 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/MessagePrioritizationRepositories.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/MessagePrioritizationRepositories.kt
@@ -77,12 +77,24 @@ interface PrioritizationMessageRepository : JpaRepository<MessagePrioritization,
@Modifying
@Transactional
+ @Query("UPDATE MessagePrioritization SET priority = :priority, updatedDate = :currentDate " +
+ "WHERE id = :id")
+ fun setPriorityForMessageId(id: String, priority: String, currentDate: Date): Int
+
+ @Modifying
+ @Transactional
@Query("UPDATE MessagePrioritization SET state = :state, updatedDate = :currentDate " +
"WHERE id IN :ids")
fun setStateForMessageIds(ids: List<String>, state: String, currentDate: Date): Int
@Modifying
@Transactional
+ @Query("UPDATE MessagePrioritization SET priority = :priority, updatedDate = :currentDate " +
+ "WHERE id IN :ids")
+ fun setPriorityForMessageIds(ids: List<String>, priority: String, currentDate: Date): Int
+
+ @Modifying
+ @Transactional
@Query("UPDATE MessagePrioritization SET state = :state, error = :error, updatedDate = :currentDate " +
"WHERE id = :id")
fun setStateAndErrorForMessageId(id: String, state: String, error: String, currentDate: Date): Int
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/PrioritizationMessageEntity.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/PrioritizationMessageEntity.kt
index 1825f91c2..15e85b0e7 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/PrioritizationMessageEntity.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/db/PrioritizationMessageEntity.kt
@@ -44,6 +44,9 @@ open class MessagePrioritization {
@Column(name = "message_state", length = 20, nullable = false)
lateinit var state: String
+ @Column(name = "priority", nullable = false)
+ var priority: Int = 5
+
@Lob
@Column(name = "message", nullable = false)
var message: String? = null
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/service/MessagePrioritizationStateService.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/service/MessagePrioritizationStateService.kt
index 8424226c2..6138fa9d3 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/service/MessagePrioritizationStateService.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/service/MessagePrioritizationStateService.kt
@@ -54,6 +54,8 @@ interface MessagePrioritizationStateService {
suspend fun setMessageState(id: String, state: String)
+ suspend fun setMessagesPriority(ids: List<String>, priority: String)
+
suspend fun setMessagesState(ids: List<String>, state: String)
suspend fun setMessageStateANdError(id: String, state: String, error: String)
@@ -141,6 +143,11 @@ open class MessagePrioritizationStateServiceImpl(
}
@Transactional
+ override suspend fun setMessagesPriority(ids: List<String>, priority: String) {
+ prioritizationMessageRepository.setPriorityForMessageIds(ids, priority, Date())
+ }
+
+ @Transactional
override suspend fun setMessagesState(ids: List<String>, state: String) {
prioritizationMessageRepository.setStateForMessageIds(ids, state, Date())
}
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessagePrioritizationSample.kt b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessagePrioritizationSample.kt
index 3281a97f9..185022973 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessagePrioritizationSample.kt
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/message/prioritization/utils/MessagePrioritizationSample.kt
@@ -93,6 +93,7 @@ object MessagePrioritizationSample {
group = groupName
type = messageType
state = messageState
+ priority = 5
correlationId = messageCorrelationId
message = "I am the Message"
createdDate = Date()
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibConfiguration.kt
index 0ec049a3c..c37c6263a 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibConfiguration.kt
@@ -45,6 +45,8 @@ fun BluePrintDependencyService.grpcClientService(jsonNode: JsonNode): BluePrintG
class GRPCLibConstants {
companion object {
const val SERVICE_BLUEPRINT_GRPC_LIB_PROPERTY = "blueprint-grpc-lib-property-service"
+ const val PROPERTY_GRPC_CLIENT_PREFIX = "blueprintsprocessor.grpcclient."
+ const val PROPERTY_GRPC_SERVER_PREFIX = "blueprintsprocessor.grpcserver."
const val TYPE_TOKEN_AUTH = "token-auth"
const val TYPE_BASIC_AUTH = "basic-auth"
const val TYPE_TLS_AUTH = "tls-auth"
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyService.kt
index fbc9ddd86..02d5cc695 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyService.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyService.kt
@@ -28,6 +28,18 @@ import org.springframework.stereotype.Service
@Service(GRPCLibConstants.SERVICE_BLUEPRINT_GRPC_LIB_PROPERTY)
open class BluePrintGrpcLibPropertyService(private var bluePrintPropertiesService: BluePrintPropertiesService) {
+ fun blueprintGrpcServerService(jsonNode: JsonNode): BluePrintGrpcServerService {
+ val grpcServerProperties = grpcServerProperties(jsonNode)
+ return blueprintGrpcServerService(grpcServerProperties)
+ }
+
+ fun blueprintGrpcServerService(selector: String): BluePrintGrpcServerService {
+ val prefix = "${GRPCLibConstants.PROPERTY_GRPC_SERVER_PREFIX}$selector"
+ val grpcServerProperties = grpcServerProperties(prefix)
+ return blueprintGrpcServerService(grpcServerProperties)
+ }
+
+
/** GRPC Server Lib Property Service */
fun grpcServerProperties(jsonNode: JsonNode): GrpcServerProperties {
return when (val type = jsonNode.get("type").textValue()) {
@@ -67,6 +79,19 @@ open class BluePrintGrpcLibPropertyService(private var bluePrintPropertiesServic
return bluePrintPropertiesService.propertyBeanType(prefix, TLSAuthGrpcServerProperties::class.java)
}
+ private fun blueprintGrpcServerService(grpcServerProperties: GrpcServerProperties)
+ : BluePrintGrpcServerService {
+ when (grpcServerProperties) {
+ is TLSAuthGrpcServerProperties -> {
+ return TLSAuthGrpcServerService(grpcServerProperties)
+ }
+ else -> {
+ throw BluePrintProcessorException("couldn't get grpc client service for properties $grpcServerProperties")
+ }
+ }
+ }
+
+
/** GRPC Client Lib Property Service */
fun blueprintGrpcClientService(jsonNode: JsonNode): BluePrintGrpcClientService {
@@ -75,7 +100,7 @@ open class BluePrintGrpcLibPropertyService(private var bluePrintPropertiesServic
}
fun blueprintGrpcClientService(selector: String): BluePrintGrpcClientService {
- val prefix = "blueprintsprocessor.grpcclient.$selector"
+ val prefix = "${GRPCLibConstants.PROPERTY_GRPC_CLIENT_PREFIX}$selector"
val restClientProperties = grpcClientProperties(prefix)
return blueprintGrpcClientService(restClientProperties)
}
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt
index e4bfd5d7c..13432c043 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt
@@ -19,6 +19,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.grpc.service
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
+import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService
@@ -190,5 +191,9 @@ class BluePrintGrpcLibPropertyServiceTest {
val jsonProperties = bluePrintGrpcLibPropertyService
.grpcServerProperties(configDsl.jsonAsJsonType()) as TLSAuthGrpcServerProperties
assertNotNull(jsonProperties, "failed to create property bean from json")
+
+ val grpcServerService = bluePrintGrpcLibPropertyService.blueprintGrpcServerService("tls-sample")
+ assertNotNull(grpcServerService, "failed to get grpc server service")
+ Assert.assertEquals(TLSAuthGrpcServerService::class.java, grpcServerService.javaClass)
}
} \ No newline at end of file