mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-11-02 11:37:54 +00:00
Adding variableBlock support & DB refactor.
This commit is contained in:
@@ -166,6 +166,12 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
example: each uuid is preceded by ent, or ven to say that the elemenet is entity or venue
|
example: each uuid is preceded by ent, or ven to say that the elemenet is entity or venue
|
||||||
|
entity:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
venue:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
|
||||||
ManagementPolicyList:
|
ManagementPolicyList:
|
||||||
type: object
|
type: object
|
||||||
@@ -219,6 +225,36 @@ components:
|
|||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
|
managementPolicies:
|
||||||
|
description: The list of UUID of the venues for this entity
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
variables:
|
||||||
|
description: The list of UUID of the venues for this entity
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
managementRoles:
|
||||||
|
description: The list of UUID of the venues for this entity
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
maps:
|
||||||
|
description: The list of UUID of the venues for this entity
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
configurations:
|
||||||
|
description: The list of UUID of the venues for this entity
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
rrm:
|
rrm:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
@@ -297,6 +333,36 @@ components:
|
|||||||
- inherit
|
- inherit
|
||||||
sourceIP:
|
sourceIP:
|
||||||
$ref: '#/components/schemas/StringList'
|
$ref: '#/components/schemas/StringList'
|
||||||
|
managementPolicies:
|
||||||
|
description: The list of UUID of the venues for this entity
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
managementRoles:
|
||||||
|
description: The list of UUID of the venues for this entity
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
variables:
|
||||||
|
description: The list of UUID of the venues for this entity
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
maps:
|
||||||
|
description: The list of UUID of the venues for this entity
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
configurations:
|
||||||
|
description: The list of UUID of the venues for this entity
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
|
||||||
VenueList:
|
VenueList:
|
||||||
type: object
|
type: object
|
||||||
@@ -337,6 +403,12 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
example: each uuid is preceded by ent, or ven to say that the elemenet is entity or venue
|
example: each uuid is preceded by ent, or ven to say that the elemenet is entity or venue
|
||||||
|
entity:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
venue:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
|
||||||
ManagementRoleList:
|
ManagementRoleList:
|
||||||
type: object
|
type: object
|
||||||
@@ -521,6 +593,15 @@ components:
|
|||||||
example: auto or a time string of the format DOW-HH:MM
|
example: auto or a time string of the format DOW-HH:MM
|
||||||
firmwareRCOnly:
|
firmwareRCOnly:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
venue:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
entity:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
subscriber:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
|
||||||
DeviceConfigurationList:
|
DeviceConfigurationList:
|
||||||
type: object
|
type: object
|
||||||
@@ -545,6 +626,9 @@ components:
|
|||||||
entity:
|
entity:
|
||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
|
subscriber:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
qrCode:
|
qrCode:
|
||||||
type: string
|
type: string
|
||||||
geoCode:
|
geoCode:
|
||||||
@@ -701,6 +785,12 @@ components:
|
|||||||
entity:
|
entity:
|
||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
|
venue:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
managementPolicy:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
data:
|
data:
|
||||||
type: string
|
type: string
|
||||||
visibility:
|
visibility:
|
||||||
@@ -778,7 +868,9 @@ components:
|
|||||||
- integer
|
- integer
|
||||||
- string
|
- string
|
||||||
- float
|
- float
|
||||||
|
- boolean
|
||||||
- variable
|
- variable
|
||||||
|
- json
|
||||||
weight:
|
weight:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ namespace OpenWifi{
|
|||||||
|
|
||||||
DB_.DeleteRecord("id", UUID);
|
DB_.DeleteRecord("id", UUID);
|
||||||
MoveUsage(StorageService()->PolicyDB(),DB_,Existing.managementPolicy,"",Existing.info.id);
|
MoveUsage(StorageService()->PolicyDB(),DB_,Existing.managementPolicy,"",Existing.info.id);
|
||||||
|
RemoveMembership(StorageService()->VenueDB(),&ProvObjects::Venue::configurations,Existing.venue,Existing.info.id);
|
||||||
|
RemoveMembership(StorageService()->EntityDB(),&ProvObjects::Entity::configurations,Existing.entity,Existing.info.id);
|
||||||
for(const auto &i:Existing.variables)
|
for(const auto &i:Existing.variables)
|
||||||
RemoveMembership(StorageService()->VariablesDB(),&ProvObjects::VariableBlock::configurations,i,Existing.info.id);
|
RemoveMembership(StorageService()->VariablesDB(),&ProvObjects::VariableBlock::configurations,i,Existing.info.id);
|
||||||
|
|
||||||
@@ -137,35 +139,47 @@ namespace OpenWifi{
|
|||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProvObjects::DeviceConfiguration C;
|
ProvObjects::DeviceConfiguration NewObject;
|
||||||
Poco::JSON::Object::Ptr Obj = ParseStream();
|
auto RawObject = ParseStream();
|
||||||
if (!C.from_json(Obj)) {
|
if (!NewObject.from_json(RawObject)) {
|
||||||
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ProvObjects::CreateObjectInfo(Obj,UserInfo_.userinfo,C.info)) {
|
if(!ProvObjects::CreateObjectInfo(RawObject,UserInfo_.userinfo,NewObject.info)) {
|
||||||
return BadRequest(RESTAPI::Errors::NameMustBeSet);
|
return BadRequest(RESTAPI::Errors::NameMustBeSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!C.managementPolicy.empty() && !StorageService()->PolicyDB().Exists("id",C.managementPolicy)) {
|
if(!NewObject.entity.empty() && !StorageService()->EntityDB().Exists("id",NewObject.entity)) {
|
||||||
return BadRequest(RESTAPI::Errors::UnknownId);
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
}
|
}
|
||||||
|
|
||||||
C.inUse.clear();
|
if(!NewObject.venue.empty() && !StorageService()->VenueDB().Exists("id",NewObject.venue)) {
|
||||||
if(C.deviceTypes.empty() || !DeviceTypeCache()->AreAcceptableDeviceTypes(C.deviceTypes, true)) {
|
return BadRequest(RESTAPI::Errors::VenueMustExist);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!NewObject.managementPolicy.empty() && !StorageService()->PolicyDB().Exists("id",NewObject.managementPolicy)) {
|
||||||
|
return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
NewObject.inUse.clear();
|
||||||
|
if(NewObject.deviceTypes.empty() || !DeviceTypeCache()->AreAcceptableDeviceTypes(NewObject.deviceTypes, true)) {
|
||||||
return BadRequest(RESTAPI::Errors::InvalidDeviceTypes);
|
return BadRequest(RESTAPI::Errors::InvalidDeviceTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Error;
|
std::string Error;
|
||||||
if(!ValidateConfigBlock(C,Error)) {
|
if(!ValidateConfigBlock(NewObject,Error)) {
|
||||||
return BadRequest(RESTAPI::Errors::ConfigBlockInvalid + ", error: " + Error);
|
return BadRequest(RESTAPI::Errors::ConfigBlockInvalid + ", error: " + Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(DB_.CreateRecord(C)) {
|
if(DB_.CreateRecord(NewObject)) {
|
||||||
MoveUsage(StorageService()->PolicyDB(),DB_,"",C.managementPolicy,C.info.id);
|
MoveUsage(StorageService()->PolicyDB(),DB_,"",NewObject.managementPolicy,NewObject.info.id);
|
||||||
DB_.GetRecord("id", C.info.id, C);
|
AddMembership(StorageService()->VenueDB(),&ProvObjects::Venue::configurations,NewObject.venue, NewObject.info.id);
|
||||||
|
AddMembership(StorageService()->EntityDB(),&ProvObjects::Entity::configurations,NewObject.entity, NewObject.info.id);
|
||||||
|
|
||||||
|
ConfigurationDB::RecordName AddedRecord;
|
||||||
|
DB_.GetRecord("id", NewObject.info.id, AddedRecord);
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
C.to_json(Answer);
|
AddedRecord.to_json(Answer);
|
||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
}
|
}
|
||||||
InternalError(RESTAPI::Errors::RecordNotCreated);
|
InternalError(RESTAPI::Errors::RecordNotCreated);
|
||||||
@@ -179,12 +193,12 @@ namespace OpenWifi{
|
|||||||
}
|
}
|
||||||
|
|
||||||
ProvObjects::DeviceConfiguration NewConfig;
|
ProvObjects::DeviceConfiguration NewConfig;
|
||||||
auto ParsedObj = ParseStream();
|
auto RawObject = ParseStream();
|
||||||
if (!NewConfig.from_json(ParsedObj)) {
|
if (!NewConfig.from_json(RawObject)) {
|
||||||
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!UpdateObjectInfo(ParsedObj, UserInfo_.userinfo, Existing.info)) {
|
if(!UpdateObjectInfo(RawObject, UserInfo_.userinfo, Existing.info)) {
|
||||||
return BadRequest(RESTAPI::Errors::NameMustBeSet);
|
return BadRequest(RESTAPI::Errors::NameMustBeSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,20 +214,24 @@ namespace OpenWifi{
|
|||||||
return BadRequest(RESTAPI::Errors::ConfigBlockInvalid + ", error: " + Error);
|
return BadRequest(RESTAPI::Errors::ConfigBlockInvalid + ", error: " + Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ParsedObj->has("configuration")) {
|
if(RawObject->has("configuration")) {
|
||||||
Existing.configuration = NewConfig.configuration;
|
Existing.configuration = NewConfig.configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string MovePolicy, ExistingPolicy;
|
std::string FromPolicy, ToPolicy;
|
||||||
if(AssignIfPresent(ParsedObj,"managementPolicy",MovePolicy)) {
|
if(!CreateMove(RawObject,"managementPolicy",&ConfigurationDB::RecordName::managementPolicy, Existing, FromPolicy, ToPolicy, StorageService()->PolicyDB()))
|
||||||
if(!MovePolicy.empty() && !StorageService()->PolicyDB().Exists("id",NewConfig.managementPolicy)) {
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
|
|
||||||
}
|
std::string FromEntity, ToEntity;
|
||||||
ExistingPolicy = Existing.managementPolicy;
|
if(!CreateMove(RawObject,"entity",&ConfigurationDB::RecordName::entity, Existing, FromEntity, ToEntity, StorageService()->EntityDB()))
|
||||||
}
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
|
|
||||||
|
std::string FromVenue, ToVenue;
|
||||||
|
if(!CreateMove(RawObject,"venue",&ConfigurationDB::RecordName::venue, Existing, FromVenue, ToVenue, StorageService()->VenueDB()))
|
||||||
|
return BadRequest(RESTAPI::Errors::VenueMustExist);
|
||||||
|
|
||||||
Types::UUIDvec_t FromVariables, ToVariables;
|
Types::UUIDvec_t FromVariables, ToVariables;
|
||||||
if(ParsedObj->has("variables")) {
|
if(RawObject->has("variables")) {
|
||||||
for(const auto &i:NewConfig.variables) {
|
for(const auto &i:NewConfig.variables) {
|
||||||
if(!i.empty() && !StorageService()->VariablesDB().Exists("id",i)) {
|
if(!i.empty() && !StorageService()->VariablesDB().Exists("id",i)) {
|
||||||
return BadRequest(RESTAPI::Errors::VariableMustExist);
|
return BadRequest(RESTAPI::Errors::VariableMustExist);
|
||||||
@@ -228,20 +246,15 @@ namespace OpenWifi{
|
|||||||
Existing.variables = ToVariables;
|
Existing.variables = ToVariables;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(AssignIfPresent(ParsedObj,"managementPolicy",MovePolicy)) {
|
AssignIfPresent(RawObject, "rrm", Existing.rrm);
|
||||||
if(!MovePolicy.empty() && !StorageService()->PolicyDB().Exists("id",NewConfig.managementPolicy)) {
|
AssignIfPresent(RawObject, "firmwareUpgrade",Existing.firmwareUpgrade);
|
||||||
return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
|
AssignIfPresent(RawObject, "firmwareRCOnly", Existing.firmwareRCOnly);
|
||||||
}
|
|
||||||
ExistingPolicy = Existing.managementPolicy;
|
|
||||||
}
|
|
||||||
|
|
||||||
AssignIfPresent(ParsedObj, "rrm", Existing.rrm);
|
|
||||||
AssignIfPresent(ParsedObj, "firmwareUpgrade",Existing.firmwareUpgrade);
|
|
||||||
AssignIfPresent(ParsedObj, "firmwareRCOnly", Existing.firmwareRCOnly);
|
|
||||||
|
|
||||||
if(DB_.UpdateRecord("id",UUID,Existing)) {
|
if(DB_.UpdateRecord("id",UUID,Existing)) {
|
||||||
MoveUsage(StorageService()->PolicyDB(), DB_, ExistingPolicy, MovePolicy, Existing.info.id);
|
|
||||||
ManageMembership(StorageService()->VariablesDB(),&ProvObjects::VariableBlock::configurations, FromVariables, ToVariables, Existing.info.id);
|
ManageMembership(StorageService()->VariablesDB(),&ProvObjects::VariableBlock::configurations, FromVariables, ToVariables, Existing.info.id);
|
||||||
|
ManageMembership(StorageService()->VenueDB(), &ProvObjects::Venue::configurations, FromVenue, ToVenue, Existing.info.id);
|
||||||
|
ManageMembership(StorageService()->EntityDB(), &ProvObjects::Entity::configurations, FromEntity, ToEntity, Existing.info.id);
|
||||||
|
MoveUsage(StorageService()->PolicyDB(),DB_,FromPolicy,ToPolicy,Existing.info.id);
|
||||||
|
|
||||||
ProvObjects::DeviceConfiguration D;
|
ProvObjects::DeviceConfiguration D;
|
||||||
DB_.GetRecord("id",UUID,D);
|
DB_.GetRecord("id",UUID,D);
|
||||||
|
|||||||
@@ -66,13 +66,11 @@ namespace OpenWifi{
|
|||||||
return BadRequest(RESTAPI::Errors::StillInUse);
|
return BadRequest(RESTAPI::Errors::StillInUse);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(DB_.DeleteRecord("id",UUID)) {
|
DB_.DeleteRecord("id",UUID);
|
||||||
if(!Existing.entity.empty())
|
RemoveMembership(StorageService()->EntityDB(),&ProvObjects::Entity::contacts,Existing.entity,Existing.info.id);
|
||||||
StorageService()->EntityDB().DeleteLocation("id",Existing.entity,UUID);
|
MoveUsage(StorageService()->PolicyDB(),DB_,Existing.info.id,"",Existing.info.id);
|
||||||
return OK();
|
return OK();
|
||||||
}
|
}
|
||||||
InternalError(RESTAPI::Errors::CouldNotBeDeleted);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RESTAPI_contact_handler::DoPost() {
|
void RESTAPI_contact_handler::DoPost() {
|
||||||
std::string UUID = GetBinding(RESTAPI::Protocol::UUID,"");
|
std::string UUID = GetBinding(RESTAPI::Protocol::UUID,"");
|
||||||
@@ -102,10 +100,8 @@ namespace OpenWifi{
|
|||||||
NewObject.inUse.clear();
|
NewObject.inUse.clear();
|
||||||
|
|
||||||
if(DB_.CreateRecord(NewObject)) {
|
if(DB_.CreateRecord(NewObject)) {
|
||||||
|
AddMembership(StorageService()->EntityDB(),&ProvObjects::Entity::contacts,NewObject.entity,NewObject.info.id);
|
||||||
StorageService()->EntityDB().AddContact("id",NewObject.entity,NewObject.info.id);
|
MoveUsage(StorageService()->PolicyDB(),DB_,"",NewObject.managementPolicy,NewObject.info.id);
|
||||||
if(!NewObject.managementPolicy.empty())
|
|
||||||
StorageService()->PolicyDB().AddInUse("id",NewObject.managementPolicy,DB_.Prefix(),NewObject.info.id);
|
|
||||||
|
|
||||||
ProvObjects::Contact NewContact;
|
ProvObjects::Contact NewContact;
|
||||||
StorageService()->ContactDB().GetRecord("id", NewObject.info.id, NewContact);
|
StorageService()->ContactDB().GetRecord("id", NewObject.info.id, NewContact);
|
||||||
@@ -135,23 +131,13 @@ namespace OpenWifi{
|
|||||||
return BadRequest(RESTAPI::Errors::NameMustBeSet);
|
return BadRequest(RESTAPI::Errors::NameMustBeSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string MoveToPolicy, MoveFromPolicy;
|
std::string FromPolicy, ToPolicy;
|
||||||
if(AssignIfPresent(RawObject,"managementPolicy",MoveToPolicy)) {
|
if(!CreateMove(RawObject,"managementPolicy",&ContactDB::RecordName::managementPolicy, Existing, FromPolicy, ToPolicy, StorageService()->PolicyDB()))
|
||||||
if(!MoveToPolicy.empty() && !StorageService()->PolicyDB().Exists("id",MoveToPolicy)) {
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
|
|
||||||
}
|
std::string FromEntity, ToEntity;
|
||||||
MoveFromPolicy = Existing.managementPolicy;
|
if(!CreateMove(RawObject,"entity",&ContactDB::RecordName::entity, Existing, FromEntity, ToEntity, StorageService()->EntityDB()))
|
||||||
Existing.managementPolicy = MoveToPolicy;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string MoveToEntity,MoveFromEntity;
|
|
||||||
if(AssignIfPresent(RawObject,"entity",MoveToEntity)) {
|
|
||||||
if(!MoveToEntity.empty() && !StorageService()->EntityDB().Exists("id",MoveToEntity)) {
|
|
||||||
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
}
|
|
||||||
MoveFromEntity = Existing.entity;
|
|
||||||
Existing.entity = MoveToEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
AssignIfPresent(RawObject, "title", Existing.title);
|
AssignIfPresent(RawObject, "title", Existing.title);
|
||||||
AssignIfPresent(RawObject, "salutation", Existing.salutation);
|
AssignIfPresent(RawObject, "salutation", Existing.salutation);
|
||||||
@@ -170,9 +156,8 @@ namespace OpenWifi{
|
|||||||
Existing.phones = NewObject.phones;
|
Existing.phones = NewObject.phones;
|
||||||
|
|
||||||
if(DB_.UpdateRecord("id", UUID, Existing)) {
|
if(DB_.UpdateRecord("id", UUID, Existing)) {
|
||||||
|
MoveUsage(StorageService()->PolicyDB(),DB_,FromPolicy,ToPolicy,Existing.info.id);
|
||||||
MoveUsage(StorageService()->PolicyDB(),DB_,MoveFromPolicy,MoveToPolicy,Existing.info.id);
|
ManageMembership(StorageService()->EntityDB(),&ProvObjects::Entity::contacts,FromEntity,ToEntity,Existing.info.id);
|
||||||
ManageMembership(StorageService()->EntityDB(),&ProvObjects::Entity::contacts,MoveFromEntity,MoveToEntity,Existing.info.id);
|
|
||||||
|
|
||||||
ProvObjects::Contact NewObjectAdded;
|
ProvObjects::Contact NewObjectAdded;
|
||||||
DB_.GetRecord("id", UUID, NewObjectAdded);
|
DB_.GetRecord("id", UUID, NewObjectAdded);
|
||||||
|
|||||||
@@ -299,4 +299,14 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Member, typename Rec, typename DB > bool CreateMove(const Poco::JSON::Object::Ptr & RawObj, const char *fieldname, Member T, Rec & Existing, std::string &From, std::string &To, DB & TheDB) {
|
||||||
|
if(RawObj->has(fieldname)) {
|
||||||
|
From = Existing.*T;
|
||||||
|
To = RawObj->get(fieldname).toString();
|
||||||
|
if(!To.empty() && !TheDB.Exists("id",To))
|
||||||
|
return false;
|
||||||
|
Existing.*T=To;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,20 +42,15 @@ namespace OpenWifi{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( !Existing.children.empty() || !Existing.devices.empty() || !Existing.venues.empty() || !Existing.locations.empty()
|
if( !Existing.children.empty() || !Existing.devices.empty() || !Existing.venues.empty() || !Existing.locations.empty()
|
||||||
|| !Existing.contacts.empty()) {
|
|| !Existing.contacts.empty() || !Existing.configurations.empty()) {
|
||||||
return BadRequest(RESTAPI::Errors::StillInUse);
|
return BadRequest(RESTAPI::Errors::StillInUse);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Existing.deviceConfiguration.empty()) {
|
MoveUsage(StorageService()->PolicyDB(),DB_,Existing.managementPolicy,"",Existing.info.id);
|
||||||
for(auto &i:Existing.deviceConfiguration)
|
DB_.DeleteRecord("id",UUID);
|
||||||
StorageService()->ConfigurationDB().DeleteInUse("id", i, DB_.Prefix(), Existing.info.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(DB_.DeleteRecord("id",UUID)) {
|
|
||||||
DB_.DeleteChild("id",Existing.parent,UUID);
|
DB_.DeleteChild("id",Existing.parent,UUID);
|
||||||
return OK();
|
return OK();
|
||||||
}
|
|
||||||
InternalError(RESTAPI::Errors::CouldNotBeDeleted);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RESTAPI_entity_handler::DoPost() {
|
void RESTAPI_entity_handler::DoPost() {
|
||||||
@@ -144,27 +139,9 @@ namespace OpenWifi{
|
|||||||
return BadRequest(RESTAPI::Errors::NameMustBeSet);
|
return BadRequest(RESTAPI::Errors::NameMustBeSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string NewManagementPolicy;
|
std::string FromPolicy, ToPolicy;
|
||||||
Types::UUIDvec_t NewConfiguration;
|
if(!CreateMove(RawObject,"managementPolicy",&EntityDB::RecordName::managementPolicy, Existing, FromPolicy, ToPolicy, StorageService()->PolicyDB()))
|
||||||
bool MovingConfiguration=false,
|
|
||||||
MovingManagementPolicy=false;
|
|
||||||
if(RawObject->has("deviceConfiguration")) {
|
|
||||||
if(!NewEntity.deviceConfiguration.empty()) {
|
|
||||||
for(auto &i:NewEntity.deviceConfiguration) {
|
|
||||||
if(!StorageService()->ConfigurationDB().Exists("id",i)) {
|
|
||||||
return BadRequest(RESTAPI::Errors::ConfigurationMustExist);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NewConfiguration = NewEntity.deviceConfiguration;
|
|
||||||
}
|
|
||||||
MovingConfiguration = Existing.deviceConfiguration != NewConfiguration;
|
|
||||||
}
|
|
||||||
if(AssignIfPresent(RawObject,"managementPolicy",NewManagementPolicy)) {
|
|
||||||
if(!NewManagementPolicy.empty() && !StorageService()->PolicyDB().Exists("id",NewManagementPolicy)) {
|
|
||||||
return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
|
return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
|
||||||
}
|
|
||||||
MovingManagementPolicy = Existing.managementPolicy != NewManagementPolicy;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(RawObject->has("sourceIP")) {
|
if(RawObject->has("sourceIP")) {
|
||||||
if(!NewEntity.sourceIP.empty() && !CIDR::ValidateIpRanges(NewEntity.sourceIP)) {
|
if(!NewEntity.sourceIP.empty() && !CIDR::ValidateIpRanges(NewEntity.sourceIP)) {
|
||||||
@@ -181,26 +158,7 @@ namespace OpenWifi{
|
|||||||
AssignIfPresent(RawObject, "rrm", Existing.rrm);
|
AssignIfPresent(RawObject, "rrm", Existing.rrm);
|
||||||
|
|
||||||
if(DB_.UpdateRecord("id",UUID,Existing)) {
|
if(DB_.UpdateRecord("id",UUID,Existing)) {
|
||||||
|
MoveUsage(StorageService()->PolicyDB(),DB_,FromPolicy,ToPolicy,Existing.info.id);
|
||||||
if(MovingConfiguration) {
|
|
||||||
if(!Existing.deviceConfiguration.empty())
|
|
||||||
for(auto &i:Existing.deviceConfiguration)
|
|
||||||
StorageService()->ConfigurationDB().DeleteInUse("id",i,DB_.Prefix(),Existing.info.id);
|
|
||||||
if(!NewConfiguration.empty())
|
|
||||||
for(auto &i:NewConfiguration)
|
|
||||||
StorageService()->ConfigurationDB().AddInUse("id",i,DB_.Prefix(),Existing.info.id);
|
|
||||||
Existing.deviceConfiguration = NewConfiguration;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(MovingManagementPolicy) {
|
|
||||||
if(!Existing.managementPolicy.empty())
|
|
||||||
StorageService()->PolicyDB().DeleteInUse("id",Existing.managementPolicy, DB_.Prefix(), Existing.info.id);
|
|
||||||
if(!NewManagementPolicy.empty())
|
|
||||||
StorageService()->PolicyDB().AddInUse("id", NewManagementPolicy, DB_.Prefix(), Existing.info.id);
|
|
||||||
Existing.managementPolicy = NewManagementPolicy;
|
|
||||||
}
|
|
||||||
|
|
||||||
DB_.UpdateRecord("id", Existing.info.id, Existing);
|
|
||||||
|
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
ProvObjects::Entity NewRecord;
|
ProvObjects::Entity NewRecord;
|
||||||
|
|||||||
@@ -103,17 +103,11 @@ namespace OpenWifi{
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Existing.venue.empty())
|
MoveUsage(StorageService()->PolicyDB(),DB_,Existing.managementPolicy,"",Existing.info.id);
|
||||||
StorageService()->VenueDB().DeleteDevice("id",Existing.venue,Existing.info.id);
|
RemoveMembership(StorageService()->VenueDB(),&ProvObjects::Venue::configurations,Existing.venue,Existing.info.id);
|
||||||
|
RemoveMembership(StorageService()->EntityDB(),&ProvObjects::Entity::configurations,Existing.entity,Existing.info.id);
|
||||||
if(!Existing.entity.empty())
|
MoveUsage(StorageService()->LocationDB(),DB_,Existing.location,"",Existing.info.id);
|
||||||
StorageService()->EntityDB().DeleteDevice("id",Existing.entity,Existing.info.id);
|
MoveUsage(StorageService()->ContactDB(),DB_,Existing.contact,"",Existing.info.id);
|
||||||
|
|
||||||
if(!Existing.location.empty())
|
|
||||||
StorageService()->LocationDB().DeleteInUse("id",Existing.location,DB_.Prefix(),Existing.info.id);
|
|
||||||
|
|
||||||
if(!Existing.contact.empty())
|
|
||||||
StorageService()->ContactDB().DeleteInUse("id",Existing.contact,DB_.Prefix(),Existing.info.id);
|
|
||||||
|
|
||||||
if(!Existing.deviceConfiguration.empty()) {
|
if(!Existing.deviceConfiguration.empty()) {
|
||||||
ProvObjects::DeviceConfiguration DC;
|
ProvObjects::DeviceConfiguration DC;
|
||||||
@@ -126,13 +120,16 @@ namespace OpenWifi{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(DB_.DeleteRecord("id", Existing.info.id)) {
|
MoveUsage(StorageService()->PolicyDB(),DB_,Existing.managementPolicy,"",Existing.info.id);
|
||||||
DB_.DeleteRecord(RESTAPI::Protocol::ID, Existing.info.id);
|
MoveUsage(StorageService()->LocationDB(),DB_,Existing.location,"",Existing.info.id);
|
||||||
|
MoveUsage(StorageService()->ContactDB(),DB_,Existing.contact,"",Existing.info.id);
|
||||||
|
MoveUsage(StorageService()->ConfigurationDB(),DB_,Existing.deviceConfiguration,"",Existing.info.id);
|
||||||
|
ManageMembership(StorageService()->EntityDB(),&ProvObjects::Entity::devices,Existing.entity,"",Existing.info.id);
|
||||||
|
ManageMembership(StorageService()->VenueDB(),&ProvObjects::Venue::devices,Existing.venue,"",Existing.info.id);
|
||||||
|
DB_.DeleteRecord("id", Existing.info.id);
|
||||||
SerialNumberCache()->DeleteSerialNumber(SerialNumber);
|
SerialNumberCache()->DeleteSerialNumber(SerialNumber);
|
||||||
return OK();
|
return OK();
|
||||||
}
|
}
|
||||||
InternalError(RESTAPI::Errors::CouldNotBeDeleted);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RESTAPI_inventory_handler::DoPost() {
|
void RESTAPI_inventory_handler::DoPost() {
|
||||||
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER,"");
|
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER,"");
|
||||||
@@ -219,18 +216,13 @@ namespace OpenWifi{
|
|||||||
|
|
||||||
if(DB_.CreateRecord(NewObject)) {
|
if(DB_.CreateRecord(NewObject)) {
|
||||||
SerialNumberCache()->AddSerialNumber(SerialNumber,NewObject.deviceType);
|
SerialNumberCache()->AddSerialNumber(SerialNumber,NewObject.deviceType);
|
||||||
if (!NewObject.venue.empty())
|
|
||||||
StorageService()->VenueDB().AddDevice("id",NewObject.venue,NewObject.info.id);
|
MoveUsage(StorageService()->PolicyDB(),DB_,NewObject.managementPolicy,"",NewObject.info.id);
|
||||||
if (!NewObject.entity.empty())
|
MoveUsage(StorageService()->LocationDB(),DB_,NewObject.location,"",NewObject.info.id);
|
||||||
StorageService()->EntityDB().AddDevice("id",NewObject.entity,NewObject.info.id);
|
MoveUsage(StorageService()->ContactDB(),DB_,NewObject.contact,"",NewObject.info.id);
|
||||||
if (!NewObject.location.empty())
|
MoveUsage(StorageService()->ConfigurationDB(),DB_,NewObject.deviceConfiguration,"",NewObject.info.id);
|
||||||
StorageService()->LocationDB().AddInUse("id",NewObject.location,DB_.Prefix(),NewObject.info.id);
|
ManageMembership(StorageService()->EntityDB(),&ProvObjects::Entity::devices,NewObject.entity,"",NewObject.info.id);
|
||||||
if (!NewObject.contact.empty())
|
ManageMembership(StorageService()->VenueDB(),&ProvObjects::Venue::devices,NewObject.venue,"",NewObject.info.id);
|
||||||
StorageService()->ContactDB().AddInUse("id",NewObject.contact,DB_.Prefix(),NewObject.info.id);
|
|
||||||
if (!NewObject.deviceConfiguration.empty())
|
|
||||||
StorageService()->ConfigurationDB().AddInUse("id",NewObject.deviceConfiguration,DB_.Prefix(),NewObject.info.id);
|
|
||||||
if (!NewObject.managementPolicy.empty())
|
|
||||||
StorageService()->PolicyDB().AddInUse("id",NewObject.managementPolicy,DB_.Prefix(),NewObject.info.id);
|
|
||||||
|
|
||||||
ProvObjects::InventoryTag NewTag;
|
ProvObjects::InventoryTag NewTag;
|
||||||
DB_.GetRecord("id",NewObject.info.id,NewTag);
|
DB_.GetRecord("id",NewObject.info.id,NewTag);
|
||||||
@@ -409,61 +401,31 @@ namespace OpenWifi{
|
|||||||
return BadRequest(RESTAPI::Errors::NameMustBeSet);
|
return BadRequest(RESTAPI::Errors::NameMustBeSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string NewVenue, NewEntity, NewLocation, NewContact, NewConfiguration, NewPolicy;
|
|
||||||
bool MovingVenue=false,
|
|
||||||
MovingEntity=false,
|
|
||||||
MovingLocation=false,
|
|
||||||
MovingContact=false,
|
|
||||||
MovingConfiguration=false,
|
|
||||||
MovingPolicy=false;
|
|
||||||
|
|
||||||
AssignIfPresent(RawObject, "rrm",Existing.rrm);
|
AssignIfPresent(RawObject, "rrm",Existing.rrm);
|
||||||
|
|
||||||
if(AssignIfPresent(RawObject, "venue",NewVenue)) {
|
std::string FromPolicy, ToPolicy;
|
||||||
if(!NewVenue.empty() && !StorageService()->VenueDB().Exists("id",NewVenue)) {
|
if(!CreateMove(RawObject,"managementPolicy",&InventoryDB::RecordName::managementPolicy, Existing, FromPolicy, ToPolicy, StorageService()->PolicyDB()))
|
||||||
return BadRequest(RESTAPI::Errors::VenueMustExist);
|
|
||||||
}
|
|
||||||
MovingVenue = Existing.venue != NewVenue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(AssignIfPresent(RawObject, "entity",NewEntity)) {
|
|
||||||
if(!NewEntity.empty() && !StorageService()->EntityDB().Exists("id",NewEntity)) {
|
|
||||||
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
}
|
|
||||||
MovingEntity = Existing.entity != NewEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!NewEntity.empty() && !NewVenue.empty()) {
|
std::string FromEntity, ToEntity;
|
||||||
return BadRequest(RESTAPI::Errors::NotBoth);
|
if(!CreateMove(RawObject,"entity",&InventoryDB::RecordName::entity, Existing, FromEntity, ToEntity, StorageService()->EntityDB()))
|
||||||
}
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
|
|
||||||
if(AssignIfPresent(RawObject, "location",NewLocation)) {
|
std::string FromVenue, ToVenue;
|
||||||
if(!NewLocation.empty() && !StorageService()->LocationDB().Exists("id",NewLocation)) {
|
if(!CreateMove(RawObject,"venue",&InventoryDB::RecordName::venue, Existing, FromVenue, ToVenue, StorageService()->VenueDB()))
|
||||||
return BadRequest(RESTAPI::Errors::LocationMustExist);
|
return BadRequest(RESTAPI::Errors::VenueMustExist);
|
||||||
}
|
|
||||||
MovingLocation = Existing.location != NewLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(AssignIfPresent(RawObject, "contact",NewContact)) {
|
std::string FromLocation, ToLocation;
|
||||||
if(!NewContact.empty() && !StorageService()->ContactDB().Exists("id",NewContact)) {
|
if(!CreateMove(RawObject,"location",&InventoryDB::RecordName::location, Existing, FromLocation, ToLocation, StorageService()->LocationDB()))
|
||||||
return BadRequest(RESTAPI::Errors::ContactMustExist);
|
return BadRequest(RESTAPI::Errors::VenueMustExist);
|
||||||
}
|
|
||||||
MovingContact = Existing.contact != NewContact;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(AssignIfPresent(RawObject, "deviceConfiguration",NewConfiguration)) {
|
std::string FromContact, ToContact;
|
||||||
if(!NewConfiguration.empty() && !StorageService()->ConfigurationDB().Exists("id",NewConfiguration)) {
|
if(!CreateMove(RawObject,"contact",&InventoryDB::RecordName::contact, Existing, FromContact, ToContact, StorageService()->ContactDB()))
|
||||||
return BadRequest(RESTAPI::Errors::ConfigurationMustExist);
|
return BadRequest(RESTAPI::Errors::VenueMustExist);
|
||||||
}
|
|
||||||
MovingConfiguration = Existing.deviceConfiguration != NewConfiguration;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(AssignIfPresent(RawObject, "managementPolicy",NewPolicy)) {
|
std::string FromConfiguration, ToConfiguration;
|
||||||
if(!NewPolicy.empty() && !StorageService()->PolicyDB().Exists("id",NewPolicy)) {
|
if(!CreateMove(RawObject,"deviceConfiguration",&InventoryDB::RecordName::deviceConfiguration, Existing, FromConfiguration, ToConfiguration, StorageService()->ContactDB()))
|
||||||
return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
|
return BadRequest(RESTAPI::Errors::VenueMustExist);
|
||||||
}
|
|
||||||
MovingPolicy = Existing.managementPolicy != NewPolicy;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string NewSubScriber;
|
std::string NewSubScriber;
|
||||||
if(AssignIfPresent(RawObject, "subscriber", NewSubScriber)) {
|
if(AssignIfPresent(RawObject, "subscriber", NewSubScriber)) {
|
||||||
@@ -489,79 +451,13 @@ namespace OpenWifi{
|
|||||||
Existing.state = NewObject.state;
|
Existing.state = NewObject.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Arg;
|
|
||||||
bool UnAssign=false;
|
|
||||||
if(HasParameter("unassign", Arg) && Arg=="true") {
|
|
||||||
UnAssign=true;
|
|
||||||
if(!Existing.venue.empty()) {
|
|
||||||
StorageService()->VenueDB().DeleteDevice("id",Existing.venue,Existing.info.id);
|
|
||||||
} else if(!Existing.entity.empty()) {
|
|
||||||
StorageService()->EntityDB().DeleteDevice("id",Existing.entity,Existing.info.id);
|
|
||||||
}
|
|
||||||
if(!Existing.location.empty())
|
|
||||||
StorageService()->LocationDB().DeleteInUse("id",Existing.location,DB_.Prefix(),Existing.info.id);
|
|
||||||
if(!Existing.contact.empty())
|
|
||||||
StorageService()->ContactDB().DeleteInUse("id",Existing.contact,DB_.Prefix(),Existing.info.id);
|
|
||||||
if(!Existing.deviceConfiguration.empty())
|
|
||||||
StorageService()->ConfigurationDB().DeleteInUse("id",Existing.deviceConfiguration,DB_.Prefix(),Existing.info.id);
|
|
||||||
if(!Existing.managementPolicy.empty())
|
|
||||||
StorageService()->PolicyDB().DeleteInUse("id",Existing.managementPolicy,DB_.Prefix(),Existing.info.id);
|
|
||||||
Existing.venue.clear();
|
|
||||||
Existing.entity.clear();
|
|
||||||
Existing.deviceConfiguration.clear();
|
|
||||||
Existing.contact.clear();
|
|
||||||
Existing.location.clear();
|
|
||||||
Existing.managementPolicy.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << "Updating: " << Existing.info.id << " " << Existing.serialNumber << std::endl;
|
|
||||||
if(StorageService()->InventoryDB().UpdateRecord("id", Existing.info.id, Existing)) {
|
if(StorageService()->InventoryDB().UpdateRecord("id", Existing.info.id, Existing)) {
|
||||||
if(!UnAssign) {
|
MoveUsage(StorageService()->PolicyDB(),DB_,FromPolicy,ToPolicy,Existing.info.id);
|
||||||
if(MovingEntity) {
|
MoveUsage(StorageService()->LocationDB(),DB_,FromLocation,ToLocation,Existing.info.id);
|
||||||
if(!Existing.entity.empty())
|
MoveUsage(StorageService()->ContactDB(),DB_,FromContact,ToContact,Existing.info.id);
|
||||||
StorageService()->EntityDB().DeleteDevice("id",Existing.entity,Existing.info.id);
|
MoveUsage(StorageService()->ConfigurationDB(),DB_,FromConfiguration,ToConfiguration,Existing.info.id);
|
||||||
if(!NewEntity.empty())
|
ManageMembership(StorageService()->EntityDB(),&ProvObjects::Entity::devices,FromEntity,ToEntity,Existing.info.id);
|
||||||
StorageService()->EntityDB().AddDevice("id", NewEntity, Existing.info.id);
|
ManageMembership(StorageService()->VenueDB(),&ProvObjects::Venue::devices,FromVenue,ToVenue,Existing.info.id);
|
||||||
Existing.entity = NewEntity;
|
|
||||||
}
|
|
||||||
if(MovingVenue) {
|
|
||||||
if(!Existing.venue.empty())
|
|
||||||
StorageService()->VenueDB().DeleteDevice("id",Existing.venue,Existing.info.id);
|
|
||||||
if(!NewVenue.empty())
|
|
||||||
StorageService()->VenueDB().AddDevice("id", NewVenue, Existing.info.id);
|
|
||||||
Existing.venue = NewVenue;
|
|
||||||
}
|
|
||||||
if(MovingConfiguration) {
|
|
||||||
if(!Existing.deviceConfiguration.empty())
|
|
||||||
StorageService()->ConfigurationDB().DeleteInUse("id",Existing.deviceConfiguration,DB_.Prefix(),Existing.info.id);
|
|
||||||
if(!NewConfiguration.empty())
|
|
||||||
StorageService()->ConfigurationDB().AddInUse("id",NewConfiguration,DB_.Prefix(),Existing.info.id);
|
|
||||||
Existing.deviceConfiguration = NewConfiguration;
|
|
||||||
}
|
|
||||||
if(MovingContact) {
|
|
||||||
if(!Existing.contact.empty())
|
|
||||||
StorageService()->ContactDB().DeleteInUse("id",Existing.contact,DB_.Prefix(),Existing.info.id);
|
|
||||||
if(!NewContact.empty())
|
|
||||||
StorageService()->ContactDB().AddInUse("id",NewContact,DB_.Prefix(),Existing.info.id);
|
|
||||||
Existing.contact = NewContact;
|
|
||||||
}
|
|
||||||
if(MovingLocation) {
|
|
||||||
if(!Existing.location.empty())
|
|
||||||
StorageService()->LocationDB().DeleteInUse("id",Existing.location,DB_.Prefix(),Existing.info.id);
|
|
||||||
if(!NewLocation.empty())
|
|
||||||
StorageService()->LocationDB().AddInUse("id",NewLocation,DB_.Prefix(),Existing.info.id);
|
|
||||||
Existing.location = NewLocation;
|
|
||||||
}
|
|
||||||
if(MovingPolicy) {
|
|
||||||
if(!Existing.managementPolicy.empty())
|
|
||||||
StorageService()->PolicyDB().DeleteInUse("id",Existing.managementPolicy,DB_.Prefix(),Existing.info.id);
|
|
||||||
if(!NewPolicy.empty())
|
|
||||||
StorageService()->PolicyDB().AddInUse("id",NewPolicy,DB_.Prefix(),Existing.info.id);
|
|
||||||
Existing.managementPolicy = NewPolicy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DB_.UpdateRecord("id", Existing.info.id, Existing);
|
|
||||||
|
|
||||||
ProvObjects::InventoryTag NewObjectCreated;
|
ProvObjects::InventoryTag NewObjectCreated;
|
||||||
DB_.GetRecord("id", Existing.info.id, NewObjectCreated);
|
DB_.GetRecord("id", Existing.info.id, NewObjectCreated);
|
||||||
|
|||||||
@@ -65,7 +65,8 @@ namespace OpenWifi{
|
|||||||
}
|
}
|
||||||
|
|
||||||
DB_.DeleteRecord("id",UUID);
|
DB_.DeleteRecord("id",UUID);
|
||||||
ManageMembership(StorageService()->EntityDB(),&ProvObjects::Entity::locations,Existing.entity,"",Existing.info.id);
|
RemoveMembership(StorageService()->EntityDB(),&ProvObjects::Entity::locations,Existing.entity,Existing.info.id);
|
||||||
|
MoveUsage(StorageService()->PolicyDB(),DB_,Existing.info.id,"",Existing.info.id);
|
||||||
return OK();
|
return OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,11 +97,11 @@ namespace OpenWifi{
|
|||||||
NewObject.inUse.clear();
|
NewObject.inUse.clear();
|
||||||
|
|
||||||
if(DB_.CreateRecord(NewObject)) {
|
if(DB_.CreateRecord(NewObject)) {
|
||||||
if(!NewObject.managementPolicy.empty())
|
MoveUsage(StorageService()->PolicyDB(),DB_,"",NewObject.managementPolicy,NewObject.info.id);
|
||||||
StorageService()->PolicyDB().AddInUse("id",NewObject.managementPolicy,DB_.Prefix(),NewObject.info.id);
|
AddMembership(StorageService()->EntityDB(),&ProvObjects::Entity::locations,NewObject.entity,NewObject.info.id);
|
||||||
|
|
||||||
StorageService()->EntityDB().AddLocation("id",NewObject.entity,NewObject.info.id);
|
|
||||||
|
|
||||||
|
LocationDB::RecordName AddedRecord;
|
||||||
|
DB_.GetRecord("id", NewObject.info.id,AddedRecord);
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
NewObject.to_json(Answer);
|
NewObject.to_json(Answer);
|
||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
@@ -125,23 +126,13 @@ namespace OpenWifi{
|
|||||||
return BadRequest( RESTAPI::Errors::NameMustBeSet);
|
return BadRequest( RESTAPI::Errors::NameMustBeSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string MoveFromPolicy,MoveToPolicy;
|
std::string FromPolicy, ToPolicy;
|
||||||
if(AssignIfPresent(RawObject,"managementPolicy",MoveToPolicy)) {
|
if(!CreateMove(RawObject,"managementPolicy",&LocationDB::RecordName::managementPolicy, Existing, FromPolicy, ToPolicy, StorageService()->PolicyDB()))
|
||||||
if(!MoveToPolicy.empty() && !StorageService()->PolicyDB().Exists("id",MoveToPolicy)) {
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
|
|
||||||
}
|
std::string FromEntity, ToEntity;
|
||||||
MoveFromPolicy = Existing.managementPolicy;
|
if(!CreateMove(RawObject,"entity",&LocationDB::RecordName::entity, Existing, FromEntity, ToEntity, StorageService()->EntityDB()))
|
||||||
Existing.managementPolicy = MoveToPolicy;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string MoveFromEntity,MoveToEntity;
|
|
||||||
if(AssignIfPresent(RawObject,"entity",MoveToEntity)) {
|
|
||||||
if(!MoveToEntity.empty() && !StorageService()->EntityDB().Exists("id",MoveToEntity)) {
|
|
||||||
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
}
|
|
||||||
MoveFromEntity = Existing.entity;
|
|
||||||
Existing.entity = MoveToEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
AssignIfPresent(RawObject, "buildingName", Existing.buildingName);
|
AssignIfPresent(RawObject, "buildingName", Existing.buildingName);
|
||||||
AssignIfPresent(RawObject, "city", Existing.city);
|
AssignIfPresent(RawObject, "city", Existing.city);
|
||||||
@@ -160,9 +151,8 @@ namespace OpenWifi{
|
|||||||
Existing.type = NewObject.type;
|
Existing.type = NewObject.type;
|
||||||
|
|
||||||
if(DB_.UpdateRecord("id", UUID, Existing)) {
|
if(DB_.UpdateRecord("id", UUID, Existing)) {
|
||||||
|
MoveUsage(StorageService()->PolicyDB(), DB_, FromPolicy, ToPolicy, Existing.info.id);
|
||||||
MoveUsage(StorageService()->PolicyDB(), DB_, MoveFromPolicy, MoveToPolicy, Existing.info.id);
|
ManageMembership(Storage().EntityDB(),&ProvObjects::Entity::locations,FromEntity, ToEntity, Existing.info.id);
|
||||||
ManageMembership(Storage().EntityDB(),&ProvObjects::Entity::locations,MoveFromEntity, MoveToEntity, Existing.info.id);
|
|
||||||
|
|
||||||
ProvObjects::Location NewObjectAdded;
|
ProvObjects::Location NewObjectAdded;
|
||||||
DB_.GetRecord("id", UUID, NewObjectAdded);
|
DB_.GetRecord("id", UUID, NewObjectAdded);
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ namespace OpenWifi{
|
|||||||
|
|
||||||
StorageService()->PolicyDB().DeleteRecord("id", UUID);
|
StorageService()->PolicyDB().DeleteRecord("id", UUID);
|
||||||
ManageMembership(StorageService()->EntityDB(),&ProvObjects::Entity::managementPolicies,Existing.entity,"",Existing.info.id);
|
ManageMembership(StorageService()->EntityDB(),&ProvObjects::Entity::managementPolicies,Existing.entity,"",Existing.info.id);
|
||||||
|
ManageMembership(StorageService()->VenueDB(),&ProvObjects::Venue::managementPolicies,Existing.venue,"",Existing.info.id);
|
||||||
return OK();
|
return OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,26 +75,32 @@ namespace OpenWifi{
|
|||||||
return BadRequest(RESTAPI::Errors::MissingUUID);
|
return BadRequest(RESTAPI::Errors::MissingUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProvObjects::ManagementPolicy NewPolicy;
|
ProvObjects::ManagementPolicy NewObject;
|
||||||
auto NewObject = ParseStream();
|
auto RawObject = ParseStream();
|
||||||
if(!NewPolicy.from_json(NewObject)) {
|
if(!NewObject.from_json(RawObject)) {
|
||||||
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!CreateObjectInfo(NewObject, UserInfo_.userinfo, NewPolicy.info)) {
|
if(!CreateObjectInfo(RawObject, UserInfo_.userinfo, NewObject.info)) {
|
||||||
return BadRequest( RESTAPI::Errors::NameMustBeSet);
|
return BadRequest( RESTAPI::Errors::NameMustBeSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NewPolicy.entity.empty() || !StorageService()->EntityDB().Exists("id", NewPolicy.entity)) {
|
if(NewObject.entity.empty() || !StorageService()->EntityDB().Exists("id", NewObject.entity)) {
|
||||||
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
}
|
}
|
||||||
|
|
||||||
NewPolicy.inUse.clear();
|
if(NewObject.venue.empty() || !StorageService()->VenueDB().Exists("id", NewObject.venue)) {
|
||||||
if(DB_.CreateRecord(NewPolicy)) {
|
return BadRequest(RESTAPI::Errors::VenueMustExist);
|
||||||
ProvObjects::ManagementPolicy Policy;
|
}
|
||||||
DB_.GetRecord("id",NewPolicy.info.id,Policy);
|
|
||||||
|
NewObject.inUse.clear();
|
||||||
|
if(DB_.CreateRecord(NewObject)) {
|
||||||
|
AddMembership(StorageService()->EntityDB(),&ProvObjects::Entity::managementPolicies,NewObject.entity,NewObject.info.id);
|
||||||
|
AddMembership(StorageService()->VenueDB(),&ProvObjects::Venue::managementPolicies,NewObject.venue,NewObject.info.id);
|
||||||
|
PolicyDB::RecordName AddedObject;
|
||||||
|
DB_.GetRecord("id",NewObject.info.id,AddedObject);
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
Policy.to_json(Answer);
|
AddedObject.to_json(Answer);
|
||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
}
|
}
|
||||||
InternalError(RESTAPI::Errors::RecordNotCreated);
|
InternalError(RESTAPI::Errors::RecordNotCreated);
|
||||||
@@ -116,20 +123,21 @@ namespace OpenWifi{
|
|||||||
return BadRequest( RESTAPI::Errors::NameMustBeSet);
|
return BadRequest( RESTAPI::Errors::NameMustBeSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string MoveFromEntity,MoveToEntity;
|
std::string FromEntity, ToEntity;
|
||||||
if(AssignIfPresent(RawObject,"entity",MoveToEntity)) {
|
if(!CreateMove(RawObject,"entity",&PolicyDB::RecordName::entity, Existing, FromEntity, ToEntity, StorageService()->EntityDB()))
|
||||||
if(!MoveToEntity.empty() && !StorageService()->EntityDB().Exists("id",MoveToEntity)) {
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
|
|
||||||
|
std::string FromVenue, ToVenue;
|
||||||
|
if(!CreateMove(RawObject,"venue",&PolicyDB::RecordName::venue, Existing, FromVenue, ToVenue, StorageService()->VenueDB()))
|
||||||
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
}
|
|
||||||
MoveFromEntity = Existing.entity;
|
|
||||||
Existing.entity = MoveToEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!NewPolicy.entries.empty())
|
if(!NewPolicy.entries.empty())
|
||||||
Existing.entries = NewPolicy.entries;
|
Existing.entries = NewPolicy.entries;
|
||||||
|
|
||||||
if(DB_.UpdateRecord("id", Existing.info.id, Existing)) {
|
if(DB_.UpdateRecord("id", Existing.info.id, Existing)) {
|
||||||
ManageMembership(StorageService()->EntityDB(),&ProvObjects::Entity::managementPolicies, MoveFromEntity,MoveToEntity,Existing.info.id);
|
ManageMembership(StorageService()->EntityDB(),&ProvObjects::Entity::managementPolicies, FromEntity,ToEntity,Existing.info.id);
|
||||||
|
ManageMembership(StorageService()->VenueDB(),&ProvObjects::Venue::managementPolicies, FromVenue,ToVenue,Existing.info.id);
|
||||||
|
|
||||||
ProvObjects::ManagementPolicy P;
|
ProvObjects::ManagementPolicy P;
|
||||||
DB_.GetRecord("id",Existing.info.id,P);
|
DB_.GetRecord("id",Existing.info.id,P);
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ namespace OpenWifi{
|
|||||||
DB_.DeleteRecord("id", Existing.info.id);
|
DB_.DeleteRecord("id", Existing.info.id);
|
||||||
MoveUsage(StorageService()->PolicyDB(),DB_,Existing.managementPolicy,"",Existing.info.id);
|
MoveUsage(StorageService()->PolicyDB(),DB_,Existing.managementPolicy,"",Existing.info.id);
|
||||||
RemoveMembership(StorageService()->EntityDB(),&ProvObjects::Entity::managementRoles,Existing.entity,Existing.info.id);
|
RemoveMembership(StorageService()->EntityDB(),&ProvObjects::Entity::managementRoles,Existing.entity,Existing.info.id);
|
||||||
|
RemoveMembership(StorageService()->VenueDB(),&ProvObjects::Venue::managementRoles,Existing.venue,Existing.info.id);
|
||||||
return OK();
|
return OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,6 +95,7 @@ namespace OpenWifi{
|
|||||||
|
|
||||||
if(DB_.CreateRecord(NewObject)) {
|
if(DB_.CreateRecord(NewObject)) {
|
||||||
AddMembership(StorageService()->EntityDB(),&ProvObjects::Entity::managementRoles,NewObject.entity,NewObject.info.id);
|
AddMembership(StorageService()->EntityDB(),&ProvObjects::Entity::managementRoles,NewObject.entity,NewObject.info.id);
|
||||||
|
AddMembership(StorageService()->VenueDB(),&ProvObjects::Venue::managementRoles,NewObject.venue,NewObject.info.id);
|
||||||
MoveUsage(StorageService()->PolicyDB(), DB_, "", NewObject.managementPolicy, NewObject.info.id);
|
MoveUsage(StorageService()->PolicyDB(), DB_, "", NewObject.managementPolicy, NewObject.info.id);
|
||||||
|
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
@@ -122,27 +124,22 @@ namespace OpenWifi{
|
|||||||
return BadRequest( RESTAPI::Errors::NameMustBeSet);
|
return BadRequest( RESTAPI::Errors::NameMustBeSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string MoveToPolicy,MoveFromPolicy;
|
std::string FromPolicy, ToPolicy;
|
||||||
if(AssignIfPresent(RawObject,"managementPolicy",MoveToPolicy)) {
|
if(!CreateMove(RawObject,"managementPolicy",&ManagementRoleDB::RecordName::managementPolicy, Existing, FromPolicy, ToPolicy, StorageService()->PolicyDB()))
|
||||||
if(!MoveToPolicy.empty() && !StorageService()->PolicyDB().Exists("id",MoveToPolicy)) {
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
|
|
||||||
}
|
std::string FromEntity, ToEntity;
|
||||||
MoveFromPolicy = Existing.managementPolicy;
|
if(!CreateMove(RawObject,"entity",&ManagementRoleDB::RecordName::entity, Existing, FromEntity, ToEntity, StorageService()->EntityDB()))
|
||||||
Existing.managementPolicy = MoveToPolicy;
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
}
|
|
||||||
|
std::string FromVenue, ToVenue;
|
||||||
std::string MoveToEntity,MoveFromEntity;
|
if(!CreateMove(RawObject,"venue",&ManagementRoleDB::RecordName::venue, Existing, FromVenue, ToVenue, StorageService()->VenueDB()))
|
||||||
if(AssignIfPresent(RawObject,"entity",MoveToEntity)) {
|
|
||||||
if(!MoveToEntity.empty() && !StorageService()->EntityDB().Exists("id",MoveToEntity)) {
|
|
||||||
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
}
|
|
||||||
MoveFromEntity = Existing.entity;
|
|
||||||
Existing.entity = MoveToEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(DB_.UpdateRecord("id",UUID,Existing)) {
|
if(DB_.UpdateRecord("id",UUID,Existing)) {
|
||||||
MoveUsage(StorageService()->PolicyDB(),DB_,MoveFromPolicy, MoveToPolicy, Existing.info.id);
|
MoveUsage(StorageService()->PolicyDB(),DB_, FromPolicy, ToPolicy, Existing.info.id);
|
||||||
ManageMembership(StorageService()->EntityDB(),&ProvObjects::Entity::managementRoles, MoveFromEntity, MoveToEntity, Existing.info.id);
|
ManageMembership(StorageService()->EntityDB(),&ProvObjects::Entity::managementRoles, FromEntity, ToEntity, Existing.info.id);
|
||||||
|
ManageMembership(StorageService()->VenueDB(),&ProvObjects::Venue::managementRoles, FromVenue, ToVenue, Existing.info.id);
|
||||||
|
|
||||||
ProvObjects::ManagementRole NewRecord;
|
ProvObjects::ManagementRole NewRecord;
|
||||||
|
|
||||||
|
|||||||
@@ -38,11 +38,12 @@ namespace OpenWifi{
|
|||||||
return UnAuthorized("You must be the creator of the map to delete it");
|
return UnAuthorized("You must be the creator of the map to delete it");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(DB_.DeleteRecord("id", Existing.info.id)) {
|
DB_.DeleteRecord("id", Existing.info.id);
|
||||||
|
MoveUsage(StorageService()->PolicyDB(),DB_,Existing.managementPolicy,"",Existing.info.id);
|
||||||
|
RemoveMembership(StorageService()->EntityDB(),&ProvObjects::Entity::maps,Existing.entity,Existing.info.id);
|
||||||
|
RemoveMembership(StorageService()->VenueDB(),&ProvObjects::Venue::maps,Existing.venue,Existing.info.id);
|
||||||
return OK();
|
return OK();
|
||||||
}
|
}
|
||||||
InternalError(RESTAPI::Errors::CouldNotBeDeleted);
|
|
||||||
}
|
|
||||||
|
|
||||||
static auto ValidateVisibility(const std::string &V) {
|
static auto ValidateVisibility(const std::string &V) {
|
||||||
return (V=="private" || V=="public" || V=="select");
|
return (V=="private" || V=="public" || V=="select");
|
||||||
@@ -54,20 +55,32 @@ namespace OpenWifi{
|
|||||||
return BadRequest(RESTAPI::Errors::MissingUUID);
|
return BadRequest(RESTAPI::Errors::MissingUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Obj = ParseStream();
|
auto RawObject = ParseStream();
|
||||||
ProvObjects::Map NewObject;
|
ProvObjects::Map NewObject;
|
||||||
if (!NewObject.from_json(Obj)) {
|
if (!NewObject.from_json(RawObject)) {
|
||||||
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!CreateObjectInfo(Obj, UserInfo_.userinfo, NewObject.info)) {
|
if(!CreateObjectInfo(RawObject, UserInfo_.userinfo, NewObject.info)) {
|
||||||
return BadRequest( RESTAPI::Errors::NameMustBeSet);
|
return BadRequest( RESTAPI::Errors::NameMustBeSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(RawObject->has("entity")) {
|
||||||
|
if(!NewObject.entity.empty() && !StorageService()->EntityDB().Exists("id",NewObject.entity))
|
||||||
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(RawObject->has("managementPolicy")) {
|
||||||
|
if(!NewObject.managementPolicy.empty() && !StorageService()->PolicyDB().Exists("id",NewObject.managementPolicy))
|
||||||
|
return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
|
||||||
|
}
|
||||||
|
|
||||||
NewObject.creator = UserInfo_.userinfo.id;
|
NewObject.creator = UserInfo_.userinfo.id;
|
||||||
|
|
||||||
if(DB_.CreateRecord(NewObject)) {
|
if(DB_.CreateRecord(NewObject)) {
|
||||||
|
AddMembership(StorageService()->EntityDB(),&ProvObjects::Entity::maps,NewObject.entity,NewObject.info.id);
|
||||||
|
AddMembership(StorageService()->VenueDB(),&ProvObjects::Venue::maps,NewObject.venue,NewObject.info.id);
|
||||||
|
MoveUsage(StorageService()->PolicyDB(),DB_,"",NewObject.managementPolicy,NewObject.info.id);
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
ProvObjects::Map M;
|
ProvObjects::Map M;
|
||||||
DB_.GetRecord("id", NewObject.info.id,M);
|
DB_.GetRecord("id", NewObject.info.id,M);
|
||||||
@@ -108,19 +121,28 @@ namespace OpenWifi{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(RawObject->has("entity") && !StorageService()->EntityDB().Exists("id",NewObject.entity)) {
|
std::string FromPolicy, ToPolicy;
|
||||||
|
if(!CreateMove(RawObject,"managementPolicy",&MapDB::RecordName::managementPolicy, Existing, FromPolicy, ToPolicy, StorageService()->PolicyDB()))
|
||||||
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
}
|
|
||||||
|
|
||||||
AssignIfPresent(RawObject,"entity",Existing.entity);
|
std::string FromEntity, ToEntity;
|
||||||
|
if(!CreateMove(RawObject,"entity",&MapDB::RecordName::entity, Existing, FromEntity, ToEntity, StorageService()->EntityDB()))
|
||||||
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
|
|
||||||
|
std::string FromVenue, ToVenue;
|
||||||
|
if(!CreateMove(RawObject,"venue",&MapDB::RecordName::venue, Existing, FromVenue, ToVenue, StorageService()->VenueDB()))
|
||||||
|
return BadRequest(RESTAPI::Errors::VenueMustExist);
|
||||||
|
|
||||||
AssignIfPresent(RawObject,"data", Existing.data);
|
AssignIfPresent(RawObject,"data", Existing.data);
|
||||||
if(RawObject->has("visibility"))
|
if(RawObject->has("visibility"))
|
||||||
Existing.visibility = NewObject.visibility;
|
Existing.visibility = NewObject.visibility;
|
||||||
|
|
||||||
if(DB_.UpdateRecord("id",UUID,Existing)) {
|
if(DB_.UpdateRecord("id",UUID,Existing)) {
|
||||||
|
MoveUsage(StorageService()->PolicyDB(),DB_,FromPolicy,ToPolicy,Existing.info.id);
|
||||||
|
ManageMembership(StorageService()->EntityDB(),&ProvObjects::Entity::maps,FromEntity,ToEntity,Existing.info.id);
|
||||||
|
ManageMembership(StorageService()->VenueDB(),&ProvObjects::Venue::maps,FromVenue,ToVenue,Existing.info.id);
|
||||||
|
|
||||||
ProvObjects::Map NewRecord;
|
ProvObjects::Map NewRecord;
|
||||||
|
|
||||||
DB_.GetRecord("id", UUID, NewRecord);
|
DB_.GetRecord("id", UUID, NewRecord);
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
NewRecord.to_json(Answer);
|
NewRecord.to_json(Answer);
|
||||||
|
|||||||
@@ -39,10 +39,11 @@ namespace OpenWifi {
|
|||||||
if(!Existing.configurations.empty()) {
|
if(!Existing.configurations.empty()) {
|
||||||
return BadRequest(RESTAPI::Errors::StillInUse);
|
return BadRequest(RESTAPI::Errors::StillInUse);
|
||||||
}
|
}
|
||||||
|
MoveUsage(StorageService()->PolicyDB(),DB_,Existing.managementPolicy,"",Existing.info.id);
|
||||||
RemoveMembership(StorageService()->VenueDB(),&ProvObjects::Venue::variables,Existing.venue,Existing.info.id);
|
RemoveMembership(StorageService()->VenueDB(),&ProvObjects::Venue::variables,Existing.venue,Existing.info.id);
|
||||||
RemoveMembership(StorageService()->EntityDB(),&ProvObjects::Entity::variables,Existing.entity,Existing.info.id);
|
RemoveMembership(StorageService()->EntityDB(),&ProvObjects::Entity::variables,Existing.entity,Existing.info.id);
|
||||||
|
|
||||||
DB_.DeleteRecord("id", UUID);
|
DB_.DeleteRecord("id", UUID);
|
||||||
|
|
||||||
return OK();
|
return OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,29 +54,34 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto RawObj = ParseStream();
|
auto RawObj = ParseStream();
|
||||||
VariablesDB::RecordName NewObj;
|
VariablesDB::RecordName NewObject;
|
||||||
if(!NewObj.from_json(RawObj)) {
|
if(!NewObject.from_json(RawObj)) {
|
||||||
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!NewObj.entity.empty() && !StorageService()->EntityDB().Exists("id",NewObj.entity)) {
|
if(!NewObject.entity.empty() && !StorageService()->EntityDB().Exists("id",NewObject.entity)) {
|
||||||
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!NewObj.venue.empty() && !StorageService()->VenueDB().Exists("id",NewObj.venue)) {
|
if(!NewObject.venue.empty() && !StorageService()->VenueDB().Exists("id",NewObject.venue)) {
|
||||||
return BadRequest(RESTAPI::Errors::VenueMustExist);
|
return BadRequest(RESTAPI::Errors::VenueMustExist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ProvObjects::CreateObjectInfo(RawObj,UserInfo_.userinfo,NewObj.info)) {
|
if(!NewObject.managementPolicy.empty() && !StorageService()->PolicyDB().Exists("id",NewObject.managementPolicy)) {
|
||||||
|
return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!ProvObjects::CreateObjectInfo(RawObj,UserInfo_.userinfo,NewObject.info)) {
|
||||||
return BadRequest((RESTAPI::Errors::MissingOrInvalidParameters));
|
return BadRequest((RESTAPI::Errors::MissingOrInvalidParameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(DB_.CreateRecord(NewObj)) {
|
if(DB_.CreateRecord(NewObject)) {
|
||||||
AddMembership(StorageService()->VenueDB(),&ProvObjects::Venue::variables,NewObj.venue, NewObj.info.id);
|
MoveUsage(StorageService()->PolicyDB(),DB_,"",NewObject.managementPolicy,NewObject.info.id);
|
||||||
AddMembership(StorageService()->EntityDB(),&ProvObjects::Entity::variables,NewObj.entity, NewObj.info.id);
|
AddMembership(StorageService()->VenueDB(),&ProvObjects::Venue::variables,NewObject.venue, NewObject.info.id);
|
||||||
|
AddMembership(StorageService()->EntityDB(),&ProvObjects::Entity::variables,NewObject.entity, NewObject.info.id);
|
||||||
|
|
||||||
VariablesDB::RecordName Added;
|
VariablesDB::RecordName Added;
|
||||||
StorageService()->VariablesDB().GetRecord("id",NewObj.info.id,Added);
|
DB_.GetRecord("id",NewObject.info.id,Added);
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
Added.to_json(Answer);
|
Added.to_json(Answer);
|
||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
@@ -94,47 +100,38 @@ namespace OpenWifi {
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto RawObj = ParseStream();
|
auto RawObject = ParseStream();
|
||||||
VariablesDB::RecordName NewObj;
|
VariablesDB::RecordName NewObj;
|
||||||
if(!NewObj.from_json(RawObj)) {
|
if(!NewObj.from_json(RawObject)) {
|
||||||
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ProvObjects::UpdateObjectInfo(RawObj,UserInfo_.userinfo,Existing.info)) {
|
if(!ProvObjects::UpdateObjectInfo(RawObject,UserInfo_.userinfo,Existing.info)) {
|
||||||
return BadRequest((RESTAPI::Errors::MissingOrInvalidParameters));
|
return BadRequest((RESTAPI::Errors::MissingOrInvalidParameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(RawObj->has("variables"))
|
if(RawObject->has("variables"))
|
||||||
Existing.variables = NewObj.variables;
|
Existing.variables = NewObj.variables;
|
||||||
|
|
||||||
std::string ExistingEntity, MovingToEntity;
|
std::string FromPolicy, ToPolicy;
|
||||||
if(RawObj->has("entity")) {
|
if(!CreateMove(RawObject,"managementPolicy",&VariablesDB::RecordName::managementPolicy, Existing, FromPolicy, ToPolicy, StorageService()->PolicyDB()))
|
||||||
ExistingEntity = Existing.entity;
|
|
||||||
MovingToEntity = RawObj->get("entity").toString();
|
|
||||||
if(!MovingToEntity.empty() && !StorageService()->EntityDB().Exists("id",MovingToEntity)) {
|
|
||||||
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
}
|
|
||||||
Existing.entity = MovingToEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ExistingVenue, MovingToVenue;
|
std::string FromEntity, ToEntity;
|
||||||
if(RawObj->has("venue")) {
|
if(!CreateMove(RawObject,"entity",&VariablesDB::RecordName::entity, Existing, FromEntity, ToEntity, StorageService()->EntityDB()))
|
||||||
ExistingVenue = Existing.venue;
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
MovingToVenue = RawObj->get("venue").toString();
|
|
||||||
if(!MovingToVenue.empty() && !StorageService()->VenueDB().Exists("id",MovingToVenue)) {
|
std::string FromVenue, ToVenue;
|
||||||
|
if(!CreateMove(RawObject,"venue",&VariablesDB::RecordName::venue, Existing, FromVenue, ToVenue, StorageService()->VenueDB()))
|
||||||
return BadRequest(RESTAPI::Errors::VenueMustExist);
|
return BadRequest(RESTAPI::Errors::VenueMustExist);
|
||||||
}
|
|
||||||
Existing.venue = MovingToVenue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(DB_.UpdateRecord("id", UUID, Existing)) {
|
if(DB_.UpdateRecord("id", UUID, Existing)) {
|
||||||
ManageMembership(StorageService()->VenueDB(), &ProvObjects::Venue::variables, ExistingVenue,
|
MoveUsage(StorageService()->PolicyDB(),DB_,FromPolicy,ToPolicy,Existing.info.id);
|
||||||
MovingToVenue, Existing.info.id);
|
ManageMembership(StorageService()->VenueDB(), &ProvObjects::Venue::variables, FromVenue, ToVenue, Existing.info.id);
|
||||||
ManageMembership(StorageService()->EntityDB(), &ProvObjects::Entity::variables, ExistingEntity,
|
ManageMembership(StorageService()->EntityDB(), &ProvObjects::Entity::variables, FromEntity, ToEntity, Existing.info.id);
|
||||||
MovingToEntity, Existing.info.id);
|
|
||||||
|
|
||||||
VariablesDB::RecordName Added;
|
VariablesDB::RecordName Added;
|
||||||
StorageService()->VariablesDB().GetRecord("id",NewObj.info.id,Added);
|
DB_.GetRecord("id",NewObj.info.id,Added);
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
Added.to_json(Answer);
|
Added.to_json(Answer);
|
||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
|
|||||||
@@ -95,6 +95,9 @@ namespace OpenWifi::ProvObjects {
|
|||||||
field_to_json( Obj,"sourceIP",sourceIP);
|
field_to_json( Obj,"sourceIP",sourceIP);
|
||||||
field_to_json( Obj,"variables", variables);
|
field_to_json( Obj,"variables", variables);
|
||||||
field_to_json( Obj,"managementPolicies", managementPolicies);
|
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) {
|
bool Entity::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
@@ -112,6 +115,9 @@ namespace OpenWifi::ProvObjects {
|
|||||||
field_from_json( Obj,"sourceIP",sourceIP);
|
field_from_json( Obj,"sourceIP",sourceIP);
|
||||||
field_from_json( Obj,"variables", variables);
|
field_from_json( Obj,"variables", variables);
|
||||||
field_from_json( Obj,"managementPolicies", managementPolicies);
|
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;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -151,6 +157,10 @@ namespace OpenWifi::ProvObjects {
|
|||||||
field_to_json( Obj,"rrm",rrm);
|
field_to_json( Obj,"rrm",rrm);
|
||||||
field_to_json( Obj,"sourceIP",sourceIP);
|
field_to_json( Obj,"sourceIP",sourceIP);
|
||||||
field_to_json( Obj,"variables", variables);
|
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) {
|
bool Venue::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
@@ -170,6 +180,10 @@ namespace OpenWifi::ProvObjects {
|
|||||||
field_from_json( Obj,"rrm",rrm);
|
field_from_json( Obj,"rrm",rrm);
|
||||||
field_from_json( Obj,"sourceIP",sourceIP);
|
field_from_json( Obj,"sourceIP",sourceIP);
|
||||||
field_from_json( Obj,"variables", variables);
|
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;
|
return true;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
||||||
@@ -199,6 +213,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
field_to_json( Obj,"managementPolicy",managementPolicy);
|
field_to_json( Obj,"managementPolicy",managementPolicy);
|
||||||
field_to_json( Obj,"users",users);
|
field_to_json( Obj,"users",users);
|
||||||
field_to_json( Obj,"entity",entity);
|
field_to_json( Obj,"entity",entity);
|
||||||
|
field_to_json( Obj,"venue",venue);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ManagementRole::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool ManagementRole::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
@@ -207,6 +222,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
field_from_json( Obj,"managementPolicy",managementPolicy);
|
field_from_json( Obj,"managementPolicy",managementPolicy);
|
||||||
field_from_json( Obj,"users",users);
|
field_from_json( Obj,"users",users);
|
||||||
field_from_json( Obj,"entity",entity);
|
field_from_json( Obj,"entity",entity);
|
||||||
|
field_from_json( Obj,"venue",venue);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
}
|
}
|
||||||
@@ -411,6 +427,9 @@ namespace OpenWifi::ProvObjects {
|
|||||||
field_to_json( Obj,"firmwareUpgrade",firmwareUpgrade);
|
field_to_json( Obj,"firmwareUpgrade",firmwareUpgrade);
|
||||||
field_to_json( Obj,"firmwareRCOnly",firmwareRCOnly);
|
field_to_json( Obj,"firmwareRCOnly",firmwareRCOnly);
|
||||||
field_to_json( Obj,"subscriberOnly",subscriberOnly);
|
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) {
|
bool DeviceConfiguration::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
@@ -425,6 +444,9 @@ namespace OpenWifi::ProvObjects {
|
|||||||
field_from_json( Obj,"firmwareUpgrade",firmwareUpgrade);
|
field_from_json( Obj,"firmwareUpgrade",firmwareUpgrade);
|
||||||
field_from_json( Obj,"firmwareRCOnly",firmwareRCOnly);
|
field_from_json( Obj,"firmwareRCOnly",firmwareRCOnly);
|
||||||
field_from_json( Obj,"subscriberOnly",subscriberOnly);
|
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;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -603,6 +625,8 @@ namespace OpenWifi::ProvObjects {
|
|||||||
RESTAPI_utils::field_to_json( Obj,"creator",creator);
|
RESTAPI_utils::field_to_json( Obj,"creator",creator);
|
||||||
field_to_json( Obj,"visibility",visibility);
|
field_to_json( Obj,"visibility",visibility);
|
||||||
RESTAPI_utils::field_to_json( Obj,"access",access);
|
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) {
|
bool Map::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
@@ -613,6 +637,8 @@ namespace OpenWifi::ProvObjects {
|
|||||||
RESTAPI_utils::field_from_json( Obj,"creator",creator);
|
RESTAPI_utils::field_from_json( Obj,"creator",creator);
|
||||||
field_from_json( Obj,"visibility",visibility);
|
field_from_json( Obj,"visibility",visibility);
|
||||||
RESTAPI_utils::field_from_json( Obj,"access",access);
|
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;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -706,6 +732,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
RESTAPI_utils::field_to_json( Obj,"subscriber", subscriber);
|
RESTAPI_utils::field_to_json( Obj,"subscriber", subscriber);
|
||||||
RESTAPI_utils::field_to_json( Obj,"inventory", inventory);
|
RESTAPI_utils::field_to_json( Obj,"inventory", inventory);
|
||||||
RESTAPI_utils::field_to_json( Obj,"configurations", configurations);
|
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) {
|
bool VariableBlock::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
@@ -717,6 +744,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
RESTAPI_utils::field_from_json( Obj,"subscriber", subscriber);
|
RESTAPI_utils::field_from_json( Obj,"subscriber", subscriber);
|
||||||
RESTAPI_utils::field_from_json( Obj,"inventory", inventory);
|
RESTAPI_utils::field_from_json( Obj,"inventory", inventory);
|
||||||
RESTAPI_utils::field_from_json( Obj,"configurations", configurations);
|
RESTAPI_utils::field_from_json( Obj,"configurations", configurations);
|
||||||
|
RESTAPI_utils::field_from_json( Obj,"managementPolicy", managementPolicy);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
std::vector<ManagementPolicyEntry> entries;
|
std::vector<ManagementPolicyEntry> entries;
|
||||||
Types::StringVec inUse;
|
Types::StringVec inUse;
|
||||||
Types::UUID_t entity;
|
Types::UUID_t entity;
|
||||||
|
Types::UUID_t venue;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
@@ -69,6 +70,8 @@ namespace OpenWifi::ProvObjects {
|
|||||||
Types::UUIDvec_t variables;
|
Types::UUIDvec_t variables;
|
||||||
Types::UUIDvec_t managementPolicies;
|
Types::UUIDvec_t managementPolicies;
|
||||||
Types::UUIDvec_t managementRoles;
|
Types::UUIDvec_t managementRoles;
|
||||||
|
Types::UUIDvec_t maps;
|
||||||
|
Types::UUIDvec_t configurations;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
@@ -100,6 +103,10 @@ namespace OpenWifi::ProvObjects {
|
|||||||
std::string rrm;
|
std::string rrm;
|
||||||
Types::StringVec sourceIP;
|
Types::StringVec sourceIP;
|
||||||
Types::UUIDvec_t variables;
|
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;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
@@ -121,6 +128,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
Types::UUIDvec_t users;
|
Types::UUIDvec_t users;
|
||||||
Types::StringVec inUse;
|
Types::StringVec inUse;
|
||||||
Types::UUID_t entity;
|
Types::UUID_t entity;
|
||||||
|
Types::UUID_t venue;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
@@ -269,6 +277,9 @@ namespace OpenWifi::ProvObjects {
|
|||||||
std::string firmwareUpgrade;
|
std::string firmwareUpgrade;
|
||||||
bool firmwareRCOnly=false;
|
bool firmwareRCOnly=false;
|
||||||
bool subscriberOnly=false;
|
bool subscriberOnly=false;
|
||||||
|
std::string venue;
|
||||||
|
std::string entity;
|
||||||
|
std::string subscriber;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
@@ -389,6 +400,8 @@ namespace OpenWifi::ProvObjects {
|
|||||||
std::string creator;
|
std::string creator;
|
||||||
VISIBILITY visibility = PRIVATE;
|
VISIBILITY visibility = PRIVATE;
|
||||||
ObjectACLList access;
|
ObjectACLList access;
|
||||||
|
Types::UUID_t managementPolicy;
|
||||||
|
std::string venue;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
@@ -451,6 +464,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
std::string subscriber;
|
std::string subscriber;
|
||||||
std::string inventory;
|
std::string inventory;
|
||||||
Types::UUIDvec_t configurations;
|
Types::UUIDvec_t configurations;
|
||||||
|
Types::UUID_t managementPolicy;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
|
|||||||
@@ -32,7 +32,10 @@ namespace OpenWifi {
|
|||||||
ORM::Field{"tags",ORM::FieldType::FT_TEXT},
|
ORM::Field{"tags",ORM::FieldType::FT_TEXT},
|
||||||
ORM::Field{"firmwareUpgrade",ORM::FieldType::FT_TEXT},
|
ORM::Field{"firmwareUpgrade",ORM::FieldType::FT_TEXT},
|
||||||
ORM::Field{"firmwareRCOnly",ORM::FieldType::FT_INT},
|
ORM::Field{"firmwareRCOnly",ORM::FieldType::FT_INT},
|
||||||
ORM::Field{"subscriberOnly",ORM::FieldType::FT_BOOLEAN}
|
ORM::Field{"subscriberOnly",ORM::FieldType::FT_BOOLEAN},
|
||||||
|
ORM::Field{"entity",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"venue",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"subscriber",ORM::FieldType::FT_TEXT}
|
||||||
};
|
};
|
||||||
|
|
||||||
static ORM::IndexVec ConfigurationDB_Indexes{
|
static ORM::IndexVec ConfigurationDB_Indexes{
|
||||||
@@ -44,7 +47,10 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
bool ConfigurationDB::Upgrade(uint32_t from, uint32_t &to) {
|
bool ConfigurationDB::Upgrade(uint32_t from, uint32_t &to) {
|
||||||
std::vector<std::string> Statements{
|
std::vector<std::string> Statements{
|
||||||
"alter table " + TableName_ + " add column subscriberOnly BOOLEAN;"
|
"alter table " + TableName_ + " add column subscriberOnly BOOLEAN;",
|
||||||
|
"alter table " + TableName_ + " add column entity TEXT;",
|
||||||
|
"alter table " + TableName_ + " add column subscriber TEXT;",
|
||||||
|
"alter table " + TableName_ + " add column venue TEXT;"
|
||||||
};
|
};
|
||||||
RunScript(Statements);
|
RunScript(Statements);
|
||||||
to = 2;
|
to = 2;
|
||||||
@@ -148,6 +154,9 @@ template<> void ORM::DB< OpenWifi::ConfigurationDBRecordType, OpenWifi::ProvO
|
|||||||
Out.firmwareUpgrade = In.get<13>();
|
Out.firmwareUpgrade = In.get<13>();
|
||||||
Out.firmwareRCOnly = In.get<14>();
|
Out.firmwareRCOnly = In.get<14>();
|
||||||
Out.subscriberOnly = In.get<15>();
|
Out.subscriberOnly = In.get<15>();
|
||||||
|
Out.entity = In.get<16>();
|
||||||
|
Out.venue = In.get<17>();
|
||||||
|
Out.subscriber = In.get<18>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void ORM::DB< OpenWifi::ConfigurationDBRecordType, OpenWifi::ProvObjects::DeviceConfiguration>::Convert(const OpenWifi::ProvObjects::DeviceConfiguration &In, OpenWifi::ConfigurationDBRecordType &Out) {
|
template<> void ORM::DB< OpenWifi::ConfigurationDBRecordType, OpenWifi::ProvObjects::DeviceConfiguration>::Convert(const OpenWifi::ProvObjects::DeviceConfiguration &In, OpenWifi::ConfigurationDBRecordType &Out) {
|
||||||
@@ -167,4 +176,7 @@ template<> void ORM::DB< OpenWifi::ConfigurationDBRecordType, OpenWifi::ProvO
|
|||||||
Out.set<13>(In.firmwareUpgrade);
|
Out.set<13>(In.firmwareUpgrade);
|
||||||
Out.set<14>(In.firmwareRCOnly);
|
Out.set<14>(In.firmwareRCOnly);
|
||||||
Out.set<15>(In.subscriberOnly);
|
Out.set<15>(In.subscriberOnly);
|
||||||
|
Out.set<16>(In.entity);
|
||||||
|
Out.set<17>(In.venue);
|
||||||
|
Out.set<18>(In.subscriber);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,10 @@ namespace OpenWifi {
|
|||||||
std::string,
|
std::string,
|
||||||
std::string,
|
std::string,
|
||||||
uint32_t,
|
uint32_t,
|
||||||
bool
|
bool,
|
||||||
|
std::string,
|
||||||
|
std::string,
|
||||||
|
std::string
|
||||||
> ConfigurationDBRecordType;
|
> ConfigurationDBRecordType;
|
||||||
|
|
||||||
class ConfigurationDB : public ORM::DB<ConfigurationDBRecordType, ProvObjects::DeviceConfiguration> {
|
class ConfigurationDB : public ORM::DB<ConfigurationDBRecordType, ProvObjects::DeviceConfiguration> {
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ namespace OpenWifi {
|
|||||||
ORM::Field{"sourceIP",ORM::FieldType::FT_TEXT},
|
ORM::Field{"sourceIP",ORM::FieldType::FT_TEXT},
|
||||||
ORM::Field{"variables",ORM::FieldType::FT_TEXT},
|
ORM::Field{"variables",ORM::FieldType::FT_TEXT},
|
||||||
ORM::Field{"managementPolicies",ORM::FieldType::FT_TEXT},
|
ORM::Field{"managementPolicies",ORM::FieldType::FT_TEXT},
|
||||||
ORM::Field{"managementRoles",ORM::FieldType::FT_TEXT}
|
ORM::Field{"managementRoles",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"maps",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"configurations",ORM::FieldType::FT_TEXT}
|
||||||
};
|
};
|
||||||
|
|
||||||
static ORM::IndexVec EntityDB_Indexes{
|
static ORM::IndexVec EntityDB_Indexes{
|
||||||
@@ -58,6 +60,8 @@ namespace OpenWifi {
|
|||||||
std::vector<std::string> Script{
|
std::vector<std::string> Script{
|
||||||
"alter table " + TableName_ + " add column variables text",
|
"alter table " + TableName_ + " add column variables text",
|
||||||
"alter table " + TableName_ + " add column managementPolicies text",
|
"alter table " + TableName_ + " add column managementPolicies text",
|
||||||
|
"alter table " + TableName_ + " add column maps text",
|
||||||
|
"alter table " + TableName_ + " add column configurations text",
|
||||||
"alter table " + TableName_ + " add column managementRoles text"
|
"alter table " + TableName_ + " add column managementRoles text"
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -245,6 +249,8 @@ template<> void ORM::DB< OpenWifi::EntityDBRecordType, OpenWifi::ProvObjects:
|
|||||||
Out.variables = OpenWifi::RESTAPI_utils::to_object_array(In.get<17>());
|
Out.variables = OpenWifi::RESTAPI_utils::to_object_array(In.get<17>());
|
||||||
Out.managementPolicies = OpenWifi::RESTAPI_utils::to_object_array(In.get<18>());
|
Out.managementPolicies = OpenWifi::RESTAPI_utils::to_object_array(In.get<18>());
|
||||||
Out.managementRoles = OpenWifi::RESTAPI_utils::to_object_array(In.get<19>());
|
Out.managementRoles = OpenWifi::RESTAPI_utils::to_object_array(In.get<19>());
|
||||||
|
Out.maps = OpenWifi::RESTAPI_utils::to_object_array(In.get<20>());
|
||||||
|
Out.configurations = OpenWifi::RESTAPI_utils::to_object_array(In.get<21>());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void ORM::DB< OpenWifi::EntityDBRecordType, OpenWifi::ProvObjects::Entity>::Convert(const OpenWifi::ProvObjects::Entity &In, OpenWifi::EntityDBRecordType &Out) {
|
template<> void ORM::DB< OpenWifi::EntityDBRecordType, OpenWifi::ProvObjects::Entity>::Convert(const OpenWifi::ProvObjects::Entity &In, OpenWifi::EntityDBRecordType &Out) {
|
||||||
@@ -268,4 +274,6 @@ template<> void ORM::DB< OpenWifi::EntityDBRecordType, OpenWifi::ProvObjects:
|
|||||||
Out.set<17>(OpenWifi::RESTAPI_utils::to_string(In.variables));
|
Out.set<17>(OpenWifi::RESTAPI_utils::to_string(In.variables));
|
||||||
Out.set<18>(OpenWifi::RESTAPI_utils::to_string(In.managementPolicies));
|
Out.set<18>(OpenWifi::RESTAPI_utils::to_string(In.managementPolicies));
|
||||||
Out.set<19>(OpenWifi::RESTAPI_utils::to_string(In.managementRoles));
|
Out.set<19>(OpenWifi::RESTAPI_utils::to_string(In.managementRoles));
|
||||||
|
Out.set<20>(OpenWifi::RESTAPI_utils::to_string(In.maps));
|
||||||
|
Out.set<21>(OpenWifi::RESTAPI_utils::to_string(In.configurations));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ namespace OpenWifi {
|
|||||||
std::string,
|
std::string,
|
||||||
std::string,
|
std::string,
|
||||||
std::string,
|
std::string,
|
||||||
|
std::string,
|
||||||
|
std::string,
|
||||||
std::string
|
std::string
|
||||||
> EntityDBRecordType;
|
> EntityDBRecordType;
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ namespace OpenWifi {
|
|||||||
ORM::Field{"inUse",ORM::FieldType::FT_TEXT},
|
ORM::Field{"inUse",ORM::FieldType::FT_TEXT},
|
||||||
ORM::Field{"tags",ORM::FieldType::FT_TEXT},
|
ORM::Field{"tags",ORM::FieldType::FT_TEXT},
|
||||||
ORM::Field{"entity",ORM::FieldType::FT_TEXT},
|
ORM::Field{"entity",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"venue",ORM::FieldType::FT_TEXT}
|
||||||
};
|
};
|
||||||
|
|
||||||
static ORM::IndexVec RolesDB_Indexes{
|
static ORM::IndexVec RolesDB_Indexes{
|
||||||
@@ -39,6 +40,16 @@ namespace OpenWifi {
|
|||||||
ManagementRoleDB::ManagementRoleDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) :
|
ManagementRoleDB::ManagementRoleDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) :
|
||||||
DB(T, "roles", RolesDB_Fields, RolesDB_Indexes, P, L, "rol") {}
|
DB(T, "roles", RolesDB_Fields, RolesDB_Indexes, P, L, "rol") {}
|
||||||
|
|
||||||
|
bool ManagementRoleDB::Upgrade(uint32_t from, uint32_t &to) {
|
||||||
|
std::vector<std::string> Statements{
|
||||||
|
"alter table " + TableName_ + " add column entity text;",
|
||||||
|
"alter table " + TableName_ + " add column venue text;"
|
||||||
|
};
|
||||||
|
RunScript(Statements);
|
||||||
|
to = 2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void ORM::DB< OpenWifi::ManagementRoleDBRecordType, OpenWifi::ProvObjects::ManagementRole>::Convert(const OpenWifi::ManagementRoleDBRecordType &In, OpenWifi::ProvObjects::ManagementRole &Out) {
|
template<> void ORM::DB< OpenWifi::ManagementRoleDBRecordType, OpenWifi::ProvObjects::ManagementRole>::Convert(const OpenWifi::ManagementRoleDBRecordType &In, OpenWifi::ProvObjects::ManagementRole &Out) {
|
||||||
@@ -53,6 +64,7 @@ template<> void ORM::DB< OpenWifi::ManagementRoleDBRecordType, OpenWifi::Prov
|
|||||||
Out.inUse = OpenWifi::RESTAPI_utils::to_object_array(In.get<8>());
|
Out.inUse = OpenWifi::RESTAPI_utils::to_object_array(In.get<8>());
|
||||||
Out.info.tags = OpenWifi::RESTAPI_utils::to_taglist(In.get<9>());
|
Out.info.tags = OpenWifi::RESTAPI_utils::to_taglist(In.get<9>());
|
||||||
Out.entity = In.get<10>();
|
Out.entity = In.get<10>();
|
||||||
|
Out.venue = In.get<11>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void ORM::DB< OpenWifi::ManagementRoleDBRecordType, OpenWifi::ProvObjects::ManagementRole>::Convert(const OpenWifi::ProvObjects::ManagementRole &In, OpenWifi::ManagementRoleDBRecordType &Out) {
|
template<> void ORM::DB< OpenWifi::ManagementRoleDBRecordType, OpenWifi::ProvObjects::ManagementRole>::Convert(const OpenWifi::ProvObjects::ManagementRole &In, OpenWifi::ManagementRoleDBRecordType &Out) {
|
||||||
@@ -67,4 +79,5 @@ template<> void ORM::DB< OpenWifi::ManagementRoleDBRecordType, OpenWifi::Prov
|
|||||||
Out.set<8>(OpenWifi::RESTAPI_utils::to_string(In.inUse));
|
Out.set<8>(OpenWifi::RESTAPI_utils::to_string(In.inUse));
|
||||||
Out.set<9>(OpenWifi::RESTAPI_utils::to_string(In.info.tags));
|
Out.set<9>(OpenWifi::RESTAPI_utils::to_string(In.info.tags));
|
||||||
Out.set<10>(In.entity);
|
Out.set<10>(In.entity);
|
||||||
|
Out.set<11>(In.venue);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ namespace OpenWifi {
|
|||||||
std::string,
|
std::string,
|
||||||
std::string,
|
std::string,
|
||||||
std::string,
|
std::string,
|
||||||
|
std::string,
|
||||||
std::string
|
std::string
|
||||||
> ManagementRoleDBRecordType;
|
> ManagementRoleDBRecordType;
|
||||||
|
|
||||||
@@ -30,5 +31,6 @@ namespace OpenWifi {
|
|||||||
public:
|
public:
|
||||||
ManagementRoleDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
|
ManagementRoleDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
|
||||||
private:
|
private:
|
||||||
|
bool Upgrade(uint32_t from, uint32_t &to) override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ namespace OpenWifi {
|
|||||||
ORM::Field{"creator",ORM::FieldType::FT_TEXT},
|
ORM::Field{"creator",ORM::FieldType::FT_TEXT},
|
||||||
ORM::Field{"visibility",ORM::FieldType::FT_TEXT},
|
ORM::Field{"visibility",ORM::FieldType::FT_TEXT},
|
||||||
ORM::Field{"access",ORM::FieldType::FT_TEXT},
|
ORM::Field{"access",ORM::FieldType::FT_TEXT},
|
||||||
ORM::Field{"entity",ORM::FieldType::FT_TEXT}
|
ORM::Field{"entity",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"managementPolicy",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"venue",ORM::FieldType::FT_TEXT}
|
||||||
};
|
};
|
||||||
|
|
||||||
static ORM::IndexVec MapsDB_Indexes{
|
static ORM::IndexVec MapsDB_Indexes{
|
||||||
@@ -32,6 +34,17 @@ namespace OpenWifi {
|
|||||||
MapDB::MapDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) :
|
MapDB::MapDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) :
|
||||||
DB(T, "maps", MapsDB_Fields, MapsDB_Indexes, P, L, "map") {}
|
DB(T, "maps", MapsDB_Fields, MapsDB_Indexes, P, L, "map") {}
|
||||||
|
|
||||||
|
bool MapDB::Upgrade(uint32_t from, uint32_t &to) {
|
||||||
|
std::vector<std::string> Statements{
|
||||||
|
"alter table " + TableName_ + " add column managementPolicy text;",
|
||||||
|
"alter table " + TableName_ + " add column entity text;",
|
||||||
|
"alter table " + TableName_ + " add column venue text;"
|
||||||
|
};
|
||||||
|
RunScript(Statements);
|
||||||
|
to = 2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void ORM::DB< OpenWifi::MapDBRecordType, OpenWifi::ProvObjects::Map>::Convert(const OpenWifi::MapDBRecordType &In, OpenWifi::ProvObjects::Map &Out) {
|
template<> void ORM::DB< OpenWifi::MapDBRecordType, OpenWifi::ProvObjects::Map>::Convert(const OpenWifi::MapDBRecordType &In, OpenWifi::ProvObjects::Map &Out) {
|
||||||
@@ -47,6 +60,8 @@ template<> void ORM::DB< OpenWifi::MapDBRecordType, OpenWifi::ProvObjects::Ma
|
|||||||
Out.visibility = OpenWifi::ProvObjects::visibility_from_string(In.get<9>());
|
Out.visibility = OpenWifi::ProvObjects::visibility_from_string(In.get<9>());
|
||||||
Out.access = OpenWifi::RESTAPI_utils::to_object<OpenWifi::ProvObjects::ObjectACLList>(In.get<10>());
|
Out.access = OpenWifi::RESTAPI_utils::to_object<OpenWifi::ProvObjects::ObjectACLList>(In.get<10>());
|
||||||
Out.entity = In.get<11>();
|
Out.entity = In.get<11>();
|
||||||
|
Out.managementPolicy = In.get<12>();
|
||||||
|
Out.venue = In.get<13>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void ORM::DB< OpenWifi::MapDBRecordType, OpenWifi::ProvObjects::Map>::Convert(const OpenWifi::ProvObjects::Map &In, OpenWifi::MapDBRecordType &Out) {
|
template<> void ORM::DB< OpenWifi::MapDBRecordType, OpenWifi::ProvObjects::Map>::Convert(const OpenWifi::ProvObjects::Map &In, OpenWifi::MapDBRecordType &Out) {
|
||||||
@@ -62,4 +77,6 @@ template<> void ORM::DB< OpenWifi::MapDBRecordType, OpenWifi::ProvObjects::Ma
|
|||||||
Out.set<9>(OpenWifi::ProvObjects::to_string(In.visibility));
|
Out.set<9>(OpenWifi::ProvObjects::to_string(In.visibility));
|
||||||
Out.set<10>(OpenWifi::RESTAPI_utils::to_string(In.access));
|
Out.set<10>(OpenWifi::RESTAPI_utils::to_string(In.access));
|
||||||
Out.set<11>(In.entity);
|
Out.set<11>(In.entity);
|
||||||
|
Out.set<12>(In.managementPolicy);
|
||||||
|
Out.set<13>(In.venue);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ namespace OpenWifi {
|
|||||||
std::string,
|
std::string,
|
||||||
std::string,
|
std::string,
|
||||||
std::string,
|
std::string,
|
||||||
|
std::string,
|
||||||
|
std::string,
|
||||||
std::string
|
std::string
|
||||||
> MapDBRecordType;
|
> MapDBRecordType;
|
||||||
|
|
||||||
@@ -27,5 +29,6 @@ namespace OpenWifi {
|
|||||||
public:
|
public:
|
||||||
MapDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
|
MapDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
|
||||||
private:
|
private:
|
||||||
|
bool Upgrade(uint32_t from, uint32_t &to) override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ namespace OpenWifi {
|
|||||||
ORM::Field{"entries",ORM::FieldType::FT_TEXT},
|
ORM::Field{"entries",ORM::FieldType::FT_TEXT},
|
||||||
ORM::Field{"inUse",ORM::FieldType::FT_TEXT},
|
ORM::Field{"inUse",ORM::FieldType::FT_TEXT},
|
||||||
ORM::Field{"tags",ORM::FieldType::FT_TEXT},
|
ORM::Field{"tags",ORM::FieldType::FT_TEXT},
|
||||||
ORM::Field{"entity",ORM::FieldType::FT_TEXT}
|
ORM::Field{"entity",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"venue",ORM::FieldType::FT_TEXT}
|
||||||
};
|
};
|
||||||
|
|
||||||
static ORM::IndexVec PolicyDB_Indexes{
|
static ORM::IndexVec PolicyDB_Indexes{
|
||||||
@@ -38,6 +38,16 @@ namespace OpenWifi {
|
|||||||
PolicyDB::PolicyDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) :
|
PolicyDB::PolicyDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) :
|
||||||
DB(T, "policies", PolicyDB_Fields, PolicyDB_Indexes, P, L, "pol") {}
|
DB(T, "policies", PolicyDB_Fields, PolicyDB_Indexes, P, L, "pol") {}
|
||||||
|
|
||||||
|
bool PolicyDB::Upgrade(uint32_t from, uint32_t &to) {
|
||||||
|
std::vector<std::string> Statements{
|
||||||
|
"alter table " + TableName_ + " add column entity text;",
|
||||||
|
"alter table " + TableName_ + " add column venue text;"
|
||||||
|
};
|
||||||
|
RunScript(Statements);
|
||||||
|
to = 2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void ORM::DB< OpenWifi::PolicyDBRecordType, OpenWifi::ProvObjects::ManagementPolicy>::Convert(const OpenWifi::PolicyDBRecordType &In, OpenWifi::ProvObjects::ManagementPolicy &Out) {
|
template<> void ORM::DB< OpenWifi::PolicyDBRecordType, OpenWifi::ProvObjects::ManagementPolicy>::Convert(const OpenWifi::PolicyDBRecordType &In, OpenWifi::ProvObjects::ManagementPolicy &Out) {
|
||||||
@@ -51,6 +61,7 @@ template<> void ORM::DB< OpenWifi::PolicyDBRecordType, OpenWifi::ProvObjects:
|
|||||||
Out.inUse = OpenWifi::RESTAPI_utils::to_object_array(In.get<7>());
|
Out.inUse = OpenWifi::RESTAPI_utils::to_object_array(In.get<7>());
|
||||||
Out.info.tags = OpenWifi::RESTAPI_utils::to_taglist(In.get<8>());
|
Out.info.tags = OpenWifi::RESTAPI_utils::to_taglist(In.get<8>());
|
||||||
Out.entity = In.get<9>();
|
Out.entity = In.get<9>();
|
||||||
|
Out.venue = In.get<10>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void ORM::DB< OpenWifi::PolicyDBRecordType, OpenWifi::ProvObjects::ManagementPolicy>::Convert(const OpenWifi::ProvObjects::ManagementPolicy &In, OpenWifi::PolicyDBRecordType &Out) {
|
template<> void ORM::DB< OpenWifi::PolicyDBRecordType, OpenWifi::ProvObjects::ManagementPolicy>::Convert(const OpenWifi::ProvObjects::ManagementPolicy &In, OpenWifi::PolicyDBRecordType &Out) {
|
||||||
@@ -64,4 +75,5 @@ template<> void ORM::DB< OpenWifi::PolicyDBRecordType, OpenWifi::ProvObjects:
|
|||||||
Out.set<7>(OpenWifi::RESTAPI_utils::to_string(In.inUse));
|
Out.set<7>(OpenWifi::RESTAPI_utils::to_string(In.inUse));
|
||||||
Out.set<8>(OpenWifi::RESTAPI_utils::to_string(In.info.tags));
|
Out.set<8>(OpenWifi::RESTAPI_utils::to_string(In.info.tags));
|
||||||
Out.set<9>(In.entity);
|
Out.set<9>(In.entity);
|
||||||
|
Out.set<10>(In.venue);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ namespace OpenWifi {
|
|||||||
std::string,
|
std::string,
|
||||||
std::string,
|
std::string,
|
||||||
std::string,
|
std::string,
|
||||||
|
std::string,
|
||||||
std::string
|
std::string
|
||||||
> PolicyDBRecordType;
|
> PolicyDBRecordType;
|
||||||
|
|
||||||
@@ -29,5 +30,6 @@ namespace OpenWifi {
|
|||||||
public:
|
public:
|
||||||
PolicyDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
|
PolicyDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
|
||||||
private:
|
private:
|
||||||
|
bool Upgrade(uint32_t from, uint32_t &to) override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ namespace OpenWifi {
|
|||||||
ORM::Field{"venue",ORM::FieldType::FT_TEXT},
|
ORM::Field{"venue",ORM::FieldType::FT_TEXT},
|
||||||
ORM::Field{"subscriber",ORM::FieldType::FT_BIGINT},
|
ORM::Field{"subscriber",ORM::FieldType::FT_BIGINT},
|
||||||
ORM::Field{"inventory",ORM::FieldType::FT_BIGINT},
|
ORM::Field{"inventory",ORM::FieldType::FT_BIGINT},
|
||||||
ORM::Field{"configurations",ORM::FieldType::FT_TEXT}
|
ORM::Field{"configurations",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"managementPolicy",ORM::FieldType::FT_TEXT}
|
||||||
};
|
};
|
||||||
|
|
||||||
const static ORM::IndexVec VariablesDB_Indexes{
|
const static ORM::IndexVec VariablesDB_Indexes{
|
||||||
@@ -41,6 +42,14 @@ namespace OpenWifi {
|
|||||||
DB(T, "variables", VariablesDB_Fields, VariablesDB_Indexes, P, L, "var") {
|
DB(T, "variables", VariablesDB_Fields, VariablesDB_Indexes, P, L, "var") {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VariablesDB::Upgrade(uint32_t from, uint32_t &to) {
|
||||||
|
std::vector<std::string> Statements{
|
||||||
|
"alter table " + TableName_ + " add column managementPolicy BOOLEAN;"
|
||||||
|
};
|
||||||
|
RunScript(Statements);
|
||||||
|
to = 2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void ORM::DB<OpenWifi::VariablesDBRecordType, OpenWifi::ProvObjects::VariableBlock>::Convert(const OpenWifi::VariablesDBRecordType &In, OpenWifi::ProvObjects::VariableBlock &Out) {
|
template<> void ORM::DB<OpenWifi::VariablesDBRecordType, OpenWifi::ProvObjects::VariableBlock>::Convert(const OpenWifi::VariablesDBRecordType &In, OpenWifi::ProvObjects::VariableBlock &Out) {
|
||||||
@@ -56,6 +65,7 @@ template<> void ORM::DB<OpenWifi::VariablesDBRecordType, OpenWifi::ProvObjects::
|
|||||||
Out.subscriber = In.get<9>();
|
Out.subscriber = In.get<9>();
|
||||||
Out.inventory = In.get<10>();
|
Out.inventory = In.get<10>();
|
||||||
Out.configurations = OpenWifi::RESTAPI_utils::to_object_array(In.get<11>());
|
Out.configurations = OpenWifi::RESTAPI_utils::to_object_array(In.get<11>());
|
||||||
|
Out.managementPolicy = In.get<12>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void ORM::DB<OpenWifi::VariablesDBRecordType, OpenWifi::ProvObjects::VariableBlock>::Convert(const OpenWifi::ProvObjects::VariableBlock &In, OpenWifi::VariablesDBRecordType &Out) {
|
template<> void ORM::DB<OpenWifi::VariablesDBRecordType, OpenWifi::ProvObjects::VariableBlock>::Convert(const OpenWifi::ProvObjects::VariableBlock &In, OpenWifi::VariablesDBRecordType &Out) {
|
||||||
@@ -71,4 +81,5 @@ template<> void ORM::DB<OpenWifi::VariablesDBRecordType, OpenWifi::ProvObjects::
|
|||||||
Out.set<9>(In.subscriber);
|
Out.set<9>(In.subscriber);
|
||||||
Out.set<10>(In.inventory);
|
Out.set<10>(In.inventory);
|
||||||
Out.set<11>(OpenWifi::RESTAPI_utils::to_string(In.configurations));
|
Out.set<11>(OpenWifi::RESTAPI_utils::to_string(In.configurations));
|
||||||
|
Out.set<12>(In.managementPolicy);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ namespace OpenWifi {
|
|||||||
std::string,
|
std::string,
|
||||||
std::string,
|
std::string,
|
||||||
std::string,
|
std::string,
|
||||||
|
std::string,
|
||||||
std::string
|
std::string
|
||||||
> VariablesDBRecordType;
|
> VariablesDBRecordType;
|
||||||
|
|
||||||
@@ -27,5 +28,6 @@ namespace OpenWifi {
|
|||||||
public:
|
public:
|
||||||
explicit VariablesDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) noexcept;
|
explicit VariablesDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) noexcept;
|
||||||
private:
|
private:
|
||||||
|
bool Upgrade(uint32_t from, uint32_t &to) override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,11 @@ namespace OpenWifi {
|
|||||||
ORM::Field{"tags",ORM::FieldType::FT_TEXT},
|
ORM::Field{"tags",ORM::FieldType::FT_TEXT},
|
||||||
ORM::Field{"deviceConfiguration",ORM::FieldType::FT_TEXT},
|
ORM::Field{"deviceConfiguration",ORM::FieldType::FT_TEXT},
|
||||||
ORM::Field{"sourceIP",ORM::FieldType::FT_TEXT},
|
ORM::Field{"sourceIP",ORM::FieldType::FT_TEXT},
|
||||||
ORM::Field{"variables",ORM::FieldType::FT_TEXT}
|
ORM::Field{"variables",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"configurations",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"maps",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"managementPolicies",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"managementRoles",ORM::FieldType::FT_TEXT}
|
||||||
};
|
};
|
||||||
|
|
||||||
static ORM::IndexVec VenueDB_Indexes{
|
static ORM::IndexVec VenueDB_Indexes{
|
||||||
@@ -53,7 +57,11 @@ namespace OpenWifi {
|
|||||||
bool VenueDB::Upgrade(uint32_t from, uint32_t &to) {
|
bool VenueDB::Upgrade(uint32_t from, uint32_t &to) {
|
||||||
to = Version();
|
to = Version();
|
||||||
std::vector<std::string> Script{
|
std::vector<std::string> Script{
|
||||||
"alter table " + TableName_ + " add column variables text"
|
"alter table " + TableName_ + " add column variables text",
|
||||||
|
"alter table " + TableName_ + " add column configurations text",
|
||||||
|
"alter table " + TableName_ + " add column maps text",
|
||||||
|
"alter table " + TableName_ + " add column managementRoles text",
|
||||||
|
"alter table " + TableName_ + " add column managementPolicies text"
|
||||||
};
|
};
|
||||||
|
|
||||||
for(const auto &i:Script) {
|
for(const auto &i:Script) {
|
||||||
@@ -134,6 +142,10 @@ template<> void ORM::DB< OpenWifi::VenueDBRecordType, OpenWifi::ProvObjects::
|
|||||||
Out.deviceConfiguration = OpenWifi::RESTAPI_utils::to_object_array(In.get<17>());
|
Out.deviceConfiguration = OpenWifi::RESTAPI_utils::to_object_array(In.get<17>());
|
||||||
Out.sourceIP = OpenWifi::RESTAPI_utils::to_object_array(In.get<18>());
|
Out.sourceIP = OpenWifi::RESTAPI_utils::to_object_array(In.get<18>());
|
||||||
Out.variables = OpenWifi::RESTAPI_utils::to_object_array(In.get<19>());
|
Out.variables = OpenWifi::RESTAPI_utils::to_object_array(In.get<19>());
|
||||||
|
Out.configurations = OpenWifi::RESTAPI_utils::to_object_array(In.get<20>());
|
||||||
|
Out.maps = OpenWifi::RESTAPI_utils::to_object_array(In.get<21>());
|
||||||
|
Out.managementPolicies = OpenWifi::RESTAPI_utils::to_object_array(In.get<22>());
|
||||||
|
Out.managementRoles = OpenWifi::RESTAPI_utils::to_object_array(In.get<23>());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void ORM::DB< OpenWifi::VenueDBRecordType, OpenWifi::ProvObjects::Venue>::Convert(const OpenWifi::ProvObjects::Venue &In, OpenWifi::VenueDBRecordType &Out) {
|
template<> void ORM::DB< OpenWifi::VenueDBRecordType, OpenWifi::ProvObjects::Venue>::Convert(const OpenWifi::ProvObjects::Venue &In, OpenWifi::VenueDBRecordType &Out) {
|
||||||
@@ -157,4 +169,8 @@ template<> void ORM::DB< OpenWifi::VenueDBRecordType, OpenWifi::ProvObjects::
|
|||||||
Out.set<17>(OpenWifi::RESTAPI_utils::to_string(In.deviceConfiguration));
|
Out.set<17>(OpenWifi::RESTAPI_utils::to_string(In.deviceConfiguration));
|
||||||
Out.set<18>(OpenWifi::RESTAPI_utils::to_string(In.sourceIP));
|
Out.set<18>(OpenWifi::RESTAPI_utils::to_string(In.sourceIP));
|
||||||
Out.set<19>(OpenWifi::RESTAPI_utils::to_string(In.variables));
|
Out.set<19>(OpenWifi::RESTAPI_utils::to_string(In.variables));
|
||||||
|
Out.set<20>(OpenWifi::RESTAPI_utils::to_string(In.configurations));
|
||||||
|
Out.set<21>(OpenWifi::RESTAPI_utils::to_string(In.maps));
|
||||||
|
Out.set<22>(OpenWifi::RESTAPI_utils::to_string(In.managementPolicies));
|
||||||
|
Out.set<23>(OpenWifi::RESTAPI_utils::to_string(In.managementRoles));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ namespace OpenWifi {
|
|||||||
std::string,
|
std::string,
|
||||||
std::string,
|
std::string,
|
||||||
std::string,
|
std::string,
|
||||||
|
std::string,
|
||||||
|
std::string,
|
||||||
|
std::string,
|
||||||
|
std::string,
|
||||||
std::string
|
std::string
|
||||||
> VenueDBRecordType;
|
> VenueDBRecordType;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user