summaryrefslogtreecommitdiffstats
path: root/dmi-stub/dmi-plugin-demo-and-csit-stub-service
diff options
context:
space:
mode:
Diffstat (limited to 'dmi-stub/dmi-plugin-demo-and-csit-stub-service')
-rw-r--r--dmi-stub/dmi-plugin-demo-and-csit-stub-service/pom.xml5
-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
2 files changed, 41 insertions, 0 deletions
diff --git a/dmi-stub/dmi-plugin-demo-and-csit-stub-service/pom.xml b/dmi-stub/dmi-plugin-demo-and-csit-stub-service/pom.xml
index 78b56852..7118a616 100644
--- a/dmi-stub/dmi-plugin-demo-and-csit-stub-service/pom.xml
+++ b/dmi-stub/dmi-plugin-demo-and-csit-stub-service/pom.xml
@@ -93,6 +93,11 @@
<artifactId>cps-ncmp-events</artifactId>
<version>3.4.9</version>
</dependency>
+ <dependency>
+ <groupId>io.swagger.core.v3</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ </dependency>
+
<!-- T E S T D E P E N D E N C I E S -->
<dependency>
<groupId>org.spockframework</groupId>
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;