Fixed the http request call for VES PM message [Issue-ID: ODUHIGH-412]
[o-du/l2.git] / src / o1 / ves / VesEventHandler.cpp
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2020-2021] [HCL Technologies Ltd.]                          #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 *******************************************************************************/
18
19 /* This file contains functions to support the preparation of Common Header part
20    of VES Event*/
21
22
23 #include "VesEventHandler.hpp"
24 #include "PnfRegistrationEvent.hpp"
25 #include "SliceMeasurementEvent.hpp"
26 #include "Message.hpp"
27
28 /*******************************************************************
29  *
30  * @brief Constructor
31  *
32  * @details
33  *
34  *    Function : VesEventHandler
35  *
36  *    Functionality:
37  *      - Constructor intialization
38  *
39  * @params[in] NULL
40  * @return None
41  ******************************************************************/
42 VesEventHandler::VesEventHandler() : mVesEvent(NULL)
43 {
44
45 }
46
47 /*******************************************************************
48  *
49  * @brief Destructor
50  *
51  * @details
52  *
53  *    Function : ~VesEventHandler
54  *
55  *    Functionality:
56  *      - Destructor
57  *
58  * @params[in] None
59  * @return None
60  ******************************************************************/
61 VesEventHandler::~VesEventHandler()
62 {
63    if( mVesEvent != NULL )
64       delete mVesEvent;
65 }
66
67 /*******************************************************************
68  *
69  * @brief Prepare VES Message
70  *
71  * @details
72  *
73  *    Function : prepare
74  *
75  *    Functionality:
76  *      - prepare VES event
77  *
78  * @params[in] void
79  * @return true     - success
80  *         false    - failure
81  *
82  * ****************************************************************/
83
84 bool VesEventHandler::prepare(VesEventType evtType, const Message* msg)
85 {
86    //check event type and call funtions accordingly
87    bool ret = true;
88    switch(evtType)
89    {
90       case VesEventType::PNF_REGISTRATION:
91       {
92          O1_LOG("\nO1 VesEventHandler : Preparing PNF registration");
93          mVesEvent = new PnfRegistrationEvent();
94          break;
95       }
96       case VesEventType::PM_SLICE:
97       {
98          mVesEvent = new SliceMeasurementEvent;
99          O1_LOG("\nO1 VesEventHandler : Preparing VES PM Slice");
100          break;
101       }
102
103       default:
104          O1_LOG("\nO1 VesEventHandler : VES message type does not exist ");
105          ret = false;
106          break;
107    }
108    mVesEvent->init();
109    if(!mVesEvent->prepare(msg)) {
110       O1_LOG("\nO1 VesEventHandler : Failed to prepare VES message");
111       ret = false;
112    }
113    return ret;
114 }
115
116 /*******************************************************************
117  *
118  * @brief Send Ves Message
119  *
120  * @details
121  *
122  *    Function : send
123  *
124  *    Functionality:
125  *      - Send VES event to SMO
126  *
127  * @params[in] void
128  * @return true     - success
129  *         false    - failure
130  *
131  * ****************************************************************/
132
133 bool VesEventHandler::send()
134 {
135    if (!mVesEvent->send()) {
136       O1_LOG("\nO1 VesEventHandler : Failed to send VES event");
137       return false;
138    }
139    return true;
140 }
141 /**********************************************************************
142   End of file
143  **********************************************************************/