From 580daec680f7b5044b9999b5bd53d4a30e4faf88 Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Sun, 26 Sep 2021 18:44:14 -0700 Subject: [PATCH] Adding support for contacts and locations. --- Configuration application.docx | Bin 0 -> 23461 bytes build | 2 +- openapi/ow_prov.yaml | 4 +-- src/RESTAPI_ProvObjects.cpp | 8 +++--- src/RESTAPI_ProvObjects.h | 4 +-- src/RESTAPI_contact_handler.cpp | 47 ++++++++++++++++++++++++++++--- src/RESTAPI_errors.h | 1 + src/RESTAPI_location_handler.cpp | 47 ++++++++++++++++++++++++++++--- src/storage_contact.cpp | 6 ++-- src/storage_location.cpp | 6 ++-- 10 files changed, 102 insertions(+), 23 deletions(-) create mode 100644 Configuration application.docx diff --git a/Configuration application.docx b/Configuration application.docx new file mode 100644 index 0000000000000000000000000000000000000000..490e63b1a1d27e6877e7916f6919487adb674081 GIT binary patch literal 23461 zcmeFYb9X0SvpyVWVrOF8wr$(Cor&#CY}>YNV}eg?8x#NXJ$Tl6)_uQ&bM_z2>h9Hh z)m3#>?J5OnP%u;=2%sN8KtO~*9ria0O~61v{NJZ2KtDjVh3)NJOzm9sRXiO`optFv zY;6b%z(6SSfIz))jgJj8{HH3c$*9HHt-uPK8r}BBn@3)3jG2TR`os%JXnaBP%!t!XdGNjE=FE`Tw%e_>cg;{ zj+yC10-dn?c>c9IF~z8G{36QbQY#{39dr8*LEFlYr(6(92*!4x7lJmU57GD+VT+mw zjRqubjFhB}Z%q_J!?wi~ric9E78&bLjTETGyJg>K)O&T3hgW&)A`lbYv&YZfCKyMc z-<=TeA+!r1v5bs>2VCv~pE+!8WIqV!nBy;je?C|M3Jo|vrO)ffi7c8p-tqpJ7-TQ$ z=AA#gLXurImN>ils*@&p7{4EUtxKYCH@QFhoBIh01oZU<3Z(G=13O+kR_pb*2Frb8 z8Ri@8`c9@c&h&KuZ2u4B|BI3RKYqO`q2Fqd0aoBT=p$&pTXDS~qfn0Ccn*NE2Khr< zQU(REYPItD!Lzywq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mWx!9PpT!0H8bn_T0mrzul18A+O| zGrp`U3LeaVCmY*zJz}XVo(_%X0adOm{f%)+WPW-h`$KR{=rT00v3bCqyTni4kCD5_ zR(8seW;{`FEi@JgY19QA|2wu#LSXc!PEQP_$Xs$~Oe*ee)n^osSNvAQ1J7RVHPCxu z*x~ao9X@shE5O{bK}f`ahCSn4!UdsqrHB@Woj^8s3p-pqKB#%m=8CN5*swfb3eReN zMV}SGLM!O_l*dL}S(HvSiq2s>yOf*Ttm5u|PSiCYr=BUJ7{@#}GSCIM8cOTpT(WH=EiM(grfmRjiYxhS7 zxj%5S<|qd^8|M%Fk5(z=--CDuJOu^%JO#xcAw6>Z_rS`pxax&p@b6(3a+=%=eZU)O z{rL1hebVGG`4RX4W-bDfRM8sFR%nMml;+Sbe$r EALpv()Bpeg literal 0 HcmV?d00001 diff --git a/build b/build index 274ccca8..1e385284 100644 --- a/build +++ b/build @@ -1 +1 @@ -209 \ No newline at end of file +211 \ No newline at end of file diff --git a/openapi/ow_prov.yaml b/openapi/ow_prov.yaml index 0d6a7ac3..e4367239 100644 --- a/openapi/ow_prov.yaml +++ b/openapi/ow_prov.yaml @@ -358,7 +358,7 @@ components: type: string format: uuid example: each uuid is preceded by ent, or ven to say that the elemenet is entity or venue - owner: + entity: type: string format: uuid managementPolicy: @@ -421,7 +421,7 @@ components: items: type: string format: uuid - owner: + entity: type: string format: uuid managementPolicy: diff --git a/src/RESTAPI_ProvObjects.cpp b/src/RESTAPI_ProvObjects.cpp index 868aa31d..c3165f5f 100644 --- a/src/RESTAPI_ProvObjects.cpp +++ b/src/RESTAPI_ProvObjects.cpp @@ -209,7 +209,7 @@ namespace OpenWifi::ProvObjects { RESTAPI_utils::field_to_json( Obj,"mobiles",mobiles); RESTAPI_utils::field_to_json( Obj,"geoCode",geoCode); RESTAPI_utils::field_to_json( Obj,"inUse",inUse); - RESTAPI_utils::field_to_json( Obj,"owner",owner); + RESTAPI_utils::field_to_json( Obj,"entity",entity); RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy); } @@ -229,7 +229,7 @@ namespace OpenWifi::ProvObjects { RESTAPI_utils::field_from_json( Obj,"mobiles",mobiles); RESTAPI_utils::field_from_json( Obj,"geoCode",geoCode); RESTAPI_utils::field_from_json( Obj,"inUse",inUse); - RESTAPI_utils::field_from_json( Obj,"owner",owner); + RESTAPI_utils::field_from_json( Obj,"entity",entity); RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy); return true; } catch (...) { @@ -253,7 +253,7 @@ namespace OpenWifi::ProvObjects { RESTAPI_utils::field_to_json( Obj,"secondaryEmail",secondaryEmail); RESTAPI_utils::field_to_json( Obj,"accessPIN",accessPIN); RESTAPI_utils::field_to_json( Obj,"inUse",inUse); - RESTAPI_utils::field_to_json( Obj,"owner",owner); + RESTAPI_utils::field_to_json( Obj,"entity",entity); RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy); } @@ -275,7 +275,7 @@ namespace OpenWifi::ProvObjects { RESTAPI_utils::field_from_json( Obj,"secondaryEmail",secondaryEmail); RESTAPI_utils::field_from_json( Obj,"accessPIN",accessPIN); RESTAPI_utils::field_from_json( Obj,"inUse",inUse); - RESTAPI_utils::field_from_json( Obj,"owner",owner); + RESTAPI_utils::field_from_json( Obj,"entity",entity); RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy); return true; } catch (...) { diff --git a/src/RESTAPI_ProvObjects.h b/src/RESTAPI_ProvObjects.h index e88e1f3d..75db2c23 100644 --- a/src/RESTAPI_ProvObjects.h +++ b/src/RESTAPI_ProvObjects.h @@ -163,7 +163,7 @@ namespace OpenWifi::ProvObjects { Types::StringVec mobiles; std::string geoCode; Types::StringVec inUse; - Types::UUID_t owner; + Types::UUID_t entity; Types::UUID_t managementPolicy; void to_json(Poco::JSON::Object &Obj) const; @@ -226,7 +226,7 @@ namespace OpenWifi::ProvObjects { std::string secondaryEmail; std::string accessPIN; Types::StringVec inUse; - Types::UUID_t owner; + Types::UUID_t entity; Types::UUID_t managementPolicy; void to_json(Poco::JSON::Object &Obj) const; diff --git a/src/RESTAPI_contact_handler.cpp b/src/RESTAPI_contact_handler.cpp index 6881e035..e64dc9b6 100644 --- a/src/RESTAPI_contact_handler.cpp +++ b/src/RESTAPI_contact_handler.cpp @@ -91,6 +91,16 @@ namespace OpenWifi{ return; } + if(NewObject.entity.empty() || !Storage()->EntityDB().Exists("id",NewObject.entity)) { + BadRequest(RESTAPI::Errors::EntityMustExist); + return; + } + + if(!NewObject.managementPolicy.empty() && !Storage()->PolicyDB().Exists("id",NewObject.managementPolicy)) { + BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID); + return; + } + NewObject.info.id = Daemon()->CreateUUID(); NewObject.info.created = NewObject.info.modified = std::time(nullptr); NewObject.inUse.clear(); @@ -112,9 +122,9 @@ namespace OpenWifi{ return; } - auto Obj = ParseStream(); + auto RawObject = ParseStream(); ProvObjects::Contact NewObject; - if (!NewObject.from_json(Obj)) { + if (!NewObject.from_json(RawObject)) { BadRequest(RESTAPI::Errors::InvalidJSONDocument); return; } @@ -124,11 +134,40 @@ namespace OpenWifi{ Existing.info.notes.insert(Existing.info.notes.begin(),i); } - AssignIfPresent(Obj,"name",Existing.info.name); - AssignIfPresent(Obj,"description",Existing.info.description); + std::string MoveEntity, MovePolicy; + bool MovingEntity=false, MovingPolicy=false; + if(AssignIfPresent(RawObject,"managementPolicy",MovePolicy)) { + if(!MovePolicy.empty() && !Storage()->PolicyDB().Exists("id",MovePolicy)) { + BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID); + return; + } + MovingPolicy = MovePolicy != Existing.managementPolicy; + } + if(AssignIfPresent(RawObject,"entity",MoveEntity)) { + if(MoveEntity.empty() || !Storage()->PolicyDB().Exists("id",MoveEntity)) { + BadRequest(RESTAPI::Errors::EntityMustExist); + return; + } + MovingEntity = MoveEntity != Existing.entity; + } + + AssignIfPresent(RawObject,"name",Existing.info.name); + AssignIfPresent(RawObject,"description",Existing.info.description); Existing.info.modified = std::time(nullptr); if(DB_.UpdateRecord("id", UUID, Existing)) { + if(MovingPolicy) { + if(!Existing.managementPolicy.empty()) + Storage()->PolicyDB().DeleteInUse("id",Existing.managementPolicy,DB_.Prefix(),Existing.info.id); + if(!MovePolicy.empty()) + Storage()->PolicyDB().AddInUse("id", MovePolicy, DB_.Prefix(), Existing.info.id); + Existing.managementPolicy = MovePolicy; + } + if(MovingEntity) { + Existing.entity = MoveEntity; + } + DB_.UpdateRecord("id",UUID,Existing); + ProvObjects::Contact NewObjectAdded; DB_.GetRecord("id", UUID, NewObjectAdded); Poco::JSON::Object Answer; diff --git a/src/RESTAPI_errors.h b/src/RESTAPI_errors.h index 45f953bc..ee342248 100644 --- a/src/RESTAPI_errors.h +++ b/src/RESTAPI_errors.h @@ -37,6 +37,7 @@ namespace OpenWifi::RESTAPI::Errors { static const std::string LocationMustExist{"Location must exist."}; static const std::string OnlyWSSupported{"This endpoint only supports WebSocket."}; static const std::string DeviceConfigurationUUID{"Unknown DeviceConfiguration UUID."}; + static const std::string OwnerMissing{"Missing owning entity UUID."}; } diff --git a/src/RESTAPI_location_handler.cpp b/src/RESTAPI_location_handler.cpp index 27a9d9eb..175e984c 100644 --- a/src/RESTAPI_location_handler.cpp +++ b/src/RESTAPI_location_handler.cpp @@ -91,6 +91,16 @@ namespace OpenWifi{ return; } + if(NewObject.entity.empty() || !Storage()->EntityDB().Exists("id",NewObject.entity)) { + BadRequest(RESTAPI::Errors::EntityMustExist); + return; + } + + if(!NewObject.managementPolicy.empty() && !Storage()->PolicyDB().Exists("id",NewObject.managementPolicy)) { + BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID); + return; + } + NewObject.info.id = Daemon()->CreateUUID(); NewObject.info.created = NewObject.info.modified = std::time(nullptr); NewObject.inUse.clear(); @@ -112,23 +122,52 @@ namespace OpenWifi{ return; } - auto Obj = ParseStream(); + auto RawObject = ParseStream(); ProvObjects::Location NewObject; - if (!NewObject.from_json(Obj)) { + if (!NewObject.from_json(RawObject)) { BadRequest(RESTAPI::Errors::InvalidJSONDocument); return; } + std::string MoveEntity, MovePolicy; + bool MovingEntity=false, MovingPolicy=false; + if(AssignIfPresent(RawObject,"managementPolicy",MovePolicy)) { + if(!MovePolicy.empty() && !Storage()->PolicyDB().Exists("id",MovePolicy)) { + BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID); + return; + } + MovingPolicy = MovePolicy != Existing.managementPolicy; + } + if(AssignIfPresent(RawObject,"entity",MoveEntity)) { + if(MoveEntity.empty() || !Storage()->PolicyDB().Exists("id",MoveEntity)) { + BadRequest(RESTAPI::Errors::EntityMustExist); + return; + } + MovingEntity = MoveEntity != Existing.entity; + } + for(auto &i:NewObject.info.notes) { i.createdBy = UserInfo_.userinfo.email; Existing.info.notes.insert(Existing.info.notes.begin(),i); } - AssignIfPresent(Obj,"name",Existing.info.name); - AssignIfPresent(Obj,"description",Existing.info.description); + AssignIfPresent(RawObject,"name",Existing.info.name); + AssignIfPresent(RawObject,"description",Existing.info.description); Existing.info.modified = std::time(nullptr); if(DB_.UpdateRecord("id", UUID, Existing)) { + if(MovingPolicy) { + if(!Existing.managementPolicy.empty()) + Storage()->PolicyDB().DeleteInUse("id",Existing.managementPolicy,DB_.Prefix(),Existing.info.id); + if(!MovePolicy.empty()) + Storage()->PolicyDB().AddInUse("id", MovePolicy, DB_.Prefix(), Existing.info.id); + Existing.managementPolicy = MovePolicy; + } + if(MovingEntity) { + Existing.entity = MoveEntity; + } + + DB_.UpdateRecord("id",UUID,Existing); ProvObjects::Location NewObjectAdded; DB_.GetRecord("id", UUID, NewObjectAdded); Poco::JSON::Object Answer; diff --git a/src/storage_contact.cpp b/src/storage_contact.cpp index 15791039..bd8a2c76 100644 --- a/src/storage_contact.cpp +++ b/src/storage_contact.cpp @@ -38,7 +38,7 @@ namespace OpenWifi { ORM::Field{"inUse",ORM::FieldType::FT_TEXT}, ORM::Field{"tags",ORM::FieldType::FT_TEXT}, ORM::Field{"managementPolicy",ORM::FieldType::FT_TEXT}, - ORM::Field{"owner",ORM::FieldType::FT_TEXT} + ORM::Field{"entity",ORM::FieldType::FT_TEXT} }; static ORM::IndexVec ContactDB_Indexes{ @@ -75,7 +75,7 @@ template<> void ORM::DB(), Out.inUse); Out.info.tags = OpenWifi::RESTAPI_utils::to_taglist(In.get<19>()); Out.managementPolicy = In.get<20>(); - Out.owner = In.get<21>(); + Out.entity = In.get<21>(); } template<> void ORM::DB::Convert(OpenWifi::ProvObjects::Contact &In, OpenWifi::ContactDBRecordType &Out) { @@ -100,5 +100,5 @@ template<> void ORM::DB(OpenWifi::Types::to_string(In.inUse)); Out.set<19>(OpenWifi::RESTAPI_utils::to_string(In.info.tags)); Out.set<20>(In.managementPolicy); - Out.set<21>(In.owner); + Out.set<21>(In.entity); } diff --git a/src/storage_location.cpp b/src/storage_location.cpp index 1e1bbb38..f7ca8dad 100644 --- a/src/storage_location.cpp +++ b/src/storage_location.cpp @@ -36,7 +36,7 @@ namespace OpenWifi { ORM::Field{"inUse",ORM::FieldType::FT_TEXT}, ORM::Field{"tags",ORM::FieldType::FT_TEXT}, ORM::Field{"managementPolicy",ORM::FieldType::FT_TEXT}, - ORM::Field{"owner",ORM::FieldType::FT_TEXT} + ORM::Field{"entity",ORM::FieldType::FT_TEXT} }; static ORM::IndexVec LocationDB_Indexes{ @@ -71,7 +71,7 @@ template<> void ORM::DB(), Out.inUse); Out.info.tags = OpenWifi::RESTAPI_utils::to_taglist(In.get<17>()); Out.managementPolicy = In.get<18>(); - Out.owner = In.get<19>(); + Out.entity = In.get<19>(); } template<> void ORM::DB::Convert(OpenWifi::ProvObjects::Location &In, OpenWifi::LocationDBRecordType &Out) { @@ -94,5 +94,5 @@ template<> void ORM::DB(OpenWifi::Types::to_string(In.inUse)); Out.set<17>(OpenWifi::RESTAPI_utils::to_string(In.info.tags)); Out.set<18>(In.managementPolicy); - Out.set<19>(In.owner); + Out.set<19>(In.entity); }