summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authortragait <rahul.tyagi@est.tech>2022-01-10 12:16:25 +0000
committertragait <rahul.tyagi@est.tech>2022-01-19 13:48:30 +0000
commitdffff5df568b0f7654dcf019cee2333b29db09e2 (patch)
treec751d8b8ac88bf66582eeca1fac4be6d9e9a0c30 /src/main
parent527a90df79174fcbceee0e4f0d17fae200de6a2e (diff)
impl patch operation in dmi
Change-Id: Ie87216fa6cb120bea685286b7f0dacd8e22f603b Signed-off-by: tragait <rahul.tyagi@est.tech> Issue-ID: CPS-641
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/config/DmiConfiguration.java20
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java4
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java3
3 files changed, 24 insertions, 3 deletions
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/config/DmiConfiguration.java b/src/main/java/org/onap/cps/ncmp/dmi/config/DmiConfiguration.java
index 9b8b05b2..18b22dbe 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/config/DmiConfiguration.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/config/DmiConfiguration.java
@@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
@@ -34,6 +35,8 @@ import org.springframework.web.client.RestTemplate;
@Configuration
public class DmiConfiguration {
+ private static final int TIMEOUT = 5000;
+
@Getter
@Component
public static class CpsProperties {
@@ -62,8 +65,23 @@ public class DmiConfiguration {
public String topologyId;
}
+ /**
+ * Returns restTemplate bean for the spring context.
+ *
+ * @param restTemplateBuilder restTemplate builder
+ * @return {@code RestTemplate} rest template
+ */
@Bean
public RestTemplate restTemplate(final RestTemplateBuilder restTemplateBuilder) {
- return restTemplateBuilder.build();
+ final RestTemplate restTemplate = restTemplateBuilder.build();
+ setCustomRequestFactoryToSupportPatch(restTemplate);
+ return restTemplate;
+ }
+
+ private void setCustomRequestFactoryToSupportPatch(final RestTemplate restTemplate) {
+ final HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
+ requestFactory.setConnectTimeout(TIMEOUT);
+ requestFactory.setReadTimeout(TIMEOUT);
+ restTemplate.setRequestFactory(requestFactory);
}
} \ No newline at end of file
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 97848c3e..077c4ab4 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
@@ -36,7 +36,6 @@ import org.onap.cps.ncmp.dmi.rest.api.DmiPluginInternalApi;
import org.onap.cps.ncmp.dmi.service.DmiService;
import org.onap.cps.ncmp.dmi.service.model.ModuleReference;
import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -135,7 +134,7 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi {
dataAccessRequest.getOperation(),
cmHandle,
resourceIdentifier,
- MediaType.APPLICATION_JSON_VALUE,
+ dataAccessRequest.getDataType(),
dataAccessRequest.getData());
}
return new ResponseEntity<>(sdncResponse, getHttpStatus(dataAccessRequest));
@@ -157,6 +156,7 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi {
break;
case READ:
case UPDATE:
+ case PATCH:
httpStatus = HttpStatus.OK;
break;
case DELETE:
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java b/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java
index ced9b061..5903eacf 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java
@@ -248,6 +248,9 @@ public class SdncOperations {
case CREATE:
httpMethod = HttpMethod.POST;
break;
+ case PATCH:
+ httpMethod = HttpMethod.PATCH;
+ break;
case UPDATE:
httpMethod = HttpMethod.PUT;
break;