mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-11-06 13:38:05 +00:00
Debugging
This commit is contained in:
@@ -82,19 +82,23 @@ namespace OpenWifi{
|
||||
return false;
|
||||
}
|
||||
|
||||
auto Blocks = P.parse(i.configuration).extract<Poco::JSON::Object::Ptr>();
|
||||
auto N = Blocks->getNames();
|
||||
for (const auto &j: N) {
|
||||
if (std::find(SectionNames.cbegin(), SectionNames.cend(), j) == SectionNames.cend()) {
|
||||
std::cout << "Block section name rejected: " << j << std::endl;
|
||||
BadRequest(RESTAPI::Errors::ConfigBlockInvalid);
|
||||
return false;
|
||||
try {
|
||||
auto Blocks = P.parse(i.configuration).extract<Poco::JSON::Object::Ptr>();
|
||||
auto N = Blocks->getNames();
|
||||
for (const auto &j: N) {
|
||||
if (std::find(SectionNames.cbegin(), SectionNames.cend(), j) == SectionNames.cend()) {
|
||||
std::cout << "Block section name rejected: " << j << std::endl;
|
||||
BadRequest(RESTAPI::Errors::ConfigBlockInvalid);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (const Poco::JSON::JSONException &E ) {
|
||||
Error = "Block " + i.name + " failed parsing: " + E.message();
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
if (ValidateUCentralConfiguration(i.configuration, Error)) {
|
||||
/* nothing to do */ ;
|
||||
std::cout << "Block: " << i.name << " is valid" << std::endl;
|
||||
} else {
|
||||
std::cout << "Block: " << std::endl << ">>>" << std::endl << i.configuration << std::endl
|
||||
@@ -116,8 +120,6 @@ namespace OpenWifi{
|
||||
return BadRequest(RESTAPI::Errors::MissingUUID);
|
||||
}
|
||||
|
||||
std::cout << __LINE__ << std::endl;
|
||||
|
||||
std::string Arg;
|
||||
if(HasParameter("validateOnly",Arg) && Arg=="true") {
|
||||
auto Body = ParseStream();
|
||||
@@ -132,48 +134,38 @@ namespace OpenWifi{
|
||||
Answer.set("error", Error);
|
||||
return ReturnObject(Answer);
|
||||
}
|
||||
std::cout << __LINE__ << std::endl;
|
||||
|
||||
ProvObjects::DeviceConfiguration C;
|
||||
Poco::JSON::Object::Ptr Obj = ParseStream();
|
||||
if (!C.from_json(Obj)) {
|
||||
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
||||
}
|
||||
std::cout << __LINE__ << std::endl;
|
||||
|
||||
if(!ProvObjects::CreateObjectInfo(Obj,UserInfo_.userinfo,C.info)) {
|
||||
return BadRequest(RESTAPI::Errors::NameMustBeSet);
|
||||
}
|
||||
std::cout << __LINE__ << std::endl;
|
||||
|
||||
if(!C.managementPolicy.empty() && !StorageService()->PolicyDB().Exists("id",C.managementPolicy)) {
|
||||
return BadRequest(RESTAPI::Errors::UnknownId);
|
||||
}
|
||||
std::cout << __LINE__ << std::endl;
|
||||
|
||||
C.inUse.clear();
|
||||
if(C.deviceTypes.empty() || !DeviceTypeCache()->AreAcceptableDeviceTypes(C.deviceTypes, true)) {
|
||||
return BadRequest(RESTAPI::Errors::InvalidDeviceTypes);
|
||||
}
|
||||
std::cout << __LINE__ << std::endl;
|
||||
|
||||
std::string Error;
|
||||
if(!ValidateConfigBlock(C,Error)) {
|
||||
return BadRequest(RESTAPI::Errors::ConfigBlockInvalid + ", error: " + Error);
|
||||
}
|
||||
std::cout << __LINE__ << std::endl;
|
||||
|
||||
if(DB_.CreateRecord(C)) {
|
||||
std::cout << __LINE__ << std::endl;
|
||||
DB_.GetRecord("id", C.info.id, C);
|
||||
std::cout << __LINE__ << std::endl;
|
||||
if(!C.managementPolicy.empty())
|
||||
StorageService()->PolicyDB().AddInUse("id",C.managementPolicy,DB_.Prefix(), C.info.id);
|
||||
|
||||
std::cout << __LINE__ << std::endl;
|
||||
Poco::JSON::Object Answer;
|
||||
C.to_json(Answer);
|
||||
std::cout << __LINE__ << std::endl;
|
||||
return ReturnObject(Answer);
|
||||
}
|
||||
InternalError(RESTAPI::Errors::RecordNotCreated);
|
||||
|
||||
Reference in New Issue
Block a user