diff --git a/src/APConfig.cpp b/src/APConfig.cpp index 5e25600..d7ca164 100644 --- a/src/APConfig.cpp +++ b/src/APConfig.cpp @@ -91,32 +91,24 @@ namespace OpenWifi { } - bool APConfig::Get(std::string &Config) { + bool APConfig::Get(Poco::JSON::Object &Configuration) { if(Config_.empty()) { try { - std::cout << __LINE__ << std::endl; ProvObjects::InventoryTag D; - std::cout << __LINE__ << std::endl; if(Storage()->InventoryDB().GetRecord("serialNumber", SerialNumber_, D)) { - std::cout << __LINE__ << std::endl; - if(!D.deviceConfiguration.empty()) { - std::cout << __LINE__ << std::endl; AddConfiguration(D.deviceConfiguration); } if(!D.entity.empty()) { - std::cout << __LINE__ << std::endl; AddEntityConfig(D.entity); } else if(!D.venue.empty()) { - std::cout << __LINE__ << std::endl; AddVenueConfig(D.venue); } } // Now we have all the config we need. } catch (const Poco::Exception &E ) { - std::cout << __LINE__ << std::endl; Logger_.log(E); } } @@ -131,30 +123,19 @@ namespace OpenWifi { Poco::JSON::Object CFG; for(const auto &i:Config_) { - std::cout << __LINE__ << std::endl; for(const auto &ConfigElement:i.configuration) { - std::cout << __LINE__ << std::endl; Poco::JSON::Parser P; - std::cout << __LINE__ << std::endl; auto O = P.parse(ConfigElement.configuration).extract(); for(const auto &j:*O) { - std::cout << __LINE__ << std::endl; CFG.set(j.first,j.second); } } } - std::stringstream O; - Poco::JSON::Stringifier::stringify(CFG,O); - - std::cout << __LINE__ << std::endl; - Config = O.str(); - std::cout << __LINE__ << std::endl; + Configuration = CFG; if(Config_.empty()) return false; - - std::cout << __LINE__ << std::endl; return true; } diff --git a/src/APConfig.h b/src/APConfig.h index 150e28b..d7c3923 100644 --- a/src/APConfig.h +++ b/src/APConfig.h @@ -18,7 +18,7 @@ namespace OpenWifi { explicit APConfig(const std::string & SerialNumber, const std::string & DeviceType, Poco::Logger & L); - [[nodiscard]] bool Get(std::string &Config); + [[nodiscard]] bool Get(Poco::JSON::Object &Configuration); void AddConfiguration(const std::string &UUID); void AddVenueConfig(const std::string &UUID); diff --git a/src/RESTAPI_inventory_handler.cpp b/src/RESTAPI_inventory_handler.cpp index 4cba260..7c4e8bd 100644 --- a/src/RESTAPI_inventory_handler.cpp +++ b/src/RESTAPI_inventory_handler.cpp @@ -40,41 +40,28 @@ namespace OpenWifi{ void RESTAPI_inventory_handler::DoGet(Poco::Net::HTTPServerRequest &Request, Poco::Net::HTTPServerResponse &Response) { try { - std::cout << __LINE__ << std::endl; std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER,""); - std::cout << __LINE__ << std::endl; if(SerialNumber.empty()) { - std::cout << __LINE__ << std::endl; BadRequest(Request, Response, "Missing SerialNumber."); return; } ProvObjects::InventoryTag IT; - std::cout << __LINE__ << std::endl; if(Storage()->InventoryDB().GetRecord(RESTAPI::Protocol::SERIALNUMBER,SerialNumber,IT)) { std::string Arg; - std::cout << __LINE__ << std::endl; if(HasParameter("config",Arg) && Arg=="true") { - std::cout << __LINE__ << std::endl; APConfig Device(SerialNumber,IT.deviceType,Logger_); - std::cout << __LINE__ << std::endl; Poco::JSON::Object Answer; - std::string C; - if(Device.Get(C)) { - std::cout << __LINE__ << std::endl; - Answer.set("config", C); - std::cout << __LINE__ << std::endl; + Poco::JSON::Object Configuration; + if(Device.Get(Configuration)) { + Answer.set("config", Configuration); } else { - std::cout << __LINE__ << std::endl; Answer.set("config","none"); - std::cout << __LINE__ << std::endl; } ReturnObject(Request, Answer, Response); - std::cout << __LINE__ << std::endl; return; } else { - std::cout << __LINE__ << std::endl; Poco::JSON::Object Answer; IT.to_json(Answer); ReturnObject(Request, Answer, Response); diff --git a/test_scripts/curl/cli b/test_scripts/curl/cli index d4e5a5f..e977982 100755 --- a/test_scripts/curl/cli +++ b/test_scripts/curl/cli @@ -332,13 +332,11 @@ listconfigs() { } deviceconfig() { - gettag() { - curl ${FLAGS} "https://${OWPROV}/api/v1/inventory/$1?config=true" \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer ${token}" \ - -H "accept: application/json" > ${result_file} - jq < ${result_file} - } + curl ${FLAGS} "https://${OWPROV}/api/v1/inventory/$1?config=true" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer ${token}" \ + -H "accept: application/json" > ${result_file} + jq < ${result_file} } shopt -s nocasematch