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
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());
}
}
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
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
// 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
import org.onap.ccsdk.apps.controllerblueprints.core.getAsString\r
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode\r
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
import org.slf4j.LoggerFactory\r
\r
/**\r
log.info("Preparing Response...")\r
executionServiceOutput.commonHeader = executionServiceInput.commonHeader\r
executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers\r
- executionServiceOutput.payload = executionServiceInput.payload\r
+\r
\r
// Resolve the Output Expression\r
val stepOutputs = bluePrintRuntimeService\r
\r
bluePrintRuntimeService.put("$stepName-step-outputs", stepOutputs.asJsonNode())\r
\r
+ executionServiceOutput.payload = JacksonUtils.objectNodeFromObject(stepOutputs)\r
+\r
// Populate Status\r
val status = Status()\r
status.eventType = "EVENT-COMPONENT-EXECUTED"\r
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)
}