Framework update.

This commit is contained in:
stephb9959
2021-10-25 14:34:14 -07:00
parent ed13053648
commit d695614567
6 changed files with 39 additions and 10 deletions

2
build
View File

@@ -1 +1 @@
74
75

View File

@@ -437,4 +437,14 @@ namespace OpenWifi::ProvObjects {
return false;
}
bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I) {
if(O->has("name"))
I.name = O->get("name").toString();
if(O->has("description"))
I.description = O->get("description").toString();
SecurityObjects::MergeNotes(O,U,I.notes);
I.modified = std::time(nullptr);
return true;
}
};

View File

@@ -57,7 +57,7 @@ namespace OpenWifi::ProvObjects {
Types::UUIDvec_t contacts; // all contacts associated in this entity
Types::UUIDvec_t locations; // all locations associated in this entity
Types::UUID_t managementPolicy;
std::string deviceConfiguration;
Types::UUIDvec_t deviceConfiguration;
Types::UUIDvec_t devices;
std::string rrm;
Types::StringVec sourceIP;
@@ -86,7 +86,7 @@ namespace OpenWifi::ProvObjects {
Types::UUIDvec_t devices;
DiGraph topology;
std::string design;
std::string deviceConfiguration;
Types::UUIDvec_t deviceConfiguration;
std::string contact;
std::string location;
std::string rrm;
@@ -316,6 +316,8 @@ namespace OpenWifi::ProvObjects {
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I);
};

View File

@@ -398,20 +398,31 @@ namespace OpenWifi::SecurityObjects {
return false;
}
bool append_from_json(Poco::JSON::Object::Ptr Obj, const UserInfo &UInfo, NoteInfoVec & Notes) {
bool MergeNotes(Poco::JSON::Object::Ptr Obj, const UserInfo &UInfo, NoteInfoVec & Notes) {
try {
if(Obj->has("notes") && Obj->isArray("notes")) {
SecurityObjects::NoteInfoVec NIV;
NIV = RESTAPI_utils::to_object_array<SecurityObjects::NoteInfo>(Obj->get("notes").toString());
for(auto const &i:NIV) {
SecurityObjects::NoteInfo ii{.created=(uint64_t)std::time(nullptr), .createdBy=UInfo.email, .note=i.note};
Notes.push_back(ii);
}
}
return true;
} catch(...) {
}
return false;
}
bool MergeNotes(const NoteInfoVec & NewNotes, const UserInfo &UInfo, NoteInfoVec & ExistingNotes) {
for(auto const &i:NewNotes) {
SecurityObjects::NoteInfo ii{.created=(uint64_t)std::time(nullptr), .createdBy=UInfo.email, .note=i.note};
ExistingNotes.push_back(ii);
}
return true;
}
void ProfileAction::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"resource", resource);
field_to_json<ResourceAccessType>(Obj,"access", access, ResourceAccessTypeToString);

View File

@@ -137,7 +137,9 @@ namespace OpenWifi::SecurityObjects {
};
typedef std::vector<UserInfo> UserInfoVec;
bool append_from_json(Poco::JSON::Object::Ptr Obj, const UserInfo &UInfo, NoteInfoVec & Notes);
// bool append_from_json(Poco::JSON::Object::Ptr Obj, const UserInfo &UInfo, NoteInfoVec & Notes);
bool MergeNotes(Poco::JSON::Object::Ptr Obj, const UserInfo &UInfo, NoteInfoVec & Notes);
bool MergeNotes(const NoteInfoVec & NewNotes, const UserInfo &UInfo, NoteInfoVec & ExistingNotes);
struct InternalServiceInfo {
std::string privateURI;

View File

@@ -1292,10 +1292,14 @@ namespace OpenWifi {
}
}
inline bool NeedAdditionalInfo() const { return QB_.AdditionalInfo; }
inline const std::string & SelectedRecords() const { return QB_.Select; }
inline const Poco::JSON::Object::Ptr & ParseStream() {
return IncomingParser_.parse(Request->stream()).extract<Poco::JSON::Object::Ptr>();
}
inline static bool ParseBindings(const std::string & Request, const std::list<const char *> & EndPoints, BindingMap &bindings) {
bindings.clear();
std::vector<std::string> PathItems = Utils::Split(Request, '/');