2 * Copyright (c) 2019 Amdocs
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.nbi.apis.hub;
18 import org.onap.nbi.apis.hub.service.NotificationAspect;
19 import org.onap.nbi.commons.ResourceManagement;
20 import org.onap.nbi.exceptions.BackendFunctionalException;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23 import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.http.MediaType;
25 import org.springframework.scheduling.annotation.EnableScheduling;
26 import org.springframework.web.bind.annotation.PostMapping;
27 import org.springframework.web.bind.annotation.RequestBody;
28 import org.springframework.web.bind.annotation.RequestMapping;
29 import org.springframework.web.bind.annotation.RestController;
30 import org.onap.nbi.apis.hub.model.Event;
35 @RequestMapping("/listener")
37 public class ListenerResource extends ResourceManagement {
40 NotificationAspect notificationAspect;
42 private static final Logger LOGGER = LoggerFactory.getLogger(ListenerResource.class);
44 @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE)
45 public void receiveNotification(@RequestBody Event event) {
47 LOGGER.debug("Received notification from external NBI || Sending it to original listener");
48 notificationAspect.forwardNotificationToOriginalListener(event);
49 }catch(BackendFunctionalException ex) {
50 LOGGER.error("Unable to send the recieved notification to original Listener");