mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-11-01 19:27:59 +00:00
Framework update.
This commit is contained in:
@@ -4148,10 +4148,10 @@ namespace OpenWifi {
|
|||||||
Producer.produce(
|
Producer.produce(
|
||||||
cppkafka::MessageBuilder(Msg->Topic()).key(Msg->Key()).payload(Msg->Payload()));
|
cppkafka::MessageBuilder(Msg->Topic()).key(Msg->Key()).payload(Msg->Payload()));
|
||||||
}
|
}
|
||||||
|
} catch (const cppkafka::HandleException &E) {
|
||||||
|
KafkaManager()->Logger().warning(fmt::format("Caught a Kafka exception (producer): {}", E.what()));
|
||||||
} catch( const Poco::Exception &E) {
|
} catch( const Poco::Exception &E) {
|
||||||
KafkaManager()->Logger().log(E);
|
KafkaManager()->Logger().log(E);
|
||||||
} catch (const cppkafka::HandleException &E) {
|
|
||||||
KafkaManager()->Logger().error(fmt::format("{}: Exception --> {}", E.get_error().to_string(), E.what()));
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
KafkaManager()->Logger().error("std::exception");
|
KafkaManager()->Logger().error("std::exception");
|
||||||
}
|
}
|
||||||
@@ -4212,7 +4212,8 @@ namespace OpenWifi {
|
|||||||
if (Msg.get_error()) {
|
if (Msg.get_error()) {
|
||||||
if (!Msg.is_eof()) {
|
if (!Msg.is_eof()) {
|
||||||
KafkaManager()->Logger().error(fmt::format("Error: {}", Msg.get_error().to_string()));
|
KafkaManager()->Logger().error(fmt::format("Error: {}", Msg.get_error().to_string()));
|
||||||
}if(!AutoCommit)
|
}
|
||||||
|
if(!AutoCommit)
|
||||||
Consumer.async_commit(Msg);
|
Consumer.async_commit(Msg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,7 +208,8 @@ namespace ORM {
|
|||||||
int Place=0;
|
int Place=0;
|
||||||
|
|
||||||
for(const auto &i:Fields) {
|
for(const auto &i:Fields) {
|
||||||
FieldNames_[i.Name] = Place;
|
std::string FieldName = Poco::toLower(i.Name);
|
||||||
|
FieldNames_[FieldName] = Place;
|
||||||
if(!first) {
|
if(!first) {
|
||||||
CreateFields_ += ", ";
|
CreateFields_ += ", ";
|
||||||
SelectFields_ += ", ";
|
SelectFields_ += ", ";
|
||||||
@@ -218,9 +219,9 @@ namespace ORM {
|
|||||||
SelectList_ += "(";
|
SelectList_ += "(";
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateFields_ += i.Name + " " + FieldTypeToChar(Type_, i.Type,i.Size) + (i.Index ? " unique primary key" : "");
|
CreateFields_ += FieldName + " " + FieldTypeToChar(Type_, i.Type,i.Size) + (i.Index ? " unique primary key" : "");
|
||||||
SelectFields_ += i.Name ;
|
SelectFields_ += FieldName ;
|
||||||
UpdateFields_ += i.Name + "=?";
|
UpdateFields_ += FieldName + "=?";
|
||||||
SelectList_ += "?";
|
SelectList_ += "?";
|
||||||
first = false;
|
first = false;
|
||||||
Place++;
|
Place++;
|
||||||
@@ -235,12 +236,13 @@ namespace ORM {
|
|||||||
IndexLine = std::string("CREATE INDEX IF NOT EXISTS ") + j.Name + std::string(" ON ") + TableName_+ " (";
|
IndexLine = std::string("CREATE INDEX IF NOT EXISTS ") + j.Name + std::string(" ON ") + TableName_+ " (";
|
||||||
bool first_entry=true;
|
bool first_entry=true;
|
||||||
for(const auto &k:j.Entries) {
|
for(const auto &k:j.Entries) {
|
||||||
assert(FieldNames_.find(k.FieldName) != FieldNames_.end());
|
auto IndexFieldName = Poco::toLower(k.FieldName);
|
||||||
|
assert(ValidFieldName(IndexFieldName));
|
||||||
if(!first_entry) {
|
if(!first_entry) {
|
||||||
IndexLine += " , ";
|
IndexLine += " , ";
|
||||||
}
|
}
|
||||||
first_entry = false;
|
first_entry = false;
|
||||||
IndexLine += k.FieldName + std::string(" ") + std::string(k.Type == Indextype::ASC ? "ASC" : "DESC") ;
|
IndexLine += IndexFieldName + std::string(" ") + std::string(k.Type == Indextype::ASC ? "ASC" : "DESC") ;
|
||||||
}
|
}
|
||||||
IndexLine += " )";
|
IndexLine += " )";
|
||||||
IndexCreation_.template emplace_back(IndexLine);
|
IndexCreation_.template emplace_back(IndexLine);
|
||||||
@@ -255,12 +257,13 @@ namespace ORM {
|
|||||||
IndexLine += " INDEX " + j.Name + " ( " ;
|
IndexLine += " INDEX " + j.Name + " ( " ;
|
||||||
bool first_entry=true;
|
bool first_entry=true;
|
||||||
for(const auto &k:j.Entries) {
|
for(const auto &k:j.Entries) {
|
||||||
assert(FieldNames_.find(k.FieldName) != FieldNames_.end());
|
auto IndexFieldName = Poco::toLower(k.FieldName);
|
||||||
|
assert(FieldNames_.find(IndexFieldName) != FieldNames_.end());
|
||||||
if(!first_entry) {
|
if(!first_entry) {
|
||||||
IndexLine += " ,";
|
IndexLine += " ,";
|
||||||
}
|
}
|
||||||
first_entry = false;
|
first_entry = false;
|
||||||
IndexLine += k.FieldName + std::string(k.Type == Indextype::ASC ? " ASC" : " DESC");
|
IndexLine += IndexFieldName + std::string(k.Type == Indextype::ASC ? " ASC" : " DESC");
|
||||||
}
|
}
|
||||||
IndexLine += " ) ";
|
IndexLine += " ) ";
|
||||||
}
|
}
|
||||||
@@ -275,27 +278,27 @@ namespace ORM {
|
|||||||
[[nodiscard]] const std::string & UpdateFields() const { return UpdateFields_; };
|
[[nodiscard]] const std::string & UpdateFields() const { return UpdateFields_; };
|
||||||
|
|
||||||
inline std::string OP(field_name_t F, SqlComparison O , bool V) {
|
inline std::string OP(field_name_t F, SqlComparison O , bool V) {
|
||||||
assert( FieldNames_.find(F) != FieldNames_.end() );
|
assert(ValidFieldName(F));
|
||||||
return std::string{"("} + F + SQLCOMPS[O] + (V ? "true" : "false") + ")" ;
|
return std::string{"("} + F + SQLCOMPS[O] + (V ? "true" : "false") + ")" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string OP(field_name_t F, SqlComparison O , int V) {
|
inline std::string OP(field_name_t F, SqlComparison O , int V) {
|
||||||
assert( FieldNames_.find(F) != FieldNames_.end() );
|
assert(ValidFieldName(F));
|
||||||
return std::string{"("} + F + SQLCOMPS[O] + std::to_string(V) + ")" ;
|
return std::string{"("} + F + SQLCOMPS[O] + std::to_string(V) + ")" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string OP(field_name_t F, SqlComparison O , uint64_t V) {
|
inline std::string OP(field_name_t F, SqlComparison O , uint64_t V) {
|
||||||
assert( FieldNames_.find(F) != FieldNames_.end() );
|
assert(ValidFieldName(F));
|
||||||
return std::string{"("} + F + SQLCOMPS[O] + std::to_string(V) + ")" ;
|
return std::string{"("} + F + SQLCOMPS[O] + std::to_string(V) + ")" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string OP(field_name_t F, SqlComparison O , const std::string & V) {
|
std::string OP(field_name_t F, SqlComparison O , const std::string & V) {
|
||||||
assert( FieldNames_.find(F) != FieldNames_.end() );
|
assert(ValidFieldName(F));
|
||||||
return std::string{"("} + F + SQLCOMPS[O] + "'" + Escape(V) + "')" ;
|
return std::string{"("} + F + SQLCOMPS[O] + "'" + Escape(V) + "')" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string OP(field_name_t F, SqlComparison O , const char * V) {
|
std::string OP(field_name_t F, SqlComparison O , const char * V) {
|
||||||
assert( FieldNames_.find(F) != FieldNames_.end() );
|
assert(ValidFieldName(F));
|
||||||
return std::string{"("} + F + SQLCOMPS[O] + "'" + Escape(V) + "')" ;
|
return std::string{"("} + F + SQLCOMPS[O] + "'" + Escape(V) + "')" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,7 +420,7 @@ namespace ORM {
|
|||||||
|
|
||||||
template<typename T> bool GetRecord(field_name_t FieldName, const T & Value, RecordType & R) {
|
template<typename T> bool GetRecord(field_name_t FieldName, const T & Value, RecordType & R) {
|
||||||
try {
|
try {
|
||||||
assert( FieldNames_.find(FieldName) != FieldNames_.end() );
|
assert(ValidFieldName(FieldName));
|
||||||
|
|
||||||
if(Cache_) {
|
if(Cache_) {
|
||||||
if(Cache_->GetFromCache(FieldName, Value, R))
|
if(Cache_->GetFromCache(FieldName, Value, R))
|
||||||
@@ -455,7 +458,7 @@ namespace ORM {
|
|||||||
typename T0, typename T1> bool GR(field_name_t FieldName, T & R,T0 &V0, T1 &V1) {
|
typename T0, typename T1> bool GR(field_name_t FieldName, T & R,T0 &V0, T1 &V1) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
assert( FieldNames_.find(FieldName) != FieldNames_.end() );
|
assert( ValidFieldName(FieldName) );
|
||||||
|
|
||||||
Poco::Data::Session Session = Pool_.get();
|
Poco::Data::Session Session = Pool_.get();
|
||||||
Poco::Data::Statement Select(Session);
|
Poco::Data::Statement Select(Session);
|
||||||
@@ -513,7 +516,7 @@ namespace ORM {
|
|||||||
|
|
||||||
template <typename T> bool UpdateRecord(field_name_t FieldName, const T & Value, const RecordType & R) {
|
template <typename T> bool UpdateRecord(field_name_t FieldName, const T & Value, const RecordType & R) {
|
||||||
try {
|
try {
|
||||||
assert( FieldNames_.find(FieldName) != FieldNames_.end() );
|
assert( ValidFieldName(FieldName) );
|
||||||
|
|
||||||
Poco::Data::Session Session = Pool_.get();
|
Poco::Data::Session Session = Pool_.get();
|
||||||
Poco::Data::Statement Update(Session);
|
Poco::Data::Statement Update(Session);
|
||||||
@@ -567,7 +570,7 @@ namespace ORM {
|
|||||||
|
|
||||||
template <typename T> bool GetNameAndDescription(field_name_t FieldName, const T & Value, std::string & Name, std::string & Description ) {
|
template <typename T> bool GetNameAndDescription(field_name_t FieldName, const T & Value, std::string & Name, std::string & Description ) {
|
||||||
try {
|
try {
|
||||||
assert( FieldNames_.find(FieldName) != FieldNames_.end() );
|
assert( ValidFieldName(FieldName) );
|
||||||
Poco::Data::Session Session = Pool_.get();
|
Poco::Data::Session Session = Pool_.get();
|
||||||
Poco::Data::Statement Select(Session);
|
Poco::Data::Statement Select(Session);
|
||||||
RecordTuple RT;
|
RecordTuple RT;
|
||||||
@@ -594,7 +597,7 @@ namespace ORM {
|
|||||||
|
|
||||||
template <typename T> bool DeleteRecord(field_name_t FieldName, const T & Value) {
|
template <typename T> bool DeleteRecord(field_name_t FieldName, const T & Value) {
|
||||||
try {
|
try {
|
||||||
assert( FieldNames_.find(FieldName) != FieldNames_.end() );
|
assert( ValidFieldName(FieldName) );
|
||||||
|
|
||||||
Poco::Data::Session Session = Pool_.get();
|
Poco::Data::Session Session = Pool_.get();
|
||||||
Poco::Data::Statement Delete(Session);
|
Poco::Data::Statement Delete(Session);
|
||||||
@@ -632,7 +635,7 @@ namespace ORM {
|
|||||||
|
|
||||||
bool Exists(field_name_t FieldName, const std::string & Value) {
|
bool Exists(field_name_t FieldName, const std::string & Value) {
|
||||||
try {
|
try {
|
||||||
assert( FieldNames_.find(FieldName) != FieldNames_.end() );
|
assert( ValidFieldName(FieldName) );
|
||||||
|
|
||||||
RecordType R;
|
RecordType R;
|
||||||
if(GetRecord(FieldName,Value,R))
|
if(GetRecord(FieldName,Value,R))
|
||||||
@@ -721,7 +724,7 @@ namespace ORM {
|
|||||||
|
|
||||||
template <typename X> bool ManipulateVectorMember( X T, field_name_t FieldName, const std::string & ParentUUID, const std::string & ChildUUID, bool Add) {
|
template <typename X> bool ManipulateVectorMember( X T, field_name_t FieldName, const std::string & ParentUUID, const std::string & ChildUUID, bool Add) {
|
||||||
try {
|
try {
|
||||||
assert( FieldNames_.find(FieldName) != FieldNames_.end() );
|
assert( ValidFieldName(FieldName) );
|
||||||
|
|
||||||
RecordType R;
|
RecordType R;
|
||||||
if(GetRecord(FieldName, ParentUUID, R)) {
|
if(GetRecord(FieldName, ParentUUID, R)) {
|
||||||
@@ -870,6 +873,15 @@ namespace ORM {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool ValidFieldName(const std::string &FieldName) {
|
||||||
|
return FieldNames_.find(Poco::toLower(FieldName)) != FieldNames_.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool ValidFieldName(const char *FieldName) {
|
||||||
|
std::string Field{FieldName};
|
||||||
|
return ValidFieldName(Field);
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] inline std::string ComputeRange(uint64_t From, uint64_t HowMany) {
|
[[nodiscard]] inline std::string ComputeRange(uint64_t From, uint64_t HowMany) {
|
||||||
if(From<1) From=0;
|
if(From<1) From=0;
|
||||||
switch(Type_) {
|
switch(Type_) {
|
||||||
|
|||||||
@@ -415,7 +415,13 @@ namespace OpenWifi::uCentralProtocol {
|
|||||||
|
|
||||||
static const char *SCRIPT = "script";
|
static const char *SCRIPT = "script";
|
||||||
static const char *TYPE = "type";
|
static const char *TYPE = "type";
|
||||||
}
|
|
||||||
|
static const char *RADIUS = "radius";
|
||||||
|
static const char *RADIUSDATA = "data";
|
||||||
|
static const char *RADIUSACCT = "acct";
|
||||||
|
static const char *RADIUSAUTH = "auth";
|
||||||
|
static const char *RADIUSDST = "dst";
|
||||||
|
}
|
||||||
|
|
||||||
namespace OpenWifi::uCentralProtocol::Events {
|
namespace OpenWifi::uCentralProtocol::Events {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user