From c38ada1f4b44cf5dcc9f8cc4fb49cd9a8568a774 Mon Sep 17 00:00:00 2001 From: sourabh_sourabh Date: Tue, 8 Aug 2023 19:30:41 +0100 Subject: Modify DmiDataOperationRequest to make it identical as DataOperationRequest - Modified DmiDataOperationRequest attribute from operationType to operation. - Wrapped operation details to parent attribute operationd array. Issue-ID: CPS-1833 Signed-off-by: sourabh_sourabh Change-Id: I79aa943e10e1c32c3252a6eb4375c14496476f8b Signed-off-by: sourabh_sourabh --- .../stub/controller/DmiRestStubController.java | 25 ++++++++++------- .../data/operational/DataOperationRequest.java | 2 ++ .../data/operational/DmiDataOperationRequest.java | 32 ++++++++++++++++++++++ .../operational/ResourceDataOperationRequests.java | 27 ------------------ 4 files changed, 49 insertions(+), 37 deletions(-) create mode 100644 dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/model/data/operational/DmiDataOperationRequest.java delete mode 100644 dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/model/data/operational/ResourceDataOperationRequests.java (limited to 'dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service') diff --git a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java index b7e67d7556..275331e186 100644 --- a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java +++ b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java @@ -37,7 +37,7 @@ import org.onap.cps.ncmp.api.NcmpEventResponseCode; import org.onap.cps.ncmp.api.impl.utils.EventDateTimeFormatter; import org.onap.cps.ncmp.dmi.rest.stub.model.data.operational.CmHandle; import org.onap.cps.ncmp.dmi.rest.stub.model.data.operational.DataOperationRequest; -import org.onap.cps.ncmp.dmi.rest.stub.model.data.operational.ResourceDataOperationRequests; +import org.onap.cps.ncmp.dmi.rest.stub.model.data.operational.DmiDataOperationRequest; import org.onap.cps.ncmp.dmi.rest.stub.utils.ResourceFileReaderUtil; import org.onap.cps.ncmp.events.async1_0_0.Data; import org.onap.cps.ncmp.events.async1_0_0.DataOperationEvent; @@ -108,9 +108,9 @@ public class DmiRestStubController { /** * This method is not implemented for ONAP DMI plugin. * - * @param topic client given topic name - * @param requestId requestId generated by NCMP as an ack for client - * @param resourceDataOperationRequests list of operation details + * @param topic client given topic name + * @param requestId requestId generated by NCMP as an ack for client + * @param dmiDataOperationRequest list of operation details * @return (@ code ResponseEntity) response entity */ @PostMapping("/v1/data") @@ -118,12 +118,17 @@ public class DmiRestStubController { final String topic, @RequestParam(value = "requestId") final String requestId, - @RequestBody final ResourceDataOperationRequests - resourceDataOperationRequests) { - log.info("Request received from the NCMP to DMI Plugin"); - resourceDataOperationRequests.forEach(resourceDataOperationRequest -> { - final DataOperationEvent dataOperationEvent = getDataOperationEvent(resourceDataOperationRequest); - resourceDataOperationRequest.getCmHandles().forEach(cmHandle -> { + @RequestBody final DmiDataOperationRequest + dmiDataOperationRequest) { + try { + log.info("Request received from the NCMP to DMI Plugin: {}", + objectMapper.writeValueAsString(dmiDataOperationRequest)); + } catch (final JsonProcessingException jsonProcessingException) { + log.info("Unable to process dmi data operation request to json string"); + } + dmiDataOperationRequest.getOperations().forEach(dmiDataOperation -> { + final DataOperationEvent dataOperationEvent = getDataOperationEvent(dmiDataOperation); + dmiDataOperation.getCmHandles().forEach(cmHandle -> { dataOperationEvent.getData().getResponses().get(0).setIds(List.of(cmHandle.getId())); final CloudEvent cloudEvent = buildAndGetCloudEvent(topic, requestId, dataOperationEvent); cloudEventKafkaTemplate.send(ncmpAsyncM2mTopic, UUID.randomUUID().toString(), cloudEvent); diff --git a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/model/data/operational/DataOperationRequest.java b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/model/data/operational/DataOperationRequest.java index 2c0cb919b9..85c649e233 100644 --- a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/model/data/operational/DataOperationRequest.java +++ b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/model/data/operational/DataOperationRequest.java @@ -20,11 +20,13 @@ package org.onap.cps.ncmp.dmi.rest.stub.model.data.operational; +import com.fasterxml.jackson.annotation.JsonInclude; import java.util.ArrayList; import java.util.List; import lombok.Getter; import lombok.Setter; +@JsonInclude(JsonInclude.Include.NON_NULL) @Setter @Getter public class DataOperationRequest { diff --git a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/model/data/operational/DmiDataOperationRequest.java b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/model/data/operational/DmiDataOperationRequest.java new file mode 100644 index 0000000000..0771e7740c --- /dev/null +++ b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/model/data/operational/DmiDataOperationRequest.java @@ -0,0 +1,32 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2023 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.cps.ncmp.dmi.rest.stub.model.data.operational; + +import java.util.List; +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +public class DmiDataOperationRequest { + + private List operations; +} diff --git a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/model/data/operational/ResourceDataOperationRequests.java b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/model/data/operational/ResourceDataOperationRequests.java deleted file mode 100644 index 68a222a306..0000000000 --- a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/model/data/operational/ResourceDataOperationRequests.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2023 Nordix Foundation - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.cps.ncmp.dmi.rest.stub.model.data.operational; - -import java.util.ArrayList; - -public class ResourceDataOperationRequests extends ArrayList { - private static final long serialVersionUID = 3553323170854399881L; -} -- cgit 1.2.3-korg