mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-30 02:02:36 +00:00
Adding tree.
This commit is contained in:
@@ -151,7 +151,7 @@ namespace OpenWifi{
|
||||
AssignIfPresent(RawObject, "name", Existing.info.name);
|
||||
AssignIfPresent(RawObject, "description", Existing.info.description);
|
||||
|
||||
std::string NewPolicy;
|
||||
std::string NewPolicy,OldPolicy = Existing.managementPolicy;
|
||||
AssignIfPresent(RawObject, "managementPolicy", NewPolicy);
|
||||
if(!NewPolicy.empty() && !Storage()->PolicyDB().Exists("id",NewPolicy)) {
|
||||
BadRequest(Request, Response, "Unknown Policy:" + NewPolicy);
|
||||
@@ -164,19 +164,31 @@ namespace OpenWifi{
|
||||
return;
|
||||
}
|
||||
|
||||
if(!NewPolicy.empty())
|
||||
Existing.managementPolicy = NewPolicy;
|
||||
|
||||
if(Storage()->RolesDB().UpdateRecord("id",UUID,Existing)) {
|
||||
if(!OldPolicy.empty())
|
||||
Storage()->PolicyDB().DeleteInUse("id",OldPolicy,Storage()->RolesDB().Prefix(),UUID);
|
||||
for(const auto &i:Parameters_) {
|
||||
if(i.first=="add") {
|
||||
auto T = Poco::StringTokenizer(i.second,":");
|
||||
if(T[0]==SecurityDBProxy()->Prefix()) {
|
||||
for(const auto &i:Existing.users) {
|
||||
|
||||
}
|
||||
Storage()->RolesDB().AddUser("id",UUID,T[1]);
|
||||
}
|
||||
} else if(i.second=="del") {
|
||||
|
||||
auto T = Poco::StringTokenizer(i.second,":");
|
||||
if(T[0]==SecurityDBProxy()->Prefix()) {
|
||||
Storage()->RolesDB().DelUser("id",UUID,T[1]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Storage()->RolesDB().GetRecord("id", UUID, Existing);
|
||||
Poco::JSON::Object Answer;
|
||||
Existing.to_json(Answer);
|
||||
ReturnObject(Request, Answer, Response);
|
||||
return;
|
||||
}
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
}
|
||||
|
||||
@@ -599,6 +599,14 @@ namespace ORM {
|
||||
return ManipulateVectorMember(&RecordType::entities, FieldName, ParentUUID, ChildUUID, false);
|
||||
}
|
||||
|
||||
inline bool AddUser( const char *FieldName, std::string & ParentUUID, std::string & ChildUUID) {
|
||||
return ManipulateVectorMember(&RecordType::users, FieldName, ParentUUID, ChildUUID, true);
|
||||
}
|
||||
|
||||
inline bool DelUser( const char *FieldName, std::string & ParentUUID, std::string & ChildUUID) {
|
||||
return ManipulateVectorMember(&RecordType::users, FieldName, ParentUUID, ChildUUID, false);
|
||||
}
|
||||
|
||||
inline bool AddInUse(const char *FieldName, std::string & ParentUUID, const std::string & Prefix, const std::string & ChildUUID) {
|
||||
std::string FakeUUID{ Prefix + ":" + ChildUUID};
|
||||
return ManipulateVectorMember(&RecordType::inUse,FieldName, ParentUUID, FakeUUID, true);
|
||||
|
||||
Reference in New Issue
Block a user