diff options
Diffstat (limited to 'ms/blueprintsprocessor/modules')
4 files changed, 3 insertions, 90 deletions
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..edb1d31dc 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 @@ -37,8 +37,7 @@ class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration: Blu 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/ExecutionServiceHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt index 4447dd4bf..c53f03935 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 @@ -61,8 +60,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) { 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..df17785c3 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,11 +15,9 @@ */ 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 @@ -33,47 +31,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 { @@ -154,7 +111,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/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..04a2c1e8e 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,11 +1,5 @@ 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 @@ -134,39 +128,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 |