diff options
author | 2021-08-25 13:43:51 +0000 | |
---|---|---|
committer | 2021-08-25 13:43:51 +0000 | |
commit | 528022a0f33225f3eab6930ff27c3ab8d1638568 (patch) | |
tree | 87170d1b5354ad456ce8a37a04bffa6b3140e309 /src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java | |
parent | b8f72560c6f29c49ee80672072d6a168351ce00a (diff) | |
parent | 79e41e0794035ea8dd3ae3064f8d368b5345df95 (diff) |
Merge "Write data for cm handle passthrough:running"
Diffstat (limited to 'src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java')
-rw-r--r-- | src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java | 99 |
1 files changed, 59 insertions, 40 deletions
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java b/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java index 79c11a4e..32651e4d 100644 --- a/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java +++ b/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java @@ -27,14 +27,16 @@ import javax.validation.Valid; import javax.validation.constraints.Min; import lombok.extern.slf4j.Slf4j; import org.onap.cps.ncmp.dmi.model.CmHandles; +import org.onap.cps.ncmp.dmi.model.DataAccessReadRequest; +import org.onap.cps.ncmp.dmi.model.DataAccessWriteRequest; import org.onap.cps.ncmp.dmi.model.ModuleReference; import org.onap.cps.ncmp.dmi.model.ModuleRequestParent; import org.onap.cps.ncmp.dmi.model.ModuleSet; -import org.onap.cps.ncmp.dmi.model.OperationalRequest; import org.onap.cps.ncmp.dmi.rest.api.DmiPluginApi; import org.onap.cps.ncmp.dmi.rest.api.DmiPluginInternalApi; import org.onap.cps.ncmp.dmi.service.DmiService; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -61,7 +63,7 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi { @Override public ResponseEntity<Object> retrieveModuleResources(@Valid final ModuleRequestParent moduleRequestParent, - final String cmHandle) { + final String cmHandle) { if (moduleRequestParent.getOperation().toString().equals("read")) { final var moduleReferenceList = convertRestObjectToJavaApiObject(moduleRequestParent); final var response = dmiService.getModuleResources(cmHandle, moduleReferenceList); @@ -74,6 +76,25 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi { } /** + * Write data using passthrough for the given cmHandle. + * + * @param dataAccessWriteRequest pass through request + * @param cmHandle cmHandle + * @param resourceIdentifier resource identifier + * @return (@ code ResponseEntity) response entity + */ + @Override + public ResponseEntity<Object> writeDataByPassthroughRunningForCmHandle( + final DataAccessWriteRequest dataAccessWriteRequest, + final String cmHandle, final String resourceIdentifier) { + final String response = dmiService.writeResourceDataPassthroughForCmHandle(cmHandle, + resourceIdentifier, + MediaType.APPLICATION_JSON_VALUE, + dataAccessWriteRequest.getData()); + return new ResponseEntity<>(response, HttpStatus.OK); + } + + /** * This method register given list of cm-handles to ncmp. * * @param cmHandles list of cm-handles @@ -89,60 +110,58 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi { } /** - * This method fetches the resource for given cm handle using pass - * through operational. It filters the response on the basis of depth and field - * query parameters and returns response. + * This method fetches the resource for given cm handle using pass through operational. It filters the response on + * the basis of depth and field query parameters and returns response. * - * @param cmHandle cm handle identifier - * @param resourceIdentifier resource identifier to fetch data - * @param body operational body - * @param accept accept header parameter - * @param fields fields to filter the response data - * @param depth depth parameter for the response + * @param cmHandle cm handle identifier + * @param resourceIdentifier resource identifier to fetch data + * @param dataAccessReadRequest data Access Read Request + * @param accept accept header parameter + * @param fields fields to filter the response data + * @param depth depth parameter for the response * @return {@code ResponseEntity} response entity */ @Override public ResponseEntity<Object> getResourceDataOperationalForCmHandle(final String cmHandle, - final String resourceIdentifier, - final @Valid OperationalRequest body, - final String accept, - final @Valid String fields, - final @Min(1) @Valid Integer depth) { + final String resourceIdentifier, + final @Valid DataAccessReadRequest dataAccessReadRequest, + final String accept, + final @Valid String fields, + final @Min(1) @Valid Integer depth) { final var modulesListAsJson = dmiService.getResourceDataOperationalForCmHandle(cmHandle, - resourceIdentifier, - accept, - fields, - depth, - body.getCmHandleProperties()); + resourceIdentifier, + accept, + fields, + depth, + dataAccessReadRequest.getCmHandleProperties()); return ResponseEntity.ok(modulesListAsJson); } /** - * This method fetches the resource for given cm handle using pass - * through running. It filters the response on the basis of depth and field - * query parameters and returns response. + * This method fetches the resource for given cm handle using pass through running. It filters the response on the + * basis of depth and field query parameters and returns response. * - * @param cmHandle cm handle identifier - * @param resourceIdentifier resource identifier to fetch data - * @param body operational body - * @param accept accept header parameter - * @param fields fields to filter the response data - * @param depth depth parameter for the response + * @param cmHandle cm handle identifier + * @param resourceIdentifier resource identifier to fetch data + * @param dataAccessReadRequest data Access Read Request + * @param accept accept header parameter + * @param fields fields to filter the response data + * @param depth depth parameter for the response * @return {@code ResponseEntity} response entity */ @Override public ResponseEntity<Object> getResourceDataPassthroughRunningForCmHandle(final String cmHandle, - final String resourceIdentifier, - final @Valid OperationalRequest body, - final String accept, - final @Valid String fields, - final @Min(1) @Valid Integer depth) { + final String resourceIdentifier, + final @Valid DataAccessReadRequest dataAccessReadRequest, + final String accept, + final @Valid String fields, + final @Min(1) @Valid Integer depth) { final var modulesListAsJson = dmiService.getResourceDataPassThroughRunningForCmHandle(cmHandle, - resourceIdentifier, - accept, - fields, - depth, - body.getCmHandleProperties()); + resourceIdentifier, + accept, + fields, + depth, + dataAccessReadRequest.getCmHandleProperties()); return ResponseEntity.ok(modulesListAsJson); } |