diff options
author | JosephKeenan <joseph.keenan@est.tech> | 2022-05-23 15:43:05 +0100 |
---|---|---|
committer | JosephKeenan <joseph.keenan@est.tech> | 2022-06-01 16:56:50 +0100 |
commit | 2cd8b98223bd49975fcca0ec7f1d4673a4163074 (patch) | |
tree | d26e809ad7befaf8b7815271a6fcc501f67b3117 /src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java | |
parent | df26bc38a75f10650ce5785cdc9bd7b9516f6f25 (diff) |
Async request response dmi -> NCMP
-Added Async for passthrough running and operational
-Build will fail until cps is merged https://gerrit.onap.org/r/c/cps/+/128685
Issue-ID: CPS-830
Change-Id: Iedbfab109f5cd777a5be8eed7414758d0f5ec05c
Signed-off-by: JosephKeenan <joseph.keenan@est.tech>
Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
Signed-off-by: JosephKeenan <joseph.keenan@est.tech>
Diffstat (limited to 'src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java')
-rw-r--r-- | src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java | 20 |
1 files changed, 6 insertions, 14 deletions
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 22d47442..753d16f7 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 @@ -33,9 +33,9 @@ import lombok.extern.slf4j.Slf4j; import org.onap.cps.ncmp.dmi.config.DmiPluginConfig.DmiPluginProperties; import org.onap.cps.ncmp.dmi.exception.CmHandleRegistrationException; import org.onap.cps.ncmp.dmi.exception.DmiException; +import org.onap.cps.ncmp.dmi.exception.HttpClientRequestException; import org.onap.cps.ncmp.dmi.exception.ModuleResourceNotFoundException; import org.onap.cps.ncmp.dmi.exception.ModulesNotFoundException; -import org.onap.cps.ncmp.dmi.exception.ResourceDataNotFound; import org.onap.cps.ncmp.dmi.model.DataAccessRequest; import org.onap.cps.ncmp.dmi.model.ModuleSet; import org.onap.cps.ncmp.dmi.model.ModuleSetSchemas; @@ -59,8 +59,6 @@ public class DmiServiceImpl implements DmiService { private NcmpRestClient ncmpRestClient; private ObjectMapper objectMapper; private DmiPluginProperties dmiPluginProperties; - private static final String RESPONSE_CODE = "response code : "; - private static final String MESSAGE = " message : "; /** * Constructor. @@ -107,8 +105,8 @@ public class DmiServiceImpl implements DmiService { "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()); + throw new HttpClientRequestException( + cmHandle, responseEntity.getBody(), responseEntity.getStatusCode()); } } return yangResources; @@ -166,20 +164,14 @@ public class DmiServiceImpl implements DmiService { final String dataType, final String data) { final ResponseEntity<String> responseEntity = sdncOperations.writeData(operation, cmHandle, resourceIdentifier, dataType, data); - if (responseEntity.getStatusCode().is2xxSuccessful()) { - return responseEntity.getBody(); - } else { - throw new DmiException(cmHandle, - RESPONSE_CODE + responseEntity.getStatusCode() + MESSAGE + responseEntity.getBody()); - } + return prepareAndSendResponse(responseEntity, cmHandle); } private String prepareAndSendResponse(final ResponseEntity<String> responseEntity, final String cmHandle) { - if (responseEntity.getStatusCode() == HttpStatus.OK) { + if (responseEntity.getStatusCode().is2xxSuccessful()) { return responseEntity.getBody(); } else { - throw new ResourceDataNotFound(cmHandle, - RESPONSE_CODE + responseEntity.getStatusCode() + MESSAGE + responseEntity.getBody()); + throw new HttpClientRequestException(cmHandle, responseEntity.getBody(), responseEntity.getStatusCode()); } } |