From 8fd8e9fc86a24be49d61841e381423120a41296d Mon Sep 17 00:00:00 2001 From: PatrikBuhr Date: Mon, 10 May 2021 13:42:22 +0200 Subject: [PATCH] NONRTRIC - ECS updates of the NBI Major changes of the data producer and data consumer APIs to generalize it. Signed-off-by: PatrikBuhr Issue-ID: NONRTRIC-512 Change-Id: I7d618a5260f2a40c8213fadffb6ed21aff0c7a30 --- enrichment-coordinator-service/api/ecs-api.json | 612 +++++++++---------- enrichment-coordinator-service/api/ecs-api.yaml | 673 +++++++++++---------- .../java/org/oransc/enrichment/BeanFactory.java | 30 +- .../java/org/oransc/enrichment/SwaggerConfig.java | 9 +- .../enrichment/controllers/ErrorResponse.java | 2 +- .../enrichment/controllers/StatusController.java | 22 +- .../enrichment/controllers/a1e/A1eCallbacks.java | 18 +- .../enrichment/controllers/a1e/A1eController.java | 61 +- .../enrichment/controllers/a1e/A1eEiJobInfo.java | 8 +- .../controllers/r1consumer/ConsumerController.java | 70 ++- .../r1consumer/ConsumerInfoTypeInfo.java | 8 +- .../controllers/r1consumer/ConsumerJobInfo.java | 47 +- .../controllers/r1consumer/ConsumerJobStatus.java | 14 +- .../controllers/r1producer/ProducerCallbacks.java | 52 +- .../controllers/r1producer/ProducerConsts.java | 2 +- .../controllers/r1producer/ProducerController.java | 216 ++++--- ...erEiTypeInfo.java => ProducerInfoTypeInfo.java} | 14 +- .../controllers/r1producer/ProducerJobInfo.java | 38 +- .../r1producer/ProducerRegistrationInfo.java | 24 +- .../controllers/r1producer/ProducerStatusInfo.java | 2 +- .../repository/{EiJob.java => InfoJob.java} | 4 +- .../repository/{EiJobs.java => InfoJobs.java} | 48 +- .../{EiProducer.java => InfoProducer.java} | 14 +- .../{EiProducers.java => InfoProducers.java} | 77 +-- .../repository/{EiType.java => InfoType.java} | 4 +- .../repository/{EiTypes.java => InfoTypes.java} | 28 +- .../enrichment/tasks/ProducerSupervision.java | 46 +- .../org/oransc/enrichment/ApplicationTest.java | 365 +++++------ .../controller/ConsumerSimulatorController.java | 16 +- .../controller/ProducerSimulatorController.java | 32 +- 30 files changed, 1313 insertions(+), 1243 deletions(-) rename enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/{ProducerEiTypeInfo.java => ProducerInfoTypeInfo.java} (72%) rename enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/{EiJob.java => InfoJob.java} (95%) rename enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/{EiJobs.java => InfoJobs.java} (76%) rename enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/{EiProducer.java => InfoProducer.java} (84%) rename enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/{EiProducers.java => InfoProducers.java} (59%) rename enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/{EiType.java => InfoType.java} (92%) rename enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/{EiTypes.java => InfoTypes.java} (84%) diff --git a/enrichment-coordinator-service/api/ecs-api.json b/enrichment-coordinator-service/api/ecs-api.json index 3d6882aa..6e7b541e 100644 --- a/enrichment-coordinator-service/api/ecs-api.json +++ b/enrichment-coordinator-service/api/ecs-api.json @@ -1,35 +1,13 @@ { "components": {"schemas": { - "producer_ei_job_request": { - "description": "The body of the EI producer callbacks for EI job creation and deletion", + "consumer_information_type": { + "description": "Information for an Information type", "type": "object", - "required": ["ei_job_identity"], - "properties": { - "owner": { - "description": "The owner of the job", - "type": "string" - }, - "ei_job_identity": { - "description": "Idenitity of the EI job", - "type": "string" - }, - "last_updated": { - "description": "The time when the job was last updated or created (ISO-8601)", - "type": "string" - }, - "ei_job_data": { - "description": "Json for the job data", - "type": "object" - }, - "target_uri": { - "description": "URI for the target of the EI", - "type": "string" - }, - "ei_type_identity": { - "description": "Type idenitity for the job", - "type": "string" - } - } + "required": ["job_data_schema"], + "properties": {"job_data_schema": { + "description": "Json schema for the job data", + "type": "object" + }} }, "EiTypeObject": { "description": "Information for an EI type", @@ -46,17 +24,17 @@ "properties": { "no_of_producers": { "format": "int32", - "description": "Number of EI producers", + "description": "Number of Information Producers", "type": "integer" }, "no_of_types": { "format": "int32", - "description": "Number of EI types", + "description": "Number of Information Types", "type": "integer" }, "no_of_jobs": { "format": "int32", - "description": "Number of EI jobs", + "description": "Number of Information Jobs", "type": "integer" }, "status": { @@ -65,38 +43,29 @@ } } }, - "producer_ei_type_info": { - "description": "Information for an EI type", - "type": "object", - "required": ["ei_job_data_schema"], - "properties": {"ei_job_data_schema": { - "description": "Json schema for the job data", - "type": "object" - }} - }, "producer_registration_info": { - "description": "Information for an EI producer", + "description": "Information for an Information Producer", "type": "object", "required": [ - "ei_job_callback_url", - "ei_producer_supervision_callback_url", - "supported_ei_types" + "info_job_callback_url", + "info_producer_supervision_callback_url", + "supported_info_types" ], "properties": { - "supported_ei_types": { - "description": "Supported EI type IDs", + "info_producer_supervision_callback_url": { + "description": "callback for producer supervision", + "type": "string" + }, + "supported_info_types": { + "description": "Supported Information Type IDs", "type": "array", "items": { - "description": "Supported EI type IDs", + "description": "Supported Information Type IDs", "type": "string" } }, - "ei_producer_supervision_callback_url": { - "description": "callback for producer supervision", - "type": "string" - }, - "ei_job_callback_url": { - "description": "callback for EI job", + "info_job_callback_url": { + "description": "callback for Information Job", "type": "string" } } @@ -108,7 +77,7 @@ "detail": { "description": "A human-readable explanation specific to this occurrence of the problem.", "type": "string", - "example": "EI job type not found" + "example": "Information Job type not found" }, "status": { "format": "int32", @@ -131,6 +100,19 @@ ] }} }, + "consumer_job_status": { + "description": "Status for an Information Job", + "type": "object", + "required": ["info_job_status"], + "properties": {"info_job_status": { + "description": "Allowed values for Information Job status", + "type": "string", + "enum": [ + "ENABLED", + "DISABLED" + ] + }} + }, "EiJobObject": { "description": "Information for an Enrichment Information Job", "type": "object", @@ -163,97 +145,113 @@ } } }, - "JobStatus": { - "description": "Status for an EI job", + "producer_info_type_info": { + "description": "Information for an Information Type", "type": "object", - "required": ["eiJobStatus"], - "properties": {"eiJobStatus": { - "description": "Allowed values for EI job status", - "type": "string", - "enum": [ - "ENABLED", - "DISABLED" - ] + "required": ["info_job_data_schema"], + "properties": {"info_job_data_schema": { + "description": "Json schema for the job data", + "type": "object" }} }, - "producer_status": { - "description": "Status for an EI Producer", + "producer_info_job_request": { + "description": "The body of the Information Producer callbacks for Information Job creation and deletion", "type": "object", - "required": ["operational_state"], - "properties": {"operational_state": { - "description": "Represents the operational states", - "type": "string", - "enum": [ - "ENABLED", - "DISABLED" - ] - }} - }, - "Void": { - "description": "Void/empty ", - "type": "object" + "required": ["info_job_identity"], + "properties": { + "owner": { + "description": "The owner of the job", + "type": "string" + }, + "last_updated": { + "description": "The time when the job was last updated or created (ISO-8601)", + "type": "string" + }, + "info_job_identity": { + "description": "Identity of the Information Job", + "type": "string" + }, + "target_uri": { + "description": "URI for the target of the produced Information", + "type": "string" + }, + "info_job_data": { + "description": "Json for the job data", + "type": "object" + }, + "info_type_identity": { + "description": "Type identity for the job", + "type": "string" + } + } }, - "Job": { - "description": "Information for an Enrichment Information Job", + "consumer_job": { + "description": "Information for an Enrichment Information Job", "type": "object", "required": [ - "infoTypeId", - "jobDefinition", - "jobOwner", - "jobResultUri" + "info_type_id", + "job_definition", + "job_owner", + "job_result_uri" ], "properties": { - "jobResultUri": { - "description": "The target URI of the subscribed information", - "type": "string" - }, - "infoTypeId": { + "info_type_id": { "description": "Information type Idenitifier of the subscription job", "type": "string" }, - "jobOwner": { - "description": "Identity of the owner of the job", + "job_result_uri": { + "description": "The target URI of the subscribed information", "type": "string" }, - "statusNotificationUri": { - "description": "The target of Information subscription job status notifications", + "job_owner": { + "description": "Identity of the owner of the job", "type": "string" }, - "jobDefinition": { + "job_definition": { "description": "Information type specific job data", "type": "object" + }, + "status_notification_uri": { + "description": "The target of Information subscription job status notifications", + "type": "string" } } }, - "InformationType": { - "description": "Information for an Information type", + "producer_status": { + "description": "Status for an Info Producer", "type": "object", - "required": ["consumer_job_data_schema"], - "properties": {"consumer_job_data_schema": { - "description": "Json schema for the job data", - "type": "object" + "required": ["operational_state"], + "properties": {"operational_state": { + "description": "Represents the operational states", + "type": "string", + "enum": [ + "ENABLED", + "DISABLED" + ] }} + }, + "Void": { + "description": "Void/empty ", + "type": "object" } }}, "openapi": "3.0.1", "paths": { - "/producer_simulator/ei_job": {"post": { - "summary": "Callback for EI job creation/modification", - "requestBody": { - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/producer_ei_job_request"}}}, - "required": true - }, - "description": "The call is invoked to activate or to modify a data subscription. The endpoint is provided by the EI producer.", - "operationId": "jobCreatedCallback", + "/data-producer/v1/info-types": {"get": { + "summary": "Info Type identifiers", + "operationId": "getInfoTypdentifiers", "responses": {"200": { - "description": "OK", - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Void"}}} + "description": "Info Type identifiers", + "content": {"application/json": {"schema": { + "type": "array", + "items": {"type": "string"} + }}} }}, - "tags": ["Data producer (callbacks)"] + "tags": ["Data producer (registration)"] }}, "/A1-EI/v1/eitypes/{eiTypeId}": {"get": { "summary": "Individual EI type", - "operationId": "getEiType_1", + "operationId": "getEiType", "responses": { "200": { "description": "EI type", @@ -272,104 +270,31 @@ }], "tags": ["A1-EI (registration)"] }}, - "/ei-producer/v1/eitypes": {"get": { - "summary": "EI type identifiers", - "operationId": "getEiTypeIdentifiers", - "responses": {"200": { - "description": "EI type identifiers", - "content": {"application/json": {"schema": { - "type": "array", - "items": {"type": "string"} - }}} - }}, - "tags": ["Data producer (registration)"] - }}, - "/A1-EI/v1/eitypes": {"get": { - "summary": "EI type identifiers", - "operationId": "getEiTypeIdentifiers_1", - "responses": {"200": { - "description": "EI type identifiers", - "content": {"application/json": {"schema": { - "type": "array", - "items": {"type": "string"} - }}} - }}, - "tags": ["A1-EI (registration)"] - }}, - "/data-consumer/v1/info-types": {"get": { - "summary": "Information type identifiers", - "operationId": "getinfoTypeIdentifiers", - "responses": {"200": { - "description": "Information type identifiers", - "content": {"application/json": {"schema": { - "type": "array", - "items": {"type": "string"} - }}} - }}, - "tags": ["Data consumer"] - }}, - "/ei-producer/v1/eiproducers/{eiProducerId}/status": {"get": { - "summary": "EI producer status", - "operationId": "getEiProducerStatus", - "responses": { - "200": { - "description": "EI producer status", - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/producer_status"}}} - }, - "404": { - "description": "Enrichment Information producer is not found", - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProblemDetails"}}} - } - }, - "parameters": [{ - "schema": {"type": "string"}, - "in": "path", - "name": "eiProducerId", - "required": true - }], - "tags": ["Data producer (registration)"] - }}, - "/producer_simulator/ei_job/{eiJobId}": {"delete": { - "summary": "Callback for EI job deletion", - "description": "The call is invoked to terminate a data subscription. The endpoint is provided by the EI producer.", - "operationId": "jobDeletedCallback", - "responses": {"200": { - "description": "OK", - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Void"}}} - }}, - "parameters": [{ - "schema": {"type": "string"}, - "in": "path", - "name": "eiJobId", - "required": true - }], - "tags": ["Data producer (callbacks)"] - }}, - "/ei-producer/v1/eitypes/{eiTypeId}": { + "/data-producer/v1/info-types/{infoTypeId}": { "get": { - "summary": "Individual EI type", - "operationId": "getEiType", + "summary": "Individual Information Type", + "operationId": "getInfoType", "responses": { "200": { - "description": "EI type", - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/producer_ei_type_info"}}} + "description": "Info Type", + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/producer_info_type_info"}}} }, "404": { - "description": "Enrichment Information type is not found", + "description": "Information type is not found", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProblemDetails"}}} } }, "parameters": [{ "schema": {"type": "string"}, "in": "path", - "name": "eiTypeId", + "name": "infoTypeId", "required": true }], "tags": ["Data producer (registration)"] }, "delete": { - "summary": "Individual EI type", - "operationId": "deleteEiType", + "summary": "Individual Information Type", + "operationId": "deleteInfoType", "responses": { "200": { "description": "Not used", @@ -380,29 +305,29 @@ "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Void"}}} }, "404": { - "description": "Enrichment Information type is not found", + "description": "Information type is not found", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProblemDetails"}}} }, "406": { - "description": "The Enrichment Information type has one or several active producers", + "description": "The Information type has one or several active producers", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProblemDetails"}}} } }, "parameters": [{ "schema": {"type": "string"}, "in": "path", - "name": "eiTypeId", + "name": "infoTypeId", "required": true }], "tags": ["Data producer (registration)"] }, "put": { - "summary": "Individual EI type", + "summary": "Individual Information Type", "requestBody": { - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/producer_ei_type_info"}}}, + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/producer_info_type_info"}}}, "required": true }, - "operationId": "putEiType", + "operationId": "putInfoType", "responses": { "200": { "description": "Type updated", @@ -420,197 +345,218 @@ "parameters": [{ "schema": {"type": "string"}, "in": "path", - "name": "eiTypeId", + "name": "infoTypeId", "required": true }], "tags": ["Data producer (registration)"] } }, - "/status": {"get": { - "summary": "Returns status and statistics of this service", - "operationId": "getStatus", + "/A1-EI/v1/eitypes": {"get": { + "summary": "EI type identifiers", + "operationId": "getEiTypeIdentifiers", "responses": {"200": { - "description": "Service is living", - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/status_info"}}} + "description": "EI type identifiers", + "content": {"application/json": {"schema": { + "type": "array", + "items": {"type": "string"} + }}} }}, - "tags": ["Service status"] + "tags": ["A1-EI (registration)"] }}, - "/ei-producer/v1/eiproducers": {"get": { - "summary": "EI producer identifiers", - "operationId": "getEiProducerIdentifiers", + "/data-consumer/v1/info-types": {"get": { + "summary": "Information type identifiers", + "operationId": "getinfoTypeIdentifiers", "responses": {"200": { - "description": "EI producer identifiers", + "description": "Information type identifiers", "content": {"application/json": {"schema": { "type": "array", "items": {"type": "string"} }}} }}, - "parameters": [{ - "schema": {"type": "string"}, - "in": "query", - "name": "ei_type_id", - "description": "If given, only the producers for the EI Data type is returned.", - "required": false - }], - "tags": ["Data producer (registration)"] + "tags": ["Data consumer"] }}, - "/A1-EI/v1/eijobs/{eiJobId}": { + "/data-producer/v1/info-producers/{infoProducerId}": { "get": { - "summary": "Individual EI job", - "operationId": "getIndividualEiJob_1", + "summary": "Individual Information Producer", + "operationId": "getInfoProducer", "responses": { "200": { - "description": "EI job", - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EiJobObject"}}} + "description": "Information producer", + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/producer_registration_info"}}} }, "404": { - "description": "Enrichment Information job is not found", + "description": "Information producer is not found", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProblemDetails"}}} } }, "parameters": [{ "schema": {"type": "string"}, "in": "path", - "name": "eiJobId", + "name": "infoProducerId", "required": true }], - "tags": ["A1-EI (registration)"] + "tags": ["Data producer (registration)"] }, "delete": { - "summary": "Individual EI job", - "operationId": "deleteIndividualEiJob_1", + "summary": "Individual Information Producer", + "operationId": "deleteInfoProducer", "responses": { "200": { "description": "Not used", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Void"}}} }, "204": { - "description": "Job deleted", + "description": "Producer deleted", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Void"}}} }, "404": { - "description": "Enrichment Information job is not found", + "description": "Producer is not found", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProblemDetails"}}} } }, "parameters": [{ "schema": {"type": "string"}, "in": "path", - "name": "eiJobId", + "name": "infoProducerId", "required": true }], - "tags": ["A1-EI (registration)"] + "tags": ["Data producer (registration)"] }, "put": { - "summary": "Individual EI job", + "summary": "Individual Information Producer", "requestBody": { - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EiJobObject"}}}, + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/producer_registration_info"}}}, "required": true }, - "operationId": "putIndividualEiJob", + "operationId": "putInfoProducer", "responses": { "200": { - "description": "Job updated", + "description": "Producer updated", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Void"}}} }, "201": { - "description": "Job created", + "description": "Producer created", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Void"}}} }, "404": { - "description": "Enrichment Information type is not found", + "description": "Producer not found", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProblemDetails"}}} } }, "parameters": [{ "schema": {"type": "string"}, "in": "path", - "name": "eiJobId", + "name": "infoProducerId", "required": true }], - "tags": ["A1-EI (registration)"] + "tags": ["Data producer (registration)"] } }, - "/ei-producer/v1/eiproducers/{eiProducerId}": { + "/producer_simulator/info_job/{infoJobId}": {"delete": { + "summary": "Callback for Information Job deletion", + "description": "The call is invoked to terminate a data subscription. The endpoint is provided by the Information Producer.", + "operationId": "jobDeletedCallback", + "responses": {"200": { + "description": "OK", + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Void"}}} + }}, + "parameters": [{ + "schema": {"type": "string"}, + "in": "path", + "name": "infoJobId", + "required": true + }], + "tags": ["Data producer (callbacks)"] + }}, + "/status": {"get": { + "summary": "Returns status and statistics of this service", + "operationId": "getStatus", + "responses": {"200": { + "description": "Service is living", + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/status_info"}}} + }}, + "tags": ["Service status"] + }}, + "/A1-EI/v1/eijobs/{eiJobId}": { "get": { - "summary": "Individual EI producer", - "operationId": "getEiProducer", + "summary": "Individual EI job", + "operationId": "getIndividualEiJob_1", "responses": { "200": { - "description": "EI producer", - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/producer_registration_info"}}} + "description": "EI job", + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EiJobObject"}}} }, "404": { - "description": "Enrichment Information producer is not found", + "description": "Enrichment Information job is not found", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProblemDetails"}}} } }, "parameters": [{ "schema": {"type": "string"}, "in": "path", - "name": "eiProducerId", + "name": "eiJobId", "required": true }], - "tags": ["Data producer (registration)"] + "tags": ["A1-EI (registration)"] }, "delete": { - "summary": "Individual EI producer", - "operationId": "deleteEiProducer", + "summary": "Individual EI job", + "operationId": "deleteIndividualEiJob_1", "responses": { "200": { "description": "Not used", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Void"}}} }, "204": { - "description": "Producer deleted", + "description": "Job deleted", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Void"}}} }, "404": { - "description": "Producer is not found", + "description": "Enrichment Information job is not found", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProblemDetails"}}} } }, "parameters": [{ "schema": {"type": "string"}, "in": "path", - "name": "eiProducerId", + "name": "eiJobId", "required": true }], - "tags": ["Data producer (registration)"] + "tags": ["A1-EI (registration)"] }, "put": { - "summary": "Individual EI producer", + "summary": "Individual EI job", "requestBody": { - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/producer_registration_info"}}}, + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EiJobObject"}}}, "required": true }, - "operationId": "putEiProducer", + "operationId": "putIndividualEiJob", "responses": { "200": { - "description": "Producer updated", + "description": "Job updated", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Void"}}} }, "201": { - "description": "Producer created", + "description": "Job created", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Void"}}} }, "404": { - "description": "Producer not found", + "description": "Enrichment Information type is not found", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProblemDetails"}}} } }, "parameters": [{ "schema": {"type": "string"}, "in": "path", - "name": "eiProducerId", + "name": "eiJobId", "required": true }], - "tags": ["Data producer (registration)"] + "tags": ["A1-EI (registration)"] } }, "/producer_simulator/health_check": {"get": { "summary": "Producer supervision", - "description": "The endpoint is provided by the EI producer and is used for supervision of the producer.", + "description": "The endpoint is provided by the Information Producer and is used for supervision of the producer.", "operationId": "producerSupervision", "responses": {"200": { "description": "The producer is OK", @@ -619,7 +565,7 @@ "tags": ["Data producer (callbacks)"] }}, "/data-consumer/v1/info-jobs": {"get": { - "summary": "EI job identifiers", + "summary": "Information Job identifiers", "description": "query for information job identifiers", "operationId": "getJobIds", "responses": { @@ -660,7 +606,7 @@ "responses": { "200": { "description": "Information subscription job", - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Job"}}} + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/consumer_job"}}} }, "404": { "description": "Information subscription job is not found", @@ -703,7 +649,7 @@ "put": { "summary": "Individual data subscription job", "requestBody": { - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Job"}}}, + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/consumer_job"}}}, "required": true }, "description": "The job will be enabled when a producer is available", @@ -718,7 +664,7 @@ "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Void"}}} }, "404": { - "description": "Enrichment Information type is not found", + "description": "Information type is not found", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProblemDetails"}}} } }, @@ -743,38 +689,32 @@ "tags": ["Data consumer"] } }, - "/ei-producer/v1/eiproducers/{eiProducerId}/eijobs": {"get": { - "summary": "EI job definitions", - "description": "EI job definitions for one EI producer", - "operationId": "getEiProducerJobs", - "responses": { - "200": { - "description": "EI producer", - "content": {"application/json": {"schema": { - "type": "array", - "items": {"$ref": "#/components/schemas/producer_ei_job_request"} - }}} - }, - "404": { - "description": "Enrichment Information producer is not found", - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProblemDetails"}}} - } - }, + "/data-producer/v1/info-producers": {"get": { + "summary": "Information producer identifiers", + "operationId": "getInfoProducerIdentifiers", + "responses": {"200": { + "description": "Information producer identifiers", + "content": {"application/json": {"schema": { + "type": "array", + "items": {"type": "string"} + }}} + }}, "parameters": [{ "schema": {"type": "string"}, - "in": "path", - "name": "eiProducerId", - "required": true + "in": "query", + "name": "info_type_id", + "description": "If given, only the producers for the EI Data type is returned.", + "required": false }], "tags": ["Data producer (registration)"] }}, "/data-consumer/v1/info-types/{infoTypeId}": {"get": { "summary": "Individual information type", - "operationId": "getInfoType", + "operationId": "getInfoType_1", "responses": { "200": { "description": "Information type", - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/InformationType"}}} + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/consumer_information_type"}}} }, "404": { "description": "Information type is not found", @@ -789,6 +729,40 @@ }], "tags": ["Data consumer"] }}, + "/producer_simulator/info_job": {"post": { + "summary": "Callback for Information Job creation/modification", + "requestBody": { + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/producer_info_job_request"}}}, + "required": true + }, + "description": "The call is invoked to activate or to modify a data subscription. The endpoint is provided by the Information Producer.", + "operationId": "jobCreatedCallback", + "responses": {"200": { + "description": "OK", + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Void"}}} + }}, + "tags": ["Data producer (callbacks)"] + }}, + "/example_dataconsumer/info_jobs/{infoJobId}/status": {"post": { + "summary": "Callback for changed Information Job status", + "requestBody": { + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EiJobStatusObject"}}}, + "required": true + }, + "description": "The primitive is implemented by the data consumer and is invoked when a Information Job status has been changed.", + "operationId": "jobStatusCallback", + "responses": {"200": { + "description": "OK", + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Void"}}} + }}, + "parameters": [{ + "schema": {"type": "string"}, + "in": "path", + "name": "infoJobId", + "required": true + }], + "tags": ["A1-EI (callbacks)"] + }}, "/A1-EI/v1/eijobs": {"get": { "summary": "EI job identifiers", "description": "query for EI job identifiers", @@ -845,25 +819,51 @@ }], "tags": ["A1-EI (registration)"] }}, - "/example_dataconsumer/eijobs/{eiJobId}/status": {"post": { - "summary": "Callback for changed EI job status", - "requestBody": { - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EiJobStatusObject"}}}, + "/data-producer/v1/info-producers/{infoProducerId}/status": {"get": { + "summary": "Information producer status", + "operationId": "getInfoProducerStatus", + "responses": { + "200": { + "description": "Information producer status", + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/producer_status"}}} + }, + "404": { + "description": "Information producer is not found", + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProblemDetails"}}} + } + }, + "parameters": [{ + "schema": {"type": "string"}, + "in": "path", + "name": "infoProducerId", "required": true + }], + "tags": ["Data producer (registration)"] + }}, + "/data-producer/v1/info-producers/{infoProducerId}/info-jobs": {"get": { + "summary": "Information Job definitions", + "description": "Information Job definitions for one Information Producer", + "operationId": "getInfoProducerJobs", + "responses": { + "200": { + "description": "Information producer", + "content": {"application/json": {"schema": { + "type": "array", + "items": {"$ref": "#/components/schemas/producer_info_job_request"} + }}} + }, + "404": { + "description": "Information producer is not found", + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProblemDetails"}}} + } }, - "description": "The primitive is implemented by the data consumer and is invoked when a EI job status has been changed.", - "operationId": "jobStatusCallback", - "responses": {"200": { - "description": "OK", - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Void"}}} - }}, "parameters": [{ "schema": {"type": "string"}, "in": "path", - "name": "eiJobId", + "name": "infoProducerId", "required": true }], - "tags": ["A1-EI (callbacks)"] + "tags": ["Data producer (registration)"] }}, "/data-consumer/v1/info-jobs/{infoJobId}/status": {"get": { "summary": "Job status", @@ -871,7 +871,7 @@ "responses": { "200": { "description": "Information subscription job status", - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/JobStatus"}}} + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/consumer_job_status"}}} }, "404": { "description": "Information subscription job is not found", @@ -892,7 +892,7 @@ "name": "Copyright (C) 2020 Nordix Foundation. Licensed under the Apache License.", "url": "http://www.apache.org/licenses/LICENSE-2.0" }, - "description": "

