Initial checkins

This commit is contained in:
stephb9959
2021-08-21 11:37:20 -07:00
parent 2559a79c3b
commit a63a70dd21
64 changed files with 573 additions and 400 deletions

View File

@@ -72,7 +72,7 @@ add_executable(owprov
src/storage_pgql.cpp src/storage_mysql.cpp src/storage_sqlite.cpp
src/storage_entity.cpp src/storage_entity.h
src/storage_policies.cpp src/storage_policies.h
src/uCentralTypes.h
src/OpenWifiTypes.h
src/storage_venue.cpp src/storage_venue.h
src/storage_location.cpp src/storage_location.h
src/storage_contact.cpp src/storage_contact.h

View File

@@ -4,11 +4,33 @@
It's UUID value is 0000-0000-0000. Its parent entity must be empty.
## Entity
You must set the parent of an entity.
### Creation rules
- You must set the parent of an entity.
- The only properties you may set at creation are:
- name
- description
- notes
- parent
### Modification rules
You may modify the following fields in the POST
- name
- description
- notes
You must use the query command parameters to modify other properties
- addContact=UUID
- delContact=UUID
- addLocation=UUID
- delLocation=UUID
## Inventory Tags
### Creation rules
- Entity must point to an existing non-root entity
- If you associate a venue, it must exist
### Modification rules
## Venue
When creating a venue, the top venue must have its entity property set to the owning entity, and its parent property empty.
For all sub venues, their entity must be set to empty and its parent entity must be set to the venue above it.
## Management policy

2
build
View File

@@ -1 +1 @@
20
23

View File

@@ -20,7 +20,7 @@
#include "Daemon.h"
#include "SubSystemServer.h"
namespace uCentral {
namespace OpenWifi {
class ALBRequestHandler: public Poco::Net::HTTPRequestHandler
/// Return a HTML document with the current date and time.

View File

@@ -8,7 +8,7 @@
#include "Daemon.h"
#include "OpenAPIRequest.h"
namespace uCentral {
namespace OpenWifi {
class AuthClient * AuthClient::instance_ = nullptr;
int AuthClient::Start() {
@@ -38,7 +38,7 @@ namespace uCentral {
} else {
Types::StringPairVec QueryData;
QueryData.push_back(std::make_pair("token",SessionToken));
OpenAPIRequestGet Req(uSERVICE_SECURITY,
OpenAPIRequestGet Req( uSERVICE_SECURITY,
"/api/v1/validateToken",
QueryData,
5000);
@@ -56,4 +56,33 @@ namespace uCentral {
}
return false;
}
bool AuthClient::IsTokenAuthorized(const std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo) {
SubMutexGuard G(Mutex_);
auto User = UserCache_.find(SessionToken);
if(User != UserCache_.end() && !IsTokenExpired(User->second.webtoken)) {
UInfo = User->second;
return true;
} else {
Types::StringPairVec QueryData;
QueryData.push_back(std::make_pair("token",SessionToken));
OpenAPIRequestGet Req(uSERVICE_SECURITY,
"/api/v1/validateToken",
QueryData,
5000);
Poco::JSON::Object::Ptr Response;
if(Req.Do(Response)==Poco::Net::HTTPResponse::HTTP_OK) {
if(Response->has("tokenInfo") && Response->has("userInfo")) {
SecurityObjects::UserInfoAndPolicy P;
P.from_json(Response);
UserCache_[SessionToken] = P;
UInfo = P;
}
return true;
}
}
return false;
}
}

View File

@@ -13,9 +13,9 @@
#include "RESTAPI_SecurityObjects.h"
#include "SubSystemServer.h"
namespace uCentral {
namespace OpenWifi {
class AuthClient : public SubSystemServer {
class AuthClient : public SubSystemServer {
public:
explicit AuthClient() noexcept:
SubSystemServer("Authentication", "AUTH-CLNT", "authentication")
@@ -31,12 +31,12 @@ namespace uCentral {
int Start() override;
void Stop() override;
bool IsAuthorized(Poco::Net::HTTPServerRequest & Request, std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo );
bool IsAuthorized(Poco::Net::HTTPServerRequest & Request, std::string &SessionToken, OpenWifi::SecurityObjects::UserInfoAndPolicy & UInfo );
void RemovedCachedToken(const std::string &Token);
bool IsTokenAuthorized(const std::string &Token, SecurityObjects::UserInfoAndPolicy & UInfo);
private:
static AuthClient *instance_;
SecurityObjects::UserInfoCache UserCache_;
OpenWifi::SecurityObjects::UserInfoCache UserCache_;
};
inline AuthClient * AuthClient() { return AuthClient::instance(); }

View File

@@ -19,7 +19,7 @@
#include "RESTAPI_server.h"
#include "RESTAPI_InternalServer.h"
namespace uCentral {
namespace OpenWifi {
class Daemon *Daemon::instance_ = nullptr;
class Daemon *Daemon::instance() {
@@ -46,7 +46,7 @@ namespace uCentral {
int main(int argc, char **argv) {
try {
auto App = uCentral::Daemon::instance();
auto App = OpenWifi::Daemon::instance();
auto ExitCode = App->run(argc, argv);
delete App;

View File

@@ -27,9 +27,9 @@
#include "Dashboard.h"
#include "MicroService.h"
#include "uCentralTypes.h"
#include "OpenWifiTypes.h"
namespace uCentral {
namespace OpenWifi {
static const char * vDAEMON_PROPERTIES_FILENAME = "owprov.properties";
static const char * vDAEMON_ROOT_ENV_VAR = "OWPROV_ROOT";

View File

@@ -5,7 +5,7 @@
#ifndef UCENTRALGW_DASHBOARD_H
#define UCENTRALGW_DASHBOARD_H
#include "uCentralTypes.h"
#include "OpenWifiTypes.h"
#include "RESTAPI_ProvObjects.h"
namespace OpenWifi {

View File

@@ -12,7 +12,7 @@
#include "Daemon.h"
#include "Utils.h"
namespace uCentral {
namespace OpenWifi {
class KafkaManager *KafkaManager::instance_ = nullptr;

View File

@@ -13,11 +13,11 @@
#include <thread>
#include "SubSystemServer.h"
#include "uCentralTypes.h"
#include "OpenWifiTypes.h"
#include "cppkafka/cppkafka.h"
namespace uCentral {
namespace OpenWifi {
class KafkaManager : public SubSystemServer {
public:

View File

@@ -5,7 +5,7 @@
#ifndef UCENTRALGW_KAFKA_TOPICS_H
#define UCENTRALGW_KAFKA_TOPICS_H
namespace uCentral::KafkaTopics {
namespace OpenWifi::KafkaTopics {
static const std::string HEALTHCHECK{"healthcheck"};
static const std::string STATE{"state"};
static const std::string CONNECTION{"connection"};

View File

@@ -34,7 +34,7 @@
#include "AuthClient.h"
#endif
namespace uCentral {
namespace OpenWifi {
void MyErrorHandler::exception(const Poco::Exception & E) {
Poco::Thread * CurrentThread = Poco::Thread::current();

View File

@@ -24,10 +24,10 @@
#include "Poco/Net/HTTPServerRequest.h"
#include "Poco/Process.h"
#include "uCentralTypes.h"
#include "OpenWifiTypes.h"
#include "SubSystemServer.h"
namespace uCentral {
namespace OpenWifi {
static const std::string uSERVICE_SECURITY{"ucentralsec"};
static const std::string uSERVICE_GATEWAY{"ucentralgw"};

View File

@@ -17,7 +17,7 @@
#include "Utils.h"
#include "Daemon.h"
namespace uCentral {
namespace OpenWifi {
OpenAPIRequestGet::OpenAPIRequestGet( const std::string & ServiceType,
const std::string & EndPoint,

View File

@@ -7,9 +7,9 @@
#include "Poco/JSON/Object.h"
#include "uCentralTypes.h"
#include "OpenWifiTypes.h"
namespace uCentral {
namespace OpenWifi {
class OpenAPIRequestGet {
public:

View File

@@ -17,7 +17,7 @@
#include "Poco/StringTokenizer.h"
namespace uCentral::Types {
namespace OpenWifi::Types {
typedef std::pair<std::string,std::string> StringPair;
typedef std::vector<StringPair> StringPairVec;
typedef std::queue<StringPair> StringPairQueue;
@@ -33,12 +33,12 @@ namespace uCentral::Types {
typedef std::string UUID_t;
typedef std::vector<UUID_t> UUIDvec_t;
inline void UpdateCountedMap(CountedMap &M, const std::string &S ) {
inline void UpdateCountedMap(CountedMap &M, const std::string &S, uint64_t Increment=1) {
auto it = M.find(S);
if(it==M.end())
M[S]=1;
M[S] = Increment;
else
it->second += 1;
it->second += Increment;
}
inline std::string to_string( const StringVec &V) {

View File

@@ -10,7 +10,7 @@
#include "Utils.h"
namespace uCentral {
namespace OpenWifi {
class RESTAPI_InternalServer *RESTAPI_InternalServer::instance_ = nullptr;
@@ -52,7 +52,7 @@ namespace uCentral {
Poco::Net::HTTPRequestHandler *InternalRequestHandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest & Request) {
Logger_.debug(
Poco::format("REQUEST(%s): %s %s", uCentral::Utils::FormatIPv6(Request.clientAddress().toString()),
Poco::format("REQUEST(%s): %s %s", Utils::FormatIPv6(Request.clientAddress().toString()),
Request.getMethod(), Request.getURI()));
Poco::URI uri(Request.getURI());

View File

@@ -12,7 +12,7 @@
#include "Poco/Net/HTTPServerRequest.h"
#include "Poco/Net/NetException.h"
namespace uCentral {
namespace OpenWifi {
class RESTAPI_InternalServer : public SubSystemServer {

View File

@@ -5,28 +5,25 @@
#include "RESTAPI_ProvObjects.h"
#include "RESTAPI_utils.h"
using uCentral::RESTAPI_utils::field_from_json;
using uCentral::RESTAPI_utils::field_to_json;
namespace OpenWifi::ProvObjects {
void ObjectInfo::to_json(Poco::JSON::Object &Obj) const {
uCentral::RESTAPI_utils::field_to_json(Obj,"id",id);
uCentral::RESTAPI_utils::field_to_json(Obj,"name",name);
uCentral::RESTAPI_utils::field_to_json(Obj,"description",description);
uCentral::RESTAPI_utils::field_to_json(Obj,"created",created);
uCentral::RESTAPI_utils::field_to_json(Obj,"modified",modified);
uCentral::RESTAPI_utils::field_to_json(Obj,"notes",notes);
RESTAPI_utils::field_to_json(Obj,"id",id);
RESTAPI_utils::field_to_json(Obj,"name",name);
RESTAPI_utils::field_to_json(Obj,"description",description);
RESTAPI_utils::field_to_json(Obj,"created",created);
RESTAPI_utils::field_to_json(Obj,"modified",modified);
RESTAPI_utils::field_to_json(Obj,"notes",notes);
}
bool ObjectInfo::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
uCentral::RESTAPI_utils::field_from_json(Obj,"id",id);
uCentral::RESTAPI_utils::field_from_json(Obj,"name",name);
uCentral::RESTAPI_utils::field_from_json(Obj,"description",description);
uCentral::RESTAPI_utils::field_from_json(Obj,"created",created);
uCentral::RESTAPI_utils::field_from_json(Obj,"modified",modified);
uCentral::RESTAPI_utils::field_from_json(Obj,"notes",notes);
RESTAPI_utils::field_from_json(Obj,"id",id);
RESTAPI_utils::field_from_json(Obj,"name",name);
RESTAPI_utils::field_from_json(Obj,"description",description);
RESTAPI_utils::field_from_json(Obj,"created",created);
RESTAPI_utils::field_from_json(Obj,"modified",modified);
RESTAPI_utils::field_from_json(Obj,"notes",notes);
return true;
} catch(...) {
@@ -35,18 +32,18 @@ namespace OpenWifi::ProvObjects {
}
void ManagementPolicyEntry::to_json(Poco::JSON::Object &Obj) const {
uCentral::RESTAPI_utils::field_to_json( Obj,"users",users);
uCentral::RESTAPI_utils::field_to_json( Obj,"resources",resources);
uCentral::RESTAPI_utils::field_to_json( Obj,"access",access);
uCentral::RESTAPI_utils::field_to_json( Obj,"policy",policy);
RESTAPI_utils::field_to_json( Obj,"users",users);
RESTAPI_utils::field_to_json( Obj,"resources",resources);
RESTAPI_utils::field_to_json( Obj,"access",access);
RESTAPI_utils::field_to_json( Obj,"policy",policy);
}
bool ManagementPolicyEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
uCentral::RESTAPI_utils::field_from_json( Obj,"users",users);
uCentral::RESTAPI_utils::field_from_json( Obj,"resources",resources);
uCentral::RESTAPI_utils::field_from_json( Obj,"access",access);
uCentral::RESTAPI_utils::field_from_json( Obj,"policy",policy);
RESTAPI_utils::field_from_json( Obj,"users",users);
RESTAPI_utils::field_from_json( Obj,"resources",resources);
RESTAPI_utils::field_from_json( Obj,"access",access);
RESTAPI_utils::field_from_json( Obj,"policy",policy);
return true;
} catch(...) {
@@ -56,13 +53,13 @@ namespace OpenWifi::ProvObjects {
void ManagementPolicy::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
uCentral::RESTAPI_utils::field_to_json(Obj, "entries", entries);
RESTAPI_utils::field_to_json(Obj, "entries", entries);
}
bool ManagementPolicy::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
info.from_json(Obj);
uCentral::RESTAPI_utils::field_from_json(Obj, "entries", entries);
RESTAPI_utils::field_from_json(Obj, "entries", entries);
return true;
} catch(...) {
@@ -72,23 +69,23 @@ namespace OpenWifi::ProvObjects {
void Entity::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
uCentral::RESTAPI_utils::field_to_json( Obj,"parent",parent);
uCentral::RESTAPI_utils::field_to_json( Obj,"venues",venues);
uCentral::RESTAPI_utils::field_to_json( Obj,"children",children);
uCentral::RESTAPI_utils::field_to_json( Obj,"contacts",contacts);
uCentral::RESTAPI_utils::field_to_json( Obj,"locations",locations);
uCentral::RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy);
RESTAPI_utils::field_to_json( Obj,"parent",parent);
RESTAPI_utils::field_to_json( Obj,"venues",venues);
RESTAPI_utils::field_to_json( Obj,"children",children);
RESTAPI_utils::field_to_json( Obj,"contacts",contacts);
RESTAPI_utils::field_to_json( Obj,"locations",locations);
RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy);
}
bool Entity::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
info.from_json(Obj);
uCentral::RESTAPI_utils::field_from_json( Obj,"parent",parent);
uCentral::RESTAPI_utils::field_from_json( Obj,"venues",venues);
uCentral::RESTAPI_utils::field_from_json( Obj,"children",children);
uCentral::RESTAPI_utils::field_from_json( Obj,"contacts",contacts);
uCentral::RESTAPI_utils::field_from_json( Obj,"locations",locations);
uCentral::RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy);
RESTAPI_utils::field_from_json( Obj,"parent",parent);
RESTAPI_utils::field_from_json( Obj,"venues",venues);
RESTAPI_utils::field_from_json( Obj,"children",children);
RESTAPI_utils::field_from_json( Obj,"contacts",contacts);
RESTAPI_utils::field_from_json( Obj,"locations",locations);
RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy);
return true;
} catch(...) {
@@ -97,14 +94,14 @@ namespace OpenWifi::ProvObjects {
}
void DiGraphEntry::to_json(Poco::JSON::Object &Obj) const {
uCentral::RESTAPI_utils::field_to_json( Obj,"parent",parent);
uCentral::RESTAPI_utils::field_to_json( Obj,"child",child);
RESTAPI_utils::field_to_json( Obj,"parent",parent);
RESTAPI_utils::field_to_json( Obj,"child",child);
}
bool DiGraphEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
uCentral::RESTAPI_utils::field_from_json( Obj,"parent",parent);
uCentral::RESTAPI_utils::field_from_json( Obj,"child",child);
RESTAPI_utils::field_from_json( Obj,"parent",parent);
RESTAPI_utils::field_from_json( Obj,"child",child);
return true;
} catch (...) {
@@ -114,27 +111,27 @@ namespace OpenWifi::ProvObjects {
void Venue::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
uCentral::RESTAPI_utils::field_to_json( Obj,"parent",parent);
uCentral::RESTAPI_utils::field_to_json( Obj,"owner",entity);
uCentral::RESTAPI_utils::field_to_json( Obj,"children",children);
uCentral::RESTAPI_utils::field_to_json( Obj,"devices",devices);
uCentral::RESTAPI_utils::field_to_json( Obj,"topology",topology);
uCentral::RESTAPI_utils::field_to_json( Obj,"parent",parent);
uCentral::RESTAPI_utils::field_to_json( Obj,"design",design);
uCentral::RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy);
RESTAPI_utils::field_to_json( Obj,"parent",parent);
RESTAPI_utils::field_to_json( Obj,"owner",entity);
RESTAPI_utils::field_to_json( Obj,"children",children);
RESTAPI_utils::field_to_json( Obj,"devices",devices);
RESTAPI_utils::field_to_json( Obj,"topology",topology);
RESTAPI_utils::field_to_json( Obj,"parent",parent);
RESTAPI_utils::field_to_json( Obj,"design",design);
RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy);
}
bool Venue::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
info.from_json(Obj);
uCentral::RESTAPI_utils::field_from_json( Obj,"parent",parent);
uCentral::RESTAPI_utils::field_from_json( Obj,"owner",entity);
uCentral::RESTAPI_utils::field_from_json( Obj,"children",children);
uCentral::RESTAPI_utils::field_from_json( Obj,"devices",devices);
uCentral::RESTAPI_utils::field_from_json( Obj,"topology",topology);
uCentral::RESTAPI_utils::field_from_json( Obj,"parent",parent);
uCentral::RESTAPI_utils::field_from_json( Obj,"design",design);
uCentral::RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy);
RESTAPI_utils::field_from_json( Obj,"parent",parent);
RESTAPI_utils::field_from_json( Obj,"owner",entity);
RESTAPI_utils::field_from_json( Obj,"children",children);
RESTAPI_utils::field_from_json( Obj,"devices",devices);
RESTAPI_utils::field_from_json( Obj,"topology",topology);
RESTAPI_utils::field_from_json( Obj,"parent",parent);
RESTAPI_utils::field_from_json( Obj,"design",design);
RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy);
return true;
} catch (...) {
@@ -143,16 +140,16 @@ namespace OpenWifi::ProvObjects {
}
void UserInfoDigest::to_json(Poco::JSON::Object &Obj) const {
uCentral::RESTAPI_utils::field_to_json( Obj,"id",id);
uCentral::RESTAPI_utils::field_to_json( Obj,"owner",loginId);
uCentral::RESTAPI_utils::field_to_json( Obj,"children",userType);
RESTAPI_utils::field_to_json( Obj,"id",id);
RESTAPI_utils::field_to_json( Obj,"owner",loginId);
RESTAPI_utils::field_to_json( Obj,"children",userType);
}
bool UserInfoDigest::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
uCentral::RESTAPI_utils::field_from_json( Obj,"id",id);
uCentral::RESTAPI_utils::field_from_json( Obj,"owner",loginId);
uCentral::RESTAPI_utils::field_from_json( Obj,"children",userType);
RESTAPI_utils::field_from_json( Obj,"id",id);
RESTAPI_utils::field_from_json( Obj,"owner",loginId);
RESTAPI_utils::field_from_json( Obj,"children",userType);
return true;
} catch(...) {
}
@@ -161,15 +158,15 @@ namespace OpenWifi::ProvObjects {
void ManagementRole::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
uCentral::RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy);
uCentral::RESTAPI_utils::field_to_json( Obj,"users",users);
RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy);
RESTAPI_utils::field_to_json( Obj,"users",users);
}
bool ManagementRole::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
info.from_json(Obj);
uCentral::RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy);
uCentral::RESTAPI_utils::field_from_json( Obj,"users",users);
RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy);
RESTAPI_utils::field_from_json( Obj,"users",users);
return true;
} catch(...) {
}
@@ -178,37 +175,37 @@ namespace OpenWifi::ProvObjects {
void Location::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
uCentral::RESTAPI_utils::field_to_json( Obj,"type",OpenWifi::ProvObjects::to_string(type));
uCentral::RESTAPI_utils::field_to_json( Obj,"buildingName",buildingName);
uCentral::RESTAPI_utils::field_to_json( Obj,"addressLines",addressLines);
uCentral::RESTAPI_utils::field_to_json( Obj,"city",city);
uCentral::RESTAPI_utils::field_to_json( Obj,"state",state);
uCentral::RESTAPI_utils::field_to_json( Obj,"postal",postal);
uCentral::RESTAPI_utils::field_to_json( Obj,"country",country);
uCentral::RESTAPI_utils::field_to_json( Obj,"phones",phones);
uCentral::RESTAPI_utils::field_to_json( Obj,"mobiles",mobiles);
uCentral::RESTAPI_utils::field_to_json( Obj,"venues",venues);
uCentral::RESTAPI_utils::field_to_json( Obj,"entities",entities);
uCentral::RESTAPI_utils::field_to_json( Obj,"geoCode",geoCode);
RESTAPI_utils::field_to_json( Obj,"type",OpenWifi::ProvObjects::to_string(type));
RESTAPI_utils::field_to_json( Obj,"buildingName",buildingName);
RESTAPI_utils::field_to_json( Obj,"addressLines",addressLines);
RESTAPI_utils::field_to_json( Obj,"city",city);
RESTAPI_utils::field_to_json( Obj,"state",state);
RESTAPI_utils::field_to_json( Obj,"postal",postal);
RESTAPI_utils::field_to_json( Obj,"country",country);
RESTAPI_utils::field_to_json( Obj,"phones",phones);
RESTAPI_utils::field_to_json( Obj,"mobiles",mobiles);
RESTAPI_utils::field_to_json( Obj,"venues",venues);
RESTAPI_utils::field_to_json( Obj,"entities",entities);
RESTAPI_utils::field_to_json( Obj,"geoCode",geoCode);
}
bool Location::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
info.from_json(Obj);
std::string tmp_type;
uCentral::RESTAPI_utils::field_from_json( Obj,"type", tmp_type);
RESTAPI_utils::field_from_json( Obj,"type", tmp_type);
type = location_from_string(tmp_type);
uCentral::RESTAPI_utils::field_from_json( Obj,"buildingName",buildingName);
uCentral::RESTAPI_utils::field_from_json( Obj,"addressLines",addressLines);
uCentral::RESTAPI_utils::field_from_json( Obj,"city",city);
uCentral::RESTAPI_utils::field_from_json( Obj,"state",state);
uCentral::RESTAPI_utils::field_from_json( Obj,"postal",postal);
uCentral::RESTAPI_utils::field_from_json( Obj,"country",country);
uCentral::RESTAPI_utils::field_from_json( Obj,"phones",phones);
uCentral::RESTAPI_utils::field_from_json( Obj,"mobiles",mobiles);
uCentral::RESTAPI_utils::field_from_json( Obj,"venues",venues);
uCentral::RESTAPI_utils::field_from_json( Obj,"entities",entities);
uCentral::RESTAPI_utils::field_from_json( Obj,"geoCode",geoCode);
RESTAPI_utils::field_from_json( Obj,"buildingName",buildingName);
RESTAPI_utils::field_from_json( Obj,"addressLines",addressLines);
RESTAPI_utils::field_from_json( Obj,"city",city);
RESTAPI_utils::field_from_json( Obj,"state",state);
RESTAPI_utils::field_from_json( Obj,"postal",postal);
RESTAPI_utils::field_from_json( Obj,"country",country);
RESTAPI_utils::field_from_json( Obj,"phones",phones);
RESTAPI_utils::field_from_json( Obj,"mobiles",mobiles);
RESTAPI_utils::field_from_json( Obj,"venues",venues);
RESTAPI_utils::field_from_json( Obj,"entities",entities);
RESTAPI_utils::field_from_json( Obj,"geoCode",geoCode);
return true;
} catch (...) {
@@ -218,41 +215,41 @@ namespace OpenWifi::ProvObjects {
void Contact::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
uCentral::RESTAPI_utils::field_to_json( Obj,"type", to_string(type));
uCentral::RESTAPI_utils::field_to_json( Obj,"title",title);
uCentral::RESTAPI_utils::field_to_json( Obj,"salutation",salutation);
uCentral::RESTAPI_utils::field_to_json( Obj,"firstname",firstname);
uCentral::RESTAPI_utils::field_to_json( Obj,"lastname",lastname);
uCentral::RESTAPI_utils::field_to_json( Obj,"initials",initials);
uCentral::RESTAPI_utils::field_to_json( Obj,"visual",visual);
uCentral::RESTAPI_utils::field_to_json( Obj,"mobiles",mobiles);
uCentral::RESTAPI_utils::field_to_json( Obj,"phones",phones);
uCentral::RESTAPI_utils::field_to_json( Obj,"primaryEmail",primaryEmail);
uCentral::RESTAPI_utils::field_to_json( Obj,"secondaryEmail",secondaryEmail);
uCentral::RESTAPI_utils::field_to_json( Obj,"accessPIN",accessPIN);
uCentral::RESTAPI_utils::field_to_json( Obj,"venues",venues);
uCentral::RESTAPI_utils::field_to_json( Obj,"entities",entities);
RESTAPI_utils::field_to_json( Obj,"type", to_string(type));
RESTAPI_utils::field_to_json( Obj,"title",title);
RESTAPI_utils::field_to_json( Obj,"salutation",salutation);
RESTAPI_utils::field_to_json( Obj,"firstname",firstname);
RESTAPI_utils::field_to_json( Obj,"lastname",lastname);
RESTAPI_utils::field_to_json( Obj,"initials",initials);
RESTAPI_utils::field_to_json( Obj,"visual",visual);
RESTAPI_utils::field_to_json( Obj,"mobiles",mobiles);
RESTAPI_utils::field_to_json( Obj,"phones",phones);
RESTAPI_utils::field_to_json( Obj,"primaryEmail",primaryEmail);
RESTAPI_utils::field_to_json( Obj,"secondaryEmail",secondaryEmail);
RESTAPI_utils::field_to_json( Obj,"accessPIN",accessPIN);
RESTAPI_utils::field_to_json( Obj,"venues",venues);
RESTAPI_utils::field_to_json( Obj,"entities",entities);
}
bool Contact::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
info.from_json(Obj);
std::string tmp_type;
uCentral::RESTAPI_utils::field_from_json( Obj,"type", tmp_type);
RESTAPI_utils::field_from_json( Obj,"type", tmp_type);
type = contact_from_string(tmp_type);
uCentral::RESTAPI_utils::field_from_json( Obj,"title",title);
uCentral::RESTAPI_utils::field_from_json( Obj,"salutation",salutation);
uCentral::RESTAPI_utils::field_from_json( Obj,"firstname",firstname);
uCentral::RESTAPI_utils::field_from_json( Obj,"lastname",lastname);
uCentral::RESTAPI_utils::field_from_json( Obj,"initials",initials);
uCentral::RESTAPI_utils::field_from_json( Obj,"visual",visual);
uCentral::RESTAPI_utils::field_from_json( Obj,"mobiles",mobiles);
uCentral::RESTAPI_utils::field_from_json( Obj,"phones",phones);
uCentral::RESTAPI_utils::field_from_json( Obj,"primaryEmail",primaryEmail);
uCentral::RESTAPI_utils::field_from_json( Obj,"secondaryEmail",secondaryEmail);
uCentral::RESTAPI_utils::field_from_json( Obj,"accessPIN",accessPIN);
uCentral::RESTAPI_utils::field_from_json( Obj,"venues",venues);
uCentral::RESTAPI_utils::field_from_json( Obj,"entities",entities);
RESTAPI_utils::field_from_json( Obj,"title",title);
RESTAPI_utils::field_from_json( Obj,"salutation",salutation);
RESTAPI_utils::field_from_json( Obj,"firstname",firstname);
RESTAPI_utils::field_from_json( Obj,"lastname",lastname);
RESTAPI_utils::field_from_json( Obj,"initials",initials);
RESTAPI_utils::field_from_json( Obj,"visual",visual);
RESTAPI_utils::field_from_json( Obj,"mobiles",mobiles);
RESTAPI_utils::field_from_json( Obj,"phones",phones);
RESTAPI_utils::field_from_json( Obj,"primaryEmail",primaryEmail);
RESTAPI_utils::field_from_json( Obj,"secondaryEmail",secondaryEmail);
RESTAPI_utils::field_from_json( Obj,"accessPIN",accessPIN);
RESTAPI_utils::field_from_json( Obj,"venues",venues);
RESTAPI_utils::field_from_json( Obj,"entities",entities);
return true;
} catch (...) {
@@ -278,29 +275,29 @@ namespace OpenWifi::ProvObjects {
void InventoryTag::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
uCentral::RESTAPI_utils::field_to_json(Obj, "serialNumber", serialNumber);
uCentral::RESTAPI_utils::field_to_json(Obj, "venue", venue);
uCentral::RESTAPI_utils::field_to_json(Obj, "entity", entity);
uCentral::RESTAPI_utils::field_to_json(Obj, "subEntity", subEntity);
uCentral::RESTAPI_utils::field_to_json(Obj, "subVenue", subVenue);
uCentral::RESTAPI_utils::field_to_json(Obj, "subscriber", subscriber);
uCentral::RESTAPI_utils::field_to_json(Obj, "deviceType", deviceType);
uCentral::RESTAPI_utils::field_to_json(Obj, "qrCode", qrCode);
uCentral::RESTAPI_utils::field_to_json(Obj, "geoCode", geoCode);
RESTAPI_utils::field_to_json(Obj, "serialNumber", serialNumber);
RESTAPI_utils::field_to_json(Obj, "venue", venue);
RESTAPI_utils::field_to_json(Obj, "entity", entity);
RESTAPI_utils::field_to_json(Obj, "subEntity", subEntity);
RESTAPI_utils::field_to_json(Obj, "subVenue", subVenue);
RESTAPI_utils::field_to_json(Obj, "subscriber", subscriber);
RESTAPI_utils::field_to_json(Obj, "deviceType", deviceType);
RESTAPI_utils::field_to_json(Obj, "qrCode", qrCode);
RESTAPI_utils::field_to_json(Obj, "geoCode", geoCode);
}
bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
info.from_json(Obj);
uCentral::RESTAPI_utils::field_from_json( Obj,"serialNumber",serialNumber);
uCentral::RESTAPI_utils::field_from_json( Obj,"venue",venue);
uCentral::RESTAPI_utils::field_from_json( Obj,"entity",entity);
uCentral::RESTAPI_utils::field_from_json( Obj,"subEntity",subEntity);
uCentral::RESTAPI_utils::field_from_json( Obj,"subVenue",subVenue);
uCentral::RESTAPI_utils::field_from_json( Obj,"subscriber",subscriber);
uCentral::RESTAPI_utils::field_from_json( Obj,"deviceType",deviceType);
uCentral::RESTAPI_utils::field_from_json(Obj, "qrCode", qrCode);
uCentral::RESTAPI_utils::field_from_json( Obj,"geoCode",geoCode);
RESTAPI_utils::field_from_json( Obj,"serialNumber",serialNumber);
RESTAPI_utils::field_from_json( Obj,"venue",venue);
RESTAPI_utils::field_from_json( Obj,"entity",entity);
RESTAPI_utils::field_from_json( Obj,"subEntity",subEntity);
RESTAPI_utils::field_from_json( Obj,"subVenue",subVenue);
RESTAPI_utils::field_from_json( Obj,"subscriber",subscriber);
RESTAPI_utils::field_from_json( Obj,"deviceType",deviceType);
RESTAPI_utils::field_from_json(Obj, "qrCode", qrCode);
RESTAPI_utils::field_from_json( Obj,"geoCode",geoCode);
return true;
} catch(...) {
@@ -311,16 +308,16 @@ namespace OpenWifi::ProvObjects {
void DeviceConfiguration::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
managementPolicy.to_json(Obj);
uCentral::RESTAPI_utils::field_to_json( Obj,"deviceTypes",deviceTypes);
uCentral::RESTAPI_utils::field_to_json( Obj,"configuration",configuration);
RESTAPI_utils::field_to_json( Obj,"deviceTypes",deviceTypes);
RESTAPI_utils::field_to_json( Obj,"configuration",configuration);
}
bool DeviceConfiguration::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
info.from_json(Obj);
managementPolicy.from_json(Obj);
uCentral::RESTAPI_utils::field_from_json( Obj,"deviceTypes",deviceTypes);
uCentral::RESTAPI_utils::field_from_json( Obj,"configuration",configuration);
RESTAPI_utils::field_from_json( Obj,"deviceTypes",deviceTypes);
RESTAPI_utils::field_from_json( Obj,"configuration",configuration);
return true;
} catch(...) {
@@ -329,8 +326,8 @@ namespace OpenWifi::ProvObjects {
}
void Report::to_json(Poco::JSON::Object &Obj) const {
uCentral::RESTAPI_utils::field_to_json(Obj, "snapshot", snapShot);
uCentral::RESTAPI_utils::field_to_json(Obj, "devices", tenants);
RESTAPI_utils::field_to_json(Obj, "snapshot", snapShot);
RESTAPI_utils::field_to_json(Obj, "devices", tenants);
};
void Report::reset() {

View File

@@ -11,10 +11,10 @@
namespace OpenWifi::ProvObjects {
struct ObjectInfo {
uCentral::Types::UUID_t id;
Types::UUID_t id;
std::string name;
std::string description;
uCentral::SecurityObjects::NoteInfoVec notes;
SecurityObjects::NoteInfoVec notes;
uint64_t created;
uint64_t modified;
@@ -23,9 +23,9 @@ namespace OpenWifi::ProvObjects {
};
struct ManagementPolicyEntry {
uCentral::Types::UUIDvec_t users;
uCentral::Types::UUIDvec_t resources;
uCentral::Types::StringVec access;
Types::UUIDvec_t users;
Types::UUIDvec_t resources;
Types::StringVec access;
std::string policy;
void to_json(Poco::JSON::Object &Obj) const;
@@ -42,20 +42,20 @@ namespace OpenWifi::ProvObjects {
struct Entity {
ObjectInfo info;
uCentral::Types::UUID_t parent;
uCentral::Types::UUIDvec_t children;
uCentral::Types::UUIDvec_t venues;
uCentral::Types::UUIDvec_t contacts;
uCentral::Types::UUIDvec_t locations;
uCentral::Types::UUID_t managementPolicy;
Types::UUID_t parent;
Types::UUIDvec_t children;
Types::UUIDvec_t venues;
Types::UUIDvec_t contacts;
Types::UUIDvec_t locations;
Types::UUID_t managementPolicy;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct DiGraphEntry {
uCentral::Types::UUID_t parent;
uCentral::Types::UUID_t child;
Types::UUID_t parent;
Types::UUID_t child;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -65,11 +65,11 @@ namespace OpenWifi::ProvObjects {
struct Venue {
ObjectInfo info;
uCentral::Types::UUID_t entity;
uCentral::Types::UUID_t parent;
uCentral::Types::UUIDvec_t children;
uCentral::Types::UUID_t managementPolicy;
uCentral::Types::UUIDvec_t devices;
Types::UUID_t entity;
Types::UUID_t parent;
Types::UUIDvec_t children;
Types::UUID_t managementPolicy;
Types::UUIDvec_t devices;
DiGraph topology;
std::string design;
@@ -88,7 +88,7 @@ namespace OpenWifi::ProvObjects {
struct ManagementRole {
ObjectInfo info;
uCentral::Types::UUID_t managementPolicy;
Types::UUID_t managementPolicy;
std::vector<UserInfoDigest> users;
void to_json(Poco::JSON::Object &Obj) const;
@@ -135,15 +135,15 @@ namespace OpenWifi::ProvObjects {
ObjectInfo info;
LocationType type;
std::string buildingName;
uCentral::Types::StringVec addressLines;
Types::StringVec addressLines;
std::string city;
std::string state;
std::string postal;
std::string country;
uCentral::Types::StringVec phones;
uCentral::Types::StringVec mobiles;
uCentral::Types::StringVec venues;
uCentral::Types::StringVec entities;
Types::StringVec phones;
Types::StringVec mobiles;
Types::StringVec venues;
Types::StringVec entities;
std::string geoCode;
void to_json(Poco::JSON::Object &Obj) const;
@@ -199,13 +199,13 @@ namespace OpenWifi::ProvObjects {
std::string lastname;
std::string initials;
std::string visual;
uCentral::Types::StringVec mobiles;
uCentral::Types::StringVec phones;
Types::StringVec mobiles;
Types::StringVec phones;
std::string primaryEmail;
std::string secondaryEmail;
std::string accessPIN;
uCentral::Types::StringVec venues;
uCentral::Types::StringVec entities;
Types::StringVec venues;
Types::StringVec entities;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -222,7 +222,7 @@ namespace OpenWifi::ProvObjects {
struct DeviceConfiguration {
ObjectInfo info;
ManagementPolicy managementPolicy;
uCentral::Types::StringVec deviceTypes;
Types::StringVec deviceTypes;
std::string configuration;
void to_json(Poco::JSON::Object &Obj) const;
@@ -247,7 +247,7 @@ namespace OpenWifi::ProvObjects {
struct Report {
uint64_t snapShot;
uCentral::Types::CountedMap tenants;
Types::CountedMap tenants;
void reset();
void to_json(Poco::JSON::Object &Obj) const;

View File

@@ -12,10 +12,10 @@
#include "RESTAPI_SecurityObjects.h"
#include "RESTAPI_utils.h"
using uCentral::RESTAPI_utils::field_to_json;
using uCentral::RESTAPI_utils::field_from_json;
using OpenWifi::RESTAPI_utils::field_to_json;
using OpenWifi::RESTAPI_utils::field_from_json;
namespace uCentral::SecurityObjects {
namespace OpenWifi::SecurityObjects {
void AclTemplate::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"Read",Read_);
@@ -303,6 +303,20 @@ namespace uCentral::SecurityObjects {
return false;
}
bool append_from_json(Poco::JSON::Object::Ptr Obj, const UserInfo &UInfo, NoteInfoVec & Notes) {
try {
SecurityObjects::NoteInfoVec NIV;
NIV = RESTAPI_utils::to_object_array<SecurityObjects::NoteInfo>(Obj->get("notes").toString());
for(auto const &i:NIV) {
SecurityObjects::NoteInfo ii{.created=(uint64_t)std::time(nullptr), .createdBy=UInfo.email, .note=i.note};
Notes.push_back(ii);
}
} catch(...) {
}
return false;
}
void ProfileAction::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"resource", resource);
field_to_json<ResourceAccessType>(Obj,"access", access, ResourceAccessTypeToString);

View File

@@ -10,9 +10,9 @@
#define UCENTRAL_RESTAPI_SECURITYOBJECTS_H
#include "Poco/JSON/Object.h"
#include "uCentralTypes.h"
#include "OpenWifiTypes.h"
namespace uCentral::SecurityObjects {
namespace OpenWifi::SecurityObjects {
struct AclTemplate {
bool Read_ = true;
@@ -94,6 +94,8 @@ namespace uCentral::SecurityObjects {
};
typedef std::vector<UserInfo> UserInfoVec;
bool append_from_json(Poco::JSON::Object::Ptr Obj, const UserInfo &UInfo, NoteInfoVec & Notes);
struct InternalServiceInfo {
std::string privateURI;
std::string publicURI;

View File

@@ -34,14 +34,14 @@ namespace OpenWifi{
void RESTAPI_contact_handler::DoGet(Poco::Net::HTTPServerRequest &Request,
Poco::Net::HTTPServerResponse &Response) {
try {
std::string UUID = GetBinding(uCentral::RESTAPI::Protocol::ID,"");
std::string UUID = GetBinding(RESTAPI::Protocol::ID,"");
if(UUID.empty()) {
BadRequest(Request, Response, "Missing UUID.");
return;
}
ProvObjects::Contact C;
if(Storage()->ContactDB().GetRecord(uCentral::RESTAPI::Protocol::ID,UUID,C)) {
if(Storage()->ContactDB().GetRecord(RESTAPI::Protocol::ID,UUID,C)) {
Poco::JSON::Object Answer;
C.to_json(Answer);
ReturnObject(Request, Answer, Response);
@@ -64,7 +64,7 @@ namespace OpenWifi{
void RESTAPI_contact_handler::DoPost(Poco::Net::HTTPServerRequest &Request,
Poco::Net::HTTPServerResponse &Response) {
try {
std::string UUID = GetBinding(uCentral::RESTAPI::Protocol::ID,"");
std::string UUID = GetBinding(RESTAPI::Protocol::ID,"");
if(UUID.empty()) {
BadRequest(Request, Response, "Missing UUID.");
return;
@@ -78,7 +78,7 @@ namespace OpenWifi{
return;
}
C.info.id = uCentral::Daemon()->CreateUUID();
C.info.id = Daemon()->CreateUUID();
C.info.created = C.info.modified = std::time(nullptr);
if(C.entities.empty() || C.entities.size()!=1) {
@@ -86,7 +86,7 @@ namespace OpenWifi{
return;
}
std::string f{uCentral::RESTAPI::Protocol::ID};
std::string f{RESTAPI::Protocol::ID};
if(!Storage()->EntityDB().Exists("id",C.entities[0])) {
BadRequest(Request, Response, "Unknown entity: " + C.entities[0] );
return;

View File

@@ -10,7 +10,7 @@
#include "Poco/Net/HTTPServerResponse.h"
namespace OpenWifi {
class RESTAPI_contact_handler : public uCentral::RESTAPIHandler {
class RESTAPI_contact_handler : public RESTAPIHandler {
public:
RESTAPI_contact_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
: RESTAPIHandler(bindings, L,

View File

@@ -128,7 +128,7 @@ namespace OpenWifi{
// When creating an entity, it cannot have any relations other that parent, notes, name, description. Everything else
// must be conveyed through PUT.
E.info.id = (UUID==EntityDB::RootUUID()) ? UUID : uCentral::Daemon()->CreateUUID() ;
E.info.id = (UUID==EntityDB::RootUUID()) ? UUID : Daemon()->CreateUUID() ;
if(UUID==EntityDB::RootUUID())
E.parent="";
else if(E.parent.empty()) {
@@ -196,12 +196,7 @@ namespace OpenWifi{
Poco::JSON::Parser IncomingParser;
auto RawObject = IncomingParser.parse(Request.stream()).extract<Poco::JSON::Object::Ptr>();
if(RawObject->has("notes")) {
uCentral::SecurityObjects::NoteInfoVec NIV;
NIV = uCentral::RESTAPI_utils::to_object_array<uCentral::SecurityObjects::NoteInfo>(RawObject->get("notes").toString());
for(auto const &i:NIV) {
uCentral::SecurityObjects::NoteInfo ii{.created=(uint64_t)std::time(nullptr), .createdBy=UserInfo_.userinfo.email, .note=i.note};
LocalObject.info.notes.push_back(ii);
}
SecurityObjects::append_from_json(RawObject, UserInfo_.userinfo, LocalObject.info.notes);
}
if(RawObject->has("name"))

View File

@@ -11,7 +11,7 @@
#include "Poco/Net/HTTPServerResponse.h"
namespace OpenWifi {
class RESTAPI_entity_handler : public uCentral::RESTAPIHandler {
class RESTAPI_entity_handler : public RESTAPIHandler {
public:
RESTAPI_entity_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
: RESTAPIHandler(bindings, L,

View File

@@ -26,7 +26,7 @@ namespace OpenWifi{
Poco::Net::HTTPServerResponse &Response) {
try {
if(!QB_.Select.empty()) {
auto EntityUIDs = uCentral::Utils::Split(QB_.Select);
auto EntityUIDs = Utils::Split(QB_.Select);
Poco::JSON::Array Arr;
for(const auto &i:EntityUIDs) {
ProvObjects::Entity E;

View File

@@ -10,7 +10,7 @@
#include "Poco/Net/HTTPServerResponse.h"
namespace OpenWifi {
class RESTAPI_entity_list_handler : public uCentral::RESTAPIHandler {
class RESTAPI_entity_list_handler : public RESTAPIHandler {
public:
RESTAPI_entity_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
: RESTAPIHandler(bindings, L,

View File

@@ -27,16 +27,16 @@
#include "Utils.h"
#include "Daemon.h"
namespace uCentral {
namespace OpenWifi {
bool RESTAPIHandler::ParseBindings(const std::string & Request, const std::list<const char *> & EndPoints, BindingMap &bindings) {
std::string Param, Value;
bindings.clear();
std::vector<std::string> PathItems = uCentral::Utils::Split(Request, '/');
std::vector<std::string> PathItems = Utils::Split(Request, '/');
for(const auto &EndPoint:EndPoints) {
std::vector<std::string> ParamItems = uCentral::Utils::Split(EndPoint, '/');
std::vector<std::string> ParamItems = Utils::Split(EndPoint, '/');
if (PathItems.size() != ParamItems.size())
continue;
@@ -365,17 +365,17 @@ namespace uCentral {
}
bool RESTAPIHandler::InitQueryBlock() {
QB_.SerialNumber = GetParameter(uCentral::RESTAPI::Protocol::SERIALNUMBER, "");
QB_.StartDate = GetParameter(uCentral::RESTAPI::Protocol::STARTDATE, 0);
QB_.EndDate = GetParameter(uCentral::RESTAPI::Protocol::ENDDATE, 0);
QB_.Offset = GetParameter(uCentral::RESTAPI::Protocol::OFFSET, 1);
QB_.Limit = GetParameter(uCentral::RESTAPI::Protocol::LIMIT, 100);
QB_.Filter = GetParameter(uCentral::RESTAPI::Protocol::FILTER, "");
QB_.Select = GetParameter(uCentral::RESTAPI::Protocol::SELECT, "");
QB_.Lifetime = GetBoolParameter(uCentral::RESTAPI::Protocol::LIFETIME,false);
QB_.LogType = GetParameter(uCentral::RESTAPI::Protocol::LOGTYPE,0);
QB_.LastOnly = GetBoolParameter(uCentral::RESTAPI::Protocol::LASTONLY,false);
QB_.Newest = GetBoolParameter(uCentral::RESTAPI::Protocol::NEWEST,false);
QB_.SerialNumber = GetParameter(RESTAPI::Protocol::SERIALNUMBER, "");
QB_.StartDate = GetParameter(RESTAPI::Protocol::STARTDATE, 0);
QB_.EndDate = GetParameter(RESTAPI::Protocol::ENDDATE, 0);
QB_.Offset = GetParameter(RESTAPI::Protocol::OFFSET, 1);
QB_.Limit = GetParameter(RESTAPI::Protocol::LIMIT, 100);
QB_.Filter = GetParameter(RESTAPI::Protocol::FILTER, "");
QB_.Select = GetParameter(RESTAPI::Protocol::SELECT, "");
QB_.Lifetime = GetBoolParameter(RESTAPI::Protocol::LIFETIME,false);
QB_.LogType = GetParameter(RESTAPI::Protocol::LOGTYPE,0);
QB_.LastOnly = GetBoolParameter(RESTAPI::Protocol::LASTONLY,false);
QB_.Newest = GetBoolParameter(RESTAPI::Protocol::NEWEST,false);
if(QB_.Offset<1) return false;
return true;
@@ -400,7 +400,7 @@ namespace uCentral {
}
[[nodiscard]] uint64_t RESTAPIHandler::GetWhen(const Poco::JSON::Object::Ptr &Obj) {
return RESTAPIHandler::Get(uCentral::RESTAPI::Protocol::WHEN, Obj);
return RESTAPIHandler::Get(RESTAPI::Protocol::WHEN, Obj);
}

View File

@@ -26,7 +26,7 @@
#include "RESTAPI_SecurityObjects.h"
namespace uCentral {
namespace OpenWifi {
class RESTAPI_PartHandler: public Poco::Net::PartHandler
{

View File

@@ -34,14 +34,14 @@ namespace OpenWifi{
void RESTAPI_inventory_handler::DoGet(Poco::Net::HTTPServerRequest &Request,
Poco::Net::HTTPServerResponse &Response) {
try {
std::string SerialNumber = GetBinding(uCentral::RESTAPI::Protocol::SERIALNUMBER,"");
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER,"");
if(SerialNumber.empty()) {
BadRequest(Request, Response, "Missing SerialNumber.");
return;
}
ProvObjects::InventoryTag IT;
if(Storage()->InventoryDB().GetRecord(uCentral::RESTAPI::Protocol::SERIALNUMBER,SerialNumber,IT)) {
if(Storage()->InventoryDB().GetRecord(RESTAPI::Protocol::SERIALNUMBER,SerialNumber,IT)) {
Poco::JSON::Object Answer;
IT.to_json(Answer);
ReturnObject(Request, Answer, Response);
@@ -59,28 +59,28 @@ namespace OpenWifi{
void RESTAPI_inventory_handler::DoDelete(Poco::Net::HTTPServerRequest &Request,
Poco::Net::HTTPServerResponse &Response) {
try {
std::string SerialNumber = GetBinding(uCentral::RESTAPI::Protocol::SERIALNUMBER,"");
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER,"");
if(SerialNumber.empty()) {
BadRequest(Request, Response, "Missing SerialNumber.");
return;
}
ProvObjects::InventoryTag IT;
if(!Storage()->InventoryDB().GetRecord(uCentral::RESTAPI::Protocol::SERIALNUMBER,SerialNumber,IT)) {
if(!Storage()->InventoryDB().GetRecord(RESTAPI::Protocol::SERIALNUMBER,SerialNumber,IT)) {
NotFound(Request,Response);
return;
}
if(!IT.entity.empty())
Storage()->EntityDB().DeleteChild(uCentral::RESTAPI::Protocol::ID,IT.entity,IT.info.id);
Storage()->EntityDB().DeleteChild(RESTAPI::Protocol::ID,IT.entity,IT.info.id);
if(!IT.subEntity.empty())
Storage()->EntityDB().DeleteChild(uCentral::RESTAPI::Protocol::ID,IT.subEntity,IT.info.id);
Storage()->EntityDB().DeleteChild(RESTAPI::Protocol::ID,IT.subEntity,IT.info.id);
if(!IT.venue.empty())
Storage()->EntityDB().DeleteChild(uCentral::RESTAPI::Protocol::ID,IT.venue,IT.info.id);
Storage()->EntityDB().DeleteChild(RESTAPI::Protocol::ID,IT.venue,IT.info.id);
if(!IT.subVenue.empty())
Storage()->EntityDB().DeleteChild(uCentral::RESTAPI::Protocol::ID,IT.subVenue,IT.info.id);
Storage()->EntityDB().DeleteChild(RESTAPI::Protocol::ID,IT.subVenue,IT.info.id);
Storage()->InventoryDB().DeleteRecord(uCentral::RESTAPI::Protocol::ID, IT.info.id);
Storage()->InventoryDB().DeleteRecord(RESTAPI::Protocol::ID, IT.info.id);
OK(Request, Response);
return;
} catch(const Poco::Exception &E) {
@@ -92,13 +92,13 @@ namespace OpenWifi{
void RESTAPI_inventory_handler::DoPost(Poco::Net::HTTPServerRequest &Request,
Poco::Net::HTTPServerResponse &Response) {
try {
std::string SerialNumber = GetBinding(uCentral::RESTAPI::Protocol::SERIALNUMBER,"");
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER,"");
if(SerialNumber.empty()) {
BadRequest(Request, Response, "Missing SerialNumber.");
return;
}
if(Storage()->InventoryDB().Exists(uCentral::RESTAPI::Protocol::SERIALNUMBER,SerialNumber)) {
if(Storage()->InventoryDB().Exists(RESTAPI::Protocol::SERIALNUMBER,SerialNumber)) {
BadRequest(Request,Response, "SerialNumber: " + SerialNumber + " already exists.");
return;
}
@@ -111,22 +111,19 @@ namespace OpenWifi{
return;
}
if(IT.entity.empty()) {
BadRequest(Request, Response, "Device must be associated with a top entity.");
if(IT.entity.empty() || OpenWifi::EntityDB::IsRoot(IT.entity) || !Storage()->InventoryDB().Exists("id",IT.entity)) {
BadRequest(Request, Response, "Device must be associated with a non-root and existing entity. UUID="+IT.entity);
return;
}
IT.info.modified = IT.info.created = std::time(nullptr);
if(!IT.entity.empty() && !Storage()->InventoryDB().Exists("id",IT.entity)) {
BadRequest(Request, Response, "Entity: " + IT.entity + " does not exist.");
return;
}
if(!IT.venue.empty() && !Storage()->VenueDB().Exists("id",IT.venue)) {
BadRequest(Request, Response, "Venue: " + IT.venue + " does not exist.");
return;
}
IT.info.modified = IT.info.created = std::time(nullptr);
IT.subEntity = IT.subVenue = "";
IT.info.id = uCentral::Daemon()->CreateUUID();
IT.info.id = Daemon()->CreateUUID();
if(Storage()->InventoryDB().CreateRecord(IT)) {
Storage()->EntityDB().AddChild("id",IT.entity,IT.info.id);
@@ -148,14 +145,14 @@ namespace OpenWifi{
void RESTAPI_inventory_handler::DoPut(Poco::Net::HTTPServerRequest &Request,
Poco::Net::HTTPServerResponse &Response) {
try {
std::string SerialNumber = GetBinding(uCentral::RESTAPI::Protocol::SERIALNUMBER,"");
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER,"");
if(SerialNumber.empty()) {
BadRequest(Request, Response, "Missing SerialNumber.");
return;
}
ProvObjects::InventoryTag ExistingObject;
if(!Storage()->InventoryDB().GetRecord(uCentral::RESTAPI::Protocol::SERIALNUMBER,SerialNumber,ExistingObject)) {
if(!Storage()->InventoryDB().GetRecord(RESTAPI::Protocol::SERIALNUMBER,SerialNumber,ExistingObject)) {
NotFound(Request, Response);
return;
}
@@ -163,12 +160,7 @@ namespace OpenWifi{
Poco::JSON::Parser IncomingParser;
Poco::JSON::Object::Ptr RawObject = IncomingParser.parse(Request.stream()).extract<Poco::JSON::Object::Ptr>();
if(RawObject->has("notes")) {
uCentral::SecurityObjects::NoteInfoVec NIV;
NIV = uCentral::RESTAPI_utils::to_object_array<uCentral::SecurityObjects::NoteInfo>(RawObject->get("notes").toString());
for(auto const &i:NIV) {
uCentral::SecurityObjects::NoteInfo ii{.created=(uint64_t)std::time(nullptr), .createdBy=UserInfo_.userinfo.email, .note=i.note};
ExistingObject.info.notes.push_back(ii);
}
SecurityObjects::append_from_json(RawObject, UserInfo_.userinfo, ExistingObject.info.notes);
}
if(RawObject->has("name"))
@@ -190,6 +182,18 @@ namespace OpenWifi{
}
}
if(RawObject->has("subEntity")) {
std::string subEntity{RawObject->get("subEntity").toString()};
if(!Storage()->EntityDB().Exists("id",subEntity)) {
BadRequest(Request, Response, "subEntity association does not exist.");
return;
}
if(subEntity!=ExistingObject.entity) {
Storage()->EntityDB().DeleteChild("id", ExistingObject.subEntity, ExistingObject.info.id);
Storage()->EntityDB().AddChild("id",subEntity,ExistingObject.info.id);
}
}
if(RawObject->has("venue")) {
std::string Venue{RawObject->get("venue").toString()};
if(!Storage()->VenueDB().Exists("id",Venue)) {
@@ -203,6 +207,19 @@ namespace OpenWifi{
}
}
if(RawObject->has("subVenue")) {
std::string subVenue{RawObject->get("subVenue").toString()};
if(!Storage()->VenueDB().Exists("id",subVenue)) {
BadRequest(Request, Response, "Venue association does not exist.");
return;
}
if(subVenue!=ExistingObject.subVenue) {
if(!ExistingObject.subVenue.empty())
Storage()->VenueDB().DeleteChild("id", ExistingObject.subVenue, ExistingObject.info.id);
Storage()->VenueDB().AddChild("id",subVenue,ExistingObject.info.id);
}
}
if(RawObject->has("deviceType")) {
std::string DeviceType{RawObject->get("deviceType").toString()};
ExistingObject.deviceType = DeviceType;

View File

@@ -10,7 +10,7 @@
#include "Poco/Net/HTTPServerResponse.h"
namespace OpenWifi {
class RESTAPI_inventory_handler : public uCentral::RESTAPIHandler {
class RESTAPI_inventory_handler : public RESTAPIHandler {
public:
RESTAPI_inventory_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
: RESTAPIHandler(bindings, L,

View File

@@ -27,7 +27,7 @@ namespace OpenWifi{
try {
if(!QB_.Select.empty()) {
auto DevUIIDS = uCentral::Utils::Split(QB_.Select);
auto DevUIIDS = Utils::Split(QB_.Select);
Poco::JSON::Array Arr;
for(const auto &i:DevUIIDS) {
ProvObjects::InventoryTag E;

View File

@@ -11,7 +11,7 @@
#include "Poco/Net/HTTPServerResponse.h"
namespace OpenWifi {
class RESTAPI_inventory_list_handler : public uCentral::RESTAPIHandler {
class RESTAPI_inventory_list_handler : public RESTAPIHandler {
public:
RESTAPI_inventory_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
: RESTAPIHandler(bindings, L,

View File

@@ -10,7 +10,7 @@
#include "Poco/Net/HTTPServerResponse.h"
namespace OpenWifi {
class RESTAPI_location_handler : public uCentral::RESTAPIHandler {
class RESTAPI_location_handler : public RESTAPIHandler {
public:
RESTAPI_location_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
: RESTAPIHandler(bindings, L,

View File

@@ -10,7 +10,7 @@
#include "Poco/Net/HTTPServerResponse.h"
namespace OpenWifi {
class RESTAPI_managementPolicy_handler : public uCentral::RESTAPIHandler {
class RESTAPI_managementPolicy_handler : public RESTAPIHandler {
public:
RESTAPI_managementPolicy_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
: RESTAPIHandler(bindings, L,

View File

@@ -9,7 +9,7 @@
#ifndef UCENTRALGW_RESTAPI_PROTOCOL_H
#define UCENTRALGW_RESTAPI_PROTOCOL_H
namespace uCentral::RESTAPI::Protocol {
namespace OpenWifi::RESTAPI::Protocol {
static const char * CAPABILITIES = "capabilities";
static const char * LOGS = "logs";
static const char * HEALTHCHECKS = "healthchecks";

View File

@@ -19,7 +19,7 @@
#include "RESTAPI_inventory_list_handler.h"
#include "RESTAPI_entity_list_handler.h"
namespace uCentral {
namespace OpenWifi {
class RESTAPI_server *RESTAPI_server::instance_ = nullptr;
@@ -56,7 +56,7 @@ namespace uCentral {
Poco::Net::HTTPRequestHandler *RequestHandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest & Request) {
Logger_.debug(Poco::format("REQUEST(%s): %s %s", uCentral::Utils::FormatIPv6(Request.clientAddress().toString()), Request.getMethod(), Request.getURI()));
Logger_.debug(Poco::format("REQUEST(%s): %s %s", Utils::FormatIPv6(Request.clientAddress().toString()), Request.getMethod(), Request.getURI()));
Poco::URI uri(Request.getURI());
auto *Path = uri.getPath().c_str();

View File

@@ -13,7 +13,7 @@
#include "SubSystemServer.h"
namespace uCentral {
namespace OpenWifi {
class RESTAPI_server : public SubSystemServer {

View File

@@ -13,7 +13,7 @@
#include "Daemon.h"
#include "RESTAPI_protocol.h"
namespace uCentral {
namespace OpenWifi {
void RESTAPI_system_command::handleRequest(Poco::Net::HTTPServerRequest &Request,
Poco::Net::HTTPServerResponse &Response) {
@@ -36,19 +36,19 @@ namespace uCentral {
Poco::JSON::Parser parser;
auto Obj = parser.parse(Request.stream()).extract<Poco::JSON::Object::Ptr>();
if (Obj->has(uCentral::RESTAPI::Protocol::COMMAND)) {
auto Command = Poco::toLower(Obj->get(uCentral::RESTAPI::Protocol::COMMAND).toString());
if (Command == uCentral::RESTAPI::Protocol::SETLOGLEVEL) {
if (Obj->has(uCentral::RESTAPI::Protocol::PARAMETERS) &&
Obj->isArray(uCentral::RESTAPI::Protocol::PARAMETERS)) {
auto ParametersBlock = Obj->getArray(uCentral::RESTAPI::Protocol::PARAMETERS);
if (Obj->has(RESTAPI::Protocol::COMMAND)) {
auto Command = Poco::toLower(Obj->get(RESTAPI::Protocol::COMMAND).toString());
if (Command == RESTAPI::Protocol::SETLOGLEVEL) {
if (Obj->has(RESTAPI::Protocol::PARAMETERS) &&
Obj->isArray(RESTAPI::Protocol::PARAMETERS)) {
auto ParametersBlock = Obj->getArray(RESTAPI::Protocol::PARAMETERS);
for (const auto &i:*ParametersBlock) {
Poco::JSON::Parser pp;
auto InnerObj = pp.parse(i).extract<Poco::JSON::Object::Ptr>();
if (InnerObj->has(uCentral::RESTAPI::Protocol::TAG) &&
InnerObj->has(uCentral::RESTAPI::Protocol::VALUE)) {
auto Name = GetS(uCentral::RESTAPI::Protocol::TAG, InnerObj);
auto Value = GetS(uCentral::RESTAPI::Protocol::VALUE, InnerObj);
if (InnerObj->has(RESTAPI::Protocol::TAG) &&
InnerObj->has(RESTAPI::Protocol::VALUE)) {
auto Name = GetS(RESTAPI::Protocol::TAG, InnerObj);
auto Value = GetS(RESTAPI::Protocol::VALUE, InnerObj);
Daemon()->SetSubsystemLogLevel(Name, Value);
Logger_.information(Poco::format("Setting log level for %s at %s", Name, Value));
}
@@ -56,38 +56,38 @@ namespace uCentral {
OK(Request, Response);
return;
}
} else if (Command == uCentral::RESTAPI::Protocol::GETLOGLEVELS) {
} else if (Command == RESTAPI::Protocol::GETLOGLEVELS) {
auto CurrentLogLevels = Daemon()->GetLogLevels();
Poco::JSON::Object Result;
Poco::JSON::Array Array;
for(auto &[Name,Level]:CurrentLogLevels) {
Poco::JSON::Object Pair;
Pair.set( uCentral::RESTAPI::Protocol::TAG,Name);
Pair.set(uCentral::RESTAPI::Protocol::VALUE,Level);
Pair.set( RESTAPI::Protocol::TAG,Name);
Pair.set(RESTAPI::Protocol::VALUE,Level);
Array.add(Pair);
}
Result.set(uCentral::RESTAPI::Protocol::TAGLIST,Array);
Result.set(RESTAPI::Protocol::TAGLIST,Array);
ReturnObject(Request,Result,Response);
return;
} else if (Command == uCentral::RESTAPI::Protocol::GETLOGLEVELNAMES) {
} else if (Command == RESTAPI::Protocol::GETLOGLEVELNAMES) {
Poco::JSON::Object Result;
Poco::JSON::Array LevelNamesArray;
const Types::StringVec & LevelNames = Daemon()->GetLogLevelNames();
for(const auto &i:LevelNames)
LevelNamesArray.add(i);
Result.set(uCentral::RESTAPI::Protocol::LIST,LevelNamesArray);
Result.set(RESTAPI::Protocol::LIST,LevelNamesArray);
ReturnObject(Request,Result,Response);
return;
} else if (Command == uCentral::RESTAPI::Protocol::GETSUBSYSTEMNAMES) {
} else if (Command == RESTAPI::Protocol::GETSUBSYSTEMNAMES) {
Poco::JSON::Object Result;
Poco::JSON::Array LevelNamesArray;
const Types::StringVec & SubSystemNames = Daemon()->GetSubSystems();
for(const auto &i:SubSystemNames)
LevelNamesArray.add(i);
Result.set(uCentral::RESTAPI::Protocol::LIST,LevelNamesArray);
Result.set(RESTAPI::Protocol::LIST,LevelNamesArray);
ReturnObject(Request,Result,Response);
return;
} else if (Command == uCentral::RESTAPI::Protocol::STATS) {
} else if (Command == RESTAPI::Protocol::STATS) {
}
}

View File

@@ -11,7 +11,7 @@
#include "RESTAPI_handler.h"
namespace uCentral {
namespace OpenWifi {
class RESTAPI_system_command : public RESTAPIHandler {
public:
RESTAPI_system_command(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)

View File

@@ -4,7 +4,7 @@
#include "RESTAPI_utils.h"
namespace uCentral::RESTAPI_utils {
namespace OpenWifi::RESTAPI_utils {
void EmbedDocument(const std::string & ObjName, Poco::JSON::Object & Obj, const std::string &ObjStr) {
std::string D = ObjStr.empty() ? "{}" : ObjStr;

View File

@@ -9,10 +9,10 @@
#include "Poco/JSON/Object.h"
#include "Poco/JSON/Parser.h"
#include "Poco/Net/HTTPServerRequest.h"
#include "uCentralTypes.h"
#include "OpenWifiTypes.h"
#include "Utils.h"
namespace uCentral::RESTAPI_utils {
namespace OpenWifi::RESTAPI_utils {
void EmbedDocument(const std::string & ObjName, Poco::JSON::Object & Obj, const std::string &ObjStr);

View File

@@ -27,14 +27,22 @@ namespace OpenWifi{
}
void RESTAPI_venue_handler::DoGet(Poco::Net::HTTPServerRequest &Request,
Poco::Net::HTTPServerResponse &Response) {}
Poco::Net::HTTPServerResponse &Response) {
}
void RESTAPI_venue_handler::DoDelete(Poco::Net::HTTPServerRequest &Request,
Poco::Net::HTTPServerResponse &Response) {}
Poco::Net::HTTPServerResponse &Response) {
}
void RESTAPI_venue_handler::DoPost(Poco::Net::HTTPServerRequest &Request,
Poco::Net::HTTPServerResponse &Response) {}
Poco::Net::HTTPServerResponse &Response) {
}
void RESTAPI_venue_handler::DoPut(Poco::Net::HTTPServerRequest &Request,
Poco::Net::HTTPServerResponse &Response) {}
Poco::Net::HTTPServerResponse &Response) {
}
}

View File

@@ -10,7 +10,7 @@
#include "Poco/Net/HTTPServerResponse.h"
namespace OpenWifi {
class RESTAPI_venue_handler : public uCentral::RESTAPIHandler {
class RESTAPI_venue_handler : public RESTAPIHandler {
public:
RESTAPI_venue_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
: RESTAPIHandler(bindings, L,

View File

@@ -7,10 +7,12 @@
//
#include "Poco/Util/Application.h"
#include "Poco/Net/HTTPResponse.h"
#include "StorageService.h"
#include "Daemon.h"
#include "Utils.h"
#include "OpenAPIRequest.h"
namespace OpenWifi {
@@ -26,7 +28,7 @@ namespace OpenWifi {
Logger_.setLevel(Poco::Message::PRIO_NOTICE);
Logger_.notice("Starting.");
std::string DBType = uCentral::Daemon()->ConfigGetString("storage.type");
std::string DBType = Daemon()->ConfigGetString("storage.type");
if (DBType == "sqlite") {
DBType_ = ORM::DBType::sqlite;
@@ -58,10 +60,83 @@ namespace OpenWifi {
OpenWifi::ProvObjects::Entity R;
EntityDB_->GetRecord("id","xxx",R);
return 0;
Updater_.start(*this);
return 0;
}
void Storage::run() {
Running_ = true ;
bool FirstRun=true;
uint64_t Retry = 10000;
while(Running_) {
if(!FirstRun)
Poco::Thread::trySleep(DeviceTypes_.empty() ? 5000 : 60000);
if(!Running_)
break;
if(UpdateDeviceTypes())
FirstRun = false;
}
}
/* Get the device types... /api/v1/firmwares?deviceSet=true
{
"deviceTypes": [
"cig_wf160d",
"cig_wf188",
"cig_wf194c",
"edgecore_eap101",
"edgecore_eap102",
"edgecore_ecs4100-12ph",
"edgecore_ecw5211",
"edgecore_ecw5410",
"edgecore_oap100",
"edgecore_spw2ac1200",
"edgecore_ssw2ac2600",
"indio_um-305ac",
"linksys_e8450-ubi",
"linksys_ea8300",
"mikrotik_nand",
"mikrotik_nand-large",
"tplink_cpe210_v3",
"tplink_cpe510_v3",
"tplink_eap225_outdoor_v1",
"tplink_ec420",
"tplink_ex227",
"tplink_ex228",
"tplink_ex447",
"wallys_dr40x9"
]
}
*/
bool Storage::UpdateDeviceTypes() {
Types::StringPairVec QueryData;
QueryData.push_back(std::make_pair("deviceSet","true"));
OpenAPIRequestGet Req(uSERVICE_SECURITY,
"/api/v1/validateToken",
QueryData,
5000);
// TODO
Poco::JSON::Object::Ptr Response;
if(Req.Do(Response)==Poco::Net::HTTPResponse::HTTP_OK) {
if(Response->has("tokenInfo") && Response->has("userInfo")) {
SecurityObjects::UserInfoAndPolicy P;
P.from_json(Response);
}
return true;
}
return false;
}
void Storage::Stop() {
Running_=false;
Updater_.wakeUp();
Updater_.join();
Logger_.notice("Stopping.");
}

View File

@@ -30,7 +30,7 @@
namespace OpenWifi {
class Storage : public uCentral::SubSystemServer {
class Storage : public SubSystemServer, Poco::Runnable {
public:
static Storage *instance() {
if (instance_ == nullptr) {
@@ -58,6 +58,10 @@ namespace OpenWifi {
bool Validate(const Poco::URI::QueryParameters &P, std::string &Error);
inline bool IsAcceptableDeviceType(const std::string &D) const { return (DeviceTypes_.find(D)!=DeviceTypes_.end());};
void run() override final;
private:
static Storage *instance_;
std::unique_ptr<Poco::Data::SessionPool> Pool_= nullptr;
@@ -74,6 +78,11 @@ namespace OpenWifi {
std::unique_ptr<OpenWifi::InventoryDB> InventoryDB_;
std::unique_ptr<OpenWifi::ManagementRoleDB> RolesDB_;
Poco::Thread Updater_;
std::set<std::string> DeviceTypes_;
std::atomic_bool Running_=false;
bool UpdateDeviceTypes();
Storage() noexcept;
};

View File

@@ -19,7 +19,7 @@
#include "Daemon.h"
namespace uCentral {
namespace OpenWifi {
SubSystemServer::SubSystemServer(std::string Name, const std::string &LoggingPrefix,
std::string SubSystemConfigPrefix)
: Name_(std::move(Name)), Logger_(Poco::Logger::get(LoggingPrefix)),

View File

@@ -23,7 +23,7 @@
using SubMutex = std::recursive_mutex;
using SubMutexGuard = std::lock_guard<SubMutex>;
namespace uCentral {
namespace OpenWifi {
class PropertiesFileServerEntry {
public:
PropertiesFileServerEntry(std::string Address, uint32_t port, std::string Key_file,

View File

@@ -28,7 +28,7 @@
#include "uCentralProtocol.h"
#include "Daemon.h"
namespace uCentral::Utils {
namespace OpenWifi::Utils {
[[nodiscard]] bool ValidSerialNumber(const std::string &Serial) {
return ((Serial.size() < uCentralProtocol::SERIAL_NUMBER_LENGTH) &&

View File

@@ -18,11 +18,11 @@
#include "Poco/Net/IPAddress.h"
#include "Poco/String.h"
#include "Poco/File.h"
#include "uCentralTypes.h"
#include "OpenWifiTypes.h"
#define DBGLINE { std::cout << __FILE__ << ":" << __func__ << ":" << __LINE__ << std::endl; };
namespace uCentral::Utils {
namespace OpenWifi::Utils {
enum MediaTypeEncodings {
PLAIN,

View File

@@ -4,7 +4,7 @@
#include "storage_contact.h"
#include "Utils.h"
#include "uCentralTypes.h"
#include "OpenWifiTypes.h"
#include "RESTAPI_utils.h"
#include "RESTAPI_SecurityObjects.h"
@@ -50,7 +50,7 @@ template<> void ORM::DB< OpenWifi::ContactDBRecordType, OpenWifi::ProvObjects
Out.info.id = In.get<0>();
Out.info.name = In.get<1>();
Out.info.description = In.get<2>();
Out.info.notes = uCentral::RESTAPI_utils::to_object_array<uCentral::SecurityObjects::NoteInfo>(In.get<3>());
Out.info.notes = OpenWifi::RESTAPI_utils::to_object_array<OpenWifi::SecurityObjects::NoteInfo>(In.get<3>());
Out.info.created = In.get<4>();
Out.info.modified = In.get<5>();
@@ -61,20 +61,20 @@ template<> void ORM::DB< OpenWifi::ContactDBRecordType, OpenWifi::ProvObjects
Out.lastname = In.get<10>();
Out.initials = In.get<11>();
Out.visual = In.get<12>();
uCentral::Types::from_string(In.get<13>(), Out.mobiles);
uCentral::Types::from_string(In.get<14>(), Out.phones);
OpenWifi::Types::from_string(In.get<13>(), Out.mobiles);
OpenWifi::Types::from_string(In.get<14>(), Out.phones);
Out.primaryEmail = In.get<15>();
Out.secondaryEmail = In.get<16>();
Out.accessPIN = In.get<17>();
uCentral::Types::from_string(In.get<18>(), Out.venues);
uCentral::Types::from_string(In.get<19>(), Out.entities);
OpenWifi::Types::from_string(In.get<18>(), Out.venues);
OpenWifi::Types::from_string(In.get<19>(), Out.entities);
}
template<> void ORM::DB< OpenWifi::ContactDBRecordType, OpenWifi::ProvObjects::Contact>::Convert(OpenWifi::ProvObjects::Contact &In, OpenWifi::ContactDBRecordType &Out) {
Out.set<0>(In.info.id);
Out.set<1>(In.info.name);
Out.set<2>(In.info.description);
Out.set<3>(uCentral::RESTAPI_utils::to_string(In.info.notes));
Out.set<3>(OpenWifi::RESTAPI_utils::to_string(In.info.notes));
Out.set<4>(In.info.created);
Out.set<5>(In.info.modified);
Out.set<6>(to_string(In.type));
@@ -84,11 +84,11 @@ template<> void ORM::DB< OpenWifi::ContactDBRecordType, OpenWifi::ProvObjects
Out.set<10>(In.lastname);
Out.set<11>(In.initials);
Out.set<12>(In.visual);
Out.set<13>(uCentral::Types::to_string(In.mobiles));
Out.set<14>(uCentral::Types::to_string(In.phones));
Out.set<13>(OpenWifi::Types::to_string(In.mobiles));
Out.set<14>(OpenWifi::Types::to_string(In.phones));
Out.set<15>(In.primaryEmail);
Out.set<16>(In.secondaryEmail);
Out.set<17>(In.accessPIN);
Out.set<18>(uCentral::Types::to_string(In.venues));
Out.set<19>(uCentral::Types::to_string(In.entities));
Out.set<18>(OpenWifi::Types::to_string(In.venues));
Out.set<19>(OpenWifi::Types::to_string(In.entities));
}

View File

@@ -4,12 +4,14 @@
#include "storage_entity.h"
#include "Utils.h"
#include "uCentralTypes.h"
#include "OpenWifiTypes.h"
#include "RESTAPI_utils.h"
#include "RESTAPI_SecurityObjects.h"
namespace OpenWifi {
const std::string EntityDB::RootUUID_{"0000-0000-0000"};
static ORM::FieldVec EntityDB_Fields{
// object info
ORM::Field{"id",64, true},
@@ -54,28 +56,28 @@ template<> void ORM::DB< OpenWifi::EntityDBRecordType, OpenWifi::ProvObjects:
Out.info.id = In.get<0>();
Out.info.name = In.get<1>();
Out.info.description = In.get<2>();
Out.info.notes = uCentral::RESTAPI_utils::to_object_array<uCentral::SecurityObjects::NoteInfo>(In.get<3>());
Out.info.notes = OpenWifi::RESTAPI_utils::to_object_array<OpenWifi::SecurityObjects::NoteInfo>(In.get<3>());
Out.info.created = In.get<4>();
Out.info.modified = In.get<5>();
Out.parent = In.get<6>();
uCentral::Types::from_string(In.get<7>(), Out.children);
uCentral::Types::from_string(In.get<8>(), Out.contacts);
uCentral::Types::from_string(In.get<9>(), Out.locations);
OpenWifi::Types::from_string(In.get<7>(), Out.children);
OpenWifi::Types::from_string(In.get<8>(), Out.contacts);
OpenWifi::Types::from_string(In.get<9>(), Out.locations);
Out.managementPolicy = In.get<10>();
uCentral::Types::from_string(In.get<11>(), Out.venues);
OpenWifi::Types::from_string(In.get<11>(), Out.venues);
}
template<> void ORM::DB< OpenWifi::EntityDBRecordType, OpenWifi::ProvObjects::Entity>::Convert(OpenWifi::ProvObjects::Entity &In, OpenWifi::EntityDBRecordType &Out) {
Out.set<0>(In.info.id);
Out.set<1>(In.info.name);
Out.set<2>(In.info.description);
Out.set<3>(uCentral::RESTAPI_utils::to_string(In.info.notes));
Out.set<3>(OpenWifi::RESTAPI_utils::to_string(In.info.notes));
Out.set<4>(In.info.created);
Out.set<5>(In.info.modified);
Out.set<6>(In.parent);
Out.set<7>(uCentral::Types::to_string(In.children));
Out.set<8>(uCentral::Types::to_string(In.contacts));
Out.set<9>(uCentral::Types::to_string(In.locations));
Out.set<7>(OpenWifi::Types::to_string(In.children));
Out.set<8>(OpenWifi::Types::to_string(In.contacts));
Out.set<9>(OpenWifi::Types::to_string(In.locations));
Out.set<10>(In.managementPolicy);
Out.set<11>(uCentral::Types::to_string(In.venues));
Out.set<11>(OpenWifi::Types::to_string(In.venues));
}

View File

@@ -27,9 +27,11 @@ namespace OpenWifi {
class EntityDB : public ORM::DB<EntityDBRecordType, ProvObjects::Entity> {
public:
static const std::string RootUUID_;
EntityDB( ORM::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
inline bool RootExists() const { return RootExists_; };
static inline const std::string RootUUID() { return "0000-0000-0000"; }
static inline bool IsRoot(const std::string &UUID) { return (UUID == RootUUID_); }
static inline const std::string RootUUID() { return RootUUID_; }
bool CheckForRoot();
private:
bool RootExists_=false;

View File

@@ -4,7 +4,7 @@
#include "storage_inventory.h"
#include "Utils.h"
#include "uCentralTypes.h"
#include "OpenWifiTypes.h"
#include "RESTAPI_utils.h"
#include "RESTAPI_SecurityObjects.h"
@@ -47,7 +47,7 @@ template<> void ORM::DB< OpenWifi::InventoryDBRecordType, OpenWifi::ProvObjec
Out.info.id = In.get<0>();
Out.info.name = In.get<1>();
Out.info.description = In.get<2>();
Out.info.notes = uCentral::RESTAPI_utils::to_object_array<uCentral::SecurityObjects::NoteInfo>(In.get<3>());
Out.info.notes = OpenWifi::RESTAPI_utils::to_object_array<OpenWifi::SecurityObjects::NoteInfo>(In.get<3>());
Out.info.created = In.get<4>();
Out.info.modified = In.get<5>();
Out.serialNumber = In.get<6>();
@@ -63,7 +63,7 @@ template<> void ORM::DB< OpenWifi::InventoryDBRecordType, OpenWifi::ProvObjec
Out.set<0>(In.info.id);
Out.set<1>(In.info.name);
Out.set<2>(In.info.description);
Out.set<3>(uCentral::RESTAPI_utils::to_string(In.info.notes));
Out.set<3>(OpenWifi::RESTAPI_utils::to_string(In.info.notes));
Out.set<4>(In.info.created);
Out.set<5>(In.info.modified);
Out.set<6>(In.serialNumber);

View File

@@ -4,7 +4,7 @@
#include "storage_location.h"
#include "Utils.h"
#include "uCentralTypes.h"
#include "OpenWifiTypes.h"
#include "RESTAPI_utils.h"
#include "RESTAPI_SecurityObjects.h"
@@ -44,44 +44,45 @@ namespace OpenWifi {
}
template<> void ORM::DB< OpenWifi::LocationDBRecordType, OpenWifi::ProvObjects::Location>::Convert(OpenWifi::LocationDBRecordType &In, OpenWifi::ProvObjects::Location &Out) {
template<> void ORM::DB<OpenWifi::LocationDBRecordType, OpenWifi::ProvObjects::Location>::Convert(OpenWifi::LocationDBRecordType &In, OpenWifi::ProvObjects::Location &Out) {
Out.info.id = In.get<0>();
Out.info.name = In.get<1>();
Out.info.description = In.get<2>();
Out.info.notes = uCentral::RESTAPI_utils::to_object_array<uCentral::SecurityObjects::NoteInfo>(In.get<3>());
Out.info.notes = OpenWifi::RESTAPI_utils::to_object_array<OpenWifi::SecurityObjects::NoteInfo>(In.get<3>());
Out.info.created = In.get<4>();
Out.info.modified = In.get<5>();
Out.type = OpenWifi::ProvObjects::location_from_string(In.get<6>());
Out.buildingName = In.get<7>();
uCentral::Types::from_string(In.get<8>(), Out.addressLines);
OpenWifi::Types::from_string(In.get<8>(), Out.addressLines);
Out.city = In.get<9>();
Out.state = In.get<10>();
Out.postal = In.get<11>();
Out.country = In.get<12>();
uCentral::Types::from_string(In.get<13>(), Out.phones);
uCentral::Types::from_string(In.get<14>(), Out.mobiles);
uCentral::Types::from_string(In.get<15>(), Out.venues);
uCentral::Types::from_string(In.get<16>(), Out.entities);
OpenWifi::Types::from_string(In.get<13>(), Out.phones);
OpenWifi::Types::from_string(In.get<14>(), Out.mobiles);
OpenWifi::Types::from_string(In.get<15>(), Out.venues);
OpenWifi::Types::from_string(In.get<16>(), Out.entities);
Out.geoCode = In.get<17>();
}
template<> void ORM::DB< OpenWifi::LocationDBRecordType, OpenWifi::ProvObjects::Location>::Convert(OpenWifi::ProvObjects::Location &In, OpenWifi::LocationDBRecordType &Out) {
template<> void ::ORM::DB<OpenWifi::LocationDBRecordType, OpenWifi::ProvObjects::Location>::Convert(OpenWifi::ProvObjects::Location &In, OpenWifi::LocationDBRecordType &Out) {
Out.set<0>(In.info.id);
Out.set<1>(In.info.name);
Out.set<2>(In.info.description);
Out.set<3>(uCentral::RESTAPI_utils::to_string(In.info.notes));
Out.set<3>(OpenWifi::RESTAPI_utils::to_string(In.info.notes));
Out.set<4>(In.info.created);
Out.set<5>(In.info.modified);
Out.set<6>(OpenWifi::ProvObjects::to_string(In.type));
Out.set<7>(In.buildingName);
Out.set<8>(uCentral::Types::to_string(In.addressLines));
Out.set<8>(OpenWifi::Types::to_string(In.addressLines));
Out.set<9>(In.city);
Out.set<10>(In.state);
Out.set<11>(In.postal);
Out.set<12>(In.country);
Out.set<13>(uCentral::Types::to_string(In.phones));
Out.set<14>(uCentral::Types::to_string(In.mobiles));
Out.set<15>(uCentral::Types::to_string(In.venues));
Out.set<16>(uCentral::Types::to_string(In.entities));
Out.set<13>(OpenWifi::Types::to_string(In.phones));
Out.set<14>(OpenWifi::Types::to_string(In.mobiles));
Out.set<15>(OpenWifi::Types::to_string(In.venues));
Out.set<16>(OpenWifi::Types::to_string(In.entities));
Out.set<17>(In.geoCode);
}

View File

@@ -3,7 +3,7 @@
//
#include "storage_management_roles.h"
#include "uCentralTypes.h"
#include "OpenWifiTypes.h"
#include "RESTAPI_utils.h"
#include "RESTAPI_SecurityObjects.h"
@@ -37,20 +37,20 @@ template<> void ORM::DB< OpenWifi::ManagementRoleDBRecordType, OpenWifi::Prov
Out.info.id = In.get<0>();
Out.info.name = In.get<1>();
Out.info.description = In.get<2>();
Out.info.notes = uCentral::RESTAPI_utils::to_object_array<uCentral::SecurityObjects::NoteInfo>(In.get<3>());
Out.info.notes = OpenWifi::RESTAPI_utils::to_object_array<OpenWifi::SecurityObjects::NoteInfo>(In.get<3>());
Out.info.created = In.get<4>();
Out.info.modified = In.get<5>();
Out.managementPolicy = In.get<6>();
Out.users = uCentral::RESTAPI_utils::to_object_array<OpenWifi::ProvObjects::UserInfoDigest>(In.get<7>());
Out.users = OpenWifi::RESTAPI_utils::to_object_array<OpenWifi::ProvObjects::UserInfoDigest>(In.get<7>());
}
template<> void ORM::DB< OpenWifi::ManagementRoleDBRecordType, OpenWifi::ProvObjects::ManagementRole>::Convert(OpenWifi::ProvObjects::ManagementRole &In, OpenWifi::ManagementRoleDBRecordType &Out) {
Out.set<0>(In.info.id);
Out.set<1>(In.info.name);
Out.set<2>(In.info.description);
Out.set<3>(uCentral::RESTAPI_utils::to_string(In.info.notes));
Out.set<3>(OpenWifi::RESTAPI_utils::to_string(In.info.notes));
Out.set<4>(In.info.created);
Out.set<5>(In.info.modified);
Out.set<6>(In.managementPolicy);
Out.set<7>(uCentral::RESTAPI_utils::to_string(In.users));
Out.set<7>(OpenWifi::RESTAPI_utils::to_string(In.users));
}

View File

@@ -12,19 +12,19 @@
namespace OpenWifi {
#ifdef SMALL_BUILD
int Service::Setup_MySQL() { uCentral::instance()->exit(Poco::Util::Application::EXIT_CONFIG);}
int Service::Setup_MySQL() { instance()->exit(Poco::Util::Application::EXIT_CONFIG);}
#else
int Storage::Setup_MySQL() {
Logger_.notice("MySQL Storage enabled.");
auto NumSessions = uCentral::Daemon()->ConfigGetInt("storage.type.mysql.maxsessions", 64);
auto IdleTime = uCentral::Daemon()->ConfigGetInt("storage.type.mysql.idletime", 60);
auto Host = uCentral::Daemon()->ConfigGetString("storage.type.mysql.host");
auto Username = uCentral::Daemon()->ConfigGetString("storage.type.mysql.username");
auto Password = uCentral::Daemon()->ConfigGetString("storage.type.mysql.password");
auto Database = uCentral::Daemon()->ConfigGetString("storage.type.mysql.database");
auto Port = uCentral::Daemon()->ConfigGetString("storage.type.mysql.port");
auto NumSessions = Daemon()->ConfigGetInt("storage.type.mysql.maxsessions", 64);
auto IdleTime = Daemon()->ConfigGetInt("storage.type.mysql.idletime", 60);
auto Host = Daemon()->ConfigGetString("storage.type.mysql.host");
auto Username = Daemon()->ConfigGetString("storage.type.mysql.username");
auto Password = Daemon()->ConfigGetString("storage.type.mysql.password");
auto Database = Daemon()->ConfigGetString("storage.type.mysql.database");
auto Port = Daemon()->ConfigGetString("storage.type.mysql.port");
std::string ConnectionStr =
"host=" + Host +

View File

@@ -12,19 +12,19 @@
namespace OpenWifi {
#ifdef SMALL_BUILD
int Service::Setup_PostgreSQL() { uCentral::instance()->exit(Poco::Util::Application::EXIT_CONFIG);}
int Service::Setup_PostgreSQL() { instance()->exit(Poco::Util::Application::EXIT_CONFIG);}
#else
int Storage::Setup_PostgreSQL() {
Logger_.notice("PostgreSQL Storage enabled.");
auto NumSessions = uCentral::Daemon()->ConfigGetInt("storage.type.postgresql.maxsessions", 64);
auto IdleTime = uCentral::Daemon()->ConfigGetInt("storage.type.postgresql.idletime", 60);
auto Host = uCentral::Daemon()->ConfigGetString("storage.type.postgresql.host");
auto Username = uCentral::Daemon()->ConfigGetString("storage.type.postgresql.username");
auto Password = uCentral::Daemon()->ConfigGetString("storage.type.postgresql.password");
auto Database = uCentral::Daemon()->ConfigGetString("storage.type.postgresql.database");
auto Port = uCentral::Daemon()->ConfigGetString("storage.type.postgresql.port");
auto ConnectionTimeout = uCentral::Daemon()->ConfigGetString("storage.type.postgresql.connectiontimeout");
auto NumSessions = Daemon()->ConfigGetInt("storage.type.postgresql.maxsessions", 64);
auto IdleTime = Daemon()->ConfigGetInt("storage.type.postgresql.idletime", 60);
auto Host = Daemon()->ConfigGetString("storage.type.postgresql.host");
auto Username = Daemon()->ConfigGetString("storage.type.postgresql.username");
auto Password = Daemon()->ConfigGetString("storage.type.postgresql.password");
auto Database = Daemon()->ConfigGetString("storage.type.postgresql.database");
auto Port = Daemon()->ConfigGetString("storage.type.postgresql.port");
auto ConnectionTimeout = Daemon()->ConfigGetString("storage.type.postgresql.connectiontimeout");
std::string ConnectionStr =
"host=" + Host +

View File

@@ -4,7 +4,7 @@
#include "storage_policies.h"
#include "Utils.h"
#include "uCentralTypes.h"
#include "OpenWifiTypes.h"
#include "RESTAPI_utils.h"
#include "RESTAPI_SecurityObjects.h"
@@ -37,18 +37,18 @@ template<> void ORM::DB< OpenWifi::PolicyDBRecordType, OpenWifi::ProvObjects:
Out.info.id = In.get<0>();
Out.info.name = In.get<1>();
Out.info.description = In.get<2>();
Out.info.notes = uCentral::RESTAPI_utils::to_object_array<uCentral::SecurityObjects::NoteInfo>(In.get<3>());
Out.info.notes = OpenWifi::RESTAPI_utils::to_object_array<OpenWifi::SecurityObjects::NoteInfo>(In.get<3>());
Out.info.created = In.get<4>();
Out.info.modified = In.get<5>();
Out.entries = uCentral::RESTAPI_utils::to_object_array<OpenWifi::ProvObjects::ManagementPolicyEntry>(In.get<6>());
Out.entries = OpenWifi::RESTAPI_utils::to_object_array<OpenWifi::ProvObjects::ManagementPolicyEntry>(In.get<6>());
}
template<> void ORM::DB< OpenWifi::PolicyDBRecordType, OpenWifi::ProvObjects::ManagementPolicy>::Convert(OpenWifi::ProvObjects::ManagementPolicy &In, OpenWifi::PolicyDBRecordType &Out) {
Out.set<0>(In.info.id);
Out.set<1>(In.info.name);
Out.set<2>(In.info.description);
Out.set<3>(uCentral::RESTAPI_utils::to_string(In.info.notes));
Out.set<3>(OpenWifi::RESTAPI_utils::to_string(In.info.notes));
Out.set<4>(In.info.created);
Out.set<5>(In.info.modified);
Out.set<6>(uCentral::RESTAPI_utils::to_string(In.entries));
Out.set<6>(OpenWifi::RESTAPI_utils::to_string(In.entries));
}

View File

@@ -13,9 +13,9 @@ namespace OpenWifi {
int Storage::Setup_SQLite() {
Logger_.notice("SQLite Storage enabled.");
auto DBName = uCentral::Daemon()->DataDir() + "/" + uCentral::Daemon()->ConfigGetString("storage.type.sqlite.db");
auto NumSessions = uCentral::Daemon()->ConfigGetInt("storage.type.sqlite.maxsessions", 64);
auto IdleTime = uCentral::Daemon()->ConfigGetInt("storage.type.sqlite.idletime", 60);
auto DBName = Daemon()->DataDir() + "/" + Daemon()->ConfigGetString("storage.type.sqlite.db");
auto NumSessions = Daemon()->ConfigGetInt("storage.type.sqlite.maxsessions", 64);
auto IdleTime = Daemon()->ConfigGetInt("storage.type.sqlite.idletime", 60);
SQLiteConn_ = std::make_unique<Poco::Data::SQLite::Connector>();
SQLiteConn_->registerConnector();

View File

@@ -3,7 +3,7 @@
//
#include "storage_venue.h"
#include "uCentralTypes.h"
#include "OpenWifiTypes.h"
#include "RESTAPI_utils.h"
#include "RESTAPI_SecurityObjects.h"
@@ -42,14 +42,14 @@ template<> void ORM::DB< OpenWifi::VenueDBRecordType, OpenWifi::ProvObjects::
Out.info.id = In.get<0>();
Out.info.name = In.get<1>();
Out.info.description = In.get<2>();
Out.info.notes = uCentral::RESTAPI_utils::to_object_array<uCentral::SecurityObjects::NoteInfo>(In.get<3>());
Out.info.notes = OpenWifi::RESTAPI_utils::to_object_array<OpenWifi::SecurityObjects::NoteInfo>(In.get<3>());
Out.info.created = In.get<4>();
Out.info.modified = In.get<5>();
Out.entity = In.get<6>();
Out.parent = In.get<7>();
uCentral::Types::from_string(In.get<8>(), Out.children);
uCentral::Types::from_string(In.get<9>(), Out.devices);
Out.topology = uCentral::RESTAPI_utils::to_object_array<OpenWifi::ProvObjects::DiGraphEntry>(In.get<10>());
OpenWifi::Types::from_string(In.get<8>(), Out.children);
OpenWifi::Types::from_string(In.get<9>(), Out.devices);
Out.topology = OpenWifi::RESTAPI_utils::to_object_array<OpenWifi::ProvObjects::DiGraphEntry>(In.get<10>());
Out.design = In.get<11>();
}
@@ -57,13 +57,13 @@ template<> void ORM::DB< OpenWifi::VenueDBRecordType, OpenWifi::ProvObjects::
Out.set<0>(In.info.id);
Out.set<1>(In.info.name);
Out.set<2>(In.info.description);
Out.set<3>(uCentral::RESTAPI_utils::to_string(In.info.notes));
Out.set<3>(OpenWifi::RESTAPI_utils::to_string(In.info.notes));
Out.set<4>(In.info.created);
Out.set<5>(In.info.modified);
Out.set<6>(In.entity);
Out.set<7>(In.parent);
Out.set<8>(uCentral::Types::to_string(In.children));
Out.set<9>(uCentral::Types::to_string(In.devices));
Out.set<10>(uCentral::RESTAPI_utils::to_string(In.topology));
Out.set<8>(OpenWifi::Types::to_string(In.children));
Out.set<9>(OpenWifi::Types::to_string(In.devices));
Out.set<10>(OpenWifi::RESTAPI_utils::to_string(In.topology));
Out.set<11>(In.design);
}

View File

@@ -11,7 +11,7 @@
#include "Poco/String.h"
namespace uCentral::uCentralProtocol {
namespace OpenWifi::uCentralProtocol {
const int SERIAL_NUMBER_LENGTH = 30;