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/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