summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authortragait <rahul.tyagi@est.tech>2021-09-10 10:45:31 +0100
committertragait <rahul.tyagi@est.tech>2021-09-10 12:12:18 +0100
commitaea4b371e4c06a7d5b4191ab8a602e99abd1f140 (patch)
tree1ce41c5f7d82c49a613ca7f82c531c5f1fbafabc /src/main/java
parent7eb4d1b72e0d45ede0c67223082fcc9760be4ead (diff)
revert cps:634 postpone this bug to jakarta
This commit also have fix in application yaml for correct ncmp api path for registration url. Issue-ID: CPS-634 Issue-ID: CPS-617 Signed-off-by: tragait <rahul.tyagi@est.tech> Change-Id: I465991492a01092e28b97583f84ed959c54ffaa6
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java2
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java15
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/client/NcmpRestClient.java3
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java2
4 files changed, 16 insertions, 6 deletions
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java b/src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java
index 7f79a04c..f1446084 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java
@@ -106,5 +106,5 @@ public interface DmiService {
* @return response from sdnc
*/
String writeResourceDataPassthroughForCmHandle(String cmHandle, String resourceIdentifier, String dataType,
- String data);
+ Object data);
} \ 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 e9ecc592..2512ce2f 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
@@ -211,14 +211,23 @@ public class DmiServiceImpl implements DmiService {
@Override
public String writeResourceDataPassthroughForCmHandle(final String cmHandle, final String resourceIdentifier,
- final String dataType, final String data) {
+ final String dataType, final Object data) {
+ final String jsonData;
+ try {
+ jsonData = objectMapper.writeValueAsString(data);
+ } catch (final JsonProcessingException e) {
+ log.error("JSON exception occurred when processing pass through request data for the given cmHandle {}",
+ cmHandle);
+ throw new DmiException("Unable to process incoming JSON from the request body.",
+ "JSON exception occurred when writing data for the given cmHandle " + cmHandle, e);
+ }
final ResponseEntity<String> responseEntity =
- sdncOperations.writeResourceDataPassthroughRunning(cmHandle, resourceIdentifier, dataType, data);
+ sdncOperations.writeResourceDataPassthroughRunning(cmHandle, resourceIdentifier, dataType, jsonData);
if (responseEntity.getStatusCode() == HttpStatus.CREATED) {
return responseEntity.getBody();
} else {
throw new DmiException(cmHandle,
- RESPONSE_CODE + responseEntity.getStatusCode() + MESSAGE + responseEntity.getBody());
+ RESPONSE_CODE + responseEntity.getStatusCode() + MESSAGE + responseEntity.getBody());
}
}
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/service/client/NcmpRestClient.java b/src/main/java/org/onap/cps/ncmp/dmi/service/client/NcmpRestClient.java
index 47651346..94783f3b 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/service/client/NcmpRestClient.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/client/NcmpRestClient.java
@@ -23,6 +23,7 @@ package org.onap.cps.ncmp.dmi.service.client;
import org.onap.cps.ncmp.dmi.config.DmiConfiguration.CpsProperties;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
@@ -51,7 +52,7 @@ public class NcmpRestClient {
httpHeaders.setBasicAuth(cpsProperties.getAuthUsername(), cpsProperties.getAuthPassword());
httpHeaders.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
final var httpEntity = new HttpEntity<>(jsonData, httpHeaders);
- return restTemplate.postForEntity(ncmpRegistrationUrl, httpEntity, String.class);
+ return restTemplate.exchange(ncmpRegistrationUrl, HttpMethod.POST, httpEntity, String.class);
}
private String buildNcmpRegistrationUrl() {
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java b/src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java
index bbc39da5..b8e33dfc 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java
@@ -79,6 +79,6 @@ public class SdncRestconfClient {
final var sdncRestconfUrl = sdncBaseUrl.concat(postResourceUrl);
httpHeaders.setBasicAuth(sdncProperties.getAuthUsername(), sdncProperties.getAuthPassword());
final var httpEntity = new HttpEntity<>(jsonData, httpHeaders);
- return restTemplate.postForEntity(sdncRestconfUrl, httpEntity, String.class);
+ return restTemplate.exchange(sdncRestconfUrl, HttpMethod.POST, httpEntity, String.class);
}
} \ No newline at end of file