2 * ============LICENSE_START========================================================================
\r
3 * ONAP : tr-069-adapter
\r
4 * =================================================================================================
\r
5 * Copyright (C) 2020 CommScope Inc Intellectual Property.
\r
6 * =================================================================================================
\r
7 * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,
\r
8 * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You
\r
9 * may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
\r
14 * either express or implied. See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
16 * ===============LICENSE_END=======================================================================
\r
19 package org.commscope.tr069adapter.vesagent.controller;
\r
21 import com.fasterxml.jackson.core.JsonProcessingException;
\r
23 import org.commscope.tr069adapter.acs.common.inform.BootstrapInform;
\r
24 import org.commscope.tr069adapter.acs.common.inform.PeriodicInform;
\r
25 import org.commscope.tr069adapter.acs.common.inform.ValueChangeInform;
\r
26 import org.commscope.tr069adapter.mapper.model.VESNotification;
\r
27 import org.commscope.tr069adapter.mapper.model.VESNotificationResponse;
\r
28 import org.commscope.tr069adapter.vesagent.exception.InvalidFaultOperationException;
\r
29 import org.slf4j.Logger;
\r
30 import org.slf4j.LoggerFactory;
\r
31 import org.springframework.beans.factory.annotation.Autowired;
\r
32 import org.springframework.http.HttpStatus;
\r
33 import org.springframework.web.bind.annotation.PostMapping;
\r
34 import org.springframework.web.bind.annotation.RequestBody;
\r
35 import org.springframework.web.bind.annotation.RequestMapping;
\r
36 import org.springframework.web.bind.annotation.RestController;
\r
39 @RequestMapping(path = "/vesagent")
\r
40 public class VESAgentService {
\r
41 private static final Logger logger = LoggerFactory.getLogger(VESAgentService.class);
\r
44 PnfRegMappingHandler pnfHandler;
\r
47 AlarmMappingHandler alarmHanler;
\r
50 HeartBeatMessageHandler hbHandler;
\r
52 @PostMapping(path = "/deviceEvent", consumes = "application/json")
\r
53 public VESNotificationResponse processDeviceNotificationAsVESEvent(
\r
54 @RequestBody VESNotification notification)
\r
55 throws JsonProcessingException, InvalidFaultOperationException {
\r
56 VESNotificationResponse response = null;
\r
57 logger.debug("VES Notification request processing started");
\r
58 if (notification.getDevnotification() == null) {
\r
59 logger.debug("VES Notification request PnfRegister on container restart processing started");
\r
60 response = pnfHandler.handlePnfRegNotificationOnRestart(notification);
\r
61 } else if (notification.getDevnotification() instanceof BootstrapInform) {
\r
62 logger.debug("VES Notification request PnfRegister processing started");
\r
63 response = pnfHandler.handlePnfRegNotification(notification);
\r
64 logger.debug("VES Notification request PnfRegister processing completed");
\r
65 } else if (notification.getDevnotification() instanceof ValueChangeInform) {
\r
66 logger.debug("VES Notification request Fault processing started");
\r
67 response = alarmHanler.handleAlarmNotification(notification);
\r
68 logger.debug("VES Notification request Fault processing completed");
\r
69 } else if (notification.getDevnotification() instanceof PeriodicInform) {
\r
70 logger.debug("VES Notification request PI processing started");
\r
71 response = hbHandler.handlePINotification(notification);
\r
72 logger.debug("VES Notification request PI processing completed");
\r
74 logger.error("VES Notification request is unknown");
\r
76 new VESNotificationResponse(HttpStatus.BAD_REQUEST.value(), "Method not supported");
\r
78 logger.debug("VES Notification request processing completed");
\r