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, "name", Existing.info.name);
|
||||||
AssignIfPresent(RawObject, "description", Existing.info.description);
|
AssignIfPresent(RawObject, "description", Existing.info.description);
|
||||||
|
|
||||||
std::string NewPolicy;
|
std::string NewPolicy,OldPolicy = Existing.managementPolicy;
|
||||||
AssignIfPresent(RawObject, "managementPolicy", NewPolicy);
|
AssignIfPresent(RawObject, "managementPolicy", NewPolicy);
|
||||||
if(!NewPolicy.empty() && !Storage()->PolicyDB().Exists("id",NewPolicy)) {
|
if(!NewPolicy.empty() && !Storage()->PolicyDB().Exists("id",NewPolicy)) {
|
||||||
BadRequest(Request, Response, "Unknown Policy:" + NewPolicy);
|
BadRequest(Request, Response, "Unknown Policy:" + NewPolicy);
|
||||||
@@ -164,19 +164,31 @@ namespace OpenWifi{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(const auto &i:Parameters_) {
|
if(!NewPolicy.empty())
|
||||||
if(i.first=="add") {
|
Existing.managementPolicy = NewPolicy;
|
||||||
auto T = Poco::StringTokenizer(i.second,":");
|
|
||||||
if(T[0]==SecurityDBProxy()->Prefix()) {
|
|
||||||
for(const auto &i:Existing.users) {
|
|
||||||
|
|
||||||
|
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()) {
|
||||||
|
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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(i.second=="del") {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Storage()->RolesDB().GetRecord("id", UUID, Existing);
|
||||||
|
Poco::JSON::Object Answer;
|
||||||
|
Existing.to_json(Answer);
|
||||||
|
ReturnObject(Request, Answer, Response);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch(const Poco::Exception &E) {
|
} catch(const Poco::Exception &E) {
|
||||||
Logger_.log(E);
|
Logger_.log(E);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -599,6 +599,14 @@ namespace ORM {
|
|||||||
return ManipulateVectorMember(&RecordType::entities, FieldName, ParentUUID, ChildUUID, false);
|
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) {
|
inline bool AddInUse(const char *FieldName, std::string & ParentUUID, const std::string & Prefix, const std::string & ChildUUID) {
|
||||||
std::string FakeUUID{ Prefix + ":" + ChildUUID};
|
std::string FakeUUID{ Prefix + ":" + ChildUUID};
|
||||||
return ManipulateVectorMember(&RecordType::inUse,FieldName, ParentUUID, FakeUUID, true);
|
return ManipulateVectorMember(&RecordType::inUse,FieldName, ParentUUID, FakeUUID, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user