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.DeviceRPCRequest;
\r
24 import org.commscope.tr069adapter.acs.common.DeviceRPCResponse;
\r
25 import org.commscope.tr069adapter.acs.common.inform.BootstrapInform;
\r
26 import org.commscope.tr069adapter.acs.common.inform.ConnectionRequestInform;
\r
27 import org.commscope.tr069adapter.acs.common.inform.PeriodicInform;
\r
28 import org.commscope.tr069adapter.acs.common.inform.ValueChangeInform;
\r
29 import org.commscope.tr069adapter.mapper.model.VESNotification;
\r
30 import org.commscope.tr069adapter.mapper.model.VESNotificationResponse;
\r
31 import org.commscope.tr069adapter.vesagent.async.WaitForNotifications;
\r
32 import org.commscope.tr069adapter.vesagent.exception.InvalidFaultOperationException;
\r
33 import org.slf4j.Logger;
\r
34 import org.slf4j.LoggerFactory;
\r
35 import org.springframework.beans.factory.annotation.Autowired;
\r
36 import org.springframework.http.HttpStatus;
\r
37 import org.springframework.web.bind.annotation.PostMapping;
\r
38 import org.springframework.web.bind.annotation.RequestBody;
\r
39 import org.springframework.web.bind.annotation.RequestMapping;
\r
40 import org.springframework.web.bind.annotation.RestController;
\r
43 @RequestMapping(path = "/vesagent")
\r
44 public class VESAgentService {
\r
45 private static final Logger logger = LoggerFactory.getLogger(VESAgentService.class);
\r
48 PnfRegMappingHandler pnfHandler;
\r
51 AlarmMappingHandler alarmHanler;
\r
54 HeartBeatMessageHandler hbHandler;
\r
57 WaitForNotifications waitForNotifications;
\r
59 @PostMapping(path = "/deviceEvent", consumes = "application/json")
\r
60 public VESNotificationResponse processDeviceNotificationAsVESEvent(
\r
61 @RequestBody VESNotification notification)
\r
62 throws JsonProcessingException, InvalidFaultOperationException {
\r
63 VESNotificationResponse response = null;
\r
64 logger.debug("VES Notification request processing started");
\r
65 if (notification.getDevnotification() == null) {
\r
66 logger.debug("VES Notification request PnfRegister on container restart processing started");
\r
67 response = pnfHandler.handlePnfRegNotificationOnRestart(notification);
\r
68 } else if (notification.getDevnotification() instanceof BootstrapInform) {
\r
69 logger.debug("VES Notification request PnfRegister processing started");
\r
70 response = pnfHandler.handlePnfRegNotification(notification);
\r
71 hbHandler.handleRegisterRequest(notification);
\r
72 logger.debug("VES Notification request PnfRegister processing completed");
\r
73 } else if (notification.getDevnotification() instanceof ValueChangeInform) {
\r
74 logger.debug("VES Notification request Fault processing started");
\r
75 response = alarmHanler.handleAlarmNotification(notification);
\r
76 waitForNotifications.notifyDeviceNotification(notification);
\r
77 logger.debug("VES Notification request Fault processing completed");
\r
78 } else if (notification.getDevnotification() instanceof PeriodicInform) {
\r
79 logger.debug("VES Notification request PI processing started");
\r
80 waitForNotifications.notifyDeviceNotification(notification);
\r
81 logger.debug("VES Notification request PI processing completed");
\r
82 } else if (notification.getDevnotification() instanceof ConnectionRequestInform) {
\r
83 logger.debug("Recieived ConnectionRequest inform from device.");
\r
84 waitForNotifications.notifyDeviceNotification(notification);
\r
86 logger.error("VES Notification request is unknown");
\r
88 new VESNotificationResponse(HttpStatus.BAD_REQUEST.value(), "Method not supported");
\r
90 logger.debug("VES Notification request processing completed");
\r
94 @PostMapping(path = "/deleteConfig", consumes = "application/json")
\r
95 public VESNotificationResponse processDeleteConfigRequest(
\r
96 @RequestBody VESNotification vesNotification) {
\r
97 VESNotificationResponse response = null;
\r
99 logger.debug("Initiating deleteConfig VES Notification request");
\r
100 response = hbHandler.handleDeleteConfigRequest(vesNotification);
\r
101 logger.debug("deleteConfig VES Notification request is completed");
\r
105 @PostMapping(path = "/editConfig", consumes = "application/json")
\r
106 public DeviceRPCResponse processEditConfigRequest(
\r
107 @RequestBody DeviceRPCRequest deviceRPCRequest) {
\r
108 DeviceRPCResponse response = null;
\r
110 logger.debug("Initiating setConfig VES Notification request");
\r
111 response = hbHandler.handleSetConfigRequest(deviceRPCRequest);
\r
112 logger.debug("setConfig VES Notification request is compelted");
\r
116 @PostMapping(path = "/getConfig", consumes = "application/json")
\r
117 public DeviceRPCResponse processGetConfigRequest(@RequestBody DeviceRPCRequest deviceRPCRequest) {
\r
118 DeviceRPCResponse response = null;
\r
120 logger.debug("Initiating getConfig VES Notification request");
\r
121 response = hbHandler.handleGetConfigRequest(deviceRPCRequest);
\r
122 logger.debug("getConfig VES Notification request is compelted");
\r