summaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2019-02-25 13:48:02 +0000
committerGerrit Code Review <gerrit@onap.org>2019-02-25 13:48:02 +0000
commite9d20bd21789fd0bcf5649fbbb0d388f68a3c063 (patch)
tree8a71e88fb736aabcd4ab79e811ea4e52a4541dbe /ms
parenta15a3effb98c412f7dc2deb3133f7d4f99749f86 (diff)
parent3e426bef0c727ef65cdd11166d054356b5217a5b (diff)
Merge "Provide correct output to #process request"
Diffstat (limited to 'ms')
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt11
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt8
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt5
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt4
4 files changed, 20 insertions, 8 deletions
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 262c33f9..4447dd4b 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
@@ -16,6 +16,7 @@
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
@@ -66,19 +67,19 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC
executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC -> {
GlobalScope.launch(Dispatchers.Default) {
val executionServiceOutput = doProcess(executionServiceInput)
- responseObserver.onNext(executionServiceOutput.toProto(inputPayload))
+ responseObserver.onNext(executionServiceOutput.toProto())
responseObserver.onCompleted()
}
- responseObserver.onNext(response(executionServiceInput).toProto(inputPayload))
+ responseObserver.onNext(response(executionServiceInput).toProto())
}
executionServiceInput.actionIdentifiers.mode == ACTION_MODE_SYNC -> {
val executionServiceOutput = doProcess(executionServiceInput)
- responseObserver.onNext(executionServiceOutput.toProto(inputPayload))
+ responseObserver.onNext(executionServiceOutput.toProto())
responseObserver.onCompleted()
}
else -> responseObserver.onNext(response(executionServiceInput,
"Failed to process request, 'actionIdentifiers.mode' not specified. Valid value are: 'sync' or 'async'.",
- true).toProto(inputPayload));
+ true).toProto());
}
}
@@ -108,7 +109,7 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC
val executionServiceOutput = ExecutionServiceOutput()
executionServiceOutput.commonHeader = executionServiceInput.commonHeader
executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers
- executionServiceOutput.payload = executionServiceInput.payload
+ executionServiceOutput.payload = JsonNodeFactory.instance.objectNode()
val status = Status()
status.errorMessage = errorMessage
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 c8ce1c30..b261c41b 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
@@ -20,10 +20,12 @@ 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.Flag
import org.onap.ccsdk.apps.controllerblueprints.common.api.Status
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput
import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput
import java.text.SimpleDateFormat
@@ -158,11 +160,13 @@ fun ExecutionServiceInput.toJava(): org.onap.ccsdk.apps.blueprintsprocessor.core
// EXECUTION OUPUT
-fun org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput.toProto(payload: Struct): ExecutionServiceOutput {
+fun org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput.toProto(): ExecutionServiceOutput {
val executionServiceOuput = ExecutionServiceOutput.newBuilder()
executionServiceOuput.actionIdentifiers = this.actionIdentifiers.toProto()
executionServiceOuput.commonHeader = this.commonHeader.toProto()
executionServiceOuput.status = this.status.toProto()
- executionServiceOuput.payload = payload
+ val struct = Struct.newBuilder()
+ JsonFormat.parser().merge(JacksonUtils.getJson(this.payload), struct)
+ executionServiceOuput.payload = struct.build()
return executionServiceOuput.build()
} \ No newline at end of file
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 930dc074..7086ebbc 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
@@ -29,6 +29,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.apps.controllerblueprints.core.getAsString
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.LoggerFactory
/**
@@ -100,7 +101,7 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
log.info("Preparing Response...")
executionServiceOutput.commonHeader = executionServiceInput.commonHeader
executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers
- executionServiceOutput.payload = executionServiceInput.payload
+
// Resolve the Output Expression
val stepOutputs = bluePrintRuntimeService
@@ -108,6 +109,8 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
bluePrintRuntimeService.put("$stepName-step-outputs", stepOutputs.asJsonNode())
+ executionServiceOutput.payload = JacksonUtils.objectNodeFromObject(stepOutputs)
+
// Populate Status
val status = Status()
status.eventType = "EVENT-COMPONENT-EXECUTED"
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
index 9bf9d13c..76f3f329 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
@@ -98,6 +98,10 @@ class JacksonUtils {
return readValue(content, valueType)
}
+ fun objectNodeFromObject(from: kotlin.Any): ObjectNode {
+ return jacksonObjectMapper().convertValue(from, ObjectNode::class.java)
+ }
+
fun jsonNodeFromObject(from: kotlin.Any): JsonNode {
return jacksonObjectMapper().convertValue(from, JsonNode::class.java)
}