API documentation<\/h1>

General<\/h2>

The service is mainly a broker between data producers and data consumers. A data producer has the ability to produce one or several types of data (EI type). One type of data can be produced by zero to many producers.

A data consumer can have several active data subscriptions (EI job). One EI job consists of the type of data to produce and additional parameters for filtering of the data. These parameters are different for different data types.<\/p>

APIs provided by the service<\/h2>

A1-EI<\/h4>

This API is between Near-RT RIC and the Non-RT RIC. The Near-RT RIC is a data consumer, which creates Enrichment Information Jobs to subscribe for data.<\/p>

Data producer API<\/h4>

This API is provided by the Non-RT RIC platform and is intended to be part of the O-RAN R1 interface. The API is for use by different kinds of data producers and provides support for:

  • Registry of supported information types and which parameters needed to setup a subscription.<\/li>
  • Registry of existing data producers.<\/li>
  • Callback API provided by producers to setup subscriptions.<\/li><\/ul><\/p>

    Data consumer API<\/h4>

    This API is provided by the Non-RT RIC platform and is intended to be part of the O-RAN R1 interface. The API is for use by different kinds of data consumers and provides support for:

    • Querying of available types of data to consume.<\/li>
    • Management of data subscription jobs<\/li><\/ul><\/p>

      EI Service status<\/h4>

      This API provides a means to monitor the service.<\/p>", + "description": "

      API documentation<\/h1>

      General<\/h2>

      The service is mainly a broker between data producers and data consumers. A data producer has the ability to produce one or several types of data (Information Type). One type of data can be produced by zero to many producers.

      A data consumer can have several active data subscriptions (Information Job). One Information Job consists of the type of data to produce and additional parameters for filtering of the data. These parameters are different for different data types.<\/p>

      APIs provided by the service<\/h2>

      A1-EI<\/h4>

      This API is between Near-RT RIC and the Non-RT RIC. The Near-RT RIC is a data consumer, which creates Information Jobs to subscribe for data. In this context, the information is referred to as 'Enrichment Information', EI.<\/p>

      Data producer API<\/h4>

      This API is provided by the Non-RT RIC platform and is intended to be part of the O-RAN R1 interface. The API is for use by different kinds of data producers and provides support for:

      • Registry of supported information types and which parameters needed to setup a subscription.<\/li>
      • Registry of existing data producers.<\/li>
      • Callback API provided by producers to setup subscriptions.<\/li><\/ul><\/p>

        Data consumer API<\/h4>

        This API is provided by the Non-RT RIC platform and is intended to be part of the O-RAN R1 interface. The API is for use by different kinds of data consumers and provides support for:

        • Querying of available types of data to consume.<\/li>
        • Management of data subscription jobs<\/li><\/ul><\/p>

          Service status<\/h4>

          This API provides a means to monitor the health of this service.<\/p>", "title": "Data management and exposure", "version": "1.0" }, diff --git a/enrichment-coordinator-service/api/ecs-api.yaml b/enrichment-coordinator-service/api/ecs-api.yaml index 3eda306a..50b8a12e 100644 --- a/enrichment-coordinator-service/api/ecs-api.yaml +++ b/enrichment-coordinator-service/api/ecs-api.yaml @@ -3,23 +3,25 @@ info: title: Data management and exposure description:

          API documentation

          General

          The service is mainly a broker between data producers and data consumers. A data producer has the ability - to produce one or several types of data (EI type). One type of data can be produced - by zero to many producers.

          A data consumer can have several active - data subscriptions (EI job). One EI job consists of the type of data to produce - and additional parameters for filtering of the data. These parameters are different - for different data types.

          APIs provided by the service

          A1-EI

          This - API is between Near-RT RIC and the Non-RT RIC. The Near-RT RIC is a data consumer, - which creates Enrichment Information Jobs to subscribe for data.

          Data producer - API

          This API is provided by the Non-RT RIC platform and is intended to - be part of the O-RAN R1 interface. The API is for use by different kinds of data - producers and provides support for:

          • Registry of supported information types - and which parameters needed to setup a subscription.
          • Registry of existing - data producers.
          • Callback API provided by producers to setup subscriptions.

          Data - consumer API

          This API is provided by the Non-RT RIC platform and is intended - to be part of the O-RAN R1 interface. The API is for use by different kinds of - data consumers and provides support for:

          • Querying of available types of - data to consume.
          • Management of data subscription jobs

          EI - Service status

          This API provides a means to monitor the service.

          + to produce one or several types of data (Information Type). One type of data can + be produced by zero to many producers.

          A data consumer can have several + active data subscriptions (Information Job). One Information Job consists of the + type of data to produce and additional parameters for filtering of the data. These + parameters are different for different data types.

          APIs provided by the + service

          A1-EI

          This API is between Near-RT RIC and the Non-RT + RIC. The Near-RT RIC is a data consumer, which creates Information Jobs to subscribe + for data. In this context, the information is referred to as 'Enrichment Information', + EI.

          Data producer API

          This API is provided by the Non-RT RIC platform + and is intended to be part of the O-RAN R1 interface. The API is for use by different + kinds of data producers and provides support for:

          • Registry of supported + information types and which parameters needed to setup a subscription.
          • Registry + of existing data producers.
          • Callback API provided by producers to setup + subscriptions.

          Data consumer API

          This API is provided + by the Non-RT RIC platform and is intended to be part of the O-RAN R1 interface. The + API is for use by different kinds of data consumers and provides support for:

          • Querying + of available types of data to consume.
          • Management of data subscription + jobs

          Service status

          This API provides a means to monitor + the health of this service.

          license: name: Copyright (C) 2020 Nordix Foundation. Licensed under the Apache License. url: http://www.apache.org/licenses/LICENSE-2.0 @@ -40,33 +42,27 @@ tags: - name: Data consumer description: API for data consumers paths: - /producer_simulator/ei_job: - post: + /data-producer/v1/info-types: + get: tags: - - Data producer (callbacks) - summary: Callback for EI job creation/modification - description: The call is invoked to activate or to modify a data subscription. - The endpoint is provided by the EI producer. - operationId: jobCreatedCallback - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/producer_ei_job_request' - required: true + - Data producer (registration) + summary: Info Type identifiers + operationId: getInfoTypdentifiers responses: 200: - description: OK + description: Info Type identifiers content: application/json: schema: - $ref: '#/components/schemas/Void' + type: array + items: + type: string /A1-EI/v1/eitypes/{eiTypeId}: get: tags: - A1-EI (registration) summary: Individual EI type - operationId: getEiType_1 + operationId: getEiType parameters: - name: eiTypeId in: path @@ -88,109 +84,14 @@ paths: application/json: schema: $ref: '#/components/schemas/ProblemDetails' - /ei-producer/v1/eitypes: + /data-producer/v1/info-types/{infoTypeId}: get: tags: - Data producer (registration) - summary: EI type identifiers - operationId: getEiTypeIdentifiers - responses: - 200: - description: EI type identifiers - content: - application/json: - schema: - type: array - items: - type: string - /A1-EI/v1/eitypes: - get: - tags: - - A1-EI (registration) - summary: EI type identifiers - operationId: getEiTypeIdentifiers_1 - responses: - 200: - description: EI type identifiers - content: - application/json: - schema: - type: array - items: - type: string - /data-consumer/v1/info-types: - get: - tags: - - Data consumer - summary: Information type identifiers - operationId: getinfoTypeIdentifiers - responses: - 200: - description: Information type identifiers - content: - application/json: - schema: - type: array - items: - type: string - /ei-producer/v1/eiproducers/{eiProducerId}/status: - get: - tags: - - Data producer (registration) - summary: EI producer status - operationId: getEiProducerStatus - parameters: - - name: eiProducerId - in: path - required: true - style: simple - explode: false - schema: - type: string - responses: - 200: - description: EI producer status - content: - application/json: - schema: - $ref: '#/components/schemas/producer_status' - 404: - description: Enrichment Information producer is not found - content: - application/json: - schema: - $ref: '#/components/schemas/ProblemDetails' - /producer_simulator/ei_job/{eiJobId}: - delete: - tags: - - Data producer (callbacks) - summary: Callback for EI job deletion - description: The call is invoked to terminate a data subscription. The endpoint - is provided by the EI producer. - operationId: jobDeletedCallback - parameters: - - name: eiJobId - in: path - required: true - style: simple - explode: false - schema: - type: string - responses: - 200: - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Void' - /ei-producer/v1/eitypes/{eiTypeId}: - get: - tags: - - Data producer (registration) - summary: Individual EI type - operationId: getEiType + summary: Individual Information Type + operationId: getInfoType parameters: - - name: eiTypeId + - name: infoTypeId in: path required: true style: simple @@ -199,13 +100,13 @@ paths: type: string responses: 200: - description: EI type + description: Info Type content: application/json: schema: - $ref: '#/components/schemas/producer_ei_type_info' + $ref: '#/components/schemas/producer_info_type_info' 404: - description: Enrichment Information type is not found + description: Information type is not found content: application/json: schema: @@ -213,10 +114,10 @@ paths: put: tags: - Data producer (registration) - summary: Individual EI type - operationId: putEiType + summary: Individual Information Type + operationId: putInfoType parameters: - - name: eiTypeId + - name: infoTypeId in: path required: true style: simple @@ -227,7 +128,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/producer_ei_type_info' + $ref: '#/components/schemas/producer_info_type_info' required: true responses: 200: @@ -251,10 +152,10 @@ paths: delete: tags: - Data producer (registration) - summary: Individual EI type - operationId: deleteEiType + summary: Individual Information Type + operationId: deleteInfoType parameters: - - name: eiTypeId + - name: infoTypeId in: path required: true style: simple @@ -275,62 +176,55 @@ paths: schema: $ref: '#/components/schemas/Void' 404: - description: Enrichment Information type is not found + description: Information type is not found content: application/json: schema: $ref: '#/components/schemas/ProblemDetails' 406: - description: The Enrichment Information type has one or several active producers + description: The Information type has one or several active producers content: application/json: schema: $ref: '#/components/schemas/ProblemDetails' - /status: + /A1-EI/v1/eitypes: get: tags: - - Service status - summary: Returns status and statistics of this service - operationId: getStatus + - A1-EI (registration) + summary: EI type identifiers + operationId: getEiTypeIdentifiers responses: 200: - description: Service is living + description: EI type identifiers content: application/json: schema: - $ref: '#/components/schemas/status_info' - /ei-producer/v1/eiproducers: + type: array + items: + type: string + /data-consumer/v1/info-types: get: tags: - - Data producer (registration) - summary: EI producer identifiers - operationId: getEiProducerIdentifiers - parameters: - - name: ei_type_id - in: query - description: If given, only the producers for the EI Data type is returned. - required: false - style: form - explode: true - schema: - type: string + - Data consumer + summary: Information type identifiers + operationId: getinfoTypeIdentifiers responses: 200: - description: EI producer identifiers + description: Information type identifiers content: application/json: schema: type: array items: type: string - /A1-EI/v1/eijobs/{eiJobId}: + /data-producer/v1/info-producers/{infoProducerId}: get: tags: - - A1-EI (registration) - summary: Individual EI job - operationId: getIndividualEiJob_1 + - Data producer (registration) + summary: Individual Information Producer + operationId: getInfoProducer parameters: - - name: eiJobId + - name: infoProducerId in: path required: true style: simple @@ -339,24 +233,24 @@ paths: type: string responses: 200: - description: EI job + description: Information producer content: application/json: schema: - $ref: '#/components/schemas/EiJobObject' + $ref: '#/components/schemas/producer_registration_info' 404: - description: Enrichment Information job is not found + description: Information producer is not found content: application/json: schema: $ref: '#/components/schemas/ProblemDetails' put: tags: - - A1-EI (registration) - summary: Individual EI job - operationId: putIndividualEiJob + - Data producer (registration) + summary: Individual Information Producer + operationId: putInfoProducer parameters: - - name: eiJobId + - name: infoProducerId in: path required: true style: simple @@ -367,34 +261,34 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/EiJobObject' + $ref: '#/components/schemas/producer_registration_info' required: true responses: 200: - description: Job updated + description: Producer updated content: application/json: schema: $ref: '#/components/schemas/Void' 201: - description: Job created + description: Producer created content: application/json: schema: $ref: '#/components/schemas/Void' 404: - description: Enrichment Information type is not found + description: Producer not found content: application/json: schema: $ref: '#/components/schemas/ProblemDetails' delete: tags: - - A1-EI (registration) - summary: Individual EI job - operationId: deleteIndividualEiJob_1 + - Data producer (registration) + summary: Individual Information Producer + operationId: deleteInfoProducer parameters: - - name: eiJobId + - name: infoProducerId in: path required: true style: simple @@ -409,25 +303,61 @@ paths: schema: $ref: '#/components/schemas/Void' 204: - description: Job deleted + description: Producer deleted content: application/json: schema: $ref: '#/components/schemas/Void' 404: - description: Enrichment Information job is not found + description: Producer is not found content: application/json: schema: $ref: '#/components/schemas/ProblemDetails' - /ei-producer/v1/eiproducers/{eiProducerId}: + /producer_simulator/info_job/{infoJobId}: + delete: + tags: + - Data producer (callbacks) + summary: Callback for Information Job deletion + description: The call is invoked to terminate a data subscription. The endpoint + is provided by the Information Producer. + operationId: jobDeletedCallback + parameters: + - name: infoJobId + in: path + required: true + style: simple + explode: false + schema: + type: string + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Void' + /status: get: tags: - - Data producer (registration) - summary: Individual EI producer - operationId: getEiProducer + - Service status + summary: Returns status and statistics of this service + operationId: getStatus + responses: + 200: + description: Service is living + content: + application/json: + schema: + $ref: '#/components/schemas/status_info' + /A1-EI/v1/eijobs/{eiJobId}: + get: + tags: + - A1-EI (registration) + summary: Individual EI job + operationId: getIndividualEiJob_1 parameters: - - name: eiProducerId + - name: eiJobId in: path required: true style: simple @@ -436,24 +366,24 @@ paths: type: string responses: 200: - description: EI producer + description: EI job content: application/json: schema: - $ref: '#/components/schemas/producer_registration_info' + $ref: '#/components/schemas/EiJobObject' 404: - description: Enrichment Information producer is not found + description: Enrichment Information job is not found content: application/json: schema: $ref: '#/components/schemas/ProblemDetails' put: tags: - - Data producer (registration) - summary: Individual EI producer - operationId: putEiProducer + - A1-EI (registration) + summary: Individual EI job + operationId: putIndividualEiJob parameters: - - name: eiProducerId + - name: eiJobId in: path required: true style: simple @@ -464,34 +394,34 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/producer_registration_info' + $ref: '#/components/schemas/EiJobObject' required: true responses: 200: - description: Producer updated + description: Job updated content: application/json: schema: $ref: '#/components/schemas/Void' 201: - description: Producer created + description: Job created content: application/json: schema: $ref: '#/components/schemas/Void' 404: - description: Producer not found + description: Enrichment Information type is not found content: application/json: schema: $ref: '#/components/schemas/ProblemDetails' delete: tags: - - Data producer (registration) - summary: Individual EI producer - operationId: deleteEiProducer + - A1-EI (registration) + summary: Individual EI job + operationId: deleteIndividualEiJob_1 parameters: - - name: eiProducerId + - name: eiJobId in: path required: true style: simple @@ -506,13 +436,13 @@ paths: schema: $ref: '#/components/schemas/Void' 204: - description: Producer deleted + description: Job deleted content: application/json: schema: $ref: '#/components/schemas/Void' 404: - description: Producer is not found + description: Enrichment Information job is not found content: application/json: schema: @@ -522,8 +452,8 @@ paths: tags: - Data producer (callbacks) summary: Producer supervision - description: The endpoint is provided by the EI producer and is used for supervision - of the producer. + description: The endpoint is provided by the Information Producer and is used + for supervision of the producer. operationId: producerSupervision responses: 200: @@ -536,7 +466,7 @@ paths: get: tags: - Data consumer - summary: EI job identifiers + summary: Information Job identifiers description: query for information job identifiers operationId: getJobIds parameters: @@ -591,7 +521,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Job' + $ref: '#/components/schemas/consumer_job' 404: description: Information subscription job is not found content: @@ -626,7 +556,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Job' + $ref: '#/components/schemas/consumer_job' required: true responses: 200: @@ -642,7 +572,7 @@ paths: schema: $ref: '#/components/schemas/Void' 404: - description: Enrichment Information type is not found + description: Information type is not found content: application/json: schema: @@ -679,42 +609,36 @@ paths: application/json: schema: $ref: '#/components/schemas/ProblemDetails' - /ei-producer/v1/eiproducers/{eiProducerId}/eijobs: + /data-producer/v1/info-producers: get: tags: - Data producer (registration) - summary: EI job definitions - description: EI job definitions for one EI producer - operationId: getEiProducerJobs + summary: Information producer identifiers + operationId: getInfoProducerIdentifiers parameters: - - name: eiProducerId - in: path - required: true - style: simple - explode: false + - name: info_type_id + in: query + description: If given, only the producers for the EI Data type is returned. + required: false + style: form + explode: true schema: type: string responses: 200: - description: EI producer + description: Information producer identifiers content: application/json: schema: type: array items: - $ref: '#/components/schemas/producer_ei_job_request' - 404: - description: Enrichment Information producer is not found - content: - application/json: - schema: - $ref: '#/components/schemas/ProblemDetails' + type: string /data-consumer/v1/info-types/{infoTypeId}: get: tags: - Data consumer summary: Individual information type - operationId: getInfoType + operationId: getInfoType_1 parameters: - name: infoTypeId in: path @@ -729,13 +653,63 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/InformationType' + $ref: '#/components/schemas/consumer_information_type' 404: description: Information type is not found content: application/json: schema: $ref: '#/components/schemas/ProblemDetails' + /producer_simulator/info_job: + post: + tags: + - Data producer (callbacks) + summary: Callback for Information Job creation/modification + description: The call is invoked to activate or to modify a data subscription. + The endpoint is provided by the Information Producer. + operationId: jobCreatedCallback + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/producer_info_job_request' + required: true + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Void' + /example_dataconsumer/info_jobs/{infoJobId}/status: + post: + tags: + - A1-EI (callbacks) + summary: Callback for changed Information Job status + description: The primitive is implemented by the data consumer and is invoked + when a Information Job status has been changed. + operationId: jobStatusCallback + parameters: + - name: infoJobId + in: path + required: true + style: simple + explode: false + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/EiJobStatusObject' + required: true + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Void' /A1-EI/v1/eijobs: get: tags: @@ -802,35 +776,63 @@ paths: application/json: schema: $ref: '#/components/schemas/ProblemDetails' - /example_dataconsumer/eijobs/{eiJobId}/status: - post: + /data-producer/v1/info-producers/{infoProducerId}/status: + get: tags: - - A1-EI (callbacks) - summary: Callback for changed EI job status - description: The primitive is implemented by the data consumer and is invoked - when a EI job status has been changed. - operationId: jobStatusCallback + - Data producer (registration) + summary: Information producer status + operationId: getInfoProducerStatus parameters: - - name: eiJobId + - name: infoProducerId in: path required: true style: simple explode: false schema: type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/EiJobStatusObject' + responses: + 200: + description: Information producer status + content: + application/json: + schema: + $ref: '#/components/schemas/producer_status' + 404: + description: Information producer is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + /data-producer/v1/info-producers/{infoProducerId}/info-jobs: + get: + tags: + - Data producer (registration) + summary: Information Job definitions + description: Information Job definitions for one Information Producer + operationId: getInfoProducerJobs + parameters: + - name: infoProducerId + in: path required: true + style: simple + explode: false + schema: + type: string responses: 200: - description: OK + description: Information producer content: application/json: schema: - $ref: '#/components/schemas/Void' + type: array + items: + $ref: '#/components/schemas/producer_info_job_request' + 404: + description: Information producer is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' /data-consumer/v1/info-jobs/{infoJobId}/status: get: tags: @@ -851,7 +853,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/JobStatus' + $ref: '#/components/schemas/consumer_job_status' 404: description: Information subscription job is not found content: @@ -860,30 +862,15 @@ paths: $ref: '#/components/schemas/ProblemDetails' components: schemas: - producer_ei_job_request: + consumer_information_type: required: - - ei_job_identity + - job_data_schema type: object properties: - owner: - type: string - description: The owner of the job - ei_job_identity: - type: string - description: Idenitity of the EI job - last_updated: - type: string - description: The time when the job was last updated or created (ISO-8601) - ei_job_data: + job_data_schema: type: object - description: Json for the job data - target_uri: - type: string - description: URI for the target of the EI - ei_type_identity: - type: string - description: Type idenitity for the job - description: The body of the EI producer callbacks for EI job creation and deletion + description: Json schema for the job data + description: Information for an Information type EiTypeObject: type: object description: Information for an EI type @@ -897,48 +884,39 @@ components: properties: no_of_producers: type: integer - description: Number of EI producers + description: Number of Information Producers format: int32 no_of_types: type: integer - description: Number of EI types + description: Number of Information Types format: int32 no_of_jobs: type: integer - description: Number of EI jobs + description: Number of Information Jobs format: int32 status: type: string description: status text - producer_ei_type_info: - required: - - ei_job_data_schema - type: object - properties: - ei_job_data_schema: - type: object - description: Json schema for the job data - description: Information for an EI type producer_registration_info: required: - - ei_job_callback_url - - ei_producer_supervision_callback_url - - supported_ei_types + - info_job_callback_url + - info_producer_supervision_callback_url + - supported_info_types type: object properties: - supported_ei_types: + info_producer_supervision_callback_url: + type: string + description: callback for producer supervision + supported_info_types: type: array - description: Supported EI type IDs + description: Supported Information Type IDs items: type: string - description: Supported EI type IDs - ei_producer_supervision_callback_url: + description: Supported Information Type IDs + info_job_callback_url: type: string - description: callback for producer supervision - ei_job_callback_url: - type: string - description: callback for EI job - description: Information for an EI producer + description: callback for Information Job + description: Information for an Information Producer ProblemDetails: type: object properties: @@ -946,7 +924,7 @@ components: type: string description: A human-readable explanation specific to this occurrence of the problem. - example: EI job type not found + example: Information Job type not found status: type: integer description: The HTTP status code generated by the origin server for this @@ -967,6 +945,18 @@ components: - ENABLED - DISABLED description: Status for an EI job + consumer_job_status: + required: + - info_job_status + type: object + properties: + info_job_status: + type: string + description: Allowed values for Information Job status + enum: + - ENABLED + - DISABLED + description: Status for an Information Job EiJobObject: required: - eiTypeId @@ -991,63 +981,76 @@ components: type: object description: EI type specific job data description: Information for an Enrichment Information Job - JobStatus: + producer_info_type_info: required: - - eiJobStatus + - info_job_data_schema type: object properties: - eiJobStatus: - type: string - description: Allowed values for EI job status - enum: - - ENABLED - - DISABLED - description: Status for an EI job - producer_status: + info_job_data_schema: + type: object + description: Json schema for the job data + description: Information for an Information Type + producer_info_job_request: required: - - operational_state + - info_job_identity type: object properties: - operational_state: + owner: type: string - description: Represents the operational states - enum: - - ENABLED - - DISABLED - description: Status for an EI Producer - Void: - type: object - description: 'Void/empty ' - Job: + description: The owner of the job + last_updated: + type: string + description: The time when the job was last updated or created (ISO-8601) + info_job_identity: + type: string + description: Identity of the Information Job + target_uri: + type: string + description: URI for the target of the produced Information + info_job_data: + type: object + description: Json for the job data + info_type_identity: + type: string + description: Type identity for the job + description: The body of the Information Producer callbacks for Information + Job creation and deletion + consumer_job: required: - - infoTypeId - - jobDefinition - - jobOwner - - jobResultUri + - info_type_id + - job_definition + - job_owner + - job_result_uri type: object properties: - jobResultUri: - type: string - description: The target URI of the subscribed information - infoTypeId: + info_type_id: type: string description: Information type Idenitifier of the subscription job - jobOwner: + job_result_uri: type: string - description: Identity of the owner of the job - statusNotificationUri: + description: The target URI of the subscribed information + job_owner: type: string - description: The target of Information subscription job status notifications - jobDefinition: + description: Identity of the owner of the job + job_definition: type: object description: Information type specific job data - description: Information for an Enrichment Information Job - InformationType: + status_notification_uri: + type: string + description: The target of Information subscription job status notifications + description: Information for an Enrichment Information Job + producer_status: required: - - consumer_job_data_schema + - operational_state type: object properties: - consumer_job_data_schema: - type: object - description: Json schema for the job data - description: Information for an Information type + operational_state: + type: string + description: Represents the operational states + enum: + - ENABLED + - DISABLED + description: Status for an Info Producer + Void: + type: object + description: 'Void/empty ' diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/BeanFactory.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/BeanFactory.java index e636e50f..1d493bb1 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/BeanFactory.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/BeanFactory.java @@ -27,8 +27,8 @@ import java.lang.invoke.MethodHandles; import org.apache.catalina.connector.Connector; import org.oransc.enrichment.configuration.ApplicationConfig; import org.oransc.enrichment.controllers.r1producer.ProducerCallbacks; -import org.oransc.enrichment.repository.EiJobs; -import org.oransc.enrichment.repository.EiTypes; +import org.oransc.enrichment.repository.InfoJobs; +import org.oransc.enrichment.repository.InfoTypes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; @@ -47,8 +47,8 @@ class BeanFactory { private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private ProducerCallbacks producerCallbacks; - private EiTypes eiTypes; - private EiJobs eiJobs; + private InfoTypes infoTypes; + private InfoJobs infoJobs; @Bean public ObjectMapper mapper() { @@ -65,29 +65,29 @@ class BeanFactory { } @Bean - public EiJobs eiJobs() { - if (eiJobs == null) { - eiJobs = new EiJobs(getApplicationConfig(), producerCallbacks()); + public InfoJobs infoJobs() { + if (infoJobs == null) { + infoJobs = new InfoJobs(getApplicationConfig(), producerCallbacks()); try { - eiJobs.restoreJobsFromDatabase(); + infoJobs.restoreJobsFromDatabase(); } catch (Exception e) { logger.error("Could not restore jobs from database: {}", e.getMessage()); } } - return eiJobs; + return infoJobs; } @Bean - public EiTypes eiTypes() { - if (this.eiTypes == null) { - eiTypes = new EiTypes(getApplicationConfig()); + public InfoTypes infoTypes() { + if (this.infoTypes == null) { + infoTypes = new InfoTypes(getApplicationConfig()); try { - eiTypes.restoreTypesFromDatabase(); + infoTypes.restoreTypesFromDatabase(); } catch (Exception e) { - logger.error("Could not restore EI types from database: {}", e.getMessage()); + logger.error("Could not restore Information Types from database: {}", e.getMessage()); } } - return eiTypes; + return infoTypes; } @Bean diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/SwaggerConfig.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/SwaggerConfig.java index 58f69de8..6b5edc03 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/SwaggerConfig.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/SwaggerConfig.java @@ -63,13 +63,14 @@ public class SwaggerConfig { static final String DESCRIPTION = "

          API documentation

          " // + "

          General

          " // + "

          " // - + " The service is mainly a broker between data producers and data consumers. A data producer has the ability to produce one or several types of data (EI type). One type of data can be produced by zero to many producers.

          A data consumer can have several active data subscriptions (EI job). One EI job consists of the type of data to produce and additional parameters for filtering of the data. These parameters are different for different data types." // + + " The service is mainly a broker between data producers and data consumers. A data producer has the ability to produce one or several types of data (Information Type). One type of data can be produced by zero to many producers.

          A data consumer can have several active data subscriptions (Information Job). One Information Job consists of the type of data to produce and additional parameters for filtering of the data. These parameters are different for different data types." // + "

          " // + "

          APIs provided by the service

          " // + "

          A1-EI

          " // + "

          " // + " This API is between Near-RT RIC and the Non-RT RIC." // - + " The Near-RT RIC is a data consumer, which creates Enrichment Information Jobs to subscribe for data." // + + " The Near-RT RIC is a data consumer, which creates Information Jobs to subscribe for data." // + + " In this context, the information is referred to as 'Enrichment Information', EI." // + "

          " // + "

          Data producer API

          " // + "

          " // @@ -90,9 +91,9 @@ public class SwaggerConfig { + "

        • Management of data subscription jobs
        • " // + "
        " // + "

        " // - + "

        EI Service status

        " // + + "

        Service status

        " // + "

        " // - + " This API provides a means to monitor the service." // + + " This API provides a means to monitor the health of this service." // + "

        "; } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/ErrorResponse.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/ErrorResponse.java index d423e19f..1539d8c2 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/ErrorResponse.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/ErrorResponse.java @@ -69,7 +69,7 @@ public class ErrorResponse { } @Schema( - example = "EI job type not found", + example = "Information Job type not found", description = "A human-readable explanation specific to this occurrence of the problem.") public String getDetail() { return this.detail; diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/StatusController.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/StatusController.java index b23d606d..68b654e4 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/StatusController.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/StatusController.java @@ -31,9 +31,9 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import org.immutables.gson.Gson; -import org.oransc.enrichment.repository.EiJobs; -import org.oransc.enrichment.repository.EiProducers; -import org.oransc.enrichment.repository.EiTypes; +import org.oransc.enrichment.repository.InfoJobs; +import org.oransc.enrichment.repository.InfoProducers; +import org.oransc.enrichment.repository.InfoTypes; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -50,13 +50,13 @@ public class StatusController { public static final String API_DESCRIPTION = "API for monitoring of the service"; @Autowired - private EiJobs eiJobs; + private InfoJobs infoJobs; @Autowired - private EiTypes eiTypes; + private InfoTypes infoTypes; @Autowired - private EiProducers eiProducers; + private InfoProducers infoProducers; @Gson.TypeAdapters @Schema(name = "status_info") @@ -66,22 +66,22 @@ public class StatusController { @JsonProperty(value = "status", required = true) public final String status; - @Schema(name = "no_of_producers", description = "Number of EI producers") + @Schema(name = "no_of_producers", description = "Number of Information Producers") @SerializedName("no_of_producers") @JsonProperty(value = "no_of_producers", required = true) public final int noOfProducers; - @Schema(name = "no_of_types", description = "Number of EI types") + @Schema(name = "no_of_types", description = "Number of Information Types") @SerializedName("no_of_types") @JsonProperty(value = "no_of_types", required = true) public final int noOfTypes; - @Schema(name = "no_of_jobs", description = "Number of EI jobs") + @Schema(name = "no_of_jobs", description = "Number of Information Jobs") @SerializedName("no_of_jobs") @JsonProperty(value = "no_of_jobs", required = true) public final int noOfJobs; - public StatusInfo(String status, EiProducers producers, EiTypes types, EiJobs jobs) { + public StatusInfo(String status, InfoProducers producers, InfoTypes types, InfoJobs jobs) { this.status = status; this.noOfJobs = jobs.size(); this.noOfProducers = producers.size(); @@ -99,7 +99,7 @@ public class StatusController { content = @Content(schema = @Schema(implementation = StatusInfo.class))) // }) public Mono> getStatus() { - StatusInfo info = new StatusInfo("hunky dory", this.eiProducers, this.eiTypes, this.eiJobs); + StatusInfo info = new StatusInfo("hunky dory", this.infoProducers, this.infoTypes, this.infoJobs); return Mono.just(new ResponseEntity<>(info, HttpStatus.OK)); } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/a1e/A1eCallbacks.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/a1e/A1eCallbacks.java index fc17ee2e..17f63516 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/a1e/A1eCallbacks.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/a1e/A1eCallbacks.java @@ -29,10 +29,10 @@ import java.util.Collection; import org.oransc.enrichment.clients.AsyncRestClient; import org.oransc.enrichment.clients.AsyncRestClientFactory; import org.oransc.enrichment.configuration.ApplicationConfig; -import org.oransc.enrichment.repository.EiJob; -import org.oransc.enrichment.repository.EiJobs; -import org.oransc.enrichment.repository.EiProducers; -import org.oransc.enrichment.repository.EiType; +import org.oransc.enrichment.repository.InfoJob; +import org.oransc.enrichment.repository.InfoJobs; +import org.oransc.enrichment.repository.InfoProducers; +import org.oransc.enrichment.repository.InfoType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -52,18 +52,18 @@ public class A1eCallbacks { private static Gson gson = new GsonBuilder().create(); private final AsyncRestClient restClient; - private final EiJobs eiJobs; - private final EiProducers eiProducers; + private final InfoJobs eiJobs; + private final InfoProducers eiProducers; @Autowired - public A1eCallbacks(ApplicationConfig config, EiJobs eiJobs, EiProducers eiProducers) { + public A1eCallbacks(ApplicationConfig config, InfoJobs eiJobs, InfoProducers eiProducers) { AsyncRestClientFactory restClientFactory = new AsyncRestClientFactory(config.getWebClientConfig()); this.restClient = restClientFactory.createRestClientUseHttpProxy(""); this.eiJobs = eiJobs; this.eiProducers = eiProducers; } - public Flux notifyJobStatus(Collection eiTypes) { + public Flux notifyJobStatus(Collection eiTypes) { return Flux.fromIterable(eiTypes) // .flatMap(eiType -> Flux.fromIterable(this.eiJobs.getJobsForType(eiType))) // .filter(eiJob -> !eiJob.getJobStatusUrl().isEmpty()) // @@ -71,7 +71,7 @@ public class A1eCallbacks { .flatMap(this::noifyStatusToJobOwner); } - private Mono noifyStatusToJobOwner(EiJob job) { + private Mono noifyStatusToJobOwner(InfoJob job) { boolean isJobEnabled = this.eiProducers.isJobEnabled(job); A1eEiJobStatus status = isJobEnabled ? new A1eEiJobStatus(A1eEiJobStatus.EiJobStatusValues.ENABLED) : new A1eEiJobStatus(A1eEiJobStatus.EiJobStatusValues.DISABLED); diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/a1e/A1eController.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/a1e/A1eController.java index 34d9725e..4c5f5d0c 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/a1e/A1eController.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/a1e/A1eController.java @@ -34,6 +34,8 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import java.lang.invoke.MethodHandles; +import java.net.URI; +import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; @@ -43,11 +45,11 @@ import org.oransc.enrichment.controllers.ErrorResponse; import org.oransc.enrichment.controllers.VoidResponse; import org.oransc.enrichment.controllers.r1producer.ProducerCallbacks; import org.oransc.enrichment.exceptions.ServiceException; -import org.oransc.enrichment.repository.EiJob; -import org.oransc.enrichment.repository.EiJobs; -import org.oransc.enrichment.repository.EiProducers; -import org.oransc.enrichment.repository.EiType; -import org.oransc.enrichment.repository.EiTypes; +import org.oransc.enrichment.repository.InfoJob; +import org.oransc.enrichment.repository.InfoJobs; +import org.oransc.enrichment.repository.InfoProducers; +import org.oransc.enrichment.repository.InfoType; +import org.oransc.enrichment.repository.InfoTypes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -76,13 +78,13 @@ public class A1eController { ApplicationConfig applicationConfig; @Autowired - private EiJobs eiJobs; + private InfoJobs eiJobs; @Autowired - private EiTypes eiTypes; + private InfoTypes eiTypes; @Autowired - private EiProducers eiProducers; + private InfoProducers infoProducers; @Autowired ProducerCallbacks producerCallbacks; @@ -101,7 +103,7 @@ public class A1eController { public ResponseEntity getEiTypeIdentifiers( // ) { List result = new ArrayList<>(); - for (EiType eiType : this.eiTypes.getAllInfoTypes()) { + for (InfoType eiType : this.eiTypes.getAllInfoTypes()) { result.add(eiType.getId()); } @@ -159,7 +161,7 @@ public class A1eController { try { List result = new ArrayList<>(); if (owner != null) { - for (EiJob job : this.eiJobs.getJobsForOwner(owner)) { + for (InfoJob job : this.eiJobs.getJobsForOwner(owner)) { if (eiTypeId == null || job.getTypeId().equals(eiTypeId)) { result.add(job.getId()); } @@ -193,7 +195,7 @@ public class A1eController { public ResponseEntity getIndividualEiJob( // @PathVariable("eiJobId") String eiJobId) { try { - EiJob job = this.eiJobs.getJob(eiJobId); + InfoJob job = this.eiJobs.getJob(eiJobId); return new ResponseEntity<>(gson.toJson(toEiJobInfo(job)), HttpStatus.OK); } catch (Exception e) { return ErrorResponse.create(e, HttpStatus.NOT_FOUND); @@ -216,15 +218,15 @@ public class A1eController { public ResponseEntity getEiJobStatus( // @PathVariable("eiJobId") String eiJobId) { try { - EiJob job = this.eiJobs.getJob(eiJobId); + InfoJob job = this.eiJobs.getJob(eiJobId); return new ResponseEntity<>(gson.toJson(toEiJobStatus(job)), HttpStatus.OK); } catch (Exception e) { return ErrorResponse.create(e, HttpStatus.NOT_FOUND); } } - private A1eEiJobStatus toEiJobStatus(EiJob job) { - return this.eiProducers.isJobEnabled(job) ? new A1eEiJobStatus(A1eEiJobStatus.EiJobStatusValues.ENABLED) + private A1eEiJobStatus toEiJobStatus(InfoJob job) { + return this.infoProducers.isJobEnabled(job) ? new A1eEiJobStatus(A1eEiJobStatus.EiJobStatusValues.ENABLED) : new A1eEiJobStatus(A1eEiJobStatus.EiJobStatusValues.DISABLED); } @@ -249,8 +251,8 @@ public class A1eController { public ResponseEntity deleteIndividualEiJob( // @PathVariable("eiJobId") String eiJobId) { try { - EiJob job = this.eiJobs.getJob(eiJobId); - this.eiJobs.remove(job, this.eiProducers); + InfoJob job = this.eiJobs.getJob(eiJobId); + this.eiJobs.remove(job, this.infoProducers); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } catch (Exception e) { return ErrorResponse.create(e, HttpStatus.NOT_FOUND); @@ -290,18 +292,20 @@ public class A1eController { .onErrorResume(throwable -> Mono.just(ErrorResponse.create(throwable, HttpStatus.NOT_FOUND))); } - private Mono startEiJob(EiJob newEiJob) { - return this.producerCallbacks.startInfoSubscriptionJob(newEiJob, eiProducers) // + private Mono startEiJob(InfoJob newEiJob) { + return this.producerCallbacks.startInfoSubscriptionJob(newEiJob, infoProducers) // .doOnNext(noOfAcceptingProducers -> this.logger.debug( "Started EI job {}, number of activated producers: {}", newEiJob.getId(), noOfAcceptingProducers)) // .flatMap(noOfAcceptingProducers -> Mono.just(newEiJob)); } - private Mono validatePutEiJob(String eiJobId, A1eEiJobInfo eiJobInfo) { + private Mono validatePutEiJob(String eiJobId, A1eEiJobInfo eiJobInfo) { try { - EiType eiType = this.eiTypes.getType(eiJobInfo.eiTypeId); + InfoType eiType = this.eiTypes.getType(eiJobInfo.eiTypeId); validateJsonObjectAgainstSchema(eiType.getJobDataSchema(), eiJobInfo.jobDefinition); - EiJob existingEiJob = this.eiJobs.get(eiJobId); + InfoJob existingEiJob = this.eiJobs.get(eiJobId); + validateUri(eiJobInfo.jobResultUri); + validateUri(eiJobInfo.statusNotificationUri); if (existingEiJob != null && !existingEiJob.getTypeId().equals(eiJobInfo.eiTypeId)) { throw new ServiceException("Not allowed to change type for existing EI job", HttpStatus.CONFLICT); @@ -312,6 +316,15 @@ public class A1eController { } } + private void validateUri(String url) throws URISyntaxException, ServiceException { + if (url != null && !url.isEmpty()) { + URI uri = new URI(url); + if (!uri.isAbsolute()) { + throw new ServiceException("URI: " + url + " is not absolute", HttpStatus.CONFLICT); + } + } + } + private void validateJsonObjectAgainstSchema(Object schemaObj, Object object) throws ServiceException { if (schemaObj != null) { // schema is optional for now try { @@ -330,8 +343,8 @@ public class A1eController { } } - private EiJob toEiJob(A1eEiJobInfo info, String id, EiType type) { - return EiJob.builder() // + private InfoJob toEiJob(A1eEiJobInfo info, String id, InfoType type) { + return InfoJob.builder() // .id(id) // .typeId(type.getId()) // .owner(info.owner) // @@ -345,7 +358,7 @@ public class A1eController { return new A1eEiTypeInfo(); } - private A1eEiJobInfo toEiJobInfo(EiJob s) { + private A1eEiJobInfo toEiJobInfo(InfoJob s) { return new A1eEiJobInfo(s.getTypeId(), s.getJobData(), s.getOwner(), s.getTargetUrl(), s.getJobStatusUrl()); } } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/a1e/A1eEiJobInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/a1e/A1eEiJobInfo.java index 05506d21..61038c3d 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/a1e/A1eEiJobInfo.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/a1e/A1eEiJobInfo.java @@ -34,12 +34,12 @@ public class A1eEiJobInfo { @Schema(name = "eiTypeId", description = "EI type Idenitifier of the EI job", required = true) @SerializedName("eiTypeId") @JsonProperty(value = "eiTypeId", required = true) - public String eiTypeId; + public String eiTypeId = ""; @Schema(name = "jobOwner", description = "Identity of the owner of the job", required = true) @SerializedName("jobOwner") @JsonProperty(value = "jobOwner", required = true) - public String owner; + public String owner = ""; @Schema(name = "jobDefinition", description = "EI type specific job data", required = true) @SerializedName("jobDefinition") @@ -49,12 +49,12 @@ public class A1eEiJobInfo { @Schema(name = "jobResultUri", description = "The target URI of the EI data", required = true) @SerializedName("jobResultUri") @JsonProperty(value = "jobResultUri", required = true) - public String jobResultUri; + public String jobResultUri = ""; @Schema(name = "statusNotificationUri", description = "The target of EI job status notifications", required = false) @SerializedName("jobStatusNotificationUri") @JsonProperty(value = "jobStatusNotificationUri", required = false) - public String statusNotificationUri; + public String statusNotificationUri = ""; public A1eEiJobInfo() { } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerController.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerController.java index e93d9cbd..94f4684f 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerController.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerController.java @@ -34,6 +34,8 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import java.lang.invoke.MethodHandles; +import java.net.URI; +import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; @@ -43,11 +45,11 @@ import org.oransc.enrichment.controllers.ErrorResponse; import org.oransc.enrichment.controllers.VoidResponse; import org.oransc.enrichment.controllers.r1producer.ProducerCallbacks; import org.oransc.enrichment.exceptions.ServiceException; -import org.oransc.enrichment.repository.EiJob; -import org.oransc.enrichment.repository.EiJobs; -import org.oransc.enrichment.repository.EiProducers; -import org.oransc.enrichment.repository.EiType; -import org.oransc.enrichment.repository.EiTypes; +import org.oransc.enrichment.repository.InfoJob; +import org.oransc.enrichment.repository.InfoJobs; +import org.oransc.enrichment.repository.InfoProducers; +import org.oransc.enrichment.repository.InfoType; +import org.oransc.enrichment.repository.InfoTypes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -76,13 +78,13 @@ public class ConsumerController { ApplicationConfig applicationConfig; @Autowired - private EiJobs jobs; + private InfoJobs jobs; @Autowired - private EiTypes infoTypes; + private InfoTypes infoTypes; @Autowired - private EiProducers infoProducers; + private InfoProducers infoProducers; @Autowired ProducerCallbacks producerCallbacks; @@ -101,7 +103,7 @@ public class ConsumerController { public ResponseEntity getinfoTypeIdentifiers( // ) { List result = new ArrayList<>(); - for (EiType infoType : this.infoTypes.getAllInfoTypes()) { + for (InfoType infoType : this.infoTypes.getAllInfoTypes()) { result.add(infoType.getId()); } @@ -124,7 +126,7 @@ public class ConsumerController { public ResponseEntity getInfoType( // @PathVariable("infoTypeId") String infoTypeId) { try { - EiType type = this.infoTypes.getType(infoTypeId); + InfoType type = this.infoTypes.getType(infoTypeId); ConsumerInfoTypeInfo info = toInfoTypeInfo(type); return new ResponseEntity<>(gson.toJson(info), HttpStatus.OK); } catch (Exception e) { @@ -133,7 +135,7 @@ public class ConsumerController { } @GetMapping(path = "/info-jobs", produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "EI job identifiers", description = "query for information job identifiers") + @Operation(summary = "Information Job identifiers", description = "query for information job identifiers") @ApiResponses( value = { // @ApiResponse( @@ -159,7 +161,7 @@ public class ConsumerController { try { List result = new ArrayList<>(); if (owner != null) { - for (EiJob job : this.jobs.getJobsForOwner(owner)) { + for (InfoJob job : this.jobs.getJobsForOwner(owner)) { if (infoTypeId == null || job.getTypeId().equals(infoTypeId)) { result.add(job.getId()); } @@ -193,7 +195,7 @@ public class ConsumerController { public ResponseEntity getIndividualEiJob( // @PathVariable("infoJobId") String infoJobId) { try { - EiJob job = this.jobs.getJob(infoJobId); + InfoJob job = this.jobs.getJob(infoJobId); return new ResponseEntity<>(gson.toJson(toInfoJobInfo(job)), HttpStatus.OK); } catch (Exception e) { return ErrorResponse.create(e, HttpStatus.NOT_FOUND); @@ -216,14 +218,14 @@ public class ConsumerController { public ResponseEntity getEiJobStatus( // @PathVariable("infoJobId") String jobId) { try { - EiJob job = this.jobs.getJob(jobId); + InfoJob job = this.jobs.getJob(jobId); return new ResponseEntity<>(gson.toJson(toInfoJobStatus(job)), HttpStatus.OK); } catch (Exception e) { return ErrorResponse.create(e, HttpStatus.NOT_FOUND); } } - private ConsumerJobStatus toInfoJobStatus(EiJob job) { + private ConsumerJobStatus toInfoJobStatus(InfoJob job) { return this.infoProducers.isJobEnabled(job) ? new ConsumerJobStatus(ConsumerJobStatus.InfoJobStatusValues.ENABLED) : new ConsumerJobStatus(ConsumerJobStatus.InfoJobStatusValues.DISABLED); @@ -241,7 +243,8 @@ public class ConsumerController { @ApiResponse( responseCode = "204", description = "Job deleted", // - content = @Content(schema = @Schema(implementation = VoidResponse.class))), // "Individual EI job" + content = @Content(schema = @Schema(implementation = VoidResponse.class))), // "Individual + // Information Job" @ApiResponse( responseCode = "404", description = "Information subscription job is not found", // @@ -250,7 +253,7 @@ public class ConsumerController { public ResponseEntity deleteIndividualEiJob( // @PathVariable("infoJobId") String jobId) { try { - EiJob job = this.jobs.getJob(jobId); + InfoJob job = this.jobs.getJob(jobId); this.jobs.remove(job, this.infoProducers); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } catch (Exception e) { @@ -275,7 +278,7 @@ public class ConsumerController { content = @Content(schema = @Schema(implementation = VoidResponse.class))), // @ApiResponse( responseCode = "404", - description = "Enrichment Information type is not found", // + description = "Information type is not found", // content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))) // }) public Mono> putIndividualInfoJob( // @@ -299,20 +302,22 @@ public class ConsumerController { .onErrorResume(throwable -> Mono.just(ErrorResponse.create(throwable, HttpStatus.NOT_FOUND))); } - private Mono startInfoSubscriptionJob(EiJob newInfoJob) { + private Mono startInfoSubscriptionJob(InfoJob newInfoJob) { return this.producerCallbacks.startInfoSubscriptionJob(newInfoJob, infoProducers) // .doOnNext(noOfAcceptingProducers -> this.logger.debug("Started job {}, number of activated producers: {}", newInfoJob.getId(), noOfAcceptingProducers)) // .flatMap(noOfAcceptingProducers -> Mono.just(newInfoJob)); } - private Mono validatePutInfoJob(String jobId, ConsumerJobInfo jobInfo, boolean performTypeCheck) { + private Mono validatePutInfoJob(String jobId, ConsumerJobInfo jobInfo, boolean performTypeCheck) { try { if (performTypeCheck) { - EiType infoType = this.infoTypes.getType(jobInfo.infoTypeId); + InfoType infoType = this.infoTypes.getType(jobInfo.infoTypeId); validateJsonObjectAgainstSchema(infoType.getJobDataSchema(), jobInfo.jobDefinition); } - EiJob existingEiJob = this.jobs.get(jobId); + InfoJob existingEiJob = this.jobs.get(jobId); + validateUri(jobInfo.statusNotificationUri); + validateUri(jobInfo.jobResultUri); if (existingEiJob != null && !existingEiJob.getTypeId().equals(jobInfo.infoTypeId)) { throw new ServiceException("Not allowed to change type for existing job", HttpStatus.CONFLICT); @@ -323,6 +328,15 @@ public class ConsumerController { } } + private void validateUri(String url) throws URISyntaxException, ServiceException { + if (url != null && !url.isEmpty()) { + URI uri = new URI(url); + if (!uri.isAbsolute()) { + throw new ServiceException("URI: " + url + " is not absolute", HttpStatus.CONFLICT); + } + } + } + private void validateJsonObjectAgainstSchema(Object schemaObj, Object object) throws ServiceException { if (schemaObj != null) { // schema is optional for now try { @@ -341,8 +355,8 @@ public class ConsumerController { } } - private EiJob toEiJob(ConsumerJobInfo info, String id, String typeId) { - return EiJob.builder() // + private InfoJob toEiJob(ConsumerJobInfo info, String id, String typeId) { + return InfoJob.builder() // .id(id) // .typeId(typeId) // .owner(info.owner) // @@ -352,15 +366,11 @@ public class ConsumerController { .build(); } - private EiJob toEiJob(ConsumerJobInfo info, String id, EiType type) { - return toEiJob(info, id, type.getId()); - } - - private ConsumerInfoTypeInfo toInfoTypeInfo(EiType type) { + private ConsumerInfoTypeInfo toInfoTypeInfo(InfoType type) { return new ConsumerInfoTypeInfo(type.getJobDataSchema()); } - private ConsumerJobInfo toInfoJobInfo(EiJob s) { + private ConsumerJobInfo toInfoJobInfo(InfoJob s) { return new ConsumerJobInfo(s.getTypeId(), s.getJobData(), s.getOwner(), s.getTargetUrl(), s.getJobStatusUrl()); } } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerInfoTypeInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerInfoTypeInfo.java index d07356f6..c227a203 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerInfoTypeInfo.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerInfoTypeInfo.java @@ -28,12 +28,12 @@ import io.swagger.v3.oas.annotations.media.Schema; import org.immutables.gson.Gson; @Gson.TypeAdapters -@Schema(name = "InformationType", description = "Information for an Information type") +@Schema(name = "consumer_information_type", description = "Information for an Information type") public class ConsumerInfoTypeInfo { - @Schema(name = "consumer_job_data_schema", description = "Json schema for the job data", required = true) - @SerializedName("consumer_job_data_schema") - @JsonProperty(value = "consumer_job_data_schema", required = true) + @Schema(name = "job_data_schema", description = "Json schema for the job data", required = true) + @SerializedName("job_data_schema") + @JsonProperty(value = "job_data_schema", required = true) public Object jobDataSchema; public ConsumerInfoTypeInfo(Object jobDataSchema) { diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerJobInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerJobInfo.java index 09a78fa9..bc376280 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerJobInfo.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerJobInfo.java @@ -28,43 +28,46 @@ import io.swagger.v3.oas.annotations.media.Schema; import org.immutables.gson.Gson; @Gson.TypeAdapters -@Schema(name = "Job", description = "Information for an Enrichment Information Job") +@Schema(name = "consumer_job", description = "Information for an Enrichment Information Job") public class ConsumerJobInfo { - @Schema(name = "infoTypeId", description = "Information type Idenitifier of the subscription job", required = true) - @SerializedName("infoTypeId") - @JsonProperty(value = "infoTypeId", required = true) - public String infoTypeId; + @Schema( + name = "info_type_id", + description = "Information type Idenitifier of the subscription job", + required = true) + @SerializedName("info_type_id") + @JsonProperty(value = "info_type_id", required = true) + public String infoTypeId = ""; - @Schema(name = "jobOwner", description = "Identity of the owner of the job", required = true) - @SerializedName("jobOwner") - @JsonProperty(value = "jobOwner", required = true) - public String owner; + @Schema(name = "job_owner", description = "Identity of the owner of the job", required = true) + @SerializedName("job_owner") + @JsonProperty(value = "job_owner", required = true) + public String owner = ""; - @Schema(name = "jobDefinition", description = "Information type specific job data", required = true) - @SerializedName("jobDefinition") - @JsonProperty(value = "jobDefinition", required = true) + @Schema(name = "job_definition", description = "Information type specific job data", required = true) + @SerializedName("job_definition") + @JsonProperty(value = "job_definition", required = true) public Object jobDefinition; - @Schema(name = "jobResultUri", description = "The target URI of the subscribed information", required = true) - @SerializedName("jobResultUri") - @JsonProperty(value = "jobResultUri", required = true) - public String jobResultUri; + @Schema(name = "job_result_uri", description = "The target URI of the subscribed information", required = true) + @SerializedName("job_result_uri") + @JsonProperty(value = "job_result_uri", required = true) + public String jobResultUri = ""; @Schema( - name = "statusNotificationUri", + name = "status_notification_uri", description = "The target of Information subscription job status notifications", required = false) - @SerializedName("jobStatusNotificationUri") - @JsonProperty(value = "jobStatusNotificationUri", required = false) - public String statusNotificationUri; + @SerializedName("status_notification_uri") + @JsonProperty(value = "status_notification_uri", required = false) + public String statusNotificationUri = ""; public ConsumerJobInfo() { } - public ConsumerJobInfo(String eiTypeId, Object jobData, String owner, String targetUri, + public ConsumerJobInfo(String infoTypeId, Object jobData, String owner, String targetUri, String statusNotificationUri) { - this.infoTypeId = eiTypeId; + this.infoTypeId = infoTypeId; this.jobDefinition = jobData; this.owner = owner; this.jobResultUri = targetUri; diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerJobStatus.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerJobStatus.java index 034fc33d..d40ecda5 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerJobStatus.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerJobStatus.java @@ -28,22 +28,22 @@ import io.swagger.v3.oas.annotations.media.Schema; import org.immutables.gson.Gson; @Gson.TypeAdapters -@Schema(name = "JobStatus", description = "Status for an EI job") +@Schema(name = "consumer_job_status", description = "Status for an Information Job") public class ConsumerJobStatus { @Gson.TypeAdapters - @Schema(name = "JobStatusValues", description = "Allowed values for EI job status") + @Schema(name = "info_job_status_values", description = "Allowed values for Information Job status") public enum InfoJobStatusValues { ENABLED, DISABLED } private static final String OPERATIONAL_STATE_DESCRIPTION = "values:\n" // - + "ENABLED: the A1-EI producer is able to deliver EI result for the EI job\n" // - + "DISABLED: the A1-EI producer is unable to deliver EI result for the EI job"; + + "ENABLED: the A1-Information producer is able to deliver result for the Information Job\n" // + + "DISABLED: the A1-Information producer is unable to deliver result for the Information Job"; - @Schema(name = "eiJobStatus", description = OPERATIONAL_STATE_DESCRIPTION, required = true) - @SerializedName("eiJobStatus") - @JsonProperty(value = "eiJobStatus", required = true) + @Schema(name = "info_job_status", description = OPERATIONAL_STATE_DESCRIPTION, required = true) + @SerializedName("info_job_status") + @JsonProperty(value = "info_job_status", required = true) public InfoJobStatusValues state; public ConsumerJobStatus() { diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerCallbacks.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerCallbacks.java index 26dd1a1b..61cd519d 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerCallbacks.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerCallbacks.java @@ -30,10 +30,10 @@ import java.util.Collection; import org.oransc.enrichment.clients.AsyncRestClient; import org.oransc.enrichment.clients.AsyncRestClientFactory; import org.oransc.enrichment.configuration.ApplicationConfig; -import org.oransc.enrichment.repository.EiJob; -import org.oransc.enrichment.repository.EiJobs; -import org.oransc.enrichment.repository.EiProducer; -import org.oransc.enrichment.repository.EiProducers; +import org.oransc.enrichment.repository.InfoJob; +import org.oransc.enrichment.repository.InfoJobs; +import org.oransc.enrichment.repository.InfoProducer; +import org.oransc.enrichment.repository.InfoProducers; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,7 +42,7 @@ import reactor.core.publisher.Mono; import reactor.util.retry.Retry; /** - * Callbacks to the EiProducer + * Callbacks to the Producer */ @SuppressWarnings("java:S3457") // No need to call "toString()" method as formatting and string .. public class ProducerCallbacks { @@ -57,14 +57,14 @@ public class ProducerCallbacks { this.restClient = restClientFactory.createRestClientNoHttpProxy(""); } - public Mono healthCheck(EiProducer producer) { + public Mono healthCheck(InfoProducer producer) { return restClient.get(producer.getProducerSupervisionCallbackUrl()); } - public void stopEiJob(EiJob eiJob, EiProducers eiProducers) { - for (EiProducer producer : getProducersForJob(eiJob, eiProducers)) { - String url = producer.getJobCallbackUrl() + "/" + eiJob.getId(); - producer.setJobDisabled(eiJob); + public void stopInfoJob(InfoJob infoJob, InfoProducers infoProducers) { + for (InfoProducer producer : getProducersForJob(infoJob, infoProducers)) { + String url = producer.getJobCallbackUrl() + "/" + infoJob.getId(); + producer.setJobDisabled(infoJob); restClient.delete(url) // .subscribe(response -> logger.debug("Producer job deleted OK {}", producer.getId()), // throwable -> logger.warn("Producer job delete failed {} {}", producer.getId(), @@ -76,13 +76,13 @@ public class ProducerCallbacks { /** * Start a job in all producers that suports the job type * - * @param eiJob an EI job + * @param infoJob an Information Job * @return the number of producers that returned OK */ - public Mono startInfoSubscriptionJob(EiJob eiJob, EiProducers eiProducers) { + public Mono startInfoSubscriptionJob(InfoJob infoJob, InfoProducers infoProducers) { Retry retrySpec = Retry.fixedDelay(1, Duration.ofSeconds(1)); - return Flux.fromIterable(getProducersForJob(eiJob, eiProducers)) // - .flatMap(eiProducer -> startEiJob(eiProducer, eiJob, retrySpec)) // + return Flux.fromIterable(getProducersForJob(infoJob, infoProducers)) // + .flatMap(infoProducer -> startInfoJob(infoProducer, infoJob, retrySpec)) // .collectList() // .flatMap(okResponses -> Mono.just(Integer.valueOf(okResponses.size()))); // } @@ -91,34 +91,34 @@ public class ProducerCallbacks { * Start all jobs for one producer * * @param producer - * @param eiJobs + * @param infoJobs */ - public Flux startEiJobs(EiProducer producer, EiJobs eiJobs) { + public Flux startInfoJobs(InfoProducer producer, InfoJobs infoJobs) { final int maxNoOfParalellRequests = 10; Retry retrySpec = Retry.backoff(3, Duration.ofSeconds(1)); - return Flux.fromIterable(producer.getEiTypes()) // - .flatMap(type -> Flux.fromIterable(eiJobs.getJobsForType(type))) // - .flatMap(job -> startEiJob(producer, job, retrySpec), maxNoOfParalellRequests); + return Flux.fromIterable(producer.getInfoTypes()) // + .flatMap(type -> Flux.fromIterable(infoJobs.getJobsForType(type))) // + .flatMap(job -> startInfoJob(producer, job, retrySpec), maxNoOfParalellRequests); } - public Mono startEiJob(EiProducer producer, EiJob eiJob, Retry retrySpec) { - ProducerJobInfo request = new ProducerJobInfo(eiJob); + public Mono startInfoJob(InfoProducer producer, InfoJob infoJob, Retry retrySpec) { + ProducerJobInfo request = new ProducerJobInfo(infoJob); String body = gson.toJson(request); return restClient.post(producer.getJobCallbackUrl(), body) // .retryWhen(retrySpec) // - .doOnNext(resp -> logger.debug("Job subscription {} started OK {}", eiJob.getId(), producer.getId())) // + .doOnNext(resp -> logger.debug("Job subscription {} started OK {}", infoJob.getId(), producer.getId())) // .onErrorResume(throwable -> { - producer.setJobDisabled(eiJob); + producer.setJobDisabled(infoJob); logger.warn("Job subscription failed {}", producer.getId(), throwable.toString()); return Mono.empty(); }) // - .doOnNext(resp -> producer.setJobEnabled(eiJob)); + .doOnNext(resp -> producer.setJobEnabled(infoJob)); } - private Collection getProducersForJob(EiJob eiJob, EiProducers eiProducers) { - return eiProducers.getProducersForType(eiJob.getTypeId()); + private Collection getProducersForJob(InfoJob infoJob, InfoProducers infoProducers) { + return infoProducers.getProducersForType(infoJob.getTypeId()); } } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerConsts.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerConsts.java index 46161303..a1be7c62 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerConsts.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerConsts.java @@ -22,7 +22,7 @@ package org.oransc.enrichment.controllers.r1producer; public class ProducerConsts { public static final String PRODUCER_API_NAME = "Data producer (registration)"; - public static final String API_ROOT = "/ei-producer/v1"; + public static final String API_ROOT = "/data-producer/v1"; public static final String PRODUCER_API_DESCRIPTION = "API for data producers"; public static final String PRODUCER_API_CALLBACKS_NAME = "Data producer (callbacks)"; diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerController.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerController.java index b63e8342..236d32a0 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerController.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerController.java @@ -32,6 +32,8 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; +import java.net.URI; +import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -39,13 +41,12 @@ import java.util.List; import org.oransc.enrichment.controllers.ErrorResponse; import org.oransc.enrichment.controllers.VoidResponse; import org.oransc.enrichment.exceptions.ServiceException; -import org.oransc.enrichment.repository.EiJob; -import org.oransc.enrichment.repository.EiJobs; -import org.oransc.enrichment.repository.EiProducer; -import org.oransc.enrichment.repository.EiProducers; -import org.oransc.enrichment.repository.EiType; -import org.oransc.enrichment.repository.EiTypes; -import org.oransc.enrichment.repository.ImmutableEiProducerRegistrationInfo; +import org.oransc.enrichment.repository.InfoJob; +import org.oransc.enrichment.repository.InfoJobs; +import org.oransc.enrichment.repository.InfoProducer; +import org.oransc.enrichment.repository.InfoProducers; +import org.oransc.enrichment.repository.InfoType; +import org.oransc.enrichment.repository.InfoTypes; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -66,57 +67,61 @@ public class ProducerController { private static Gson gson = new GsonBuilder().create(); @Autowired - private EiJobs eiJobs; + private InfoJobs infoJobs; @Autowired - private EiTypes eiTypes; + private InfoTypes infoTypes; @Autowired - private EiProducers eiProducers; + private InfoProducers infoProducers; - @GetMapping(path = ProducerConsts.API_ROOT + "/eitypes", produces = MediaType.APPLICATION_JSON_VALUE) // - @Operation(summary = "EI type identifiers", description = "") // + @GetMapping(path = ProducerConsts.API_ROOT + "/info-types", produces = MediaType.APPLICATION_JSON_VALUE) // + @Operation(summary = "Info Type identifiers", description = "") // @ApiResponses( value = { // @ApiResponse( responseCode = "200", - description = "EI type identifiers", // + description = "Info Type identifiers", // content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))) // }) - public ResponseEntity getEiTypeIdentifiers( // + public ResponseEntity getInfoTypdentifiers( // ) { List result = new ArrayList<>(); - for (EiType eiType : this.eiTypes.getAllInfoTypes()) { - result.add(eiType.getId()); + for (InfoType infoType : this.infoTypes.getAllInfoTypes()) { + result.add(infoType.getId()); } return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK); } - @GetMapping(path = ProducerConsts.API_ROOT + "/eitypes/{eiTypeId}", produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Individual EI type", description = "") + @GetMapping( + path = ProducerConsts.API_ROOT + "/info-types/{infoTypeId}", + produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "Individual Information Type", description = "") @ApiResponses( value = { // @ApiResponse( responseCode = "200", - description = "EI type", // - content = @Content(schema = @Schema(implementation = ProducerEiTypeInfo.class))), // + description = "Info Type", // + content = @Content(schema = @Schema(implementation = ProducerInfoTypeInfo.class))), // @ApiResponse( responseCode = "404", - description = "Enrichment Information type is not found", // + description = "Information type is not found", // content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class)))}) - public ResponseEntity getEiType( // - @PathVariable("eiTypeId") String eiTypeId) { + public ResponseEntity getInfoType( // + @PathVariable("infoTypeId") String infoTypeId) { try { - EiType t = this.eiTypes.getType(eiTypeId); - ProducerEiTypeInfo info = toEiTypeInfo(t); + InfoType t = this.infoTypes.getType(infoTypeId); + ProducerInfoTypeInfo info = toInfoTypeInfo(t); return new ResponseEntity<>(gson.toJson(info), HttpStatus.OK); } catch (Exception e) { return ErrorResponse.create(e, HttpStatus.NOT_FOUND); } } - @PutMapping(path = ProducerConsts.API_ROOT + "/eitypes/{eiTypeId}", produces = MediaType.APPLICATION_JSON_VALUE) + @PutMapping( + path = ProducerConsts.API_ROOT + "/info-types/{infoTypeId}", + produces = MediaType.APPLICATION_JSON_VALUE) @ApiResponses( value = { // @ApiResponse( @@ -131,21 +136,23 @@ public class ProducerController { responseCode = "400", description = "Bad request", // content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class)))}) - @Operation(summary = "Individual EI type", description = "") - public ResponseEntity putEiType( // - @PathVariable("eiTypeId") String eiTypeId, // - @RequestBody ProducerEiTypeInfo registrationInfo) { + @Operation(summary = "Individual Information Type", description = "") + public ResponseEntity putInfoType( // + @PathVariable("infoTypeId") String infoTypeId, // + @RequestBody ProducerInfoTypeInfo registrationInfo) { - EiType previousDefinition = this.eiTypes.get(eiTypeId); + InfoType previousDefinition = this.infoTypes.get(infoTypeId); if (registrationInfo.jobDataSchema == null) { return ErrorResponse.create("No schema provided", HttpStatus.BAD_REQUEST); } - this.eiTypes.put(new EiType(eiTypeId, registrationInfo.jobDataSchema)); + this.infoTypes.put(new InfoType(infoTypeId, registrationInfo.jobDataSchema)); return new ResponseEntity<>(previousDefinition == null ? HttpStatus.CREATED : HttpStatus.OK); } - @DeleteMapping(path = ProducerConsts.API_ROOT + "/eitypes/{eiTypeId}", produces = MediaType.APPLICATION_JSON_VALUE) // - @Operation(summary = "Individual EI type", description = "") // + @DeleteMapping( + path = ProducerConsts.API_ROOT + "/info-types/{infoTypeId}", + produces = MediaType.APPLICATION_JSON_VALUE) // + @Operation(summary = "Individual Information Type", description = "") // @ApiResponses( value = { // @ApiResponse( @@ -158,73 +165,73 @@ public class ProducerController { content = @Content(schema = @Schema(implementation = VoidResponse.class))), // @ApiResponse( responseCode = "404", - description = "Enrichment Information type is not found", // + description = "Information type is not found", // content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))), // @ApiResponse( responseCode = "406", - description = "The Enrichment Information type has one or several active producers", // + description = "The Information type has one or several active producers", // content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))) // }) - public ResponseEntity deleteEiType( // - @PathVariable("eiTypeId") String eiTypeId) { + public ResponseEntity deleteInfoType( // + @PathVariable("infoTypeId") String infoTypeId) { - EiType type = this.eiTypes.get(eiTypeId); + InfoType type = this.infoTypes.get(infoTypeId); if (type == null) { return ErrorResponse.create("Information type not found", HttpStatus.NOT_FOUND); } - if (!this.eiProducers.getProducersForType(type).isEmpty()) { - String firstProducerId = this.eiProducers.getProducersForType(type).iterator().next().getId(); + if (!this.infoProducers.getProducersForType(type).isEmpty()) { + String firstProducerId = this.infoProducers.getProducersForType(type).iterator().next().getId(); return ErrorResponse.create("The type has active producers: " + firstProducerId, HttpStatus.NOT_ACCEPTABLE); } - this.eiTypes.remove(type); + this.infoTypes.remove(type); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } - @GetMapping(path = ProducerConsts.API_ROOT + "/eiproducers", produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "EI producer identifiers", description = "") + @GetMapping(path = ProducerConsts.API_ROOT + "/info-producers", produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "Information producer identifiers", description = "") @ApiResponses( value = { // @ApiResponse( responseCode = "200", - description = "EI producer identifiers", // + description = "Information producer identifiers", // content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))) // }) - public ResponseEntity getEiProducerIdentifiers( // + public ResponseEntity getInfoProducerIdentifiers( // @Parameter( - name = "ei_type_id", + name = "info_type_id", required = false, description = "If given, only the producers for the EI Data type is returned.") // - @RequestParam(name = "ei_type_id", required = false) String typeId // + @RequestParam(name = "info_type_id", required = false) String typeId // ) { List result = new ArrayList<>(); - for (EiProducer eiProducer : typeId == null ? this.eiProducers.getAllProducers() - : this.eiProducers.getProducersForType(typeId)) { - result.add(eiProducer.getId()); + for (InfoProducer infoProducer : typeId == null ? this.infoProducers.getAllProducers() + : this.infoProducers.getProducersForType(typeId)) { + result.add(infoProducer.getId()); } return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK); } @GetMapping( - path = ProducerConsts.API_ROOT + "/eiproducers/{eiProducerId}", + path = ProducerConsts.API_ROOT + "/info-producers/{infoProducerId}", produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Individual EI producer", description = "") + @Operation(summary = "Individual Information Producer", description = "") @ApiResponses( value = { // @ApiResponse( responseCode = "200", - description = "EI producer", // + description = "Information producer", // content = @Content(schema = @Schema(implementation = ProducerRegistrationInfo.class))), // @ApiResponse( responseCode = "404", - description = "Enrichment Information producer is not found", // + description = "Information producer is not found", // content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class)))// }) - public ResponseEntity getEiProducer( // - @PathVariable("eiProducerId") String eiProducerId) { + public ResponseEntity getInfoProducer( // + @PathVariable("infoProducerId") String infoProducerId) { try { - EiProducer p = this.eiProducers.getProducer(eiProducerId); - ProducerRegistrationInfo info = toEiProducerRegistrationInfo(p); + InfoProducer p = this.infoProducers.getProducer(infoProducerId); + ProducerRegistrationInfo info = toProducerRegistrationInfo(p); return new ResponseEntity<>(gson.toJson(info), HttpStatus.OK); } catch (Exception e) { return ErrorResponse.create(e, HttpStatus.NOT_FOUND); @@ -232,28 +239,30 @@ public class ProducerController { } @GetMapping( - path = ProducerConsts.API_ROOT + "/eiproducers/{eiProducerId}/eijobs", + path = ProducerConsts.API_ROOT + "/info-producers/{infoProducerId}/info-jobs", produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "EI job definitions", description = "EI job definitions for one EI producer") + @Operation( + summary = "Information Job definitions", + description = "Information Job definitions for one Information Producer") @ApiResponses( value = { // @ApiResponse( responseCode = "404", - description = "Enrichment Information producer is not found", // + description = "Information producer is not found", // content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))), // @ApiResponse( responseCode = "200", - description = "EI producer", // + description = "Information producer", // content = @Content(array = @ArraySchema(schema = @Schema(implementation = ProducerJobInfo.class)))), // }) - public ResponseEntity getEiProducerJobs( // - @PathVariable("eiProducerId") String eiProducerId) { + public ResponseEntity getInfoProducerJobs( // + @PathVariable("infoProducerId") String infoProducerId) { try { - EiProducer producer = this.eiProducers.getProducer(eiProducerId); + InfoProducer producer = this.infoProducers.getProducer(infoProducerId); Collection producerJobs = new ArrayList<>(); - for (EiType type : producer.getEiTypes()) { - for (EiJob eiJob : this.eiJobs.getJobsForType(type)) { - ProducerJobInfo request = new ProducerJobInfo(eiJob); + for (InfoType type : producer.getInfoTypes()) { + for (InfoJob infoJob : this.infoJobs.getJobsForType(type)) { + ProducerJobInfo request = new ProducerJobInfo(infoJob); producerJobs.add(request); } } @@ -265,31 +274,31 @@ public class ProducerController { } @GetMapping( - path = ProducerConsts.API_ROOT + "/eiproducers/{eiProducerId}/status", + path = ProducerConsts.API_ROOT + "/info-producers/{infoProducerId}/status", produces = MediaType.APPLICATION_JSON_VALUE) // - @Operation(summary = "EI producer status") // + @Operation(summary = "Information producer status") // @ApiResponses( value = { // @ApiResponse( responseCode = "200", - description = "EI producer status", // + description = "Information producer status", // content = @Content(schema = @Schema(implementation = ProducerStatusInfo.class))), // @ApiResponse( responseCode = "404", - description = "Enrichment Information producer is not found", // + description = "Information producer is not found", // content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))) // }) - public ResponseEntity getEiProducerStatus( // - @PathVariable("eiProducerId") String eiProducerId) { + public ResponseEntity getInfoProducerStatus( // + @PathVariable("infoProducerId") String infoProducerId) { try { - EiProducer producer = this.eiProducers.getProducer(eiProducerId); + InfoProducer producer = this.infoProducers.getProducer(infoProducerId); return new ResponseEntity<>(gson.toJson(producerStatusInfo(producer)), HttpStatus.OK); } catch (Exception e) { return ErrorResponse.create(e, HttpStatus.NOT_FOUND); } } - private ProducerStatusInfo producerStatusInfo(EiProducer producer) { + private ProducerStatusInfo producerStatusInfo(InfoProducer producer) { ProducerStatusInfo.OperationalState opState = producer.isAvailable() ? ProducerStatusInfo.OperationalState.ENABLED : ProducerStatusInfo.OperationalState.DISABLED; @@ -297,9 +306,9 @@ public class ProducerController { } @PutMapping( - path = ProducerConsts.API_ROOT + "/eiproducers/{eiProducerId}", // + path = ProducerConsts.API_ROOT + "/info-producers/{infoProducerId}", // produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Individual EI producer", description = "") + @Operation(summary = "Individual Information Producer", description = "") @ApiResponses( value = { // @ApiResponse( @@ -315,22 +324,35 @@ public class ProducerController { description = "Producer not found", // content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))) // }) - public ResponseEntity putEiProducer( // - @PathVariable("eiProducerId") String eiProducerId, // + public ResponseEntity putInfoProducer( // + @PathVariable("infoProducerId") String infoProducerId, // @RequestBody ProducerRegistrationInfo registrationInfo) { try { - EiProducer previousDefinition = this.eiProducers.get(eiProducerId); - this.eiProducers.registerProducer(toEiProducerRegistrationInfo(eiProducerId, registrationInfo)); + validateUri(registrationInfo.jobCallbackUrl); + validateUri(registrationInfo.producerSupervisionCallbackUrl); + InfoProducer previousDefinition = this.infoProducers.get(infoProducerId); + this.infoProducers.registerProducer(toProducerRegistrationInfo(infoProducerId, registrationInfo)); return new ResponseEntity<>(previousDefinition == null ? HttpStatus.CREATED : HttpStatus.OK); } catch (Exception e) { return ErrorResponse.create(e, HttpStatus.NOT_FOUND); } } + private void validateUri(String url) throws URISyntaxException, ServiceException { + if (url != null && !url.isEmpty()) { + URI uri = new URI(url); + if (!uri.isAbsolute()) { + throw new ServiceException("URI: " + url + " is not absolute", HttpStatus.CONFLICT); + } + } else { + throw new ServiceException("Missing required URL", HttpStatus.CONFLICT); + } + } + @DeleteMapping( - path = ProducerConsts.API_ROOT + "/eiproducers/{eiProducerId}", + path = ProducerConsts.API_ROOT + "/info-producers/{infoProducerId}", produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Individual EI producer", description = "") + @Operation(summary = "Individual Information Producer", description = "") @ApiResponses( value = { // @ApiResponse( @@ -346,38 +368,38 @@ public class ProducerController { description = "Producer is not found", // content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))) // }) - public ResponseEntity deleteEiProducer(@PathVariable("eiProducerId") String eiProducerId) { + public ResponseEntity deleteInfoProducer(@PathVariable("infoProducerId") String infoProducerId) { try { - final EiProducer producer = this.eiProducers.getProducer(eiProducerId); - this.eiProducers.deregisterProducer(producer); + final InfoProducer producer = this.infoProducers.getProducer(infoProducerId); + this.infoProducers.deregisterProducer(producer); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } catch (Exception e) { return ErrorResponse.create(e, HttpStatus.NOT_FOUND); } } - private ProducerRegistrationInfo toEiProducerRegistrationInfo(EiProducer p) { + private ProducerRegistrationInfo toProducerRegistrationInfo(InfoProducer p) { Collection types = new ArrayList<>(); - for (EiType type : p.getEiTypes()) { + for (InfoType type : p.getInfoTypes()) { types.add(type.getId()); } return new ProducerRegistrationInfo(types, p.getJobCallbackUrl(), p.getProducerSupervisionCallbackUrl()); } - private ProducerEiTypeInfo toEiTypeInfo(EiType t) { - return new ProducerEiTypeInfo(t.getJobDataSchema()); + private ProducerInfoTypeInfo toInfoTypeInfo(InfoType t) { + return new ProducerInfoTypeInfo(t.getJobDataSchema()); } - private EiProducers.EiProducerRegistrationInfo toEiProducerRegistrationInfo(String eiProducerId, + private InfoProducers.InfoProducerRegistrationInfo toProducerRegistrationInfo(String infoProducerId, ProducerRegistrationInfo info) throws ServiceException { - Collection supportedTypes = new ArrayList<>(); + Collection supportedTypes = new ArrayList<>(); for (String typeId : info.supportedTypeIds) { - EiType type = this.eiTypes.getType(typeId); + InfoType type = this.infoTypes.getType(typeId); supportedTypes.add(type); } - return ImmutableEiProducerRegistrationInfo.builder() // - .id(eiProducerId) // + return InfoProducers.InfoProducerRegistrationInfo.builder() // + .id(infoProducerId) // .jobCallbackUrl(info.jobCallbackUrl) // .producerSupervisionCallbackUrl(info.producerSupervisionCallbackUrl) // .supportedTypes(supportedTypes) // diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerEiTypeInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerInfoTypeInfo.java similarity index 72% rename from enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerEiTypeInfo.java rename to enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerInfoTypeInfo.java index c4e495f3..0e066bc9 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerEiTypeInfo.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerInfoTypeInfo.java @@ -28,19 +28,19 @@ import io.swagger.v3.oas.annotations.media.Schema; import org.immutables.gson.Gson; @Gson.TypeAdapters -@Schema(name = "producer_ei_type_info", description = "Information for an EI type") -public class ProducerEiTypeInfo { +@Schema(name = "producer_info_type_info", description = "Information for an Information Type") +public class ProducerInfoTypeInfo { - @Schema(name = "ei_job_data_schema", description = "Json schema for the job data", required = true) - @SerializedName("ei_job_data_schema") - @JsonProperty(value = "ei_job_data_schema", required = true) + @Schema(name = "info_job_data_schema", description = "Json schema for the job data", required = true) + @SerializedName("info_job_data_schema") + @JsonProperty(value = "info_job_data_schema", required = true) public Object jobDataSchema; - public ProducerEiTypeInfo(Object jobDataSchema) { + public ProducerInfoTypeInfo(Object jobDataSchema) { this.jobDataSchema = jobDataSchema; } - public ProducerEiTypeInfo() { + public ProducerInfoTypeInfo() { } } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerJobInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerJobInfo.java index fcc7b7df..1cd3734f 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerJobInfo.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerJobInfo.java @@ -26,43 +26,43 @@ import com.google.gson.annotations.SerializedName; import io.swagger.v3.oas.annotations.media.Schema; import org.immutables.gson.Gson; -import org.oransc.enrichment.repository.EiJob; +import org.oransc.enrichment.repository.InfoJob; @Gson.TypeAdapters @Schema( - name = "producer_ei_job_request", - description = "The body of the EI producer callbacks for EI job creation and deletion") + name = "producer_info_job_request", + description = "The body of the Information Producer callbacks for Information Job creation and deletion") public class ProducerJobInfo { - @Schema(name = "ei_job_identity", description = "Idenitity of the EI job", required = true) - @SerializedName("ei_job_identity") - @JsonProperty("ei_job_identity") - public String id; + @Schema(name = "info_job_identity", description = "Identity of the Information Job", required = true) + @SerializedName("info_job_identity") + @JsonProperty("info_job_identity") + public String id = ""; - @Schema(name = "ei_type_identity", description = "Type idenitity for the job") - @SerializedName("ei_type_identity") - @JsonProperty("ei_type_identity") - public String typeId; + @Schema(name = "info_type_identity", description = "Type identity for the job") + @SerializedName("info_type_identity") + @JsonProperty("info_type_identity") + public String typeId = ""; - @Schema(name = "ei_job_data", description = "Json for the job data") - @SerializedName("ei_job_data") - @JsonProperty("ei_job_data") + @Schema(name = "info_job_data", description = "Json for the job data") + @SerializedName("info_job_data") + @JsonProperty("info_job_data") public Object jobData; - @Schema(name = "target_uri", description = "URI for the target of the EI") + @Schema(name = "target_uri", description = "URI for the target of the produced Information") @SerializedName("target_uri") @JsonProperty("target_uri") - public String targetUri; + public String targetUri = ""; @Schema(name = "owner", description = "The owner of the job") @SerializedName("owner") @JsonProperty("owner") - public String owner; + public String owner = ""; @Schema(name = "last_updated", description = "The time when the job was last updated or created (ISO-8601)") @SerializedName("last_updated") @JsonProperty("last_updated") - public String lastUpdated; + public String lastUpdated = ""; public ProducerJobInfo(Object jobData, String id, String typeId, String targetUri, String owner, String lastUpdated) { @@ -74,7 +74,7 @@ public class ProducerJobInfo { this.lastUpdated = lastUpdated; } - public ProducerJobInfo(EiJob job) { + public ProducerJobInfo(InfoJob job) { this(job.getJobData(), job.getId(), job.getTypeId(), job.getTargetUrl(), job.getOwner(), job.getLastUpdated()); } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerRegistrationInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerRegistrationInfo.java index f73819fb..28a84035 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerRegistrationInfo.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerRegistrationInfo.java @@ -30,26 +30,26 @@ import java.util.Collection; import org.immutables.gson.Gson; @Gson.TypeAdapters -@Schema(name = "producer_registration_info", description = "Information for an EI producer") +@Schema(name = "producer_registration_info", description = "Information for an Information Producer") public class ProducerRegistrationInfo { - @Schema(name = "supported_ei_types", description = "Supported EI type IDs", required = true) - @SerializedName("supported_ei_types") - @JsonProperty(value = "supported_ei_types", required = true) + @Schema(name = "supported_info_types", description = "Supported Information Type IDs", required = true) + @SerializedName("supported_info_types") + @JsonProperty(value = "supported_info_types", required = true) public Collection supportedTypeIds; - @Schema(name = "ei_job_callback_url", description = "callback for EI job", required = true) - @SerializedName("ei_job_callback_url") - @JsonProperty(value = "ei_job_callback_url", required = true) - public String jobCallbackUrl; + @Schema(name = "info_job_callback_url", description = "callback for Information Job", required = true) + @SerializedName("info_job_callback_url") + @JsonProperty(value = "info_job_callback_url", required = true) + public String jobCallbackUrl = ""; @Schema( - name = "ei_producer_supervision_callback_url", + name = "info_producer_supervision_callback_url", description = "callback for producer supervision", required = true) - @SerializedName("ei_producer_supervision_callback_url") - @JsonProperty(value = "ei_producer_supervision_callback_url", required = true) - public String producerSupervisionCallbackUrl; + @SerializedName("info_producer_supervision_callback_url") + @JsonProperty(value = "info_producer_supervision_callback_url", required = true) + public String producerSupervisionCallbackUrl = ""; public ProducerRegistrationInfo(Collection types, String jobCallbackUrl, String producerSupervisionCallbackUrl) { diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerStatusInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerStatusInfo.java index 14d4555f..055ab913 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerStatusInfo.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1producer/ProducerStatusInfo.java @@ -28,7 +28,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import org.immutables.gson.Gson; @Gson.TypeAdapters -@Schema(name = "producer_status", description = "Status for an EI Producer") +@Schema(name = "producer_status", description = "Status for an Info Producer") public class ProducerStatusInfo { @Gson.TypeAdapters diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJob.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoJob.java similarity index 95% rename from enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJob.java rename to enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoJob.java index 46602f33..9d679be9 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJob.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoJob.java @@ -30,10 +30,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Represents the dynamic information about a EI job + * Represents the dynamic information about a information job */ @Builder -public class EiJob { +public class InfoJob { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Getter diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJobs.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoJobs.java similarity index 76% rename from enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJobs.java rename to enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoJobs.java index 7ca7261e..52fa1d6d 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJobs.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoJobs.java @@ -46,13 +46,13 @@ import org.slf4j.LoggerFactory; import org.springframework.util.FileSystemUtils; /** - * Dynamic representation of all existing EI jobs. + * Dynamic representation of all existing Information Jobs. */ -public class EiJobs { - private Map allEiJobs = new HashMap<>(); +public class InfoJobs { + private Map allEiJobs = new HashMap<>(); - private MultiMap jobsByType = new MultiMap<>(); - private MultiMap jobsByOwner = new MultiMap<>(); + private MultiMap jobsByType = new MultiMap<>(); + private MultiMap jobsByOwner = new MultiMap<>(); private final Gson gson; private final ApplicationConfig config; @@ -60,7 +60,7 @@ public class EiJobs { private final ProducerCallbacks producerCallbacks; - public EiJobs(ApplicationConfig config, ProducerCallbacks producerCallbacks) { + public InfoJobs(ApplicationConfig config, ProducerCallbacks producerCallbacks) { this.config = config; GsonBuilder gsonBuilder = new GsonBuilder(); ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory); @@ -74,53 +74,53 @@ public class EiJobs { for (File file : dbDir.listFiles()) { String json = Files.readString(file.toPath()); - EiJob job = gson.fromJson(json, EiJob.class); + InfoJob job = gson.fromJson(json, InfoJob.class); this.doPut(job); } } - public synchronized void put(EiJob job) { + public synchronized void put(InfoJob job) { this.doPut(job); storeJobInFile(job); } - public synchronized Collection getJobs() { + public synchronized Collection getJobs() { return new Vector<>(allEiJobs.values()); } - public synchronized EiJob getJob(String id) throws ServiceException { - EiJob ric = allEiJobs.get(id); + public synchronized InfoJob getJob(String id) throws ServiceException { + InfoJob ric = allEiJobs.get(id); if (ric == null) { throw new ServiceException("Could not find Information job: " + id); } return ric; } - public synchronized Collection getJobsForType(String typeId) { + public synchronized Collection getJobsForType(String typeId) { return jobsByType.get(typeId); } - public synchronized Collection getJobsForType(EiType type) { + public synchronized Collection getJobsForType(InfoType type) { return jobsByType.get(type.getId()); } - public synchronized Collection getJobsForOwner(String owner) { + public synchronized Collection getJobsForOwner(String owner) { return jobsByOwner.get(owner); } - public synchronized EiJob get(String id) { + public synchronized InfoJob get(String id) { return allEiJobs.get(id); } - public synchronized EiJob remove(String id, EiProducers eiProducers) { - EiJob job = allEiJobs.get(id); + public synchronized InfoJob remove(String id, InfoProducers infoProducers) { + InfoJob job = allEiJobs.get(id); if (job != null) { - remove(job, eiProducers); + remove(job, infoProducers); } return job; } - public synchronized void remove(EiJob job, EiProducers eiProducers) { + public synchronized void remove(InfoJob job, InfoProducers infoProducers) { this.allEiJobs.remove(job.getId()); jobsByType.remove(job.getTypeId(), job.getId()); jobsByOwner.remove(job.getOwner(), job.getId()); @@ -130,7 +130,7 @@ public class EiJobs { } catch (IOException e) { logger.warn("Could not remove file: {}", e.getMessage()); } - this.producerCallbacks.stopEiJob(job, eiProducers); + this.producerCallbacks.stopInfoJob(job, infoProducers); } public synchronized int size() { @@ -153,13 +153,13 @@ public class EiJobs { } } - private void doPut(EiJob job) { + private void doPut(InfoJob job) { allEiJobs.put(job.getId(), job); jobsByType.put(job.getTypeId(), job.getId(), job); jobsByOwner.put(job.getOwner(), job.getId(), job); } - private void storeJobInFile(EiJob job) { + private void storeJobInFile(InfoJob job) { try { try (PrintStream out = new PrintStream(new FileOutputStream(getFile(job)))) { out.print(gson.toJson(job)); @@ -169,11 +169,11 @@ public class EiJobs { } } - private File getFile(EiJob job) { + private File getFile(InfoJob job) { return getPath(job).toFile(); } - private Path getPath(EiJob job) { + private Path getPath(InfoJob job) { return Path.of(getDatabaseDirectory(), job.getId()); } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiProducer.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoProducer.java similarity index 84% rename from enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiProducer.java rename to enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoProducer.java index d8b20158..41d1c0b8 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiProducer.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoProducer.java @@ -26,12 +26,12 @@ import java.util.Set; import lombok.Getter; -public class EiProducer { +public class InfoProducer { @Getter private final String id; @Getter - private final Collection eiTypes; + private final Collection infoTypes; @Getter private final String jobCallbackUrl; @@ -43,10 +43,10 @@ public class EiProducer { private int unresponsiveCounter = 0; - public EiProducer(String id, Collection eiTypes, String jobCallbackUrl, + public InfoProducer(String id, Collection infoTypes, String jobCallbackUrl, String producerSupervisionCallbackUrl) { this.id = id; - this.eiTypes = eiTypes; + this.infoTypes = infoTypes; this.jobCallbackUrl = jobCallbackUrl; this.producerSupervisionCallbackUrl = producerSupervisionCallbackUrl; } @@ -67,18 +67,18 @@ public class EiProducer { return this.unresponsiveCounter == 0; } - public synchronized void setJobEnabled(EiJob job) { + public synchronized void setJobEnabled(InfoJob job) { this.enabledJobs.add(job.getId()); } - public synchronized void setJobDisabled(EiJob job) { + public synchronized void setJobDisabled(InfoJob job) { this.enabledJobs.remove(job.getId()); } /** * Is the job enabled for this producer? */ - public synchronized boolean isJobEnabled(EiJob job) { + public synchronized boolean isJobEnabled(InfoJob job) { return this.enabledJobs.contains(job.getId()); } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiProducers.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoProducers.java similarity index 59% rename from enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiProducers.java rename to enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoProducers.java index 1fdb9864..57e7922c 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiProducers.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoProducers.java @@ -27,7 +27,9 @@ import java.util.HashMap; import java.util.Map; import java.util.Vector; -import org.immutables.value.Value.Immutable; +import lombok.Builder; +import lombok.Getter; + import org.oransc.enrichment.controllers.a1e.A1eCallbacks; import org.oransc.enrichment.controllers.r1producer.ProducerCallbacks; import org.oransc.enrichment.exceptions.ServiceException; @@ -41,10 +43,10 @@ import org.springframework.stereotype.Component; */ @SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally @Component -public class EiProducers { +public class InfoProducers { private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private final Map allEiProducers = new HashMap<>(); - private final MultiMap producersByType = new MultiMap<>(); + private final Map allEiProducers = new HashMap<>(); + private final MultiMap producersByType = new MultiMap<>(); @Autowired private ProducerCallbacks producerCallbacks; @@ -53,41 +55,42 @@ public class EiProducers { private A1eCallbacks consumerCallbacks; @Autowired - private EiJobs eiJobs; + private InfoJobs infoJobs; - @Immutable - public interface EiProducerRegistrationInfo { - String id(); + @Builder + @Getter + public static class InfoProducerRegistrationInfo { + String id; - Collection supportedTypes(); + Collection supportedTypes; - String jobCallbackUrl(); + String jobCallbackUrl; - String producerSupervisionCallbackUrl(); + String producerSupervisionCallbackUrl; } - public EiProducer registerProducer(EiProducerRegistrationInfo producerInfo) { - final String producerId = producerInfo.id(); - EiProducer previousDefinition = this.get(producerId); + public InfoProducer registerProducer(InfoProducerRegistrationInfo producerInfo) { + final String producerId = producerInfo.getId(); + InfoProducer previousDefinition = this.get(producerId); if (previousDefinition != null) { - for (EiType type : previousDefinition.getEiTypes()) { + for (InfoType type : previousDefinition.getInfoTypes()) { producersByType.remove(type.getId(), producerId); } allEiProducers.remove(producerId); } - EiProducer producer = createProducer(producerInfo); + InfoProducer producer = createProducer(producerInfo); allEiProducers.put(producer.getId(), producer); - for (EiType type : producer.getEiTypes()) { + for (InfoType type : producer.getInfoTypes()) { producersByType.put(type.getId(), producer.getId(), producer); } - Collection previousTypes = - previousDefinition != null ? previousDefinition.getEiTypes() : new ArrayList<>(); + Collection previousTypes = + previousDefinition != null ? previousDefinition.getInfoTypes() : new ArrayList<>(); - producerCallbacks.startEiJobs(producer, this.eiJobs) // + producerCallbacks.startInfoJobs(producer, this.infoJobs) // .collectList() // - .flatMapMany(list -> consumerCallbacks.notifyJobStatus(producer.getEiTypes())) // + .flatMapMany(list -> consumerCallbacks.notifyJobStatus(producer.getInfoTypes())) // .collectList() // .flatMapMany(list -> consumerCallbacks.notifyJobStatus(previousTypes)) // .subscribe(); @@ -95,24 +98,24 @@ public class EiProducers { return producer; } - private EiProducer createProducer(EiProducerRegistrationInfo producerInfo) { - return new EiProducer(producerInfo.id(), producerInfo.supportedTypes(), producerInfo.jobCallbackUrl(), - producerInfo.producerSupervisionCallbackUrl()); + private InfoProducer createProducer(InfoProducerRegistrationInfo producerInfo) { + return new InfoProducer(producerInfo.getId(), producerInfo.getSupportedTypes(), + producerInfo.getJobCallbackUrl(), producerInfo.getProducerSupervisionCallbackUrl()); } - public synchronized Collection getAllProducers() { + public synchronized Collection getAllProducers() { return new Vector<>(allEiProducers.values()); } - public synchronized EiProducer getProducer(String id) throws ServiceException { - EiProducer p = allEiProducers.get(id); + public synchronized InfoProducer getProducer(String id) throws ServiceException { + InfoProducer p = allEiProducers.get(id); if (p == null) { - throw new ServiceException("Could not find EI producer: " + id); + throw new ServiceException("Could not find Information Producer: " + id); } return p; } - public synchronized EiProducer get(String id) { + public synchronized InfoProducer get(String id) { return allEiProducers.get(id); } @@ -125,35 +128,35 @@ public class EiProducers { this.producersByType.clear(); } - public void deregisterProducer(EiProducer producer) { + public void deregisterProducer(InfoProducer producer) { allEiProducers.remove(producer.getId()); - for (EiType type : producer.getEiTypes()) { + for (InfoType type : producer.getInfoTypes()) { if (producersByType.remove(type.getId(), producer.getId()) == null) { this.logger.error("Bug, no producer found"); } } - this.consumerCallbacks.notifyJobStatus(producer.getEiTypes()) // + this.consumerCallbacks.notifyJobStatus(producer.getInfoTypes()) // .subscribe(); } - public synchronized Collection getProducersForType(EiType type) { + public synchronized Collection getProducersForType(InfoType type) { return this.producersByType.get(type.getId()); } - public synchronized Collection getProducersForType(String typeId) { + public synchronized Collection getProducersForType(String typeId) { return this.producersByType.get(typeId); } public synchronized Collection getProducerIdsForType(String typeId) { Collection producerIds = new ArrayList<>(); - for (EiProducer p : this.getProducersForType(typeId)) { + for (InfoProducer p : this.getProducersForType(typeId)) { producerIds.add(p.getId()); } return producerIds; } - public synchronized boolean isJobEnabled(EiJob job) { - for (EiProducer producer : this.producersByType.get(job.getTypeId())) { + public synchronized boolean isJobEnabled(InfoJob job) { + for (InfoProducer producer : this.producersByType.get(job.getTypeId())) { if (producer.isJobEnabled(job)) { return true; } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiType.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoType.java similarity index 92% rename from enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiType.java rename to enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoType.java index 5d9057a6..e89f0bc2 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiType.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoType.java @@ -22,14 +22,14 @@ package org.oransc.enrichment.repository; import lombok.Getter; -public class EiType { +public class InfoType { @Getter private final String id; @Getter private final Object jobDataSchema; - public EiType(String id, Object jobDataSchema) { + public InfoType(String id, Object jobDataSchema) { this.id = id; this.jobDataSchema = jobDataSchema; } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiTypes.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoTypes.java similarity index 84% rename from enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiTypes.java rename to enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoTypes.java index 6a1b8a11..e3089f92 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiTypes.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoTypes.java @@ -45,16 +45,16 @@ import org.slf4j.LoggerFactory; import org.springframework.util.FileSystemUtils; /** - * Dynamic representation of all EI types in the system. + * Dynamic representation of all Information Types in the system. */ @SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally -public class EiTypes { +public class InfoTypes { private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private final Map allEiTypes = new HashMap<>(); + private final Map allEiTypes = new HashMap<>(); private final ApplicationConfig config; private final Gson gson; - public EiTypes(ApplicationConfig config) { + public InfoTypes(ApplicationConfig config) { this.config = config; GsonBuilder gsonBuilder = new GsonBuilder(); ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory); @@ -67,33 +67,33 @@ public class EiTypes { for (File file : dbDir.listFiles()) { String json = Files.readString(file.toPath()); - EiType type = gson.fromJson(json, EiType.class); + InfoType type = gson.fromJson(json, InfoType.class); allEiTypes.put(type.getId(), type); } } - public synchronized void put(EiType type) { + public synchronized void put(InfoType type) { allEiTypes.put(type.getId(), type); storeInFile(type); } - public synchronized Collection getAllInfoTypes() { + public synchronized Collection getAllInfoTypes() { return new Vector<>(allEiTypes.values()); } - public synchronized EiType getType(String id) throws ServiceException { - EiType type = allEiTypes.get(id); + public synchronized InfoType getType(String id) throws ServiceException { + InfoType type = allEiTypes.get(id); if (type == null) { throw new ServiceException("Information type not found: " + id); } return type; } - public synchronized EiType get(String id) { + public synchronized InfoType get(String id) { return allEiTypes.get(id); } - public synchronized void remove(EiType type) { + public synchronized void remove(InfoType type) { allEiTypes.remove(type.getId()); try { Files.delete(getPath(type)); @@ -120,7 +120,7 @@ public class EiTypes { } } - private void storeInFile(EiType type) { + private void storeInFile(InfoType type) { try { try (PrintStream out = new PrintStream(new FileOutputStream(getFile(type)))) { out.print(gson.toJson(type)); @@ -130,11 +130,11 @@ public class EiTypes { } } - private File getFile(EiType type) { + private File getFile(InfoType type) { return getPath(type).toFile(); } - private Path getPath(EiType type) { + private Path getPath(InfoType type) { return getPath(type.getId()); } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/tasks/ProducerSupervision.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/tasks/ProducerSupervision.java index 7852bef6..db7c29ba 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/tasks/ProducerSupervision.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/tasks/ProducerSupervision.java @@ -23,10 +23,10 @@ package org.oransc.enrichment.tasks; import org.oransc.enrichment.configuration.ApplicationConfig; import org.oransc.enrichment.controllers.a1e.A1eCallbacks; import org.oransc.enrichment.controllers.r1producer.ProducerCallbacks; -import org.oransc.enrichment.repository.EiJob; -import org.oransc.enrichment.repository.EiJobs; -import org.oransc.enrichment.repository.EiProducer; -import org.oransc.enrichment.repository.EiProducers; +import org.oransc.enrichment.repository.InfoJob; +import org.oransc.enrichment.repository.InfoJobs; +import org.oransc.enrichment.repository.InfoProducer; +import org.oransc.enrichment.repository.InfoProducers; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -39,7 +39,7 @@ import reactor.core.publisher.Mono; import reactor.util.retry.Retry; /** - * Regularly checks the availability of the EI Producers + * Regularly checks the availability of the Info Producers */ @Component @EnableScheduling @@ -47,16 +47,16 @@ import reactor.util.retry.Retry; public class ProducerSupervision { private static final Logger logger = LoggerFactory.getLogger(ProducerSupervision.class); - private final EiProducers eiProducers; - private final EiJobs eiJobs; + private final InfoProducers infoProducers; + private final InfoJobs infoJobs; private final ProducerCallbacks producerCallbacks; private final A1eCallbacks consumerCallbacks; @Autowired - public ProducerSupervision(ApplicationConfig applicationConfig, EiProducers eiProducers, EiJobs eiJobs, + public ProducerSupervision(ApplicationConfig applicationConfig, InfoProducers infoProducers, InfoJobs infoJobs, ProducerCallbacks producerCallbacks, A1eCallbacks consumerCallbacks) { - this.eiProducers = eiProducers; - this.eiJobs = eiJobs; + this.infoProducers = infoProducers; + this.infoJobs = infoJobs; this.producerCallbacks = producerCallbacks; this.consumerCallbacks = consumerCallbacks; } @@ -67,12 +67,12 @@ public class ProducerSupervision { createTask().subscribe(null, null, () -> logger.debug("Checking all Producers completed")); } - public Flux createTask() { - return Flux.fromIterable(eiProducers.getAllProducers()) // + public Flux createTask() { + return Flux.fromIterable(infoProducers.getAllProducers()) // .flatMap(this::checkOneProducer); } - private Mono checkOneProducer(EiProducer producer) { + private Mono checkOneProducer(InfoProducer producer) { return this.producerCallbacks.healthCheck(producer) // .onErrorResume(throwable -> { handleNonRespondingProducer(throwable, producer); @@ -83,30 +83,30 @@ public class ProducerSupervision { .flatMap(responses -> Mono.just(producer)); } - private Mono checkProducerJobs(EiProducer producer) { + private Mono checkProducerJobs(InfoProducer producer) { final int MAX_CONCURRENCY = 10; return getEiJobs(producer) // - .filter(eiJob -> !producer.isJobEnabled(eiJob)) // - .flatMap(eiJob -> producerCallbacks.startEiJob(producer, eiJob, Retry.max(1)), MAX_CONCURRENCY) // + .filter(infoJob -> !producer.isJobEnabled(infoJob)) // + .flatMap(infoJob -> producerCallbacks.startInfoJob(producer, infoJob, Retry.max(1)), MAX_CONCURRENCY) // .collectList() // - .flatMapMany(startedJobs -> consumerCallbacks.notifyJobStatus(producer.getEiTypes())) // + .flatMapMany(startedJobs -> consumerCallbacks.notifyJobStatus(producer.getInfoTypes())) // .collectList(); } - private Flux getEiJobs(EiProducer producer) { - return Flux.fromIterable(producer.getEiTypes()) // - .flatMap(eiType -> Flux.fromIterable(eiJobs.getJobsForType(eiType))); + private Flux getEiJobs(InfoProducer producer) { + return Flux.fromIterable(producer.getInfoTypes()) // + .flatMap(infoType -> Flux.fromIterable(infoJobs.getJobsForType(infoType))); } - private void handleNonRespondingProducer(Throwable throwable, EiProducer producer) { + private void handleNonRespondingProducer(Throwable throwable, InfoProducer producer) { logger.warn("Unresponsive producer: {} exception: {}", producer.getId(), throwable.getMessage()); producer.setAliveStatus(false); if (producer.isDead()) { - this.eiProducers.deregisterProducer(producer); + this.infoProducers.deregisterProducer(producer); } } - private void handleRespondingProducer(String response, EiProducer producer) { + private void handleRespondingProducer(String response, InfoProducer producer) { logger.debug("{}", response); producer.setAliveStatus(true); } diff --git a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java index 9d55940e..5ea62f0e 100644 --- a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java +++ b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java @@ -59,17 +59,17 @@ import org.oransc.enrichment.controllers.r1consumer.ConsumerInfoTypeInfo; import org.oransc.enrichment.controllers.r1consumer.ConsumerJobInfo; import org.oransc.enrichment.controllers.r1producer.ProducerCallbacks; import org.oransc.enrichment.controllers.r1producer.ProducerConsts; -import org.oransc.enrichment.controllers.r1producer.ProducerEiTypeInfo; +import org.oransc.enrichment.controllers.r1producer.ProducerInfoTypeInfo; import org.oransc.enrichment.controllers.r1producer.ProducerJobInfo; import org.oransc.enrichment.controllers.r1producer.ProducerRegistrationInfo; import org.oransc.enrichment.controllers.r1producer.ProducerStatusInfo; import org.oransc.enrichment.exceptions.ServiceException; -import org.oransc.enrichment.repository.EiJob; -import org.oransc.enrichment.repository.EiJobs; -import org.oransc.enrichment.repository.EiProducer; -import org.oransc.enrichment.repository.EiProducers; -import org.oransc.enrichment.repository.EiType; -import org.oransc.enrichment.repository.EiTypes; +import org.oransc.enrichment.repository.InfoJob; +import org.oransc.enrichment.repository.InfoJobs; +import org.oransc.enrichment.repository.InfoProducer; +import org.oransc.enrichment.repository.InfoProducers; +import org.oransc.enrichment.repository.InfoType; +import org.oransc.enrichment.repository.InfoTypes; import org.oransc.enrichment.tasks.ProducerSupervision; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -111,13 +111,13 @@ class ApplicationTest { ApplicationContext context; @Autowired - EiJobs eiJobs; + InfoJobs infoJobs; @Autowired - EiTypes eiTypes; + InfoTypes infoTypes; @Autowired - EiProducers eiProducers; + InfoProducers infoProducers; @Autowired ApplicationConfig applicationConfig; @@ -152,9 +152,9 @@ class ApplicationTest { @BeforeEach void reset() { - this.eiJobs.clear(); - this.eiTypes.clear(); - this.eiProducers.clear(); + this.infoJobs.clear(); + this.infoTypes.clear(); + this.infoProducers.clear(); this.producerSimulator.getTestResults().reset(); this.consumerSimulator.getTestResults().reset(); } @@ -181,15 +181,15 @@ class ApplicationTest { @Test void a1eGetEiTypes() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, "test"); + putInfoProducerWithOneType(PRODUCER_ID, "test"); String url = A1eConsts.API_ROOT + "/eitypes"; String rsp = restClient().get(url).block(); assertThat(rsp).isEqualTo("[\"test\"]"); } @Test - void consumerGetEiTypes() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, "test"); + void consumerGetInfoTypes() throws Exception { + putInfoProducerWithOneType(PRODUCER_ID, "test"); String url = ConsumerConsts.API_ROOT + "/info-types"; String rsp = restClient().get(url).block(); assertThat(rsp).isEqualTo("[\"test\"]"); @@ -211,7 +211,7 @@ class ApplicationTest { @Test void a1eGetEiType() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, "test"); + putInfoProducerWithOneType(PRODUCER_ID, "test"); String url = A1eConsts.API_ROOT + "/eitypes/test"; String rsp = restClient().get(url).block(); A1eEiTypeInfo info = gson.fromJson(rsp, A1eEiTypeInfo.class); @@ -220,7 +220,7 @@ class ApplicationTest { @Test void consumerGetEiType() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, "test"); + putInfoProducerWithOneType(PRODUCER_ID, "test"); String url = ConsumerConsts.API_ROOT + "/info-types/test"; String rsp = restClient().get(url).block(); ConsumerInfoTypeInfo info = gson.fromJson(rsp, ConsumerInfoTypeInfo.class); @@ -242,10 +242,10 @@ class ApplicationTest { @Test void a1eGetEiJobsIds() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); putEiJob(TYPE_ID, "jobId"); final String JOB_ID_JSON = "[\"jobId\"]"; - String url = A1eConsts.API_ROOT + "/eijobs?eiTypeId=typeId"; + String url = A1eConsts.API_ROOT + "/eijobs?infoTypeId=typeId"; String rsp = restClient().get(url).block(); assertThat(rsp).isEqualTo(JOB_ID_JSON); @@ -272,7 +272,7 @@ class ApplicationTest { @Test void consumerGetInformationJobsIds() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); putEiJob(TYPE_ID, "jobId"); final String JOB_ID_JSON = "[\"jobId\"]"; String url = ConsumerConsts.API_ROOT + "/info-jobs?infoTypeId=typeId"; @@ -302,7 +302,7 @@ class ApplicationTest { @Test void a1eGetEiJob() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); putEiJob(TYPE_ID, "jobId"); String url = A1eConsts.API_ROOT + "/eijobs/jobId"; String rsp = restClient().get(url).block(); @@ -313,7 +313,7 @@ class ApplicationTest { @Test void consumerGetEiJob() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); putEiJob(TYPE_ID, "jobId"); String url = ConsumerConsts.API_ROOT + "/info-jobs/jobId"; String rsp = restClient().get(url).block(); @@ -324,21 +324,21 @@ class ApplicationTest { @Test void a1eGetEiJobNotFound() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); String url = A1eConsts.API_ROOT + "/eijobs/junk"; testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND, "Could not find Information job: junk"); } @Test void consumerGetInfoJobNotFound() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); String url = ConsumerConsts.API_ROOT + "/info-jobs/junk"; testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND, "Could not find Information job: junk"); } @Test void a1eGetEiJobStatus() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); putEiJob(TYPE_ID, "jobId"); verifyJobStatus("jobId", "ENABLED"); @@ -346,7 +346,7 @@ class ApplicationTest { @Test void consumerGetEiJobStatus() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); putEiJob(TYPE_ID, "jobId"); String url = ConsumerConsts.API_ROOT + "/info-jobs/jobId/status"; @@ -356,12 +356,12 @@ class ApplicationTest { @Test void a1eDeleteEiJob() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); putEiJob(TYPE_ID, "jobId"); - assertThat(this.eiJobs.size()).isEqualTo(1); + assertThat(this.infoJobs.size()).isEqualTo(1); String url = A1eConsts.API_ROOT + "/eijobs/jobId"; restClient().delete(url).block(); - assertThat(this.eiJobs.size()).isZero(); + assertThat(this.infoJobs.size()).isZero(); ProducerSimulatorController.TestResults simulatorResults = this.producerSimulator.getTestResults(); await().untilAsserted(() -> assertThat(simulatorResults.jobsStopped.size()).isEqualTo(1)); @@ -370,12 +370,12 @@ class ApplicationTest { @Test void consumerDeleteEiJob() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); putEiJob(TYPE_ID, "jobId"); - assertThat(this.eiJobs.size()).isEqualTo(1); + assertThat(this.infoJobs.size()).isEqualTo(1); String url = ConsumerConsts.API_ROOT + "/info-jobs/jobId"; restClient().delete(url).block(); - assertThat(this.eiJobs.size()).isZero(); + assertThat(this.infoJobs.size()).isZero(); ProducerSimulatorController.TestResults simulatorResults = this.producerSimulator.getTestResults(); await().untilAsserted(() -> assertThat(simulatorResults.jobsStopped.size()).isEqualTo(1)); @@ -384,14 +384,14 @@ class ApplicationTest { @Test void a1eDeleteEiJobNotFound() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); String url = A1eConsts.API_ROOT + "/eijobs/junk"; testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND, "Could not find Information job: junk"); } @Test void consumerDeleteEiJobNotFound() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); String url = ConsumerConsts.API_ROOT + "/info-jobs/junk"; testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND, "Could not find Information job: junk"); } @@ -399,13 +399,13 @@ class ApplicationTest { @Test void a1ePutEiJob() throws Exception { // Test that one producer accepting a job is enough - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); putEiProducerWithOneTypeRejecting("simulateProducerError", TYPE_ID); String url = A1eConsts.API_ROOT + "/eijobs/jobId"; - String body = gson.toJson(eiJobInfo()); + String body = gson.toJson(infoJobInfo()); ResponseEntity resp = restClient().putForEntity(url, body).block(); - assertThat(this.eiJobs.size()).isEqualTo(1); + assertThat(this.infoJobs.size()).isEqualTo(1); assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.CREATED); ProducerSimulatorController.TestResults simulatorResults = this.producerSimulator.getTestResults(); @@ -419,7 +419,7 @@ class ApplicationTest { resp = restClient().putForEntity(url, body).block(); assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.OK); - EiJob job = this.eiJobs.getJob("jobId"); + InfoJob job = this.infoJobs.getJob("jobId"); assertThat(job.getOwner()).isEqualTo("owner"); verifyJobStatus(EI_JOB_ID, "ENABLED"); @@ -428,12 +428,12 @@ class ApplicationTest { @Test void consumerPutInformationJob() throws Exception { // Test that one producer accepting a job is enough - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); String url = ConsumerConsts.API_ROOT + "/info-jobs/jobId"; String body = gson.toJson(consumerJobInfo()); ResponseEntity resp = restClient().putForEntity(url, body).block(); - assertThat(this.eiJobs.size()).isEqualTo(1); + assertThat(this.infoJobs.size()).isEqualTo(1); assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.CREATED); ProducerSimulatorController.TestResults simulatorResults = this.producerSimulator.getTestResults(); @@ -443,7 +443,7 @@ class ApplicationTest { resp = restClient().putForEntity(url, body).block(); assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.OK); - EiJob job = this.eiJobs.getJob("jobId"); + InfoJob job = this.infoJobs.getJob("jobId"); assertThat(job.getOwner()).isEqualTo("owner"); verifyJobStatus(EI_JOB_ID, "ENABLED"); @@ -454,11 +454,11 @@ class ApplicationTest { String url = ConsumerConsts.API_ROOT + "/info-jobs/jobId?typeCheck=false"; String body = gson.toJson(consumerJobInfo()); ResponseEntity resp = restClient().putForEntity(url, body).block(); - assertThat(this.eiJobs.size()).isEqualTo(1); + assertThat(this.infoJobs.size()).isEqualTo(1); assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.CREATED); verifyJobStatus(EI_JOB_ID, "DISABLED"); - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); verifyJobStatus(EI_JOB_ID, "ENABLED"); @@ -466,7 +466,7 @@ class ApplicationTest { @Test void a1ePutEiJob_jsonSchemavalidationError() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); String url = A1eConsts.API_ROOT + "/eijobs/jobId"; // The element with name "property1" is mandatory in the schema @@ -479,33 +479,45 @@ class ApplicationTest { @Test void consumerPutJob_jsonSchemavalidationError() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); String url = ConsumerConsts.API_ROOT + "/info-jobs/jobId?typeCheck=true"; // The element with name "property1" is mandatory in the schema - ConsumerJobInfo jobInfo = new ConsumerJobInfo("typeId", jsonObject("{ \"XXstring\" : \"value\" }"), "owner", - "targetUri", "jobStatusUrl"); + ConsumerJobInfo jobInfo = + new ConsumerJobInfo("typeId", jsonObject("{ \"XXstring\" : \"value\" }"), "owner", "targetUri", null); String body = gson.toJson(jobInfo); testErrorCode(restClient().put(url, body), HttpStatus.CONFLICT, "Json validation failure"); } + @Test + void consumerPutJob_uriError() throws Exception { + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); + + String url = ConsumerConsts.API_ROOT + "/info-jobs/jobId?typeCheck=true"; + + ConsumerJobInfo jobInfo = new ConsumerJobInfo(TYPE_ID, jsonObject(), "owner", "junk", null); + String body = gson.toJson(jobInfo); + + testErrorCode(restClient().put(url, body), HttpStatus.CONFLICT, "URI: junk is not absolute"); + } + @Test void a1eChangingEiTypeGetRejected() throws Exception { - putEiProducerWithOneType("producer1", "typeId1"); - putEiProducerWithOneType("producer2", "typeId2"); + putInfoProducerWithOneType("producer1", "typeId1"); + putInfoProducerWithOneType("producer2", "typeId2"); putEiJob("typeId1", "jobId"); String url = A1eConsts.API_ROOT + "/eijobs/jobId"; - String body = gson.toJson(eiJobInfo("typeId2", "jobId")); + String body = gson.toJson(infoJobInfo("typeId2", "jobId")); testErrorCode(restClient().put(url, body), HttpStatus.CONFLICT, "Not allowed to change type for existing EI job"); } @Test void consumerChangingInfoTypeGetRejected() throws Exception { - putEiProducerWithOneType("producer1", "typeId1"); - putEiProducerWithOneType("producer2", "typeId2"); + putInfoProducerWithOneType("producer1", "typeId1"); + putInfoProducerWithOneType("producer2", "typeId2"); putEiJob("typeId1", "jobId"); String url = ConsumerConsts.API_ROOT + "/info-jobs/jobId"; @@ -515,34 +527,34 @@ class ApplicationTest { @Test void producerPutEiType() throws JsonMappingException, JsonProcessingException, ServiceException { - assertThat(putEiType(TYPE_ID)).isEqualTo(HttpStatus.CREATED); - assertThat(putEiType(TYPE_ID)).isEqualTo(HttpStatus.OK); + assertThat(putInfoType(TYPE_ID)).isEqualTo(HttpStatus.CREATED); + assertThat(putInfoType(TYPE_ID)).isEqualTo(HttpStatus.OK); } @Test void producerPutEiType_noSchema() { - String url = ProducerConsts.API_ROOT + "/eitypes/" + TYPE_ID; + String url = ProducerConsts.API_ROOT + "/info-types/" + TYPE_ID; String body = "{}"; testErrorCode(restClient().put(url, body), HttpStatus.BAD_REQUEST, "No schema provided"); } @Test void producerDeleteEiType() throws Exception { - putEiType(TYPE_ID); - String url = ProducerConsts.API_ROOT + "/eitypes/" + TYPE_ID; + putInfoType(TYPE_ID); + String url = ProducerConsts.API_ROOT + "/info-types/" + TYPE_ID; restClient().delete(url).block(); - assertThat(this.eiTypes.size()).isEqualTo(0); + assertThat(this.infoTypes.size()).isEqualTo(0); testErrorCode(restClient().delete(url), HttpStatus.NOT_FOUND, "Information type not found"); } @Test void producerDeleteEiTypeExistingProducer() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); - String url = ProducerConsts.API_ROOT + "/eitypes/" + TYPE_ID; + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); + String url = ProducerConsts.API_ROOT + "/info-types/" + TYPE_ID; testErrorCode(restClient().delete(url), HttpStatus.NOT_ACCEPTABLE, "The type has active producers: " + PRODUCER_ID); - assertThat(this.eiTypes.size()).isEqualTo(1); + assertThat(this.infoTypes.size()).isEqualTo(1); } @Test @@ -550,7 +562,7 @@ class ApplicationTest { throws JsonMappingException, JsonProcessingException, ServiceException { putEiProducerWithOneTypeRejecting("simulateProducerError", TYPE_ID); String url = A1eConsts.API_ROOT + "/eijobs/" + EI_JOB_ID; - String body = gson.toJson(eiJobInfo()); + String body = gson.toJson(infoJobInfo()); restClient().put(url, body).block(); ProducerSimulatorController.TestResults simulatorResults = this.producerSimulator.getTestResults(); @@ -564,11 +576,11 @@ class ApplicationTest { @Test void producerGetEiProducerTypes() throws Exception { final String EI_TYPE_ID_2 = TYPE_ID + "_2"; - putEiProducerWithOneType("producer1", TYPE_ID); + putInfoProducerWithOneType("producer1", TYPE_ID); putEiJob(TYPE_ID, "jobId"); - putEiProducerWithOneType("producer2", EI_TYPE_ID_2); + putInfoProducerWithOneType("producer2", EI_TYPE_ID_2); putEiJob(EI_TYPE_ID_2, "jobId2"); - String url = ProducerConsts.API_ROOT + "/eitypes"; + String url = ProducerConsts.API_ROOT + "/info-types"; ResponseEntity resp = restClient().getForEntity(url).block(); assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.OK); @@ -578,17 +590,18 @@ class ApplicationTest { @Test void producerPutEiProducer() throws Exception { - this.putEiType(TYPE_ID); - String url = ProducerConsts.API_ROOT + "/eiproducers/eiProducerId"; - String body = gson.toJson(producerEiRegistratioInfo(TYPE_ID)); + this.putInfoType(TYPE_ID); + String url = ProducerConsts.API_ROOT + "/info-producers/infoProducerId"; + String body = gson.toJson(producerInfoRegistratioInfo(TYPE_ID)); ResponseEntity resp = restClient().putForEntity(url, body).block(); assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.CREATED); - assertThat(this.eiTypes.size()).isEqualTo(1); - assertThat(this.eiProducers.getProducersForType(TYPE_ID).size()).isEqualTo(1); - assertThat(this.eiProducers.size()).isEqualTo(1); - assertThat(this.eiProducers.get("eiProducerId").getEiTypes().iterator().next().getId()).isEqualTo(TYPE_ID); + assertThat(this.infoTypes.size()).isEqualTo(1); + assertThat(this.infoProducers.getProducersForType(TYPE_ID).size()).isEqualTo(1); + assertThat(this.infoProducers.size()).isEqualTo(1); + assertThat(this.infoProducers.get("infoProducerId").getInfoTypes().iterator().next().getId()) + .isEqualTo(TYPE_ID); resp = restClient().putForEntity(url, body).block(); assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.OK); @@ -600,10 +613,10 @@ class ApplicationTest { @Test void producerPutEiProducerExistingJob() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); putEiJob(TYPE_ID, "jobId"); - String url = ProducerConsts.API_ROOT + "/eiproducers/eiProducerId"; - String body = gson.toJson(producerEiRegistratioInfo(TYPE_ID)); + String url = ProducerConsts.API_ROOT + "/info-producers/infoProducerId"; + String body = gson.toJson(producerInfoRegistratioInfo(TYPE_ID)); restClient().putForEntity(url, body).block(); ProducerSimulatorController.TestResults simulatorResults = this.producerSimulator.getTestResults(); @@ -614,22 +627,22 @@ class ApplicationTest { @Test void testPutEiProducer_noType() throws Exception { - String url = ProducerConsts.API_ROOT + "/eiproducers/eiProducerId"; - String body = gson.toJson(producerEiRegistratioInfo(TYPE_ID)); + String url = ProducerConsts.API_ROOT + "/info-producers/infoProducerId"; + String body = gson.toJson(producerInfoRegistratioInfo(TYPE_ID)); testErrorCode(restClient().put(url, body), HttpStatus.NOT_FOUND, "Information type not found"); } @Test void producerPutProducerAndEiJob() throws Exception { - this.putEiType(TYPE_ID); - String url = ProducerConsts.API_ROOT + "/eiproducers/eiProducerId"; - String body = gson.toJson(producerEiRegistratioInfo(TYPE_ID)); + this.putInfoType(TYPE_ID); + String url = ProducerConsts.API_ROOT + "/info-producers/infoProducerId"; + String body = gson.toJson(producerInfoRegistratioInfo(TYPE_ID)); restClient().putForEntity(url, body).block(); - assertThat(this.eiTypes.size()).isEqualTo(1); - this.eiTypes.getType(TYPE_ID); + assertThat(this.infoTypes.size()).isEqualTo(1); + this.infoTypes.getType(TYPE_ID); url = A1eConsts.API_ROOT + "/eijobs/jobId"; - body = gson.toJson(eiJobInfo()); + body = gson.toJson(infoJobInfo()); restClient().putForEntity(url, body).block(); ProducerSimulatorController.TestResults simulatorResults = this.producerSimulator.getTestResults(); @@ -640,16 +653,16 @@ class ApplicationTest { @Test void producerGetEiJobsForProducer() throws JsonMappingException, JsonProcessingException, ServiceException { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); putEiJob(TYPE_ID, "jobId1"); putEiJob(TYPE_ID, "jobId2"); // PUT a consumerRestApiTestBase.java - String url = ProducerConsts.API_ROOT + "/eiproducers/eiProducerId"; - String body = gson.toJson(producerEiRegistratioInfo(TYPE_ID)); + String url = ProducerConsts.API_ROOT + "/info-producers/infoProducerId"; + String body = gson.toJson(producerInfoRegistratioInfo(TYPE_ID)); restClient().putForEntity(url, body).block(); - url = ProducerConsts.API_ROOT + "/eiproducers/eiProducerId/eijobs"; + url = ProducerConsts.API_ROOT + "/info-producers/infoProducerId/info-jobs"; ResponseEntity resp = restClient().getForEntity(url).block(); assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.OK); @@ -660,24 +673,24 @@ class ApplicationTest { @Test void producerDeleteEiProducer() throws Exception { - putEiProducerWithOneType("eiProducerId", TYPE_ID); - putEiProducerWithOneType("eiProducerId2", TYPE_ID); + putInfoProducerWithOneType("infoProducerId", TYPE_ID); + putInfoProducerWithOneType("infoProducerId2", TYPE_ID); - assertThat(this.eiProducers.size()).isEqualTo(2); - EiType type = this.eiTypes.getType(TYPE_ID); - assertThat(this.eiProducers.getProducerIdsForType(type.getId())).contains("eiProducerId"); - assertThat(this.eiProducers.getProducerIdsForType(type.getId())).contains("eiProducerId2"); + assertThat(this.infoProducers.size()).isEqualTo(2); + InfoType type = this.infoTypes.getType(TYPE_ID); + assertThat(this.infoProducers.getProducerIdsForType(type.getId())).contains("infoProducerId"); + assertThat(this.infoProducers.getProducerIdsForType(type.getId())).contains("infoProducerId2"); putEiJob(TYPE_ID, "jobId"); - assertThat(this.eiJobs.size()).isEqualTo(1); + assertThat(this.infoJobs.size()).isEqualTo(1); - deleteEiProducer("eiProducerId"); - assertThat(this.eiProducers.size()).isEqualTo(1); - assertThat(this.eiProducers.getProducerIdsForType(TYPE_ID)).doesNotContain("eiProducerId"); + deleteEiProducer("infoProducerId"); + assertThat(this.infoProducers.size()).isEqualTo(1); + assertThat(this.infoProducers.getProducerIdsForType(TYPE_ID)).doesNotContain("infoProducerId"); verifyJobStatus("jobId", "ENABLED"); - deleteEiProducer("eiProducerId2"); - assertThat(this.eiProducers.size()).isZero(); - assertThat(this.eiTypes.size()).isEqualTo(1); + deleteEiProducer("infoProducerId2"); + assertThat(this.infoProducers.size()).isZero(); + assertThat(this.infoTypes.size()).isEqualTo(1); verifyJobStatus("jobId", "DISABLED"); } @@ -686,20 +699,20 @@ class ApplicationTest { ConsumerSimulatorController.TestResults consumerCalls = this.consumerSimulator.getTestResults(); ProducerSimulatorController.TestResults producerCalls = this.producerSimulator.getTestResults(); - putEiProducerWithOneType("eiProducerId", TYPE_ID); + putInfoProducerWithOneType("infoProducerId", TYPE_ID); putEiJob(TYPE_ID, "jobId"); - putEiProducerWithOneType("eiProducerId2", TYPE_ID); + putInfoProducerWithOneType("infoProducerId2", TYPE_ID); await().untilAsserted(() -> assertThat(producerCalls.jobsStarted.size()).isEqualTo(2)); - deleteEiProducer("eiProducerId2"); - assertThat(this.eiTypes.size()).isEqualTo(1); // The type remains, one producer left - deleteEiProducer("eiProducerId"); - assertThat(this.eiTypes.size()).isEqualTo(1); // The type remains - assertThat(this.eiJobs.size()).isEqualTo(1); // The job remains + deleteEiProducer("infoProducerId2"); + assertThat(this.infoTypes.size()).isEqualTo(1); // The type remains, one producer left + deleteEiProducer("infoProducerId"); + assertThat(this.infoTypes.size()).isEqualTo(1); // The type remains + assertThat(this.infoJobs.size()).isEqualTo(1); // The job remains await().untilAsserted(() -> assertThat(consumerCalls.status.size()).isEqualTo(1)); assertThat(consumerCalls.status.get(0).state).isEqualTo(A1eEiJobStatus.EiJobStatusValues.DISABLED); - putEiProducerWithOneType("eiProducerId", TYPE_ID); + putInfoProducerWithOneType("infoProducerId", TYPE_ID); await().untilAsserted(() -> assertThat(consumerCalls.status.size()).isEqualTo(2)); assertThat(consumerCalls.status.get(1).state).isEqualTo(A1eEiJobStatus.EiJobStatusValues.ENABLED); } @@ -709,17 +722,17 @@ class ApplicationTest { // Test replacing a producer with new and removed types // Create a job - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); putEiJob(TYPE_ID, EI_JOB_ID); // change the type for the producer, the job shall be disabled - putEiProducerWithOneType(PRODUCER_ID, "junk"); + putInfoProducerWithOneType(PRODUCER_ID, "junk"); verifyJobStatus(EI_JOB_ID, "DISABLED"); ConsumerSimulatorController.TestResults consumerCalls = this.consumerSimulator.getTestResults(); await().untilAsserted(() -> assertThat(consumerCalls.status.size()).isEqualTo(1)); assertThat(consumerCalls.status.get(0).state).isEqualTo(A1eEiJobStatus.EiJobStatusValues.DISABLED); - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); verifyJobStatus(EI_JOB_ID, "ENABLED"); await().untilAsserted(() -> assertThat(consumerCalls.status.size()).isEqualTo(2)); assertThat(consumerCalls.status.get(1).state).isEqualTo(A1eEiJobStatus.EiJobStatusValues.ENABLED); @@ -727,25 +740,25 @@ class ApplicationTest { @Test void producerGetProducerEiType() throws JsonMappingException, JsonProcessingException, ServiceException { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); - String url = ProducerConsts.API_ROOT + "/eitypes/" + TYPE_ID; + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); + String url = ProducerConsts.API_ROOT + "/info-types/" + TYPE_ID; ResponseEntity resp = restClient().getForEntity(url).block(); - ProducerEiTypeInfo info = gson.fromJson(resp.getBody(), ProducerEiTypeInfo.class); + ProducerInfoTypeInfo info = gson.fromJson(resp.getBody(), ProducerInfoTypeInfo.class); assertThat(info.jobDataSchema).isNotNull(); } @Test void producerGetProducerIdentifiers() throws JsonMappingException, JsonProcessingException, ServiceException { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); - String url = ProducerConsts.API_ROOT + "/eiproducers"; + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); + String url = ProducerConsts.API_ROOT + "/info-producers"; ResponseEntity resp = restClient().getForEntity(url).block(); assertThat(resp.getBody()).contains(PRODUCER_ID); - url = ProducerConsts.API_ROOT + "/eiproducers?ei_type_id=" + TYPE_ID; + url = ProducerConsts.API_ROOT + "/info-producers?info_type_id=" + TYPE_ID; resp = restClient().getForEntity(url).block(); assertThat(resp.getBody()).contains(PRODUCER_ID); - url = ProducerConsts.API_ROOT + "/eiproducers?ei_type_id=junk"; + url = ProducerConsts.API_ROOT + "/info-producers?info_type_id=junk"; resp = restClient().getForEntity(url).block(); assertThat(resp.getBody()).isEqualTo("[]"); } @@ -758,7 +771,7 @@ class ApplicationTest { { // Create a job - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); putEiJob(TYPE_ID, EI_JOB_ID); verifyJobStatus(EI_JOB_ID, "ENABLED"); deleteEiProducer(PRODUCER_ID); @@ -768,25 +781,25 @@ class ApplicationTest { verifyJobStatus(EI_JOB_ID, "DISABLED"); } - assertThat(this.eiProducers.size()).isEqualTo(1); - assertThat(this.eiTypes.size()).isEqualTo(1); + assertThat(this.infoProducers.size()).isEqualTo(1); + assertThat(this.infoTypes.size()).isEqualTo(1); assertProducerOpState("simulateProducerError", ProducerStatusInfo.OperationalState.ENABLED); this.producerSupervision.createTask().blockLast(); this.producerSupervision.createTask().blockLast(); // Now we have one producer that is disabled - assertThat(this.eiProducers.size()).isEqualTo(1); + assertThat(this.infoProducers.size()).isEqualTo(1); assertProducerOpState("simulateProducerError", ProducerStatusInfo.OperationalState.DISABLED); // After 3 failed checks, the producer shall be deregisterred this.producerSupervision.createTask().blockLast(); - assertThat(this.eiProducers.size()).isEqualTo(0); // The producer is removed - assertThat(this.eiTypes.size()).isEqualTo(1); // The type remains + assertThat(this.infoProducers.size()).isEqualTo(0); // The producer is removed + assertThat(this.infoTypes.size()).isEqualTo(1); // The type remains // Now we have one disabled job, and no producer. // PUT a producer, then a Job ENABLED status notification shall be received - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); await().untilAsserted(() -> assertThat(consumerResults.status.size()).isEqualTo(2)); assertThat(consumerResults.status.get(1).state).isEqualTo(A1eEiJobStatus.EiJobStatusValues.ENABLED); verifyJobStatus(EI_JOB_ID, "ENABLED"); @@ -797,11 +810,11 @@ class ApplicationTest { // Test that supervision enables not enabled jobs and sends a notification when // suceeded - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); putEiJob(TYPE_ID, EI_JOB_ID); - EiProducer producer = this.eiProducers.getProducer(PRODUCER_ID); - EiJob job = this.eiJobs.getJob(EI_JOB_ID); + InfoProducer producer = this.infoProducers.getProducer(PRODUCER_ID); + InfoJob job = this.infoJobs.getJob(EI_JOB_ID); // Pretend that the producer did reject the job and the a DISABLED notification // is sent for the job producer.setJobDisabled(job); @@ -828,34 +841,34 @@ class ApplicationTest { @Test void testEiJobDatabase() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); putEiJob(TYPE_ID, "jobId1"); putEiJob(TYPE_ID, "jobId2"); - assertThat(this.eiJobs.size()).isEqualTo(2); + assertThat(this.infoJobs.size()).isEqualTo(2); { - EiJob savedJob = this.eiJobs.getJob("jobId1"); + InfoJob savedJob = this.infoJobs.getJob("jobId1"); // Restore the jobs - EiJobs jobs = new EiJobs(this.applicationConfig, this.producerCallbacks); + InfoJobs jobs = new InfoJobs(this.applicationConfig, this.producerCallbacks); jobs.restoreJobsFromDatabase(); assertThat(jobs.size()).isEqualTo(2); - EiJob restoredJob = jobs.getJob("jobId1"); + InfoJob restoredJob = jobs.getJob("jobId1"); assertThat(restoredJob.getId()).isEqualTo("jobId1"); assertThat(restoredJob.getLastUpdated()).isEqualTo(savedJob.getLastUpdated()); - jobs.remove("jobId1", this.eiProducers); - jobs.remove("jobId2", this.eiProducers); + jobs.remove("jobId1", this.infoProducers); + jobs.remove("jobId2", this.infoProducers); } { // Restore the jobs, no jobs in database - EiJobs jobs = new EiJobs(this.applicationConfig, this.producerCallbacks); + InfoJobs jobs = new InfoJobs(this.applicationConfig, this.producerCallbacks); jobs.restoreJobsFromDatabase(); assertThat(jobs.size()).isEqualTo(0); } logger.warn("Test removing a job when the db file is gone"); - this.eiJobs.remove("jobId1", this.eiProducers); - assertThat(this.eiJobs.size()).isEqualTo(1); + this.infoJobs.remove("jobId1", this.infoProducers); + assertThat(this.infoJobs.size()).isEqualTo(1); ProducerSimulatorController.TestResults simulatorResults = this.producerSimulator.getTestResults(); await().untilAsserted(() -> assertThat(simulatorResults.jobsStopped.size()).isEqualTo(3)); @@ -863,31 +876,31 @@ class ApplicationTest { @Test void testEiTypesDatabase() throws Exception { - putEiProducerWithOneType(PRODUCER_ID, TYPE_ID); + putInfoProducerWithOneType(PRODUCER_ID, TYPE_ID); - assertThat(this.eiTypes.size()).isEqualTo(1); + assertThat(this.infoTypes.size()).isEqualTo(1); { // Restore the types - EiTypes types = new EiTypes(this.applicationConfig); + InfoTypes types = new InfoTypes(this.applicationConfig); types.restoreTypesFromDatabase(); assertThat(types.size()).isEqualTo(1); } { // Restore the jobs, no jobs in database - EiTypes types = new EiTypes(this.applicationConfig); + InfoTypes types = new InfoTypes(this.applicationConfig); types.clear(); types.restoreTypesFromDatabase(); assertThat(types.size()).isEqualTo(0); } logger.warn("Test removing a job when the db file is gone"); - this.eiTypes.remove(this.eiTypes.getType(TYPE_ID)); - assertThat(this.eiJobs.size()).isEqualTo(0); + this.infoTypes.remove(this.infoTypes.getType(TYPE_ID)); + assertThat(this.infoJobs.size()).isEqualTo(0); } - private void deleteEiProducer(String eiProducerId) { - String url = ProducerConsts.API_ROOT + "/eiproducers/" + eiProducerId; + private void deleteEiProducer(String infoProducerId) { + String url = ProducerConsts.API_ROOT + "/info-producers/" + infoProducerId; restClient().deleteForEntity(url).block(); } @@ -899,15 +912,15 @@ class ApplicationTest { private void assertProducerOpState(String producerId, ProducerStatusInfo.OperationalState expectedOperationalState) { - String statusUrl = ProducerConsts.API_ROOT + "/eiproducers/" + producerId + "/status"; + String statusUrl = ProducerConsts.API_ROOT + "/info-producers/" + producerId + "/status"; ResponseEntity resp = restClient().getForEntity(statusUrl).block(); ProducerStatusInfo statusInfo = gson.fromJson(resp.getBody(), ProducerStatusInfo.class); assertThat(statusInfo.opState).isEqualTo(expectedOperationalState); } - ProducerEiTypeInfo producerEiTypeRegistrationInfo(String typeId) + ProducerInfoTypeInfo producerEiTypeRegistrationInfo(String typeId) throws JsonMappingException, JsonProcessingException { - return new ProducerEiTypeInfo(jsonSchemaObject()); + return new ProducerInfoTypeInfo(jsonSchemaObject()); } ProducerRegistrationInfo producerEiRegistratioInfoRejecting(String typeId) @@ -917,7 +930,7 @@ class ApplicationTest { baseUrl() + ProducerSimulatorController.SUPERVISION_ERROR_URL); } - ProducerRegistrationInfo producerEiRegistratioInfo(String typeId) + ProducerRegistrationInfo producerInfoRegistratioInfo(String typeId) throws JsonMappingException, JsonProcessingException { return new ProducerRegistrationInfo(Arrays.asList(typeId), // baseUrl() + ProducerSimulatorController.JOB_URL, baseUrl() + ProducerSimulatorController.SUPERVISION_URL); @@ -927,19 +940,19 @@ class ApplicationTest { return consumerJobInfo(TYPE_ID, EI_JOB_ID); } - ConsumerJobInfo consumerJobInfo(String typeId, String eiJobId) + ConsumerJobInfo consumerJobInfo(String typeId, String infoJobId) throws JsonMappingException, JsonProcessingException { - return new ConsumerJobInfo(typeId, jsonObject(), "owner", "targetUri", - baseUrl() + ConsumerSimulatorController.getJobStatusUrl(eiJobId)); + return new ConsumerJobInfo(typeId, jsonObject(), "owner", "https://junk.com", + baseUrl() + ConsumerSimulatorController.getJobStatusUrl(infoJobId)); } - private A1eEiJobInfo eiJobInfo() throws JsonMappingException, JsonProcessingException { - return eiJobInfo(TYPE_ID, EI_JOB_ID); + private A1eEiJobInfo infoJobInfo() throws JsonMappingException, JsonProcessingException { + return infoJobInfo(TYPE_ID, EI_JOB_ID); } - A1eEiJobInfo eiJobInfo(String typeId, String eiJobId) throws JsonMappingException, JsonProcessingException { - return new A1eEiJobInfo(typeId, jsonObject(), "owner", "targetUri", - baseUrl() + ConsumerSimulatorController.getJobStatusUrl(eiJobId)); + A1eEiJobInfo infoJobInfo(String typeId, String infoJobId) throws JsonMappingException, JsonProcessingException { + return new A1eEiJobInfo(typeId, jsonObject(), "owner", "https://junk.com", + baseUrl() + ConsumerSimulatorController.getJobStatusUrl(infoJobId)); } private Object jsonObject(String json) { @@ -971,46 +984,46 @@ class ApplicationTest { return jsonObject("{ " + EI_JOB_PROPERTY + " : \"value\" }"); } - private EiJob putEiJob(String eiTypeId, String jobId) + private InfoJob putEiJob(String infoTypeId, String jobId) throws JsonMappingException, JsonProcessingException, ServiceException { String url = A1eConsts.API_ROOT + "/eijobs/" + jobId; - String body = gson.toJson(eiJobInfo(eiTypeId, jobId)); + String body = gson.toJson(infoJobInfo(infoTypeId, jobId)); restClient().putForEntity(url, body).block(); - return this.eiJobs.getJob(jobId); + return this.infoJobs.getJob(jobId); } - private HttpStatus putEiType(String eiTypeId) + private HttpStatus putInfoType(String infoTypeId) throws JsonMappingException, JsonProcessingException, ServiceException { - String url = ProducerConsts.API_ROOT + "/eitypes/" + eiTypeId; - String body = gson.toJson(producerEiTypeRegistrationInfo(eiTypeId)); + String url = ProducerConsts.API_ROOT + "/info-types/" + infoTypeId; + String body = gson.toJson(producerEiTypeRegistrationInfo(infoTypeId)); ResponseEntity resp = restClient().putForEntity(url, body).block(); - this.eiTypes.getType(eiTypeId); + this.infoTypes.getType(infoTypeId); return resp.getStatusCode(); } - private EiType putEiProducerWithOneTypeRejecting(String producerId, String eiTypeId) + private InfoType putEiProducerWithOneTypeRejecting(String producerId, String infoTypeId) throws JsonMappingException, JsonProcessingException, ServiceException { - this.putEiType(eiTypeId); - String url = ProducerConsts.API_ROOT + "/eiproducers/" + producerId; - String body = gson.toJson(producerEiRegistratioInfoRejecting(eiTypeId)); + this.putInfoType(infoTypeId); + String url = ProducerConsts.API_ROOT + "/info-producers/" + producerId; + String body = gson.toJson(producerEiRegistratioInfoRejecting(infoTypeId)); restClient().putForEntity(url, body).block(); - return this.eiTypes.getType(eiTypeId); + return this.infoTypes.getType(infoTypeId); } - private EiType putEiProducerWithOneType(String producerId, String eiTypeId) + private InfoType putInfoProducerWithOneType(String producerId, String infoTypeId) throws JsonMappingException, JsonProcessingException, ServiceException { - this.putEiType(eiTypeId); + this.putInfoType(infoTypeId); - String url = ProducerConsts.API_ROOT + "/eiproducers/" + producerId; - String body = gson.toJson(producerEiRegistratioInfo(eiTypeId)); + String url = ProducerConsts.API_ROOT + "/info-producers/" + producerId; + String body = gson.toJson(producerInfoRegistratioInfo(infoTypeId)); restClient().putForEntity(url, body).block(); - return this.eiTypes.getType(eiTypeId); + return this.infoTypes.getType(infoTypeId); } private String baseUrl() { diff --git a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ConsumerSimulatorController.java b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ConsumerSimulatorController.java index a9fae154..a9702b29 100644 --- a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ConsumerSimulatorController.java +++ b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ConsumerSimulatorController.java @@ -65,14 +65,16 @@ public class ConsumerSimulatorController { @Getter private TestResults testResults = new TestResults(); - public static String getJobStatusUrl(String eiJobId) { - return "/example_dataconsumer/eijobs/" + eiJobId + "/status"; + public static String getJobStatusUrl(String infoJobId) { + return "/example_dataconsumer/info_jobs/" + infoJobId + "/status"; } - @PostMapping(path = "/example_dataconsumer/eijobs/{eiJobId}/status", produces = MediaType.APPLICATION_JSON_VALUE) + @PostMapping( + path = "/example_dataconsumer/info_jobs/{infoJobId}/status", + produces = MediaType.APPLICATION_JSON_VALUE) @Operation( - summary = "Callback for changed EI job status", - description = "The primitive is implemented by the data consumer and is invoked when a EI job status has been changed.") + summary = "Callback for changed Information Job status", + description = "The primitive is implemented by the data consumer and is invoked when a Information Job status has been changed.") @ApiResponses( value = { // @ApiResponse( @@ -81,9 +83,9 @@ public class ConsumerSimulatorController { content = @Content(schema = @Schema(implementation = VoidResponse.class))) // }) public ResponseEntity jobStatusCallback( // - @PathVariable("eiJobId") String eiJobId, // + @PathVariable("infoJobId") String infoJobId, // @RequestBody A1eEiJobStatus status) { - logger.info("Job status callback status: {} eiJobId: {}", status.state, eiJobId); + logger.info("Job status callback status: {} infoJobId: {}", status.state, infoJobId); this.testResults.status.add(status); return new ResponseEntity<>(HttpStatus.OK); } diff --git a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java index f9828ff1..1c0767b0 100644 --- a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java +++ b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java @@ -56,8 +56,8 @@ public class ProducerSimulatorController { private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - public static final String JOB_URL = "/producer_simulator/ei_job"; - public static final String JOB_ERROR_URL = "/producer_simulator/ei_job_error"; + public static final String JOB_URL = "/producer_simulator/info_job"; + public static final String JOB_ERROR_URL = "/producer_simulator/info_job_error"; public static final String SUPERVISION_URL = "/producer_simulator/health_check"; public static final String SUPERVISION_ERROR_URL = "/producer_simulator/health_check_error"; @@ -87,8 +87,8 @@ public class ProducerSimulatorController { @PostMapping(path = JOB_URL, produces = MediaType.APPLICATION_JSON_VALUE) @Operation( - summary = "Callback for EI job creation/modification", - description = "The call is invoked to activate or to modify a data subscription. The endpoint is provided by the EI producer.") + summary = "Callback for Information Job creation/modification", + description = "The call is invoked to activate or to modify a data subscription. The endpoint is provided by the Information Producer.") @ApiResponses( value = { // @ApiResponse( @@ -111,10 +111,10 @@ public class ProducerSimulatorController { } } - @DeleteMapping(path = "/producer_simulator/ei_job/{eiJobId}", produces = MediaType.APPLICATION_JSON_VALUE) + @DeleteMapping(path = "/producer_simulator/info_job/{infoJobId}", produces = MediaType.APPLICATION_JSON_VALUE) @Operation( - summary = "Callback for EI job deletion", - description = "The call is invoked to terminate a data subscription. The endpoint is provided by the EI producer.") + summary = "Callback for Information Job deletion", + description = "The call is invoked to terminate a data subscription. The endpoint is provided by the Information Producer.") @ApiResponses( value = { // @ApiResponse( @@ -123,10 +123,10 @@ public class ProducerSimulatorController { content = @Content(schema = @Schema(implementation = VoidResponse.class))) // }) public ResponseEntity jobDeletedCallback( // - @PathVariable("eiJobId") String eiJobId) { + @PathVariable("infoJobId") String infoJobId) { try { - logger.info("Job deleted callback {}", eiJobId); - this.testResults.jobsStopped.add(eiJobId); + logger.info("Job deleted callback {}", infoJobId); + this.testResults.jobsStopped.add(infoJobId); return new ResponseEntity<>(HttpStatus.OK); } catch (Exception e) { return ErrorResponse.create(e, HttpStatus.NOT_FOUND); @@ -134,7 +134,7 @@ public class ProducerSimulatorController { } @PostMapping(path = JOB_ERROR_URL, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Callback for EI job creation, returns error", description = "", hidden = true) + @Operation(summary = "Callback for Information Job creation, returns error", description = "", hidden = true) @ApiResponses( value = { // @ApiResponse( @@ -149,8 +149,8 @@ public class ProducerSimulatorController { return ErrorResponse.create("Producer returns error on create job", HttpStatus.NOT_FOUND); } - @DeleteMapping(path = JOB_ERROR_URL + "/{eiJobId}", produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Callback for EI job deletion, returns error", description = "", hidden = true) + @DeleteMapping(path = JOB_ERROR_URL + "/{infoJobId}", produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "Callback for Information Job deletion, returns error", description = "", hidden = true) @ApiResponses( value = { // @ApiResponse( @@ -159,8 +159,8 @@ public class ProducerSimulatorController { content = @Content(schema = @Schema(implementation = VoidResponse.class))) // }) public ResponseEntity jobDeletedCallbackReturnError( // - @PathVariable("eiJobId") String eiJobId) { - logger.info("Job created (returning error) callback {}", eiJobId); + @PathVariable("infoJobId") String infoJobId) { + logger.info("Job created (returning error) callback {}", infoJobId); this.testResults.noOfRejectedDelete += 1; return ErrorResponse.create("Producer returns error on delete job", HttpStatus.NOT_FOUND); } @@ -168,7 +168,7 @@ public class ProducerSimulatorController { @GetMapping(path = SUPERVISION_URL, produces = MediaType.APPLICATION_JSON_VALUE) @Operation( summary = "Producer supervision", - description = "The endpoint is provided by the EI producer and is used for supervision of the producer.") + description = "The endpoint is provided by the Information Producer and is used for supervision of the producer.") @ApiResponses( value = { // @ApiResponse( -- 2.16.6