Framework update.

This commit is contained in:
stephb9959
2022-03-03 22:38:11 -08:00
parent 2fd563e4b1
commit e48250eb5e
4 changed files with 106 additions and 28 deletions

View File

@@ -93,6 +93,11 @@ namespace OpenWifi::ProvObjects {
field_to_json( Obj,"devices",devices);
field_to_json( Obj,"rrm",rrm);
field_to_json( Obj,"sourceIP",sourceIP);
field_to_json( Obj,"variables", variables);
field_to_json( Obj,"managementPolicies", managementPolicies);
field_to_json( Obj,"managementRoles", managementRoles);
field_to_json( Obj,"maps", maps);
field_to_json( Obj,"configurations", configurations);
}
bool Entity::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -108,6 +113,11 @@ namespace OpenWifi::ProvObjects {
field_from_json( Obj,"devices",devices);
field_from_json( Obj,"rrm",rrm);
field_from_json( Obj,"sourceIP",sourceIP);
field_from_json( Obj,"variables", variables);
field_from_json( Obj,"managementPolicies", managementPolicies);
field_from_json( Obj,"managementRoles", managementRoles);
field_from_json( Obj,"maps", maps);
field_from_json( Obj,"configurations", configurations);
return true;
} catch(...) {
@@ -146,6 +156,11 @@ namespace OpenWifi::ProvObjects {
field_to_json( Obj,"location",location);
field_to_json( Obj,"rrm",rrm);
field_to_json( Obj,"sourceIP",sourceIP);
field_to_json( Obj,"variables", variables);
field_to_json( Obj,"managementPolicies", managementPolicies);
field_to_json( Obj,"managementRoles", managementRoles);
field_to_json( Obj,"maps", maps);
field_to_json( Obj,"configurations", configurations);
}
bool Venue::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -164,6 +179,11 @@ namespace OpenWifi::ProvObjects {
field_from_json( Obj,"location",location);
field_from_json( Obj,"rrm",rrm);
field_from_json( Obj,"sourceIP",sourceIP);
field_from_json( Obj,"variables", variables);
field_from_json( Obj,"managementPolicies", managementPolicies);
field_from_json( Obj,"managementRoles", managementRoles);
field_from_json( Obj,"maps", maps);
field_from_json( Obj,"configurations", configurations);
return true;
} catch (...) {
@@ -193,6 +213,7 @@ namespace OpenWifi::ProvObjects {
field_to_json( Obj,"managementPolicy",managementPolicy);
field_to_json( Obj,"users",users);
field_to_json( Obj,"entity",entity);
field_to_json( Obj,"venue",venue);
}
bool ManagementRole::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -201,6 +222,7 @@ namespace OpenWifi::ProvObjects {
field_from_json( Obj,"managementPolicy",managementPolicy);
field_from_json( Obj,"users",users);
field_from_json( Obj,"entity",entity);
field_from_json( Obj,"venue",venue);
return true;
} catch(...) {
}
@@ -312,6 +334,7 @@ namespace OpenWifi::ProvObjects {
field_to_json( Obj,"state",state);
field_to_json( Obj,"devClass",devClass);
field_to_json( Obj,"locale",locale);
field_to_json( Obj,"realMacAddress",realMacAddress);
}
bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -332,6 +355,7 @@ namespace OpenWifi::ProvObjects {
field_from_json( Obj,"state",state);
field_from_json( Obj,"devClass",devClass);
field_from_json( Obj,"locale",locale);
field_from_json( Obj,"realMacAddress",realMacAddress);
return true;
} catch(...) {
@@ -404,6 +428,10 @@ namespace OpenWifi::ProvObjects {
field_to_json( Obj,"rrm",rrm);
field_to_json( Obj,"firmwareUpgrade",firmwareUpgrade);
field_to_json( Obj,"firmwareRCOnly",firmwareRCOnly);
field_to_json( Obj,"subscriberOnly",subscriberOnly);
field_to_json( Obj,"entity", entity);
field_to_json( Obj,"venue", venue);
field_to_json( Obj,"subscriber", subscriber);
}
bool DeviceConfiguration::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -417,6 +445,10 @@ namespace OpenWifi::ProvObjects {
field_from_json( Obj,"rrm",rrm);
field_from_json( Obj,"firmwareUpgrade",firmwareUpgrade);
field_from_json( Obj,"firmwareRCOnly",firmwareRCOnly);
field_from_json( Obj,"subscriberOnly",subscriberOnly);
field_from_json( Obj,"entity", entity);
field_from_json( Obj,"venue", venue);
field_from_json( Obj,"subscriber", subscriber);
return true;
} catch(...) {
@@ -595,6 +627,8 @@ namespace OpenWifi::ProvObjects {
RESTAPI_utils::field_to_json( Obj,"creator",creator);
field_to_json( Obj,"visibility",visibility);
RESTAPI_utils::field_to_json( Obj,"access",access);
RESTAPI_utils::field_to_json( Obj,"managementPolicy", managementPolicy);
RESTAPI_utils::field_to_json( Obj,"venue", venue);
}
bool Map::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -605,6 +639,8 @@ namespace OpenWifi::ProvObjects {
RESTAPI_utils::field_from_json( Obj,"creator",creator);
field_from_json( Obj,"visibility",visibility);
RESTAPI_utils::field_from_json( Obj,"access",access);
RESTAPI_utils::field_from_json( Obj,"managementPolicy", managementPolicy);
RESTAPI_utils::field_from_json( Obj,"venue", venue);
return true;
} catch(...) {
@@ -630,11 +666,14 @@ namespace OpenWifi::ProvObjects {
info.to_json(Obj);
RESTAPI_utils::field_to_json( Obj,"email", email);
RESTAPI_utils::field_to_json( Obj,"userId", userId);
RESTAPI_utils::field_to_json( Obj,"macAddress", macAddress);
RESTAPI_utils::field_to_json( Obj,"serialNumber", serialNumber);
RESTAPI_utils::field_to_json( Obj,"submitted", submitted);
RESTAPI_utils::field_to_json( Obj,"completed", completed);
RESTAPI_utils::field_to_json( Obj,"status", status);
RESTAPI_utils::field_to_json( Obj,"error", error);
RESTAPI_utils::field_to_json( Obj,"statusCode", statusCode);
RESTAPI_utils::field_to_json( Obj,"deviceID", deviceID);
}
bool SignupEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -642,11 +681,14 @@ namespace OpenWifi::ProvObjects {
info.from_json(Obj);
RESTAPI_utils::field_from_json( Obj,"email", email);
RESTAPI_utils::field_from_json( Obj,"userId", userId);
RESTAPI_utils::field_from_json( Obj,"macAddress", macAddress);
RESTAPI_utils::field_from_json( Obj,"serialNumber", serialNumber);
RESTAPI_utils::field_from_json( Obj,"submitted", submitted);
RESTAPI_utils::field_from_json( Obj,"completed", completed);
RESTAPI_utils::field_from_json( Obj,"status", status);
RESTAPI_utils::field_from_json( Obj,"error", error);
RESTAPI_utils::field_from_json( Obj,"statusCode", statusCode);
RESTAPI_utils::field_from_json( Obj,"deviceID", deviceID);
return true;
} catch(...) {
@@ -695,7 +737,8 @@ namespace OpenWifi::ProvObjects {
RESTAPI_utils::field_to_json( Obj,"venue", venue);
RESTAPI_utils::field_to_json( Obj,"subscriber", subscriber);
RESTAPI_utils::field_to_json( Obj,"inventory", inventory);
RESTAPI_utils::field_to_json( Obj,"inUse", inUse);
RESTAPI_utils::field_to_json( Obj,"configurations", configurations);
RESTAPI_utils::field_to_json( Obj,"managementPolicy", managementPolicy);
}
bool VariableBlock::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -706,7 +749,8 @@ namespace OpenWifi::ProvObjects {
RESTAPI_utils::field_from_json( Obj,"venue", venue);
RESTAPI_utils::field_from_json( Obj,"subscriber", subscriber);
RESTAPI_utils::field_from_json( Obj,"inventory", inventory);
RESTAPI_utils::field_from_json( Obj,"inUse", inUse);
RESTAPI_utils::field_from_json( Obj,"configurations", configurations);
RESTAPI_utils::field_from_json( Obj,"managementPolicy", managementPolicy);
return true;
} catch(...) {
}
@@ -750,7 +794,7 @@ namespace OpenWifi::ProvObjects {
}
bool CreateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I) {
uint64_t Now = std::time(nullptr);
uint64_t Now = OpenWifi::Now();
if(O->has("name"))
I.name = O->get("name").toString();

View File

@@ -48,6 +48,7 @@ namespace OpenWifi::ProvObjects {
std::vector<ManagementPolicyEntry> entries;
Types::StringVec inUse;
Types::UUID_t entity;
Types::UUID_t venue;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -66,6 +67,11 @@ namespace OpenWifi::ProvObjects {
Types::UUIDvec_t devices;
std::string rrm;
Types::StringVec sourceIP;
Types::UUIDvec_t variables;
Types::UUIDvec_t managementPolicies;
Types::UUIDvec_t managementRoles;
Types::UUIDvec_t maps;
Types::UUIDvec_t configurations;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -96,6 +102,11 @@ namespace OpenWifi::ProvObjects {
std::string location;
std::string rrm;
Types::StringVec sourceIP;
Types::UUIDvec_t variables;
Types::UUIDvec_t configurations;
Types::UUIDvec_t maps;
Types::UUIDvec_t managementPolicies;
Types::UUIDvec_t managementRoles;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -117,6 +128,7 @@ namespace OpenWifi::ProvObjects {
Types::UUIDvec_t users;
Types::StringVec inUse;
Types::UUID_t entity;
Types::UUID_t venue;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -260,10 +272,14 @@ namespace OpenWifi::ProvObjects {
Types::StringVec deviceTypes;
DeviceConfigurationElementVec configuration;
Types::StringVec inUse;
Types::StringPairVec variables;
Types::UUIDvec_t variables;
std::string rrm;
std::string firmwareUpgrade;
bool firmwareRCOnly=false;
bool subscriberOnly=false;
std::string venue;
std::string entity;
std::string subscriber;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -287,6 +303,7 @@ namespace OpenWifi::ProvObjects {
std::string state;
std::string devClass;
std::string locale;
std::string realMacAddress;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -384,6 +401,8 @@ namespace OpenWifi::ProvObjects {
std::string creator;
VISIBILITY visibility = PRIVATE;
ObjectACLList access;
Types::UUID_t managementPolicy;
std::string venue;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -396,15 +415,28 @@ namespace OpenWifi::ProvObjects {
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
enum SignupStatusCodes {
SignupCreated = 0 ,
SignupWaitingForEmail,
SignupWaitingForDevice,
SignupSuccess,
SignupFailure,
SignupCanceled,
SignupTimedOut
};
struct SignupEntry {
ObjectInfo info;
std::string email;
std::string userId;
std::string macAddress;
std::string serialNumber;
uint64_t submitted = 0 ;
uint64_t completed = 0 ;
std::string status;
uint64_t error=0;
uint64_t statusCode=0;
std::string deviceID;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -434,7 +466,8 @@ namespace OpenWifi::ProvObjects {
std::string venue;
std::string subscriber;
std::string inventory;
std::vector<std::string> inUse;
Types::UUIDvec_t configurations;
Types::UUID_t managementPolicy;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);

View File

@@ -730,11 +730,11 @@ namespace ORM {
try {
Command << i, Poco::Data::Keywords::now;
} catch (const Poco::Exception &E) {
Logger_.log(E);
Logger_.error(Poco::format("The following statement '%s' generated an exception during a table upgrade. This maya or may not be a problem.", i));
}
if(!IgnoreExceptions) {
return false;
// Logger_.log(E);
// Logger_.error(Poco::format("The following statement '%s' generated an exception during a table upgrade. This may or may not be a problem.", i));
if(!IgnoreExceptions) {
return false;
}
}
Command.reset(Session);
}
@@ -810,32 +810,32 @@ namespace ORM {
return ManipulateVectorMember(&RecordType::users, FieldName, ParentUUID, ChildUUID, false);
}
inline bool AddInUse(field_name_t FieldName, std::string & ParentUUID, const std::string & Prefix, const std::string & ChildUUID) {
inline bool AddConfiguration(field_name_t FieldName, const std::string & ParentUUID, const std::string & ChildUUID) {
return ManipulateVectorMember(&RecordType::deviceConfiguration, FieldName, ParentUUID, ChildUUID, true);
}
inline bool DelConfiguration(field_name_t FieldName, const std::string & ParentUUID, const std::string & ChildUUID) {
return ManipulateVectorMember(&RecordType::deviceConfiguration, FieldName, ParentUUID, ChildUUID, false);
}
inline bool AddVariable(field_name_t FieldName, const std::string & ParentUUID, const std::string & ChildUUID) {
return ManipulateVectorMember(&RecordType::variables, FieldName, ParentUUID, ChildUUID, true);
}
inline bool DelVariable(field_name_t FieldName, const std::string & ParentUUID, const std::string & ChildUUID) {
return ManipulateVectorMember(&RecordType::variables, FieldName, ParentUUID, ChildUUID, false);
}
inline bool AddInUse(field_name_t FieldName, const std::string & ParentUUID, const std::string & Prefix, const std::string & ChildUUID) {
std::string FakeUUID{ Prefix + ":" + ChildUUID};
return ManipulateVectorMember(&RecordType::inUse,FieldName, ParentUUID, FakeUUID, true);
}
inline bool DeleteInUse(field_name_t FieldName, std::string & ParentUUID, const std::string & Prefix, const std::string & ChildUUID) {
inline bool DeleteInUse(field_name_t FieldName, const std::string & ParentUUID, const std::string & Prefix, const std::string & ChildUUID) {
std::string FakeUUID{ Prefix + ":" + ChildUUID};
return ManipulateVectorMember(&RecordType::inUse,FieldName, ParentUUID, FakeUUID, false);
}
inline bool DeleteContact(field_name_t FieldName, std::string & ParentUUID, const std::string & ChildUUID) {
return ManipulateVectorMember(&RecordType::contacts,FieldName, ParentUUID, ChildUUID, false);
}
inline bool AddContact(field_name_t FieldName, std::string & ParentUUID, const std::string & ChildUUID) {
return ManipulateVectorMember(&RecordType::contacts,FieldName, ParentUUID, ChildUUID, true);
}
inline bool DeleteLocation(field_name_t FieldName, std::string & ParentUUID, const std::string & ChildUUID) {
return ManipulateVectorMember(&RecordType::locations,FieldName, ParentUUID, ChildUUID, false);
}
inline bool AddLocation(field_name_t FieldName, std::string & ParentUUID, const std::string & ChildUUID) {
return ManipulateVectorMember(&RecordType::locations,FieldName, ParentUUID, ChildUUID, true);
}
inline bool GetInUse(field_name_t FieldName, const std::string & UUID, std::vector<std::string> & UUIDs ) {
RecordType R;
if(GetRecord(FieldName,UUID,R)) {

View File

@@ -71,6 +71,7 @@ namespace OpenWifi::RESTAPI::Errors {
static const std::string SerialNumberNotTheProperClass{"Device is not available to subscribers. It ahs been assigned to another class of devices."};
static const std::string UserAlreadyExists{"Username already exists."};
static const std::string NotImplemented{"Function not implemented."};
static const std::string VariableMustExist{"Specified variable does not exist."};
}
namespace OpenWifi::RESTAPI::Protocol {