summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorniamhcore <niamh.core@est.tech>2021-08-26 15:31:48 +0100
committerniamhcore <niamh.core@est.tech>2021-08-27 15:09:13 +0100
commit776c1451ddb2eb676520f8d34103b9c889a4ea26 (patch)
tree6ce692ea3923c996432d8c95de98f2474164b376 /src/main
parent528022a0f33225f3eab6930ff27c3ab8d1638568 (diff)
Address minor code review comments for CPS-484
Issue-ID: CPS-565 Signed-off-by: niamhcore <niamh.core@est.tech> Change-Id: I8cb28cf60622e5a9c0211b4fa7db2f255ede165a
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java12
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java6
2 files changed, 11 insertions, 7 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 32651e4d..1d7abf24 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
@@ -29,8 +29,8 @@ 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.DmiReadRequestBody;
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.rest.api.DmiPluginApi;
import org.onap.cps.ncmp.dmi.rest.api.DmiPluginInternalApi;
@@ -62,10 +62,10 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi {
}
@Override
- public ResponseEntity<Object> retrieveModuleResources(@Valid final ModuleRequestParent moduleRequestParent,
+ public ResponseEntity<Object> retrieveModuleResources(@Valid final DmiReadRequestBody dmiReadRequestBody,
final String cmHandle) {
- if (moduleRequestParent.getOperation().toString().equals("read")) {
- final var moduleReferenceList = convertRestObjectToJavaApiObject(moduleRequestParent);
+ if (dmiReadRequestBody.getOperation().toString().equals("read")) {
+ final var moduleReferenceList = convertRestObjectToJavaApiObject(dmiReadRequestBody);
final var response = dmiService.getModuleResources(cmHandle, moduleReferenceList);
if (response.isEmpty()) {
return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
@@ -165,9 +165,9 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi {
return ResponseEntity.ok(modulesListAsJson);
}
- private List<ModuleReference> convertRestObjectToJavaApiObject(final ModuleRequestParent moduleRequestParent) {
+ private List<ModuleReference> convertRestObjectToJavaApiObject(final DmiReadRequestBody dmiReadRequestBody) {
return objectMapper
- .convertValue(moduleRequestParent.getData().getModules(), new TypeReference<List<ModuleReference>>() {
+ .convertValue(dmiReadRequestBody.getData().getModules(), new TypeReference<List<ModuleReference>>() {
});
}
} \ No newline at end of file
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java b/src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java
index a139f7be..b4f0cac5 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java
@@ -100,10 +100,14 @@ public class DmiServiceImpl implements DmiService {
final var responseEntity = sdncOperations.getModuleResource(cmHandle, moduleRequest);
if (responseEntity.getStatusCode() == HttpStatus.OK) {
getModuleResponses.add(responseEntity.getBody());
- } else {
+ } else if (responseEntity.getStatusCode() == HttpStatus.NOT_FOUND) {
log.error("SDNC did not return a module resource for the given cmHandle {}", cmHandle);
throw new ModuleResourceNotFoundException(cmHandle,
"SDNC did not return a module resource for the given cmHandle.");
+ } else {
+ log.error("Error occurred when getting module resources from SDNC for the given cmHandle {}", cmHandle);
+ throw new DmiException(cmHandle,
+ "response code : " + responseEntity.getStatusCode() + " message : " + responseEntity.getBody());
}
}
return getModuleResponses.toJSONString();