summaryrefslogtreecommitdiffstats
path: root/dmi-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java
diff options
context:
space:
mode:
authorleventecsanyi <levente.csanyi@est.tech>2024-07-18 13:45:35 +0200
committerleventecsanyi <levente.csanyi@est.tech>2024-07-19 14:19:49 +0200
commitaa4d6e27a7488ff06aae8b97aac9b45d3e4d3bfe (patch)
treeceee4cca9f8e480fb1c41d26666fe352f6097354 /dmi-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java
parent0fe1b63d10a6ce4ec452d2089b9ffe101acd38f8 (diff)
Added DataJob related stub implementations
- updated pom.xml - added dataJob related code to DMI Stub controller - uplifted swagger core dependency Issue-ID: CPS-2323 Signed-off-by: leventecsanyi <levente.csanyi@est.tech> Change-Id: If30e1fad31daec004ad67dd3f2be1815aeb538b2
Diffstat (limited to 'dmi-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java')
-rw-r--r--dmi-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/dmi-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java b/dmi-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java
index d97173ce..b8b46f06 100644
--- a/dmi-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java
+++ b/dmi-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java
@@ -32,11 +32,14 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
+import org.onap.cps.ncmp.dmi.datajobs.model.SubjobWriteRequest;
+import org.onap.cps.ncmp.dmi.datajobs.model.SubjobWriteResponse;
import org.onap.cps.ncmp.dmi.rest.stub.model.data.operational.DataOperationRequest;
import org.onap.cps.ncmp.dmi.rest.stub.model.data.operational.DmiDataOperationRequest;
import org.onap.cps.ncmp.dmi.rest.stub.model.data.operational.DmiOperationCmHandle;
@@ -86,6 +89,7 @@ public class DmiRestStubController {
private long readDataForCmHandleDelayMs;
@Value("${delay.write-data-for-cm-handle-delay-ms}")
private long writeDataForCmHandleDelayMs;
+ private AtomicInteger subJobWriteRequestCounter;
/**
* This code defines a REST API endpoint for adding new the module set tag mapping. The endpoint receives the
@@ -257,6 +261,38 @@ public class DmiRestStubController {
return new ResponseEntity<>(HttpStatus.ACCEPTED);
}
+ /**
+ * Consume sub-job write requests from NCMP.
+ *
+ * @param requestId requestId generated by NCMP as an ack for client.
+ * @param subJobWriteRequest contains a collection of write requests and metadata.
+ * @return (@ code ResponseEntity) response for the write request.
+ */
+ @PostMapping("/v1/writeJob/{requestId}")
+ public ResponseEntity<SubjobWriteResponse> consumeWriteSubJobs(@PathVariable("requestId") final String requestId,
+ @RequestBody final SubjobWriteRequest subJobWriteRequest) {
+ log.debug("Request ID: {}", requestId);
+ log.debug("Request body: {}", subJobWriteRequest);
+ return ResponseEntity.ok(new SubjobWriteResponse(String.valueOf(subJobWriteRequestCounter.incrementAndGet()),
+ "some-dmi-service-name", "my-data-producer-id"));
+ }
+
+ /**
+ * Retrieves the status of a given data job identified by {@code requestId} and {@code dataProducerJobId}.
+ *
+ * @param requestId Unique identifier for the outgoing request.
+ * @param dataProducerJobId Identifier of the data producer job.
+ * @return A ResponseEntity with HTTP status 200 (OK) and the data job's status as a string.
+ */
+ @GetMapping("/v1/dataJob/{requestId}/dataProducerJob/{dataProducerJobId}/status")
+ public ResponseEntity<String> retrieveDataJobStatus(
+ @PathVariable("requestId") final String requestId,
+ @PathVariable("dataProducerJobId") final String dataProducerJobId) {
+ log.info("Received request to retrieve data job status. Request ID: {}, Data Producer Job ID: {}",
+ requestId, dataProducerJobId);
+ return ResponseEntity.ok("FINISHED");
+ }
+
private CloudEvent buildAndGetCloudEvent(final String topic, final String requestId,
final DataOperationEvent dataOperationEvent) {
CloudEvent cloudEvent = null;