summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org')
-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();