1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2020-2021] [HCL Technologies Ltd.] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 /* This class defines functions to read Ves Config files */
20 #include "VesConfigFile.hpp"
21 #include "JsonHelper.hpp"
22 #include "GlobalDefs.hpp"
26 VesConfigFile::VesConfigFile(string filepath)
30 /* Default Destructor */
31 VesConfigFile::~VesConfigFile()
36 string VesConfigFile::getVesServerIp() const
40 string VesConfigFile::getVesServerPort() const
42 return mVesServerPort;
44 string VesConfigFile::getVesServerUsername() const
46 return mVesServerUsername;
48 string VesConfigFile::getVesServerPassword() const
50 return mVesServerPassword;
53 /*******************************************************************
55 * @brief load Ves config file
59 * Function : loadConfigFile
62 * - read Ves Config file and store its contents
64 * @params[in] IN - NULL
65 * @return true - success
68 * ****************************************************************/
70 bool VesConfigFile::loadConfigFile()
72 cJSON *json = JsonHelper::read(mFilepath.c_str());
75 O1_LOG("\nO1 VesEvent : Error reading config file :%s", JsonHelper::getError());
80 cJSON *rootNode = NULL;
81 rootNode = JsonHelper::getNode(json, "vesConfig");
84 O1_LOG("\nO1 VesEvent : Reading Config.json file\n");
85 mVesServerIp = JsonHelper::getValue(rootNode, "vesV4IpAddress");
86 mVesServerPort = JsonHelper::getValue(rootNode, "vesPort");
87 mVesServerUsername = JsonHelper::getValue(rootNode, "username");
88 mVesServerPassword = JsonHelper::getValue(rootNode, "password");
92 O1_LOG("\nO1 VesEvent : Config Object is not available in config file");
96 JsonHelper::deleteNode(json);
100 /**********************************************************************
102 **********************************************************************/