diff options
Diffstat (limited to 'src/main')
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; |