mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-29 17:52:28 +00:00
Initial checkins
This commit is contained in:
@@ -72,7 +72,7 @@ add_executable(owprov
|
|||||||
src/storage_pgql.cpp src/storage_mysql.cpp src/storage_sqlite.cpp
|
src/storage_pgql.cpp src/storage_mysql.cpp src/storage_sqlite.cpp
|
||||||
src/storage_entity.cpp src/storage_entity.h
|
src/storage_entity.cpp src/storage_entity.h
|
||||||
src/storage_policies.cpp src/storage_policies.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_venue.cpp src/storage_venue.h
|
||||||
src/storage_location.cpp src/storage_location.h
|
src/storage_location.cpp src/storage_location.h
|
||||||
src/storage_contact.cpp src/storage_contact.h
|
src/storage_contact.cpp src/storage_contact.h
|
||||||
|
|||||||
30
README.md
30
README.md
@@ -4,11 +4,33 @@
|
|||||||
It's UUID value is 0000-0000-0000. Its parent entity must be empty.
|
It's UUID value is 0000-0000-0000. Its parent entity must be empty.
|
||||||
|
|
||||||
## Entity
|
## 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
|
## Management policy
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include "Daemon.h"
|
#include "Daemon.h"
|
||||||
#include "SubSystemServer.h"
|
#include "SubSystemServer.h"
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class ALBRequestHandler: public Poco::Net::HTTPRequestHandler
|
class ALBRequestHandler: public Poco::Net::HTTPRequestHandler
|
||||||
/// Return a HTML document with the current date and time.
|
/// Return a HTML document with the current date and time.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include "Daemon.h"
|
#include "Daemon.h"
|
||||||
#include "OpenAPIRequest.h"
|
#include "OpenAPIRequest.h"
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
class AuthClient * AuthClient::instance_ = nullptr;
|
class AuthClient * AuthClient::instance_ = nullptr;
|
||||||
|
|
||||||
int AuthClient::Start() {
|
int AuthClient::Start() {
|
||||||
@@ -38,7 +38,7 @@ namespace uCentral {
|
|||||||
} else {
|
} else {
|
||||||
Types::StringPairVec QueryData;
|
Types::StringPairVec QueryData;
|
||||||
QueryData.push_back(std::make_pair("token",SessionToken));
|
QueryData.push_back(std::make_pair("token",SessionToken));
|
||||||
OpenAPIRequestGet Req(uSERVICE_SECURITY,
|
OpenAPIRequestGet Req( uSERVICE_SECURITY,
|
||||||
"/api/v1/validateToken",
|
"/api/v1/validateToken",
|
||||||
QueryData,
|
QueryData,
|
||||||
5000);
|
5000);
|
||||||
@@ -56,4 +56,33 @@ namespace uCentral {
|
|||||||
}
|
}
|
||||||
return false;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -13,9 +13,9 @@
|
|||||||
#include "RESTAPI_SecurityObjects.h"
|
#include "RESTAPI_SecurityObjects.h"
|
||||||
#include "SubSystemServer.h"
|
#include "SubSystemServer.h"
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class AuthClient : public SubSystemServer {
|
class AuthClient : public SubSystemServer {
|
||||||
public:
|
public:
|
||||||
explicit AuthClient() noexcept:
|
explicit AuthClient() noexcept:
|
||||||
SubSystemServer("Authentication", "AUTH-CLNT", "authentication")
|
SubSystemServer("Authentication", "AUTH-CLNT", "authentication")
|
||||||
@@ -31,12 +31,12 @@ namespace uCentral {
|
|||||||
|
|
||||||
int Start() override;
|
int Start() override;
|
||||||
void Stop() 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);
|
void RemovedCachedToken(const std::string &Token);
|
||||||
|
bool IsTokenAuthorized(const std::string &Token, SecurityObjects::UserInfoAndPolicy & UInfo);
|
||||||
private:
|
private:
|
||||||
static AuthClient *instance_;
|
static AuthClient *instance_;
|
||||||
SecurityObjects::UserInfoCache UserCache_;
|
OpenWifi::SecurityObjects::UserInfoCache UserCache_;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline AuthClient * AuthClient() { return AuthClient::instance(); }
|
inline AuthClient * AuthClient() { return AuthClient::instance(); }
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#include "RESTAPI_server.h"
|
#include "RESTAPI_server.h"
|
||||||
#include "RESTAPI_InternalServer.h"
|
#include "RESTAPI_InternalServer.h"
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
class Daemon *Daemon::instance_ = nullptr;
|
class Daemon *Daemon::instance_ = nullptr;
|
||||||
|
|
||||||
class Daemon *Daemon::instance() {
|
class Daemon *Daemon::instance() {
|
||||||
@@ -46,7 +46,7 @@ namespace uCentral {
|
|||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
try {
|
try {
|
||||||
auto App = uCentral::Daemon::instance();
|
auto App = OpenWifi::Daemon::instance();
|
||||||
auto ExitCode = App->run(argc, argv);
|
auto ExitCode = App->run(argc, argv);
|
||||||
delete App;
|
delete App;
|
||||||
|
|
||||||
|
|||||||
@@ -27,9 +27,9 @@
|
|||||||
|
|
||||||
#include "Dashboard.h"
|
#include "Dashboard.h"
|
||||||
#include "MicroService.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_PROPERTIES_FILENAME = "owprov.properties";
|
||||||
static const char * vDAEMON_ROOT_ENV_VAR = "OWPROV_ROOT";
|
static const char * vDAEMON_ROOT_ENV_VAR = "OWPROV_ROOT";
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#ifndef UCENTRALGW_DASHBOARD_H
|
#ifndef UCENTRALGW_DASHBOARD_H
|
||||||
#define UCENTRALGW_DASHBOARD_H
|
#define UCENTRALGW_DASHBOARD_H
|
||||||
|
|
||||||
#include "uCentralTypes.h"
|
#include "OpenWifiTypes.h"
|
||||||
#include "RESTAPI_ProvObjects.h"
|
#include "RESTAPI_ProvObjects.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#include "Daemon.h"
|
#include "Daemon.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class KafkaManager *KafkaManager::instance_ = nullptr;
|
class KafkaManager *KafkaManager::instance_ = nullptr;
|
||||||
|
|
||||||
|
|||||||
@@ -13,11 +13,11 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "SubSystemServer.h"
|
#include "SubSystemServer.h"
|
||||||
#include "uCentralTypes.h"
|
#include "OpenWifiTypes.h"
|
||||||
|
|
||||||
#include "cppkafka/cppkafka.h"
|
#include "cppkafka/cppkafka.h"
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class KafkaManager : public SubSystemServer {
|
class KafkaManager : public SubSystemServer {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#ifndef UCENTRALGW_KAFKA_TOPICS_H
|
#ifndef UCENTRALGW_KAFKA_TOPICS_H
|
||||||
#define 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 HEALTHCHECK{"healthcheck"};
|
||||||
static const std::string STATE{"state"};
|
static const std::string STATE{"state"};
|
||||||
static const std::string CONNECTION{"connection"};
|
static const std::string CONNECTION{"connection"};
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
#include "AuthClient.h"
|
#include "AuthClient.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
|
|
||||||
void MyErrorHandler::exception(const Poco::Exception & E) {
|
void MyErrorHandler::exception(const Poco::Exception & E) {
|
||||||
Poco::Thread * CurrentThread = Poco::Thread::current();
|
Poco::Thread * CurrentThread = Poco::Thread::current();
|
||||||
|
|||||||
@@ -24,10 +24,10 @@
|
|||||||
#include "Poco/Net/HTTPServerRequest.h"
|
#include "Poco/Net/HTTPServerRequest.h"
|
||||||
#include "Poco/Process.h"
|
#include "Poco/Process.h"
|
||||||
|
|
||||||
#include "uCentralTypes.h"
|
#include "OpenWifiTypes.h"
|
||||||
#include "SubSystemServer.h"
|
#include "SubSystemServer.h"
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
|
|
||||||
static const std::string uSERVICE_SECURITY{"ucentralsec"};
|
static const std::string uSERVICE_SECURITY{"ucentralsec"};
|
||||||
static const std::string uSERVICE_GATEWAY{"ucentralgw"};
|
static const std::string uSERVICE_GATEWAY{"ucentralgw"};
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "Daemon.h"
|
#include "Daemon.h"
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
|
|
||||||
OpenAPIRequestGet::OpenAPIRequestGet( const std::string & ServiceType,
|
OpenAPIRequestGet::OpenAPIRequestGet( const std::string & ServiceType,
|
||||||
const std::string & EndPoint,
|
const std::string & EndPoint,
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
|
|
||||||
#include "Poco/JSON/Object.h"
|
#include "Poco/JSON/Object.h"
|
||||||
|
|
||||||
#include "uCentralTypes.h"
|
#include "OpenWifiTypes.h"
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class OpenAPIRequestGet {
|
class OpenAPIRequestGet {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include "Poco/StringTokenizer.h"
|
#include "Poco/StringTokenizer.h"
|
||||||
|
|
||||||
namespace uCentral::Types {
|
namespace OpenWifi::Types {
|
||||||
typedef std::pair<std::string,std::string> StringPair;
|
typedef std::pair<std::string,std::string> StringPair;
|
||||||
typedef std::vector<StringPair> StringPairVec;
|
typedef std::vector<StringPair> StringPairVec;
|
||||||
typedef std::queue<StringPair> StringPairQueue;
|
typedef std::queue<StringPair> StringPairQueue;
|
||||||
@@ -33,12 +33,12 @@ namespace uCentral::Types {
|
|||||||
typedef std::string UUID_t;
|
typedef std::string UUID_t;
|
||||||
typedef std::vector<UUID_t> UUIDvec_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);
|
auto it = M.find(S);
|
||||||
if(it==M.end())
|
if(it==M.end())
|
||||||
M[S]=1;
|
M[S] = Increment;
|
||||||
else
|
else
|
||||||
it->second += 1;
|
it->second += Increment;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string to_string( const StringVec &V) {
|
inline std::string to_string( const StringVec &V) {
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class RESTAPI_InternalServer *RESTAPI_InternalServer::instance_ = nullptr;
|
class RESTAPI_InternalServer *RESTAPI_InternalServer::instance_ = nullptr;
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ namespace uCentral {
|
|||||||
Poco::Net::HTTPRequestHandler *InternalRequestHandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest & Request) {
|
Poco::Net::HTTPRequestHandler *InternalRequestHandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest & Request) {
|
||||||
|
|
||||||
Logger_.debug(
|
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()));
|
Request.getMethod(), Request.getURI()));
|
||||||
|
|
||||||
Poco::URI uri(Request.getURI());
|
Poco::URI uri(Request.getURI());
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#include "Poco/Net/HTTPServerRequest.h"
|
#include "Poco/Net/HTTPServerRequest.h"
|
||||||
#include "Poco/Net/NetException.h"
|
#include "Poco/Net/NetException.h"
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class RESTAPI_InternalServer : public SubSystemServer {
|
class RESTAPI_InternalServer : public SubSystemServer {
|
||||||
|
|
||||||
|
|||||||
@@ -5,28 +5,25 @@
|
|||||||
#include "RESTAPI_ProvObjects.h"
|
#include "RESTAPI_ProvObjects.h"
|
||||||
#include "RESTAPI_utils.h"
|
#include "RESTAPI_utils.h"
|
||||||
|
|
||||||
using uCentral::RESTAPI_utils::field_from_json;
|
|
||||||
using uCentral::RESTAPI_utils::field_to_json;
|
|
||||||
|
|
||||||
namespace OpenWifi::ProvObjects {
|
namespace OpenWifi::ProvObjects {
|
||||||
|
|
||||||
void ObjectInfo::to_json(Poco::JSON::Object &Obj) const {
|
void ObjectInfo::to_json(Poco::JSON::Object &Obj) const {
|
||||||
uCentral::RESTAPI_utils::field_to_json(Obj,"id",id);
|
RESTAPI_utils::field_to_json(Obj,"id",id);
|
||||||
uCentral::RESTAPI_utils::field_to_json(Obj,"name",name);
|
RESTAPI_utils::field_to_json(Obj,"name",name);
|
||||||
uCentral::RESTAPI_utils::field_to_json(Obj,"description",description);
|
RESTAPI_utils::field_to_json(Obj,"description",description);
|
||||||
uCentral::RESTAPI_utils::field_to_json(Obj,"created",created);
|
RESTAPI_utils::field_to_json(Obj,"created",created);
|
||||||
uCentral::RESTAPI_utils::field_to_json(Obj,"modified",modified);
|
RESTAPI_utils::field_to_json(Obj,"modified",modified);
|
||||||
uCentral::RESTAPI_utils::field_to_json(Obj,"notes",notes);
|
RESTAPI_utils::field_to_json(Obj,"notes",notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObjectInfo::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool ObjectInfo::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
uCentral::RESTAPI_utils::field_from_json(Obj,"id",id);
|
RESTAPI_utils::field_from_json(Obj,"id",id);
|
||||||
uCentral::RESTAPI_utils::field_from_json(Obj,"name",name);
|
RESTAPI_utils::field_from_json(Obj,"name",name);
|
||||||
uCentral::RESTAPI_utils::field_from_json(Obj,"description",description);
|
RESTAPI_utils::field_from_json(Obj,"description",description);
|
||||||
uCentral::RESTAPI_utils::field_from_json(Obj,"created",created);
|
RESTAPI_utils::field_from_json(Obj,"created",created);
|
||||||
uCentral::RESTAPI_utils::field_from_json(Obj,"modified",modified);
|
RESTAPI_utils::field_from_json(Obj,"modified",modified);
|
||||||
uCentral::RESTAPI_utils::field_from_json(Obj,"notes",notes);
|
RESTAPI_utils::field_from_json(Obj,"notes",notes);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -35,18 +32,18 @@ namespace OpenWifi::ProvObjects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ManagementPolicyEntry::to_json(Poco::JSON::Object &Obj) const {
|
void ManagementPolicyEntry::to_json(Poco::JSON::Object &Obj) const {
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"users",users);
|
RESTAPI_utils::field_to_json( Obj,"users",users);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"resources",resources);
|
RESTAPI_utils::field_to_json( Obj,"resources",resources);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"access",access);
|
RESTAPI_utils::field_to_json( Obj,"access",access);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"policy",policy);
|
RESTAPI_utils::field_to_json( Obj,"policy",policy);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ManagementPolicyEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool ManagementPolicyEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"users",users);
|
RESTAPI_utils::field_from_json( Obj,"users",users);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"resources",resources);
|
RESTAPI_utils::field_from_json( Obj,"resources",resources);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"access",access);
|
RESTAPI_utils::field_from_json( Obj,"access",access);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"policy",policy);
|
RESTAPI_utils::field_from_json( Obj,"policy",policy);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -56,13 +53,13 @@ namespace OpenWifi::ProvObjects {
|
|||||||
|
|
||||||
void ManagementPolicy::to_json(Poco::JSON::Object &Obj) const {
|
void ManagementPolicy::to_json(Poco::JSON::Object &Obj) const {
|
||||||
info.to_json(Obj);
|
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) {
|
bool ManagementPolicy::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
info.from_json(Obj);
|
info.from_json(Obj);
|
||||||
uCentral::RESTAPI_utils::field_from_json(Obj, "entries", entries);
|
RESTAPI_utils::field_from_json(Obj, "entries", entries);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -72,23 +69,23 @@ namespace OpenWifi::ProvObjects {
|
|||||||
|
|
||||||
void Entity::to_json(Poco::JSON::Object &Obj) const {
|
void Entity::to_json(Poco::JSON::Object &Obj) const {
|
||||||
info.to_json(Obj);
|
info.to_json(Obj);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"parent",parent);
|
RESTAPI_utils::field_to_json( Obj,"parent",parent);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"venues",venues);
|
RESTAPI_utils::field_to_json( Obj,"venues",venues);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"children",children);
|
RESTAPI_utils::field_to_json( Obj,"children",children);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"contacts",contacts);
|
RESTAPI_utils::field_to_json( Obj,"contacts",contacts);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"locations",locations);
|
RESTAPI_utils::field_to_json( Obj,"locations",locations);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy);
|
RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entity::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool Entity::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
info.from_json(Obj);
|
info.from_json(Obj);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"parent",parent);
|
RESTAPI_utils::field_from_json( Obj,"parent",parent);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"venues",venues);
|
RESTAPI_utils::field_from_json( Obj,"venues",venues);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"children",children);
|
RESTAPI_utils::field_from_json( Obj,"children",children);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"contacts",contacts);
|
RESTAPI_utils::field_from_json( Obj,"contacts",contacts);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"locations",locations);
|
RESTAPI_utils::field_from_json( Obj,"locations",locations);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy);
|
RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -97,14 +94,14 @@ namespace OpenWifi::ProvObjects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DiGraphEntry::to_json(Poco::JSON::Object &Obj) const {
|
void DiGraphEntry::to_json(Poco::JSON::Object &Obj) const {
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"parent",parent);
|
RESTAPI_utils::field_to_json( Obj,"parent",parent);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"child",child);
|
RESTAPI_utils::field_to_json( Obj,"child",child);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiGraphEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool DiGraphEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"parent",parent);
|
RESTAPI_utils::field_from_json( Obj,"parent",parent);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"child",child);
|
RESTAPI_utils::field_from_json( Obj,"child",child);
|
||||||
return true;
|
return true;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
||||||
@@ -114,27 +111,27 @@ namespace OpenWifi::ProvObjects {
|
|||||||
|
|
||||||
void Venue::to_json(Poco::JSON::Object &Obj) const {
|
void Venue::to_json(Poco::JSON::Object &Obj) const {
|
||||||
info.to_json(Obj);
|
info.to_json(Obj);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"parent",parent);
|
RESTAPI_utils::field_to_json( Obj,"parent",parent);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"owner",entity);
|
RESTAPI_utils::field_to_json( Obj,"owner",entity);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"children",children);
|
RESTAPI_utils::field_to_json( Obj,"children",children);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"devices",devices);
|
RESTAPI_utils::field_to_json( Obj,"devices",devices);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"topology",topology);
|
RESTAPI_utils::field_to_json( Obj,"topology",topology);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"parent",parent);
|
RESTAPI_utils::field_to_json( Obj,"parent",parent);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"design",design);
|
RESTAPI_utils::field_to_json( Obj,"design",design);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy);
|
RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Venue::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool Venue::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
info.from_json(Obj);
|
info.from_json(Obj);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"parent",parent);
|
RESTAPI_utils::field_from_json( Obj,"parent",parent);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"owner",entity);
|
RESTAPI_utils::field_from_json( Obj,"owner",entity);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"children",children);
|
RESTAPI_utils::field_from_json( Obj,"children",children);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"devices",devices);
|
RESTAPI_utils::field_from_json( Obj,"devices",devices);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"topology",topology);
|
RESTAPI_utils::field_from_json( Obj,"topology",topology);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"parent",parent);
|
RESTAPI_utils::field_from_json( Obj,"parent",parent);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"design",design);
|
RESTAPI_utils::field_from_json( Obj,"design",design);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy);
|
RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy);
|
||||||
return true;
|
return true;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
||||||
@@ -143,16 +140,16 @@ namespace OpenWifi::ProvObjects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UserInfoDigest::to_json(Poco::JSON::Object &Obj) const {
|
void UserInfoDigest::to_json(Poco::JSON::Object &Obj) const {
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"id",id);
|
RESTAPI_utils::field_to_json( Obj,"id",id);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"owner",loginId);
|
RESTAPI_utils::field_to_json( Obj,"owner",loginId);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"children",userType);
|
RESTAPI_utils::field_to_json( Obj,"children",userType);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UserInfoDigest::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool UserInfoDigest::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"id",id);
|
RESTAPI_utils::field_from_json( Obj,"id",id);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"owner",loginId);
|
RESTAPI_utils::field_from_json( Obj,"owner",loginId);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"children",userType);
|
RESTAPI_utils::field_from_json( Obj,"children",userType);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
}
|
}
|
||||||
@@ -161,15 +158,15 @@ namespace OpenWifi::ProvObjects {
|
|||||||
|
|
||||||
void ManagementRole::to_json(Poco::JSON::Object &Obj) const {
|
void ManagementRole::to_json(Poco::JSON::Object &Obj) const {
|
||||||
info.to_json(Obj);
|
info.to_json(Obj);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy);
|
RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"users",users);
|
RESTAPI_utils::field_to_json( Obj,"users",users);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ManagementRole::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool ManagementRole::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
info.from_json(Obj);
|
info.from_json(Obj);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy);
|
RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"users",users);
|
RESTAPI_utils::field_from_json( Obj,"users",users);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
}
|
}
|
||||||
@@ -178,37 +175,37 @@ namespace OpenWifi::ProvObjects {
|
|||||||
|
|
||||||
void Location::to_json(Poco::JSON::Object &Obj) const {
|
void Location::to_json(Poco::JSON::Object &Obj) const {
|
||||||
info.to_json(Obj);
|
info.to_json(Obj);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"type",OpenWifi::ProvObjects::to_string(type));
|
RESTAPI_utils::field_to_json( Obj,"type",OpenWifi::ProvObjects::to_string(type));
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"buildingName",buildingName);
|
RESTAPI_utils::field_to_json( Obj,"buildingName",buildingName);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"addressLines",addressLines);
|
RESTAPI_utils::field_to_json( Obj,"addressLines",addressLines);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"city",city);
|
RESTAPI_utils::field_to_json( Obj,"city",city);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"state",state);
|
RESTAPI_utils::field_to_json( Obj,"state",state);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"postal",postal);
|
RESTAPI_utils::field_to_json( Obj,"postal",postal);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"country",country);
|
RESTAPI_utils::field_to_json( Obj,"country",country);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"phones",phones);
|
RESTAPI_utils::field_to_json( Obj,"phones",phones);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"mobiles",mobiles);
|
RESTAPI_utils::field_to_json( Obj,"mobiles",mobiles);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"venues",venues);
|
RESTAPI_utils::field_to_json( Obj,"venues",venues);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"entities",entities);
|
RESTAPI_utils::field_to_json( Obj,"entities",entities);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"geoCode",geoCode);
|
RESTAPI_utils::field_to_json( Obj,"geoCode",geoCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Location::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool Location::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
info.from_json(Obj);
|
info.from_json(Obj);
|
||||||
std::string tmp_type;
|
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);
|
type = location_from_string(tmp_type);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"buildingName",buildingName);
|
RESTAPI_utils::field_from_json( Obj,"buildingName",buildingName);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"addressLines",addressLines);
|
RESTAPI_utils::field_from_json( Obj,"addressLines",addressLines);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"city",city);
|
RESTAPI_utils::field_from_json( Obj,"city",city);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"state",state);
|
RESTAPI_utils::field_from_json( Obj,"state",state);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"postal",postal);
|
RESTAPI_utils::field_from_json( Obj,"postal",postal);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"country",country);
|
RESTAPI_utils::field_from_json( Obj,"country",country);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"phones",phones);
|
RESTAPI_utils::field_from_json( Obj,"phones",phones);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"mobiles",mobiles);
|
RESTAPI_utils::field_from_json( Obj,"mobiles",mobiles);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"venues",venues);
|
RESTAPI_utils::field_from_json( Obj,"venues",venues);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"entities",entities);
|
RESTAPI_utils::field_from_json( Obj,"entities",entities);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"geoCode",geoCode);
|
RESTAPI_utils::field_from_json( Obj,"geoCode",geoCode);
|
||||||
return true;
|
return true;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
||||||
@@ -218,41 +215,41 @@ namespace OpenWifi::ProvObjects {
|
|||||||
|
|
||||||
void Contact::to_json(Poco::JSON::Object &Obj) const {
|
void Contact::to_json(Poco::JSON::Object &Obj) const {
|
||||||
info.to_json(Obj);
|
info.to_json(Obj);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"type", to_string(type));
|
RESTAPI_utils::field_to_json( Obj,"type", to_string(type));
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"title",title);
|
RESTAPI_utils::field_to_json( Obj,"title",title);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"salutation",salutation);
|
RESTAPI_utils::field_to_json( Obj,"salutation",salutation);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"firstname",firstname);
|
RESTAPI_utils::field_to_json( Obj,"firstname",firstname);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"lastname",lastname);
|
RESTAPI_utils::field_to_json( Obj,"lastname",lastname);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"initials",initials);
|
RESTAPI_utils::field_to_json( Obj,"initials",initials);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"visual",visual);
|
RESTAPI_utils::field_to_json( Obj,"visual",visual);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"mobiles",mobiles);
|
RESTAPI_utils::field_to_json( Obj,"mobiles",mobiles);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"phones",phones);
|
RESTAPI_utils::field_to_json( Obj,"phones",phones);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"primaryEmail",primaryEmail);
|
RESTAPI_utils::field_to_json( Obj,"primaryEmail",primaryEmail);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"secondaryEmail",secondaryEmail);
|
RESTAPI_utils::field_to_json( Obj,"secondaryEmail",secondaryEmail);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"accessPIN",accessPIN);
|
RESTAPI_utils::field_to_json( Obj,"accessPIN",accessPIN);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"venues",venues);
|
RESTAPI_utils::field_to_json( Obj,"venues",venues);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"entities",entities);
|
RESTAPI_utils::field_to_json( Obj,"entities",entities);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Contact::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool Contact::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
info.from_json(Obj);
|
info.from_json(Obj);
|
||||||
std::string tmp_type;
|
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);
|
type = contact_from_string(tmp_type);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"title",title);
|
RESTAPI_utils::field_from_json( Obj,"title",title);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"salutation",salutation);
|
RESTAPI_utils::field_from_json( Obj,"salutation",salutation);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"firstname",firstname);
|
RESTAPI_utils::field_from_json( Obj,"firstname",firstname);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"lastname",lastname);
|
RESTAPI_utils::field_from_json( Obj,"lastname",lastname);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"initials",initials);
|
RESTAPI_utils::field_from_json( Obj,"initials",initials);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"visual",visual);
|
RESTAPI_utils::field_from_json( Obj,"visual",visual);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"mobiles",mobiles);
|
RESTAPI_utils::field_from_json( Obj,"mobiles",mobiles);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"phones",phones);
|
RESTAPI_utils::field_from_json( Obj,"phones",phones);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"primaryEmail",primaryEmail);
|
RESTAPI_utils::field_from_json( Obj,"primaryEmail",primaryEmail);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"secondaryEmail",secondaryEmail);
|
RESTAPI_utils::field_from_json( Obj,"secondaryEmail",secondaryEmail);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"accessPIN",accessPIN);
|
RESTAPI_utils::field_from_json( Obj,"accessPIN",accessPIN);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"venues",venues);
|
RESTAPI_utils::field_from_json( Obj,"venues",venues);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"entities",entities);
|
RESTAPI_utils::field_from_json( Obj,"entities",entities);
|
||||||
return true;
|
return true;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
||||||
@@ -278,29 +275,29 @@ namespace OpenWifi::ProvObjects {
|
|||||||
|
|
||||||
void InventoryTag::to_json(Poco::JSON::Object &Obj) const {
|
void InventoryTag::to_json(Poco::JSON::Object &Obj) const {
|
||||||
info.to_json(Obj);
|
info.to_json(Obj);
|
||||||
uCentral::RESTAPI_utils::field_to_json(Obj, "serialNumber", serialNumber);
|
RESTAPI_utils::field_to_json(Obj, "serialNumber", serialNumber);
|
||||||
uCentral::RESTAPI_utils::field_to_json(Obj, "venue", venue);
|
RESTAPI_utils::field_to_json(Obj, "venue", venue);
|
||||||
uCentral::RESTAPI_utils::field_to_json(Obj, "entity", entity);
|
RESTAPI_utils::field_to_json(Obj, "entity", entity);
|
||||||
uCentral::RESTAPI_utils::field_to_json(Obj, "subEntity", subEntity);
|
RESTAPI_utils::field_to_json(Obj, "subEntity", subEntity);
|
||||||
uCentral::RESTAPI_utils::field_to_json(Obj, "subVenue", subVenue);
|
RESTAPI_utils::field_to_json(Obj, "subVenue", subVenue);
|
||||||
uCentral::RESTAPI_utils::field_to_json(Obj, "subscriber", subscriber);
|
RESTAPI_utils::field_to_json(Obj, "subscriber", subscriber);
|
||||||
uCentral::RESTAPI_utils::field_to_json(Obj, "deviceType", deviceType);
|
RESTAPI_utils::field_to_json(Obj, "deviceType", deviceType);
|
||||||
uCentral::RESTAPI_utils::field_to_json(Obj, "qrCode", qrCode);
|
RESTAPI_utils::field_to_json(Obj, "qrCode", qrCode);
|
||||||
uCentral::RESTAPI_utils::field_to_json(Obj, "geoCode", geoCode);
|
RESTAPI_utils::field_to_json(Obj, "geoCode", geoCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
info.from_json(Obj);
|
info.from_json(Obj);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"serialNumber",serialNumber);
|
RESTAPI_utils::field_from_json( Obj,"serialNumber",serialNumber);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"venue",venue);
|
RESTAPI_utils::field_from_json( Obj,"venue",venue);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"entity",entity);
|
RESTAPI_utils::field_from_json( Obj,"entity",entity);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"subEntity",subEntity);
|
RESTAPI_utils::field_from_json( Obj,"subEntity",subEntity);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"subVenue",subVenue);
|
RESTAPI_utils::field_from_json( Obj,"subVenue",subVenue);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"subscriber",subscriber);
|
RESTAPI_utils::field_from_json( Obj,"subscriber",subscriber);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"deviceType",deviceType);
|
RESTAPI_utils::field_from_json( Obj,"deviceType",deviceType);
|
||||||
uCentral::RESTAPI_utils::field_from_json(Obj, "qrCode", qrCode);
|
RESTAPI_utils::field_from_json(Obj, "qrCode", qrCode);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"geoCode",geoCode);
|
RESTAPI_utils::field_from_json( Obj,"geoCode",geoCode);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -311,16 +308,16 @@ namespace OpenWifi::ProvObjects {
|
|||||||
void DeviceConfiguration::to_json(Poco::JSON::Object &Obj) const {
|
void DeviceConfiguration::to_json(Poco::JSON::Object &Obj) const {
|
||||||
info.to_json(Obj);
|
info.to_json(Obj);
|
||||||
managementPolicy.to_json(Obj);
|
managementPolicy.to_json(Obj);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"deviceTypes",deviceTypes);
|
RESTAPI_utils::field_to_json( Obj,"deviceTypes",deviceTypes);
|
||||||
uCentral::RESTAPI_utils::field_to_json( Obj,"configuration",configuration);
|
RESTAPI_utils::field_to_json( Obj,"configuration",configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceConfiguration::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool DeviceConfiguration::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
info.from_json(Obj);
|
info.from_json(Obj);
|
||||||
managementPolicy.from_json(Obj);
|
managementPolicy.from_json(Obj);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"deviceTypes",deviceTypes);
|
RESTAPI_utils::field_from_json( Obj,"deviceTypes",deviceTypes);
|
||||||
uCentral::RESTAPI_utils::field_from_json( Obj,"configuration",configuration);
|
RESTAPI_utils::field_from_json( Obj,"configuration",configuration);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -329,8 +326,8 @@ namespace OpenWifi::ProvObjects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Report::to_json(Poco::JSON::Object &Obj) const {
|
void Report::to_json(Poco::JSON::Object &Obj) const {
|
||||||
uCentral::RESTAPI_utils::field_to_json(Obj, "snapshot", snapShot);
|
RESTAPI_utils::field_to_json(Obj, "snapshot", snapShot);
|
||||||
uCentral::RESTAPI_utils::field_to_json(Obj, "devices", tenants);
|
RESTAPI_utils::field_to_json(Obj, "devices", tenants);
|
||||||
};
|
};
|
||||||
|
|
||||||
void Report::reset() {
|
void Report::reset() {
|
||||||
|
|||||||
@@ -11,10 +11,10 @@
|
|||||||
namespace OpenWifi::ProvObjects {
|
namespace OpenWifi::ProvObjects {
|
||||||
|
|
||||||
struct ObjectInfo {
|
struct ObjectInfo {
|
||||||
uCentral::Types::UUID_t id;
|
Types::UUID_t id;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string description;
|
std::string description;
|
||||||
uCentral::SecurityObjects::NoteInfoVec notes;
|
SecurityObjects::NoteInfoVec notes;
|
||||||
uint64_t created;
|
uint64_t created;
|
||||||
uint64_t modified;
|
uint64_t modified;
|
||||||
|
|
||||||
@@ -23,9 +23,9 @@ namespace OpenWifi::ProvObjects {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct ManagementPolicyEntry {
|
struct ManagementPolicyEntry {
|
||||||
uCentral::Types::UUIDvec_t users;
|
Types::UUIDvec_t users;
|
||||||
uCentral::Types::UUIDvec_t resources;
|
Types::UUIDvec_t resources;
|
||||||
uCentral::Types::StringVec access;
|
Types::StringVec access;
|
||||||
std::string policy;
|
std::string policy;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
@@ -42,20 +42,20 @@ namespace OpenWifi::ProvObjects {
|
|||||||
|
|
||||||
struct Entity {
|
struct Entity {
|
||||||
ObjectInfo info;
|
ObjectInfo info;
|
||||||
uCentral::Types::UUID_t parent;
|
Types::UUID_t parent;
|
||||||
uCentral::Types::UUIDvec_t children;
|
Types::UUIDvec_t children;
|
||||||
uCentral::Types::UUIDvec_t venues;
|
Types::UUIDvec_t venues;
|
||||||
uCentral::Types::UUIDvec_t contacts;
|
Types::UUIDvec_t contacts;
|
||||||
uCentral::Types::UUIDvec_t locations;
|
Types::UUIDvec_t locations;
|
||||||
uCentral::Types::UUID_t managementPolicy;
|
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);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DiGraphEntry {
|
struct DiGraphEntry {
|
||||||
uCentral::Types::UUID_t parent;
|
Types::UUID_t parent;
|
||||||
uCentral::Types::UUID_t child;
|
Types::UUID_t child;
|
||||||
|
|
||||||
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);
|
||||||
@@ -65,11 +65,11 @@ namespace OpenWifi::ProvObjects {
|
|||||||
|
|
||||||
struct Venue {
|
struct Venue {
|
||||||
ObjectInfo info;
|
ObjectInfo info;
|
||||||
uCentral::Types::UUID_t entity;
|
Types::UUID_t entity;
|
||||||
uCentral::Types::UUID_t parent;
|
Types::UUID_t parent;
|
||||||
uCentral::Types::UUIDvec_t children;
|
Types::UUIDvec_t children;
|
||||||
uCentral::Types::UUID_t managementPolicy;
|
Types::UUID_t managementPolicy;
|
||||||
uCentral::Types::UUIDvec_t devices;
|
Types::UUIDvec_t devices;
|
||||||
DiGraph topology;
|
DiGraph topology;
|
||||||
std::string design;
|
std::string design;
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
|
|
||||||
struct ManagementRole {
|
struct ManagementRole {
|
||||||
ObjectInfo info;
|
ObjectInfo info;
|
||||||
uCentral::Types::UUID_t managementPolicy;
|
Types::UUID_t managementPolicy;
|
||||||
std::vector<UserInfoDigest> users;
|
std::vector<UserInfoDigest> users;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
@@ -135,15 +135,15 @@ namespace OpenWifi::ProvObjects {
|
|||||||
ObjectInfo info;
|
ObjectInfo info;
|
||||||
LocationType type;
|
LocationType type;
|
||||||
std::string buildingName;
|
std::string buildingName;
|
||||||
uCentral::Types::StringVec addressLines;
|
Types::StringVec addressLines;
|
||||||
std::string city;
|
std::string city;
|
||||||
std::string state;
|
std::string state;
|
||||||
std::string postal;
|
std::string postal;
|
||||||
std::string country;
|
std::string country;
|
||||||
uCentral::Types::StringVec phones;
|
Types::StringVec phones;
|
||||||
uCentral::Types::StringVec mobiles;
|
Types::StringVec mobiles;
|
||||||
uCentral::Types::StringVec venues;
|
Types::StringVec venues;
|
||||||
uCentral::Types::StringVec entities;
|
Types::StringVec entities;
|
||||||
std::string geoCode;
|
std::string geoCode;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
@@ -199,13 +199,13 @@ namespace OpenWifi::ProvObjects {
|
|||||||
std::string lastname;
|
std::string lastname;
|
||||||
std::string initials;
|
std::string initials;
|
||||||
std::string visual;
|
std::string visual;
|
||||||
uCentral::Types::StringVec mobiles;
|
Types::StringVec mobiles;
|
||||||
uCentral::Types::StringVec phones;
|
Types::StringVec phones;
|
||||||
std::string primaryEmail;
|
std::string primaryEmail;
|
||||||
std::string secondaryEmail;
|
std::string secondaryEmail;
|
||||||
std::string accessPIN;
|
std::string accessPIN;
|
||||||
uCentral::Types::StringVec venues;
|
Types::StringVec venues;
|
||||||
uCentral::Types::StringVec entities;
|
Types::StringVec entities;
|
||||||
|
|
||||||
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);
|
||||||
@@ -222,7 +222,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
struct DeviceConfiguration {
|
struct DeviceConfiguration {
|
||||||
ObjectInfo info;
|
ObjectInfo info;
|
||||||
ManagementPolicy managementPolicy;
|
ManagementPolicy managementPolicy;
|
||||||
uCentral::Types::StringVec deviceTypes;
|
Types::StringVec deviceTypes;
|
||||||
std::string configuration;
|
std::string configuration;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
@@ -247,7 +247,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
|
|
||||||
struct Report {
|
struct Report {
|
||||||
uint64_t snapShot;
|
uint64_t snapShot;
|
||||||
uCentral::Types::CountedMap tenants;
|
Types::CountedMap tenants;
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
|||||||
@@ -12,10 +12,10 @@
|
|||||||
#include "RESTAPI_SecurityObjects.h"
|
#include "RESTAPI_SecurityObjects.h"
|
||||||
#include "RESTAPI_utils.h"
|
#include "RESTAPI_utils.h"
|
||||||
|
|
||||||
using uCentral::RESTAPI_utils::field_to_json;
|
using OpenWifi::RESTAPI_utils::field_to_json;
|
||||||
using uCentral::RESTAPI_utils::field_from_json;
|
using OpenWifi::RESTAPI_utils::field_from_json;
|
||||||
|
|
||||||
namespace uCentral::SecurityObjects {
|
namespace OpenWifi::SecurityObjects {
|
||||||
|
|
||||||
void AclTemplate::to_json(Poco::JSON::Object &Obj) const {
|
void AclTemplate::to_json(Poco::JSON::Object &Obj) const {
|
||||||
field_to_json(Obj,"Read",Read_);
|
field_to_json(Obj,"Read",Read_);
|
||||||
@@ -303,6 +303,20 @@ namespace uCentral::SecurityObjects {
|
|||||||
return false;
|
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 {
|
void ProfileAction::to_json(Poco::JSON::Object &Obj) const {
|
||||||
field_to_json(Obj,"resource", resource);
|
field_to_json(Obj,"resource", resource);
|
||||||
field_to_json<ResourceAccessType>(Obj,"access", access, ResourceAccessTypeToString);
|
field_to_json<ResourceAccessType>(Obj,"access", access, ResourceAccessTypeToString);
|
||||||
|
|||||||
@@ -10,9 +10,9 @@
|
|||||||
#define UCENTRAL_RESTAPI_SECURITYOBJECTS_H
|
#define UCENTRAL_RESTAPI_SECURITYOBJECTS_H
|
||||||
|
|
||||||
#include "Poco/JSON/Object.h"
|
#include "Poco/JSON/Object.h"
|
||||||
#include "uCentralTypes.h"
|
#include "OpenWifiTypes.h"
|
||||||
|
|
||||||
namespace uCentral::SecurityObjects {
|
namespace OpenWifi::SecurityObjects {
|
||||||
|
|
||||||
struct AclTemplate {
|
struct AclTemplate {
|
||||||
bool Read_ = true;
|
bool Read_ = true;
|
||||||
@@ -94,6 +94,8 @@ namespace uCentral::SecurityObjects {
|
|||||||
};
|
};
|
||||||
typedef std::vector<UserInfo> UserInfoVec;
|
typedef std::vector<UserInfo> UserInfoVec;
|
||||||
|
|
||||||
|
bool append_from_json(Poco::JSON::Object::Ptr Obj, const UserInfo &UInfo, NoteInfoVec & Notes);
|
||||||
|
|
||||||
struct InternalServiceInfo {
|
struct InternalServiceInfo {
|
||||||
std::string privateURI;
|
std::string privateURI;
|
||||||
std::string publicURI;
|
std::string publicURI;
|
||||||
|
|||||||
@@ -34,14 +34,14 @@ namespace OpenWifi{
|
|||||||
void RESTAPI_contact_handler::DoGet(Poco::Net::HTTPServerRequest &Request,
|
void RESTAPI_contact_handler::DoGet(Poco::Net::HTTPServerRequest &Request,
|
||||||
Poco::Net::HTTPServerResponse &Response) {
|
Poco::Net::HTTPServerResponse &Response) {
|
||||||
try {
|
try {
|
||||||
std::string UUID = GetBinding(uCentral::RESTAPI::Protocol::ID,"");
|
std::string UUID = GetBinding(RESTAPI::Protocol::ID,"");
|
||||||
if(UUID.empty()) {
|
if(UUID.empty()) {
|
||||||
BadRequest(Request, Response, "Missing UUID.");
|
BadRequest(Request, Response, "Missing UUID.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProvObjects::Contact C;
|
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;
|
Poco::JSON::Object Answer;
|
||||||
C.to_json(Answer);
|
C.to_json(Answer);
|
||||||
ReturnObject(Request, Answer, Response);
|
ReturnObject(Request, Answer, Response);
|
||||||
@@ -64,7 +64,7 @@ namespace OpenWifi{
|
|||||||
void RESTAPI_contact_handler::DoPost(Poco::Net::HTTPServerRequest &Request,
|
void RESTAPI_contact_handler::DoPost(Poco::Net::HTTPServerRequest &Request,
|
||||||
Poco::Net::HTTPServerResponse &Response) {
|
Poco::Net::HTTPServerResponse &Response) {
|
||||||
try {
|
try {
|
||||||
std::string UUID = GetBinding(uCentral::RESTAPI::Protocol::ID,"");
|
std::string UUID = GetBinding(RESTAPI::Protocol::ID,"");
|
||||||
if(UUID.empty()) {
|
if(UUID.empty()) {
|
||||||
BadRequest(Request, Response, "Missing UUID.");
|
BadRequest(Request, Response, "Missing UUID.");
|
||||||
return;
|
return;
|
||||||
@@ -78,7 +78,7 @@ namespace OpenWifi{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
C.info.id = uCentral::Daemon()->CreateUUID();
|
C.info.id = Daemon()->CreateUUID();
|
||||||
C.info.created = C.info.modified = std::time(nullptr);
|
C.info.created = C.info.modified = std::time(nullptr);
|
||||||
|
|
||||||
if(C.entities.empty() || C.entities.size()!=1) {
|
if(C.entities.empty() || C.entities.size()!=1) {
|
||||||
@@ -86,7 +86,7 @@ namespace OpenWifi{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string f{uCentral::RESTAPI::Protocol::ID};
|
std::string f{RESTAPI::Protocol::ID};
|
||||||
if(!Storage()->EntityDB().Exists("id",C.entities[0])) {
|
if(!Storage()->EntityDB().Exists("id",C.entities[0])) {
|
||||||
BadRequest(Request, Response, "Unknown entity: " + C.entities[0] );
|
BadRequest(Request, Response, "Unknown entity: " + C.entities[0] );
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "Poco/Net/HTTPServerResponse.h"
|
#include "Poco/Net/HTTPServerResponse.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_contact_handler : public uCentral::RESTAPIHandler {
|
class RESTAPI_contact_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_contact_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
RESTAPI_contact_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ namespace OpenWifi{
|
|||||||
|
|
||||||
// When creating an entity, it cannot have any relations other that parent, notes, name, description. Everything else
|
// When creating an entity, it cannot have any relations other that parent, notes, name, description. Everything else
|
||||||
// must be conveyed through PUT.
|
// 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())
|
if(UUID==EntityDB::RootUUID())
|
||||||
E.parent="";
|
E.parent="";
|
||||||
else if(E.parent.empty()) {
|
else if(E.parent.empty()) {
|
||||||
@@ -196,12 +196,7 @@ namespace OpenWifi{
|
|||||||
Poco::JSON::Parser IncomingParser;
|
Poco::JSON::Parser IncomingParser;
|
||||||
auto RawObject = IncomingParser.parse(Request.stream()).extract<Poco::JSON::Object::Ptr>();
|
auto RawObject = IncomingParser.parse(Request.stream()).extract<Poco::JSON::Object::Ptr>();
|
||||||
if(RawObject->has("notes")) {
|
if(RawObject->has("notes")) {
|
||||||
uCentral::SecurityObjects::NoteInfoVec NIV;
|
SecurityObjects::append_from_json(RawObject, UserInfo_.userinfo, LocalObject.info.notes);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(RawObject->has("name"))
|
if(RawObject->has("name"))
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include "Poco/Net/HTTPServerResponse.h"
|
#include "Poco/Net/HTTPServerResponse.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_entity_handler : public uCentral::RESTAPIHandler {
|
class RESTAPI_entity_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_entity_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
RESTAPI_entity_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenWifi{
|
|||||||
Poco::Net::HTTPServerResponse &Response) {
|
Poco::Net::HTTPServerResponse &Response) {
|
||||||
try {
|
try {
|
||||||
if(!QB_.Select.empty()) {
|
if(!QB_.Select.empty()) {
|
||||||
auto EntityUIDs = uCentral::Utils::Split(QB_.Select);
|
auto EntityUIDs = Utils::Split(QB_.Select);
|
||||||
Poco::JSON::Array Arr;
|
Poco::JSON::Array Arr;
|
||||||
for(const auto &i:EntityUIDs) {
|
for(const auto &i:EntityUIDs) {
|
||||||
ProvObjects::Entity E;
|
ProvObjects::Entity E;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "Poco/Net/HTTPServerResponse.h"
|
#include "Poco/Net/HTTPServerResponse.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_entity_list_handler : public uCentral::RESTAPIHandler {
|
class RESTAPI_entity_list_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_entity_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
RESTAPI_entity_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
|
|||||||
@@ -27,16 +27,16 @@
|
|||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "Daemon.h"
|
#include "Daemon.h"
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
|
|
||||||
bool RESTAPIHandler::ParseBindings(const std::string & Request, const std::list<const char *> & EndPoints, BindingMap &bindings) {
|
bool RESTAPIHandler::ParseBindings(const std::string & Request, const std::list<const char *> & EndPoints, BindingMap &bindings) {
|
||||||
std::string Param, Value;
|
std::string Param, Value;
|
||||||
|
|
||||||
bindings.clear();
|
bindings.clear();
|
||||||
std::vector<std::string> PathItems = uCentral::Utils::Split(Request, '/');
|
std::vector<std::string> PathItems = Utils::Split(Request, '/');
|
||||||
|
|
||||||
for(const auto &EndPoint:EndPoints) {
|
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())
|
if (PathItems.size() != ParamItems.size())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -365,17 +365,17 @@ namespace uCentral {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool RESTAPIHandler::InitQueryBlock() {
|
bool RESTAPIHandler::InitQueryBlock() {
|
||||||
QB_.SerialNumber = GetParameter(uCentral::RESTAPI::Protocol::SERIALNUMBER, "");
|
QB_.SerialNumber = GetParameter(RESTAPI::Protocol::SERIALNUMBER, "");
|
||||||
QB_.StartDate = GetParameter(uCentral::RESTAPI::Protocol::STARTDATE, 0);
|
QB_.StartDate = GetParameter(RESTAPI::Protocol::STARTDATE, 0);
|
||||||
QB_.EndDate = GetParameter(uCentral::RESTAPI::Protocol::ENDDATE, 0);
|
QB_.EndDate = GetParameter(RESTAPI::Protocol::ENDDATE, 0);
|
||||||
QB_.Offset = GetParameter(uCentral::RESTAPI::Protocol::OFFSET, 1);
|
QB_.Offset = GetParameter(RESTAPI::Protocol::OFFSET, 1);
|
||||||
QB_.Limit = GetParameter(uCentral::RESTAPI::Protocol::LIMIT, 100);
|
QB_.Limit = GetParameter(RESTAPI::Protocol::LIMIT, 100);
|
||||||
QB_.Filter = GetParameter(uCentral::RESTAPI::Protocol::FILTER, "");
|
QB_.Filter = GetParameter(RESTAPI::Protocol::FILTER, "");
|
||||||
QB_.Select = GetParameter(uCentral::RESTAPI::Protocol::SELECT, "");
|
QB_.Select = GetParameter(RESTAPI::Protocol::SELECT, "");
|
||||||
QB_.Lifetime = GetBoolParameter(uCentral::RESTAPI::Protocol::LIFETIME,false);
|
QB_.Lifetime = GetBoolParameter(RESTAPI::Protocol::LIFETIME,false);
|
||||||
QB_.LogType = GetParameter(uCentral::RESTAPI::Protocol::LOGTYPE,0);
|
QB_.LogType = GetParameter(RESTAPI::Protocol::LOGTYPE,0);
|
||||||
QB_.LastOnly = GetBoolParameter(uCentral::RESTAPI::Protocol::LASTONLY,false);
|
QB_.LastOnly = GetBoolParameter(RESTAPI::Protocol::LASTONLY,false);
|
||||||
QB_.Newest = GetBoolParameter(uCentral::RESTAPI::Protocol::NEWEST,false);
|
QB_.Newest = GetBoolParameter(RESTAPI::Protocol::NEWEST,false);
|
||||||
|
|
||||||
if(QB_.Offset<1) return false;
|
if(QB_.Offset<1) return false;
|
||||||
return true;
|
return true;
|
||||||
@@ -400,7 +400,7 @@ namespace uCentral {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] uint64_t RESTAPIHandler::GetWhen(const Poco::JSON::Object::Ptr &Obj) {
|
[[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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include "RESTAPI_SecurityObjects.h"
|
#include "RESTAPI_SecurityObjects.h"
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class RESTAPI_PartHandler: public Poco::Net::PartHandler
|
class RESTAPI_PartHandler: public Poco::Net::PartHandler
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,14 +34,14 @@ namespace OpenWifi{
|
|||||||
void RESTAPI_inventory_handler::DoGet(Poco::Net::HTTPServerRequest &Request,
|
void RESTAPI_inventory_handler::DoGet(Poco::Net::HTTPServerRequest &Request,
|
||||||
Poco::Net::HTTPServerResponse &Response) {
|
Poco::Net::HTTPServerResponse &Response) {
|
||||||
try {
|
try {
|
||||||
std::string SerialNumber = GetBinding(uCentral::RESTAPI::Protocol::SERIALNUMBER,"");
|
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER,"");
|
||||||
if(SerialNumber.empty()) {
|
if(SerialNumber.empty()) {
|
||||||
BadRequest(Request, Response, "Missing SerialNumber.");
|
BadRequest(Request, Response, "Missing SerialNumber.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProvObjects::InventoryTag IT;
|
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;
|
Poco::JSON::Object Answer;
|
||||||
IT.to_json(Answer);
|
IT.to_json(Answer);
|
||||||
ReturnObject(Request, Answer, Response);
|
ReturnObject(Request, Answer, Response);
|
||||||
@@ -59,28 +59,28 @@ namespace OpenWifi{
|
|||||||
void RESTAPI_inventory_handler::DoDelete(Poco::Net::HTTPServerRequest &Request,
|
void RESTAPI_inventory_handler::DoDelete(Poco::Net::HTTPServerRequest &Request,
|
||||||
Poco::Net::HTTPServerResponse &Response) {
|
Poco::Net::HTTPServerResponse &Response) {
|
||||||
try {
|
try {
|
||||||
std::string SerialNumber = GetBinding(uCentral::RESTAPI::Protocol::SERIALNUMBER,"");
|
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER,"");
|
||||||
if(SerialNumber.empty()) {
|
if(SerialNumber.empty()) {
|
||||||
BadRequest(Request, Response, "Missing SerialNumber.");
|
BadRequest(Request, Response, "Missing SerialNumber.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProvObjects::InventoryTag IT;
|
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);
|
NotFound(Request,Response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!IT.entity.empty())
|
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())
|
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())
|
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())
|
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);
|
OK(Request, Response);
|
||||||
return;
|
return;
|
||||||
} catch(const Poco::Exception &E) {
|
} catch(const Poco::Exception &E) {
|
||||||
@@ -92,13 +92,13 @@ namespace OpenWifi{
|
|||||||
void RESTAPI_inventory_handler::DoPost(Poco::Net::HTTPServerRequest &Request,
|
void RESTAPI_inventory_handler::DoPost(Poco::Net::HTTPServerRequest &Request,
|
||||||
Poco::Net::HTTPServerResponse &Response) {
|
Poco::Net::HTTPServerResponse &Response) {
|
||||||
try {
|
try {
|
||||||
std::string SerialNumber = GetBinding(uCentral::RESTAPI::Protocol::SERIALNUMBER,"");
|
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER,"");
|
||||||
if(SerialNumber.empty()) {
|
if(SerialNumber.empty()) {
|
||||||
BadRequest(Request, Response, "Missing SerialNumber.");
|
BadRequest(Request, Response, "Missing SerialNumber.");
|
||||||
return;
|
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.");
|
BadRequest(Request,Response, "SerialNumber: " + SerialNumber + " already exists.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -111,22 +111,19 @@ namespace OpenWifi{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(IT.entity.empty()) {
|
if(IT.entity.empty() || OpenWifi::EntityDB::IsRoot(IT.entity) || !Storage()->InventoryDB().Exists("id",IT.entity)) {
|
||||||
BadRequest(Request, Response, "Device must be associated with a top entity.");
|
BadRequest(Request, Response, "Device must be associated with a non-root and existing entity. UUID="+IT.entity);
|
||||||
return;
|
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)) {
|
if(!IT.venue.empty() && !Storage()->VenueDB().Exists("id",IT.venue)) {
|
||||||
BadRequest(Request, Response, "Venue: " + IT.venue + " does not exist.");
|
BadRequest(Request, Response, "Venue: " + IT.venue + " does not exist.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IT.info.modified = IT.info.created = std::time(nullptr);
|
||||||
IT.subEntity = IT.subVenue = "";
|
IT.subEntity = IT.subVenue = "";
|
||||||
IT.info.id = uCentral::Daemon()->CreateUUID();
|
IT.info.id = Daemon()->CreateUUID();
|
||||||
|
|
||||||
if(Storage()->InventoryDB().CreateRecord(IT)) {
|
if(Storage()->InventoryDB().CreateRecord(IT)) {
|
||||||
Storage()->EntityDB().AddChild("id",IT.entity,IT.info.id);
|
Storage()->EntityDB().AddChild("id",IT.entity,IT.info.id);
|
||||||
@@ -148,14 +145,14 @@ namespace OpenWifi{
|
|||||||
void RESTAPI_inventory_handler::DoPut(Poco::Net::HTTPServerRequest &Request,
|
void RESTAPI_inventory_handler::DoPut(Poco::Net::HTTPServerRequest &Request,
|
||||||
Poco::Net::HTTPServerResponse &Response) {
|
Poco::Net::HTTPServerResponse &Response) {
|
||||||
try {
|
try {
|
||||||
std::string SerialNumber = GetBinding(uCentral::RESTAPI::Protocol::SERIALNUMBER,"");
|
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER,"");
|
||||||
if(SerialNumber.empty()) {
|
if(SerialNumber.empty()) {
|
||||||
BadRequest(Request, Response, "Missing SerialNumber.");
|
BadRequest(Request, Response, "Missing SerialNumber.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProvObjects::InventoryTag ExistingObject;
|
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);
|
NotFound(Request, Response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -163,12 +160,7 @@ namespace OpenWifi{
|
|||||||
Poco::JSON::Parser IncomingParser;
|
Poco::JSON::Parser IncomingParser;
|
||||||
Poco::JSON::Object::Ptr RawObject = IncomingParser.parse(Request.stream()).extract<Poco::JSON::Object::Ptr>();
|
Poco::JSON::Object::Ptr RawObject = IncomingParser.parse(Request.stream()).extract<Poco::JSON::Object::Ptr>();
|
||||||
if(RawObject->has("notes")) {
|
if(RawObject->has("notes")) {
|
||||||
uCentral::SecurityObjects::NoteInfoVec NIV;
|
SecurityObjects::append_from_json(RawObject, UserInfo_.userinfo, ExistingObject.info.notes);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(RawObject->has("name"))
|
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")) {
|
if(RawObject->has("venue")) {
|
||||||
std::string Venue{RawObject->get("venue").toString()};
|
std::string Venue{RawObject->get("venue").toString()};
|
||||||
if(!Storage()->VenueDB().Exists("id",Venue)) {
|
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")) {
|
if(RawObject->has("deviceType")) {
|
||||||
std::string DeviceType{RawObject->get("deviceType").toString()};
|
std::string DeviceType{RawObject->get("deviceType").toString()};
|
||||||
ExistingObject.deviceType = DeviceType;
|
ExistingObject.deviceType = DeviceType;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "Poco/Net/HTTPServerResponse.h"
|
#include "Poco/Net/HTTPServerResponse.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_inventory_handler : public uCentral::RESTAPIHandler {
|
class RESTAPI_inventory_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_inventory_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
RESTAPI_inventory_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace OpenWifi{
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if(!QB_.Select.empty()) {
|
if(!QB_.Select.empty()) {
|
||||||
auto DevUIIDS = uCentral::Utils::Split(QB_.Select);
|
auto DevUIIDS = Utils::Split(QB_.Select);
|
||||||
Poco::JSON::Array Arr;
|
Poco::JSON::Array Arr;
|
||||||
for(const auto &i:DevUIIDS) {
|
for(const auto &i:DevUIIDS) {
|
||||||
ProvObjects::InventoryTag E;
|
ProvObjects::InventoryTag E;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include "Poco/Net/HTTPServerResponse.h"
|
#include "Poco/Net/HTTPServerResponse.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_inventory_list_handler : public uCentral::RESTAPIHandler {
|
class RESTAPI_inventory_list_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_inventory_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
RESTAPI_inventory_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "Poco/Net/HTTPServerResponse.h"
|
#include "Poco/Net/HTTPServerResponse.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_location_handler : public uCentral::RESTAPIHandler {
|
class RESTAPI_location_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_location_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
RESTAPI_location_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "Poco/Net/HTTPServerResponse.h"
|
#include "Poco/Net/HTTPServerResponse.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_managementPolicy_handler : public uCentral::RESTAPIHandler {
|
class RESTAPI_managementPolicy_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_managementPolicy_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
RESTAPI_managementPolicy_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#ifndef UCENTRALGW_RESTAPI_PROTOCOL_H
|
#ifndef UCENTRALGW_RESTAPI_PROTOCOL_H
|
||||||
#define 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 * CAPABILITIES = "capabilities";
|
||||||
static const char * LOGS = "logs";
|
static const char * LOGS = "logs";
|
||||||
static const char * HEALTHCHECKS = "healthchecks";
|
static const char * HEALTHCHECKS = "healthchecks";
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#include "RESTAPI_inventory_list_handler.h"
|
#include "RESTAPI_inventory_list_handler.h"
|
||||||
#include "RESTAPI_entity_list_handler.h"
|
#include "RESTAPI_entity_list_handler.h"
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class RESTAPI_server *RESTAPI_server::instance_ = nullptr;
|
class RESTAPI_server *RESTAPI_server::instance_ = nullptr;
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ namespace uCentral {
|
|||||||
|
|
||||||
Poco::Net::HTTPRequestHandler *RequestHandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest & Request) {
|
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());
|
Poco::URI uri(Request.getURI());
|
||||||
auto *Path = uri.getPath().c_str();
|
auto *Path = uri.getPath().c_str();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include "SubSystemServer.h"
|
#include "SubSystemServer.h"
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class RESTAPI_server : public SubSystemServer {
|
class RESTAPI_server : public SubSystemServer {
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include "Daemon.h"
|
#include "Daemon.h"
|
||||||
#include "RESTAPI_protocol.h"
|
#include "RESTAPI_protocol.h"
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
void RESTAPI_system_command::handleRequest(Poco::Net::HTTPServerRequest &Request,
|
void RESTAPI_system_command::handleRequest(Poco::Net::HTTPServerRequest &Request,
|
||||||
Poco::Net::HTTPServerResponse &Response) {
|
Poco::Net::HTTPServerResponse &Response) {
|
||||||
|
|
||||||
@@ -36,19 +36,19 @@ namespace uCentral {
|
|||||||
Poco::JSON::Parser parser;
|
Poco::JSON::Parser parser;
|
||||||
auto Obj = parser.parse(Request.stream()).extract<Poco::JSON::Object::Ptr>();
|
auto Obj = parser.parse(Request.stream()).extract<Poco::JSON::Object::Ptr>();
|
||||||
|
|
||||||
if (Obj->has(uCentral::RESTAPI::Protocol::COMMAND)) {
|
if (Obj->has(RESTAPI::Protocol::COMMAND)) {
|
||||||
auto Command = Poco::toLower(Obj->get(uCentral::RESTAPI::Protocol::COMMAND).toString());
|
auto Command = Poco::toLower(Obj->get(RESTAPI::Protocol::COMMAND).toString());
|
||||||
if (Command == uCentral::RESTAPI::Protocol::SETLOGLEVEL) {
|
if (Command == RESTAPI::Protocol::SETLOGLEVEL) {
|
||||||
if (Obj->has(uCentral::RESTAPI::Protocol::PARAMETERS) &&
|
if (Obj->has(RESTAPI::Protocol::PARAMETERS) &&
|
||||||
Obj->isArray(uCentral::RESTAPI::Protocol::PARAMETERS)) {
|
Obj->isArray(RESTAPI::Protocol::PARAMETERS)) {
|
||||||
auto ParametersBlock = Obj->getArray(uCentral::RESTAPI::Protocol::PARAMETERS);
|
auto ParametersBlock = Obj->getArray(RESTAPI::Protocol::PARAMETERS);
|
||||||
for (const auto &i:*ParametersBlock) {
|
for (const auto &i:*ParametersBlock) {
|
||||||
Poco::JSON::Parser pp;
|
Poco::JSON::Parser pp;
|
||||||
auto InnerObj = pp.parse(i).extract<Poco::JSON::Object::Ptr>();
|
auto InnerObj = pp.parse(i).extract<Poco::JSON::Object::Ptr>();
|
||||||
if (InnerObj->has(uCentral::RESTAPI::Protocol::TAG) &&
|
if (InnerObj->has(RESTAPI::Protocol::TAG) &&
|
||||||
InnerObj->has(uCentral::RESTAPI::Protocol::VALUE)) {
|
InnerObj->has(RESTAPI::Protocol::VALUE)) {
|
||||||
auto Name = GetS(uCentral::RESTAPI::Protocol::TAG, InnerObj);
|
auto Name = GetS(RESTAPI::Protocol::TAG, InnerObj);
|
||||||
auto Value = GetS(uCentral::RESTAPI::Protocol::VALUE, InnerObj);
|
auto Value = GetS(RESTAPI::Protocol::VALUE, InnerObj);
|
||||||
Daemon()->SetSubsystemLogLevel(Name, Value);
|
Daemon()->SetSubsystemLogLevel(Name, Value);
|
||||||
Logger_.information(Poco::format("Setting log level for %s at %s", Name, Value));
|
Logger_.information(Poco::format("Setting log level for %s at %s", Name, Value));
|
||||||
}
|
}
|
||||||
@@ -56,38 +56,38 @@ namespace uCentral {
|
|||||||
OK(Request, Response);
|
OK(Request, Response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (Command == uCentral::RESTAPI::Protocol::GETLOGLEVELS) {
|
} else if (Command == RESTAPI::Protocol::GETLOGLEVELS) {
|
||||||
auto CurrentLogLevels = Daemon()->GetLogLevels();
|
auto CurrentLogLevels = Daemon()->GetLogLevels();
|
||||||
Poco::JSON::Object Result;
|
Poco::JSON::Object Result;
|
||||||
Poco::JSON::Array Array;
|
Poco::JSON::Array Array;
|
||||||
for(auto &[Name,Level]:CurrentLogLevels) {
|
for(auto &[Name,Level]:CurrentLogLevels) {
|
||||||
Poco::JSON::Object Pair;
|
Poco::JSON::Object Pair;
|
||||||
Pair.set( uCentral::RESTAPI::Protocol::TAG,Name);
|
Pair.set( RESTAPI::Protocol::TAG,Name);
|
||||||
Pair.set(uCentral::RESTAPI::Protocol::VALUE,Level);
|
Pair.set(RESTAPI::Protocol::VALUE,Level);
|
||||||
Array.add(Pair);
|
Array.add(Pair);
|
||||||
}
|
}
|
||||||
Result.set(uCentral::RESTAPI::Protocol::TAGLIST,Array);
|
Result.set(RESTAPI::Protocol::TAGLIST,Array);
|
||||||
ReturnObject(Request,Result,Response);
|
ReturnObject(Request,Result,Response);
|
||||||
return;
|
return;
|
||||||
} else if (Command == uCentral::RESTAPI::Protocol::GETLOGLEVELNAMES) {
|
} else if (Command == RESTAPI::Protocol::GETLOGLEVELNAMES) {
|
||||||
Poco::JSON::Object Result;
|
Poco::JSON::Object Result;
|
||||||
Poco::JSON::Array LevelNamesArray;
|
Poco::JSON::Array LevelNamesArray;
|
||||||
const Types::StringVec & LevelNames = Daemon()->GetLogLevelNames();
|
const Types::StringVec & LevelNames = Daemon()->GetLogLevelNames();
|
||||||
for(const auto &i:LevelNames)
|
for(const auto &i:LevelNames)
|
||||||
LevelNamesArray.add(i);
|
LevelNamesArray.add(i);
|
||||||
Result.set(uCentral::RESTAPI::Protocol::LIST,LevelNamesArray);
|
Result.set(RESTAPI::Protocol::LIST,LevelNamesArray);
|
||||||
ReturnObject(Request,Result,Response);
|
ReturnObject(Request,Result,Response);
|
||||||
return;
|
return;
|
||||||
} else if (Command == uCentral::RESTAPI::Protocol::GETSUBSYSTEMNAMES) {
|
} else if (Command == RESTAPI::Protocol::GETSUBSYSTEMNAMES) {
|
||||||
Poco::JSON::Object Result;
|
Poco::JSON::Object Result;
|
||||||
Poco::JSON::Array LevelNamesArray;
|
Poco::JSON::Array LevelNamesArray;
|
||||||
const Types::StringVec & SubSystemNames = Daemon()->GetSubSystems();
|
const Types::StringVec & SubSystemNames = Daemon()->GetSubSystems();
|
||||||
for(const auto &i:SubSystemNames)
|
for(const auto &i:SubSystemNames)
|
||||||
LevelNamesArray.add(i);
|
LevelNamesArray.add(i);
|
||||||
Result.set(uCentral::RESTAPI::Protocol::LIST,LevelNamesArray);
|
Result.set(RESTAPI::Protocol::LIST,LevelNamesArray);
|
||||||
ReturnObject(Request,Result,Response);
|
ReturnObject(Request,Result,Response);
|
||||||
return;
|
return;
|
||||||
} else if (Command == uCentral::RESTAPI::Protocol::STATS) {
|
} else if (Command == RESTAPI::Protocol::STATS) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#include "RESTAPI_handler.h"
|
#include "RESTAPI_handler.h"
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
class RESTAPI_system_command : public RESTAPIHandler {
|
class RESTAPI_system_command : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_system_command(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
RESTAPI_system_command(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "RESTAPI_utils.h"
|
#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) {
|
void EmbedDocument(const std::string & ObjName, Poco::JSON::Object & Obj, const std::string &ObjStr) {
|
||||||
std::string D = ObjStr.empty() ? "{}" : ObjStr;
|
std::string D = ObjStr.empty() ? "{}" : ObjStr;
|
||||||
|
|||||||
@@ -9,10 +9,10 @@
|
|||||||
#include "Poco/JSON/Object.h"
|
#include "Poco/JSON/Object.h"
|
||||||
#include "Poco/JSON/Parser.h"
|
#include "Poco/JSON/Parser.h"
|
||||||
#include "Poco/Net/HTTPServerRequest.h"
|
#include "Poco/Net/HTTPServerRequest.h"
|
||||||
#include "uCentralTypes.h"
|
#include "OpenWifiTypes.h"
|
||||||
#include "Utils.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);
|
void EmbedDocument(const std::string & ObjName, Poco::JSON::Object & Obj, const std::string &ObjStr);
|
||||||
|
|
||||||
|
|||||||
@@ -27,14 +27,22 @@ namespace OpenWifi{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RESTAPI_venue_handler::DoGet(Poco::Net::HTTPServerRequest &Request,
|
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,
|
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,
|
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,
|
void RESTAPI_venue_handler::DoPut(Poco::Net::HTTPServerRequest &Request,
|
||||||
Poco::Net::HTTPServerResponse &Response) {}
|
Poco::Net::HTTPServerResponse &Response) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "Poco/Net/HTTPServerResponse.h"
|
#include "Poco/Net/HTTPServerResponse.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_venue_handler : public uCentral::RESTAPIHandler {
|
class RESTAPI_venue_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_venue_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
RESTAPI_venue_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
|
|||||||
@@ -7,10 +7,12 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "Poco/Util/Application.h"
|
#include "Poco/Util/Application.h"
|
||||||
|
#include "Poco/Net/HTTPResponse.h"
|
||||||
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
#include "Daemon.h"
|
#include "Daemon.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
#include "OpenAPIRequest.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
@@ -26,7 +28,7 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
Logger_.setLevel(Poco::Message::PRIO_NOTICE);
|
Logger_.setLevel(Poco::Message::PRIO_NOTICE);
|
||||||
Logger_.notice("Starting.");
|
Logger_.notice("Starting.");
|
||||||
std::string DBType = uCentral::Daemon()->ConfigGetString("storage.type");
|
std::string DBType = Daemon()->ConfigGetString("storage.type");
|
||||||
|
|
||||||
if (DBType == "sqlite") {
|
if (DBType == "sqlite") {
|
||||||
DBType_ = ORM::DBType::sqlite;
|
DBType_ = ORM::DBType::sqlite;
|
||||||
@@ -58,10 +60,83 @@ namespace OpenWifi {
|
|||||||
OpenWifi::ProvObjects::Entity R;
|
OpenWifi::ProvObjects::Entity R;
|
||||||
EntityDB_->GetRecord("id","xxx",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() {
|
void Storage::Stop() {
|
||||||
|
Running_=false;
|
||||||
|
Updater_.wakeUp();
|
||||||
|
Updater_.join();
|
||||||
Logger_.notice("Stopping.");
|
Logger_.notice("Stopping.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class Storage : public uCentral::SubSystemServer {
|
class Storage : public SubSystemServer, Poco::Runnable {
|
||||||
public:
|
public:
|
||||||
static Storage *instance() {
|
static Storage *instance() {
|
||||||
if (instance_ == nullptr) {
|
if (instance_ == nullptr) {
|
||||||
@@ -58,6 +58,10 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
bool Validate(const Poco::URI::QueryParameters &P, std::string &Error);
|
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:
|
private:
|
||||||
static Storage *instance_;
|
static Storage *instance_;
|
||||||
std::unique_ptr<Poco::Data::SessionPool> Pool_= nullptr;
|
std::unique_ptr<Poco::Data::SessionPool> Pool_= nullptr;
|
||||||
@@ -74,6 +78,11 @@ namespace OpenWifi {
|
|||||||
std::unique_ptr<OpenWifi::InventoryDB> InventoryDB_;
|
std::unique_ptr<OpenWifi::InventoryDB> InventoryDB_;
|
||||||
std::unique_ptr<OpenWifi::ManagementRoleDB> RolesDB_;
|
std::unique_ptr<OpenWifi::ManagementRoleDB> RolesDB_;
|
||||||
|
|
||||||
|
Poco::Thread Updater_;
|
||||||
|
std::set<std::string> DeviceTypes_;
|
||||||
|
std::atomic_bool Running_=false;
|
||||||
|
|
||||||
|
bool UpdateDeviceTypes();
|
||||||
Storage() noexcept;
|
Storage() noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "Daemon.h"
|
#include "Daemon.h"
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
SubSystemServer::SubSystemServer(std::string Name, const std::string &LoggingPrefix,
|
SubSystemServer::SubSystemServer(std::string Name, const std::string &LoggingPrefix,
|
||||||
std::string SubSystemConfigPrefix)
|
std::string SubSystemConfigPrefix)
|
||||||
: Name_(std::move(Name)), Logger_(Poco::Logger::get(LoggingPrefix)),
|
: Name_(std::move(Name)), Logger_(Poco::Logger::get(LoggingPrefix)),
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
using SubMutex = std::recursive_mutex;
|
using SubMutex = std::recursive_mutex;
|
||||||
using SubMutexGuard = std::lock_guard<SubMutex>;
|
using SubMutexGuard = std::lock_guard<SubMutex>;
|
||||||
|
|
||||||
namespace uCentral {
|
namespace OpenWifi {
|
||||||
class PropertiesFileServerEntry {
|
class PropertiesFileServerEntry {
|
||||||
public:
|
public:
|
||||||
PropertiesFileServerEntry(std::string Address, uint32_t port, std::string Key_file,
|
PropertiesFileServerEntry(std::string Address, uint32_t port, std::string Key_file,
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
#include "uCentralProtocol.h"
|
#include "uCentralProtocol.h"
|
||||||
#include "Daemon.h"
|
#include "Daemon.h"
|
||||||
|
|
||||||
namespace uCentral::Utils {
|
namespace OpenWifi::Utils {
|
||||||
|
|
||||||
[[nodiscard]] bool ValidSerialNumber(const std::string &Serial) {
|
[[nodiscard]] bool ValidSerialNumber(const std::string &Serial) {
|
||||||
return ((Serial.size() < uCentralProtocol::SERIAL_NUMBER_LENGTH) &&
|
return ((Serial.size() < uCentralProtocol::SERIAL_NUMBER_LENGTH) &&
|
||||||
|
|||||||
@@ -18,11 +18,11 @@
|
|||||||
#include "Poco/Net/IPAddress.h"
|
#include "Poco/Net/IPAddress.h"
|
||||||
#include "Poco/String.h"
|
#include "Poco/String.h"
|
||||||
#include "Poco/File.h"
|
#include "Poco/File.h"
|
||||||
#include "uCentralTypes.h"
|
#include "OpenWifiTypes.h"
|
||||||
|
|
||||||
#define DBGLINE { std::cout << __FILE__ << ":" << __func__ << ":" << __LINE__ << std::endl; };
|
#define DBGLINE { std::cout << __FILE__ << ":" << __func__ << ":" << __LINE__ << std::endl; };
|
||||||
|
|
||||||
namespace uCentral::Utils {
|
namespace OpenWifi::Utils {
|
||||||
|
|
||||||
enum MediaTypeEncodings {
|
enum MediaTypeEncodings {
|
||||||
PLAIN,
|
PLAIN,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "storage_contact.h"
|
#include "storage_contact.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "uCentralTypes.h"
|
#include "OpenWifiTypes.h"
|
||||||
#include "RESTAPI_utils.h"
|
#include "RESTAPI_utils.h"
|
||||||
#include "RESTAPI_SecurityObjects.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.id = In.get<0>();
|
||||||
Out.info.name = In.get<1>();
|
Out.info.name = In.get<1>();
|
||||||
Out.info.description = In.get<2>();
|
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.created = In.get<4>();
|
||||||
Out.info.modified = In.get<5>();
|
Out.info.modified = In.get<5>();
|
||||||
|
|
||||||
@@ -61,20 +61,20 @@ template<> void ORM::DB< OpenWifi::ContactDBRecordType, OpenWifi::ProvObjects
|
|||||||
Out.lastname = In.get<10>();
|
Out.lastname = In.get<10>();
|
||||||
Out.initials = In.get<11>();
|
Out.initials = In.get<11>();
|
||||||
Out.visual = In.get<12>();
|
Out.visual = In.get<12>();
|
||||||
uCentral::Types::from_string(In.get<13>(), Out.mobiles);
|
OpenWifi::Types::from_string(In.get<13>(), Out.mobiles);
|
||||||
uCentral::Types::from_string(In.get<14>(), Out.phones);
|
OpenWifi::Types::from_string(In.get<14>(), Out.phones);
|
||||||
Out.primaryEmail = In.get<15>();
|
Out.primaryEmail = In.get<15>();
|
||||||
Out.secondaryEmail = In.get<16>();
|
Out.secondaryEmail = In.get<16>();
|
||||||
Out.accessPIN = In.get<17>();
|
Out.accessPIN = In.get<17>();
|
||||||
uCentral::Types::from_string(In.get<18>(), Out.venues);
|
OpenWifi::Types::from_string(In.get<18>(), Out.venues);
|
||||||
uCentral::Types::from_string(In.get<19>(), Out.entities);
|
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) {
|
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<0>(In.info.id);
|
||||||
Out.set<1>(In.info.name);
|
Out.set<1>(In.info.name);
|
||||||
Out.set<2>(In.info.description);
|
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<4>(In.info.created);
|
||||||
Out.set<5>(In.info.modified);
|
Out.set<5>(In.info.modified);
|
||||||
Out.set<6>(to_string(In.type));
|
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<10>(In.lastname);
|
||||||
Out.set<11>(In.initials);
|
Out.set<11>(In.initials);
|
||||||
Out.set<12>(In.visual);
|
Out.set<12>(In.visual);
|
||||||
Out.set<13>(uCentral::Types::to_string(In.mobiles));
|
Out.set<13>(OpenWifi::Types::to_string(In.mobiles));
|
||||||
Out.set<14>(uCentral::Types::to_string(In.phones));
|
Out.set<14>(OpenWifi::Types::to_string(In.phones));
|
||||||
Out.set<15>(In.primaryEmail);
|
Out.set<15>(In.primaryEmail);
|
||||||
Out.set<16>(In.secondaryEmail);
|
Out.set<16>(In.secondaryEmail);
|
||||||
Out.set<17>(In.accessPIN);
|
Out.set<17>(In.accessPIN);
|
||||||
Out.set<18>(uCentral::Types::to_string(In.venues));
|
Out.set<18>(OpenWifi::Types::to_string(In.venues));
|
||||||
Out.set<19>(uCentral::Types::to_string(In.entities));
|
Out.set<19>(OpenWifi::Types::to_string(In.entities));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,14 @@
|
|||||||
|
|
||||||
#include "storage_entity.h"
|
#include "storage_entity.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "uCentralTypes.h"
|
#include "OpenWifiTypes.h"
|
||||||
#include "RESTAPI_utils.h"
|
#include "RESTAPI_utils.h"
|
||||||
#include "RESTAPI_SecurityObjects.h"
|
#include "RESTAPI_SecurityObjects.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
|
const std::string EntityDB::RootUUID_{"0000-0000-0000"};
|
||||||
|
|
||||||
static ORM::FieldVec EntityDB_Fields{
|
static ORM::FieldVec EntityDB_Fields{
|
||||||
// object info
|
// object info
|
||||||
ORM::Field{"id",64, true},
|
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.id = In.get<0>();
|
||||||
Out.info.name = In.get<1>();
|
Out.info.name = In.get<1>();
|
||||||
Out.info.description = In.get<2>();
|
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.created = In.get<4>();
|
||||||
Out.info.modified = In.get<5>();
|
Out.info.modified = In.get<5>();
|
||||||
Out.parent = In.get<6>();
|
Out.parent = In.get<6>();
|
||||||
uCentral::Types::from_string(In.get<7>(), Out.children);
|
OpenWifi::Types::from_string(In.get<7>(), Out.children);
|
||||||
uCentral::Types::from_string(In.get<8>(), Out.contacts);
|
OpenWifi::Types::from_string(In.get<8>(), Out.contacts);
|
||||||
uCentral::Types::from_string(In.get<9>(), Out.locations);
|
OpenWifi::Types::from_string(In.get<9>(), Out.locations);
|
||||||
Out.managementPolicy = In.get<10>();
|
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) {
|
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<0>(In.info.id);
|
||||||
Out.set<1>(In.info.name);
|
Out.set<1>(In.info.name);
|
||||||
Out.set<2>(In.info.description);
|
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<4>(In.info.created);
|
||||||
Out.set<5>(In.info.modified);
|
Out.set<5>(In.info.modified);
|
||||||
Out.set<6>(In.parent);
|
Out.set<6>(In.parent);
|
||||||
Out.set<7>(uCentral::Types::to_string(In.children));
|
Out.set<7>(OpenWifi::Types::to_string(In.children));
|
||||||
Out.set<8>(uCentral::Types::to_string(In.contacts));
|
Out.set<8>(OpenWifi::Types::to_string(In.contacts));
|
||||||
Out.set<9>(uCentral::Types::to_string(In.locations));
|
Out.set<9>(OpenWifi::Types::to_string(In.locations));
|
||||||
Out.set<10>(In.managementPolicy);
|
Out.set<10>(In.managementPolicy);
|
||||||
Out.set<11>(uCentral::Types::to_string(In.venues));
|
Out.set<11>(OpenWifi::Types::to_string(In.venues));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,11 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
class EntityDB : public ORM::DB<EntityDBRecordType, ProvObjects::Entity> {
|
class EntityDB : public ORM::DB<EntityDBRecordType, ProvObjects::Entity> {
|
||||||
public:
|
public:
|
||||||
|
static const std::string RootUUID_;
|
||||||
EntityDB( ORM::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
|
EntityDB( ORM::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
|
||||||
inline bool RootExists() const { return RootExists_; };
|
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();
|
bool CheckForRoot();
|
||||||
private:
|
private:
|
||||||
bool RootExists_=false;
|
bool RootExists_=false;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "storage_inventory.h"
|
#include "storage_inventory.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "uCentralTypes.h"
|
#include "OpenWifiTypes.h"
|
||||||
#include "RESTAPI_utils.h"
|
#include "RESTAPI_utils.h"
|
||||||
#include "RESTAPI_SecurityObjects.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.id = In.get<0>();
|
||||||
Out.info.name = In.get<1>();
|
Out.info.name = In.get<1>();
|
||||||
Out.info.description = In.get<2>();
|
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.created = In.get<4>();
|
||||||
Out.info.modified = In.get<5>();
|
Out.info.modified = In.get<5>();
|
||||||
Out.serialNumber = In.get<6>();
|
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<0>(In.info.id);
|
||||||
Out.set<1>(In.info.name);
|
Out.set<1>(In.info.name);
|
||||||
Out.set<2>(In.info.description);
|
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<4>(In.info.created);
|
||||||
Out.set<5>(In.info.modified);
|
Out.set<5>(In.info.modified);
|
||||||
Out.set<6>(In.serialNumber);
|
Out.set<6>(In.serialNumber);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "storage_location.h"
|
#include "storage_location.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "uCentralTypes.h"
|
#include "OpenWifiTypes.h"
|
||||||
#include "RESTAPI_utils.h"
|
#include "RESTAPI_utils.h"
|
||||||
#include "RESTAPI_SecurityObjects.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.id = In.get<0>();
|
||||||
Out.info.name = In.get<1>();
|
Out.info.name = In.get<1>();
|
||||||
Out.info.description = In.get<2>();
|
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.created = In.get<4>();
|
||||||
Out.info.modified = In.get<5>();
|
Out.info.modified = In.get<5>();
|
||||||
Out.type = OpenWifi::ProvObjects::location_from_string(In.get<6>());
|
Out.type = OpenWifi::ProvObjects::location_from_string(In.get<6>());
|
||||||
Out.buildingName = In.get<7>();
|
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.city = In.get<9>();
|
||||||
Out.state = In.get<10>();
|
Out.state = In.get<10>();
|
||||||
Out.postal = In.get<11>();
|
Out.postal = In.get<11>();
|
||||||
Out.country = In.get<12>();
|
Out.country = In.get<12>();
|
||||||
uCentral::Types::from_string(In.get<13>(), Out.phones);
|
OpenWifi::Types::from_string(In.get<13>(), Out.phones);
|
||||||
uCentral::Types::from_string(In.get<14>(), Out.mobiles);
|
OpenWifi::Types::from_string(In.get<14>(), Out.mobiles);
|
||||||
uCentral::Types::from_string(In.get<15>(), Out.venues);
|
OpenWifi::Types::from_string(In.get<15>(), Out.venues);
|
||||||
uCentral::Types::from_string(In.get<16>(), Out.entities);
|
OpenWifi::Types::from_string(In.get<16>(), Out.entities);
|
||||||
Out.geoCode = In.get<17>();
|
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<0>(In.info.id);
|
||||||
Out.set<1>(In.info.name);
|
Out.set<1>(In.info.name);
|
||||||
Out.set<2>(In.info.description);
|
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<4>(In.info.created);
|
||||||
Out.set<5>(In.info.modified);
|
Out.set<5>(In.info.modified);
|
||||||
Out.set<6>(OpenWifi::ProvObjects::to_string(In.type));
|
Out.set<6>(OpenWifi::ProvObjects::to_string(In.type));
|
||||||
Out.set<7>(In.buildingName);
|
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<9>(In.city);
|
||||||
Out.set<10>(In.state);
|
Out.set<10>(In.state);
|
||||||
Out.set<11>(In.postal);
|
Out.set<11>(In.postal);
|
||||||
Out.set<12>(In.country);
|
Out.set<12>(In.country);
|
||||||
Out.set<13>(uCentral::Types::to_string(In.phones));
|
Out.set<13>(OpenWifi::Types::to_string(In.phones));
|
||||||
Out.set<14>(uCentral::Types::to_string(In.mobiles));
|
Out.set<14>(OpenWifi::Types::to_string(In.mobiles));
|
||||||
Out.set<15>(uCentral::Types::to_string(In.venues));
|
Out.set<15>(OpenWifi::Types::to_string(In.venues));
|
||||||
Out.set<16>(uCentral::Types::to_string(In.entities));
|
Out.set<16>(OpenWifi::Types::to_string(In.entities));
|
||||||
Out.set<17>(In.geoCode);
|
Out.set<17>(In.geoCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "storage_management_roles.h"
|
#include "storage_management_roles.h"
|
||||||
#include "uCentralTypes.h"
|
#include "OpenWifiTypes.h"
|
||||||
#include "RESTAPI_utils.h"
|
#include "RESTAPI_utils.h"
|
||||||
#include "RESTAPI_SecurityObjects.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.id = In.get<0>();
|
||||||
Out.info.name = In.get<1>();
|
Out.info.name = In.get<1>();
|
||||||
Out.info.description = In.get<2>();
|
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.created = In.get<4>();
|
||||||
Out.info.modified = In.get<5>();
|
Out.info.modified = In.get<5>();
|
||||||
Out.managementPolicy = In.get<6>();
|
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) {
|
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<0>(In.info.id);
|
||||||
Out.set<1>(In.info.name);
|
Out.set<1>(In.info.name);
|
||||||
Out.set<2>(In.info.description);
|
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<4>(In.info.created);
|
||||||
Out.set<5>(In.info.modified);
|
Out.set<5>(In.info.modified);
|
||||||
Out.set<6>(In.managementPolicy);
|
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));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,19 +12,19 @@
|
|||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
#ifdef SMALL_BUILD
|
#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
|
#else
|
||||||
|
|
||||||
int Storage::Setup_MySQL() {
|
int Storage::Setup_MySQL() {
|
||||||
|
|
||||||
Logger_.notice("MySQL Storage enabled.");
|
Logger_.notice("MySQL Storage enabled.");
|
||||||
auto NumSessions = uCentral::Daemon()->ConfigGetInt("storage.type.mysql.maxsessions", 64);
|
auto NumSessions = Daemon()->ConfigGetInt("storage.type.mysql.maxsessions", 64);
|
||||||
auto IdleTime = uCentral::Daemon()->ConfigGetInt("storage.type.mysql.idletime", 60);
|
auto IdleTime = Daemon()->ConfigGetInt("storage.type.mysql.idletime", 60);
|
||||||
auto Host = uCentral::Daemon()->ConfigGetString("storage.type.mysql.host");
|
auto Host = Daemon()->ConfigGetString("storage.type.mysql.host");
|
||||||
auto Username = uCentral::Daemon()->ConfigGetString("storage.type.mysql.username");
|
auto Username = Daemon()->ConfigGetString("storage.type.mysql.username");
|
||||||
auto Password = uCentral::Daemon()->ConfigGetString("storage.type.mysql.password");
|
auto Password = Daemon()->ConfigGetString("storage.type.mysql.password");
|
||||||
auto Database = uCentral::Daemon()->ConfigGetString("storage.type.mysql.database");
|
auto Database = Daemon()->ConfigGetString("storage.type.mysql.database");
|
||||||
auto Port = uCentral::Daemon()->ConfigGetString("storage.type.mysql.port");
|
auto Port = Daemon()->ConfigGetString("storage.type.mysql.port");
|
||||||
|
|
||||||
std::string ConnectionStr =
|
std::string ConnectionStr =
|
||||||
"host=" + Host +
|
"host=" + Host +
|
||||||
|
|||||||
@@ -12,19 +12,19 @@
|
|||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
#ifdef SMALL_BUILD
|
#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
|
#else
|
||||||
int Storage::Setup_PostgreSQL() {
|
int Storage::Setup_PostgreSQL() {
|
||||||
Logger_.notice("PostgreSQL Storage enabled.");
|
Logger_.notice("PostgreSQL Storage enabled.");
|
||||||
|
|
||||||
auto NumSessions = uCentral::Daemon()->ConfigGetInt("storage.type.postgresql.maxsessions", 64);
|
auto NumSessions = Daemon()->ConfigGetInt("storage.type.postgresql.maxsessions", 64);
|
||||||
auto IdleTime = uCentral::Daemon()->ConfigGetInt("storage.type.postgresql.idletime", 60);
|
auto IdleTime = Daemon()->ConfigGetInt("storage.type.postgresql.idletime", 60);
|
||||||
auto Host = uCentral::Daemon()->ConfigGetString("storage.type.postgresql.host");
|
auto Host = Daemon()->ConfigGetString("storage.type.postgresql.host");
|
||||||
auto Username = uCentral::Daemon()->ConfigGetString("storage.type.postgresql.username");
|
auto Username = Daemon()->ConfigGetString("storage.type.postgresql.username");
|
||||||
auto Password = uCentral::Daemon()->ConfigGetString("storage.type.postgresql.password");
|
auto Password = Daemon()->ConfigGetString("storage.type.postgresql.password");
|
||||||
auto Database = uCentral::Daemon()->ConfigGetString("storage.type.postgresql.database");
|
auto Database = Daemon()->ConfigGetString("storage.type.postgresql.database");
|
||||||
auto Port = uCentral::Daemon()->ConfigGetString("storage.type.postgresql.port");
|
auto Port = Daemon()->ConfigGetString("storage.type.postgresql.port");
|
||||||
auto ConnectionTimeout = uCentral::Daemon()->ConfigGetString("storage.type.postgresql.connectiontimeout");
|
auto ConnectionTimeout = Daemon()->ConfigGetString("storage.type.postgresql.connectiontimeout");
|
||||||
|
|
||||||
std::string ConnectionStr =
|
std::string ConnectionStr =
|
||||||
"host=" + Host +
|
"host=" + Host +
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "storage_policies.h"
|
#include "storage_policies.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "uCentralTypes.h"
|
#include "OpenWifiTypes.h"
|
||||||
#include "RESTAPI_utils.h"
|
#include "RESTAPI_utils.h"
|
||||||
#include "RESTAPI_SecurityObjects.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.id = In.get<0>();
|
||||||
Out.info.name = In.get<1>();
|
Out.info.name = In.get<1>();
|
||||||
Out.info.description = In.get<2>();
|
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.created = In.get<4>();
|
||||||
Out.info.modified = In.get<5>();
|
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) {
|
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<0>(In.info.id);
|
||||||
Out.set<1>(In.info.name);
|
Out.set<1>(In.info.name);
|
||||||
Out.set<2>(In.info.description);
|
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<4>(In.info.created);
|
||||||
Out.set<5>(In.info.modified);
|
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));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ namespace OpenWifi {
|
|||||||
int Storage::Setup_SQLite() {
|
int Storage::Setup_SQLite() {
|
||||||
Logger_.notice("SQLite Storage enabled.");
|
Logger_.notice("SQLite Storage enabled.");
|
||||||
|
|
||||||
auto DBName = uCentral::Daemon()->DataDir() + "/" + uCentral::Daemon()->ConfigGetString("storage.type.sqlite.db");
|
auto DBName = Daemon()->DataDir() + "/" + Daemon()->ConfigGetString("storage.type.sqlite.db");
|
||||||
auto NumSessions = uCentral::Daemon()->ConfigGetInt("storage.type.sqlite.maxsessions", 64);
|
auto NumSessions = Daemon()->ConfigGetInt("storage.type.sqlite.maxsessions", 64);
|
||||||
auto IdleTime = uCentral::Daemon()->ConfigGetInt("storage.type.sqlite.idletime", 60);
|
auto IdleTime = Daemon()->ConfigGetInt("storage.type.sqlite.idletime", 60);
|
||||||
|
|
||||||
SQLiteConn_ = std::make_unique<Poco::Data::SQLite::Connector>();
|
SQLiteConn_ = std::make_unique<Poco::Data::SQLite::Connector>();
|
||||||
SQLiteConn_->registerConnector();
|
SQLiteConn_->registerConnector();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "storage_venue.h"
|
#include "storage_venue.h"
|
||||||
#include "uCentralTypes.h"
|
#include "OpenWifiTypes.h"
|
||||||
#include "RESTAPI_utils.h"
|
#include "RESTAPI_utils.h"
|
||||||
#include "RESTAPI_SecurityObjects.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.id = In.get<0>();
|
||||||
Out.info.name = In.get<1>();
|
Out.info.name = In.get<1>();
|
||||||
Out.info.description = In.get<2>();
|
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.created = In.get<4>();
|
||||||
Out.info.modified = In.get<5>();
|
Out.info.modified = In.get<5>();
|
||||||
Out.entity = In.get<6>();
|
Out.entity = In.get<6>();
|
||||||
Out.parent = In.get<7>();
|
Out.parent = In.get<7>();
|
||||||
uCentral::Types::from_string(In.get<8>(), Out.children);
|
OpenWifi::Types::from_string(In.get<8>(), Out.children);
|
||||||
uCentral::Types::from_string(In.get<9>(), Out.devices);
|
OpenWifi::Types::from_string(In.get<9>(), Out.devices);
|
||||||
Out.topology = uCentral::RESTAPI_utils::to_object_array<OpenWifi::ProvObjects::DiGraphEntry>(In.get<10>());
|
Out.topology = OpenWifi::RESTAPI_utils::to_object_array<OpenWifi::ProvObjects::DiGraphEntry>(In.get<10>());
|
||||||
Out.design = In.get<11>();
|
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<0>(In.info.id);
|
||||||
Out.set<1>(In.info.name);
|
Out.set<1>(In.info.name);
|
||||||
Out.set<2>(In.info.description);
|
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<4>(In.info.created);
|
||||||
Out.set<5>(In.info.modified);
|
Out.set<5>(In.info.modified);
|
||||||
Out.set<6>(In.entity);
|
Out.set<6>(In.entity);
|
||||||
Out.set<7>(In.parent);
|
Out.set<7>(In.parent);
|
||||||
Out.set<8>(uCentral::Types::to_string(In.children));
|
Out.set<8>(OpenWifi::Types::to_string(In.children));
|
||||||
Out.set<9>(uCentral::Types::to_string(In.devices));
|
Out.set<9>(OpenWifi::Types::to_string(In.devices));
|
||||||
Out.set<10>(uCentral::RESTAPI_utils::to_string(In.topology));
|
Out.set<10>(OpenWifi::RESTAPI_utils::to_string(In.topology));
|
||||||
Out.set<11>(In.design);
|
Out.set<11>(In.design);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#include "Poco/String.h"
|
#include "Poco/String.h"
|
||||||
|
|
||||||
namespace uCentral::uCentralProtocol {
|
namespace OpenWifi::uCentralProtocol {
|
||||||
|
|
||||||
const int SERIAL_NUMBER_LENGTH = 30;
|
const int SERIAL_NUMBER_LENGTH = 30;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user