diff options
author | Piotr Borelowski <p.borelowski@partner.samsung.com> | 2020-01-31 14:03:35 +0100 |
---|---|---|
committer | Piotr Borelowski <p.borelowski@partner.samsung.com> | 2020-02-07 13:38:20 +0000 |
commit | 37dad48713382ce04354e2231bd2938246f45340 (patch) | |
tree | 73e7d823c61b5fb4bcbf0ec308b107b167e9a50a /adapters/mso-ve-vnfm-adapter/src/main/java/org | |
parent | 6db24e72ecbf4f5c63085085c10dc656568b563b (diff) |
Added communication with DMaaP
Ve-Vnfm (SOL002) Adapter project
Issue-ID: SO-2574
Signed-off-by: Piotr Borelowski <p.borelowski@partner.samsung.com>
Change-Id: Ia6674f594bbf2112cbdaab47c203cb78f1ebbff0
Diffstat (limited to 'adapters/mso-ve-vnfm-adapter/src/main/java/org')
2 files changed, 45 insertions, 0 deletions
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/controller/NotificationController.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/controller/NotificationController.java index 2e5a00ad02..1882b4e183 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/controller/NotificationController.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/controller/NotificationController.java @@ -20,9 +20,11 @@ package org.onap.so.adapters.vevnfm.controller; +import org.onap.so.adapters.vevnfm.service.DmaapService; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -33,9 +35,13 @@ public class NotificationController { private static final Logger logger = LoggerFactory.getLogger(NotificationController.class); + @Autowired + private DmaapService dmaapService; + @PostMapping("${notification.url}") public ResponseEntity receiveNotification(@RequestBody final VnfLcmOperationOccurrenceNotification notification) { logger.info("Notification received {}", notification); + dmaapService.send(notification); return ResponseEntity.ok().build(); } } diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java new file mode 100644 index 0000000000..59397cead3 --- /dev/null +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java @@ -0,0 +1,39 @@ +package org.onap.so.adapters.vevnfm.service; + +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification; +import org.onap.so.rest.service.HttpRestServiceProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; + +@Service +public class DmaapService { + + private static final Logger logger = LoggerFactory.getLogger(DmaapService.class); + + @Value("${dmaap.endpoint}") + private String endpoint; + + @Value("${dmaap.topic}") + private String topic; + + @Autowired + private HttpRestServiceProvider restProvider; + + public void send(final VnfLcmOperationOccurrenceNotification notification) { + final ResponseEntity<String> response = restProvider.postHttpRequest(notification, getUrl(), String.class); + + final HttpStatus statusCode = response.getStatusCode(); + final String body = response.getBody(); + + logger.info("The DMaaP replied with the code {} and the body {}", statusCode, body); + } + + private String getUrl() { + return endpoint + topic; + } +} |