From 579b7657572250f82b8121a937a26ab526e26266 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Mon, 4 Mar 2019 10:22:04 -0500 Subject: Define EventType contract for gRPC message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic8bde56d13f774120c8d64a56993ade71e7b4612 Issue-ID: CCSDK-1118 Signed-off-by: Alexis de Talhouët --- .../model-catalog/proto-definition/proto/BluePrintCommon.proto | 9 ++++++++- .../selfservice/api/ExecutionServiceHandler.kt | 5 +++-- .../selfservice/api/utils/BluePrintMappings.kt | 3 ++- .../selfservice/api/utils/BluePrintMappingTests.kt | 5 +++-- .../modules/services/execution-service/pom.xml | 7 ++++++- .../services/execution/AbstractComponentFunction.kt | 3 ++- ms/blueprintsprocessor/parent/pom.xml | 5 +++++ 7 files changed, 29 insertions(+), 8 deletions(-) diff --git a/components/model-catalog/proto-definition/proto/BluePrintCommon.proto b/components/model-catalog/proto-definition/proto/BluePrintCommon.proto index 0f17783a..de92bdc1 100644 --- a/components/model-catalog/proto-definition/proto/BluePrintCommon.proto +++ b/components/model-catalog/proto-definition/proto/BluePrintCommon.proto @@ -26,6 +26,13 @@ message Status { int32 code = 1; string errorMessage = 2; string message = 3; - string eventType = 4; + EventType eventType = 4; string timestamp = 5; +} + +enum EventType { + EVENT_COMPONENT_FAILURE = 0; + EVENT_COMPONENT_PROCESSING = 1; + EVENT_COMPONENT_NOTIFICATION = 2; + EVENT_COMPONENT_EXECUTED = 3; } \ No newline at end of file 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 c53f0393..5278c17e 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 @@ -30,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 @@ -112,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 df17785c..c344ca00 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 @@ -21,6 +21,7 @@ import com.google.protobuf.Struct 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 @@ -101,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() } 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 04a2c1e8..770e4a9b 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 @@ -6,6 +6,7 @@ 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 @@ -47,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 @@ -60,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) } diff --git a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml index 283a8a66..df68b952 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. --> - + 4.0.0 org.onap.ccsdk.apps.blueprintsprocessor @@ -57,6 +58,10 @@ org.onap.ccsdk.apps.controllerblueprints resource-dict + + org.onap.ccsdk.apps.components + proto-definition + org.onap.ccsdk.sli.core 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 7086ebbc..a67e006a 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 : BlueprintFunctionNodeprotobuf-java-util ${protobuff.java.utils.version} + + org.onap.ccsdk.apps.components + proto-definition + ${project.version} + -- cgit 1.2.3-korg