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(
|
||||
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) {
|
||||
KafkaManager()->Logger().log(E);
|
||||
} catch (const cppkafka::HandleException &E) {
|
||||
KafkaManager()->Logger().error(fmt::format("{}: Exception --> {}", E.get_error().to_string(), E.what()));
|
||||
} catch (...) {
|
||||
KafkaManager()->Logger().error("std::exception");
|
||||
}
|
||||
@@ -4212,7 +4212,8 @@ namespace OpenWifi {
|
||||
if (Msg.get_error()) {
|
||||
if (!Msg.is_eof()) {
|
||||
KafkaManager()->Logger().error(fmt::format("Error: {}", Msg.get_error().to_string()));
|
||||
}if(!AutoCommit)
|
||||
}
|
||||
if(!AutoCommit)
|
||||
Consumer.async_commit(Msg);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,8 @@ namespace ORM {
|
||||
int Place=0;
|
||||
|
||||
for(const auto &i:Fields) {
|
||||
FieldNames_[i.Name] = Place;
|
||||
std::string FieldName = Poco::toLower(i.Name);
|
||||
FieldNames_[FieldName] = Place;
|
||||
if(!first) {
|
||||
CreateFields_ += ", ";
|
||||
SelectFields_ += ", ";
|
||||
@@ -218,9 +219,9 @@ namespace ORM {
|
||||
SelectList_ += "(";
|
||||
}
|
||||
|
||||
CreateFields_ += i.Name + " " + FieldTypeToChar(Type_, i.Type,i.Size) + (i.Index ? " unique primary key" : "");
|
||||
SelectFields_ += i.Name ;
|
||||
UpdateFields_ += i.Name + "=?";
|
||||
CreateFields_ += FieldName + " " + FieldTypeToChar(Type_, i.Type,i.Size) + (i.Index ? " unique primary key" : "");
|
||||
SelectFields_ += FieldName ;
|
||||
UpdateFields_ += FieldName + "=?";
|
||||
SelectList_ += "?";
|
||||
first = false;
|
||||
Place++;
|
||||
@@ -235,12 +236,13 @@ namespace ORM {
|
||||
IndexLine = std::string("CREATE INDEX IF NOT EXISTS ") + j.Name + std::string(" ON ") + TableName_+ " (";
|
||||
bool first_entry=true;
|
||||
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) {
|
||||
IndexLine += " , ";
|
||||
}
|
||||
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 += " )";
|
||||
IndexCreation_.template emplace_back(IndexLine);
|
||||
@@ -255,12 +257,13 @@ namespace ORM {
|
||||
IndexLine += " INDEX " + j.Name + " ( " ;
|
||||
bool first_entry=true;
|
||||
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) {
|
||||
IndexLine += " ,";
|
||||
}
|
||||
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 += " ) ";
|
||||
}
|
||||
@@ -275,27 +278,27 @@ namespace ORM {
|
||||
[[nodiscard]] const std::string & UpdateFields() const { return UpdateFields_; };
|
||||
|
||||
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") + ")" ;
|
||||
}
|
||||
|
||||
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) + ")" ;
|
||||
}
|
||||
|
||||
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) + ")" ;
|
||||
}
|
||||
|
||||
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) + "')" ;
|
||||
}
|
||||
|
||||
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) + "')" ;
|
||||
}
|
||||
|
||||
@@ -417,7 +420,7 @@ namespace ORM {
|
||||
|
||||
template<typename T> bool GetRecord(field_name_t FieldName, const T & Value, RecordType & R) {
|
||||
try {
|
||||
assert( FieldNames_.find(FieldName) != FieldNames_.end() );
|
||||
assert(ValidFieldName(FieldName));
|
||||
|
||||
if(Cache_) {
|
||||
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) {
|
||||
try {
|
||||
|
||||
assert( FieldNames_.find(FieldName) != FieldNames_.end() );
|
||||
assert( ValidFieldName(FieldName) );
|
||||
|
||||
Poco::Data::Session Session = Pool_.get();
|
||||
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) {
|
||||
try {
|
||||
assert( FieldNames_.find(FieldName) != FieldNames_.end() );
|
||||
assert( ValidFieldName(FieldName) );
|
||||
|
||||
Poco::Data::Session Session = Pool_.get();
|
||||
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 ) {
|
||||
try {
|
||||
assert( FieldNames_.find(FieldName) != FieldNames_.end() );
|
||||
assert( ValidFieldName(FieldName) );
|
||||
Poco::Data::Session Session = Pool_.get();
|
||||
Poco::Data::Statement Select(Session);
|
||||
RecordTuple RT;
|
||||
@@ -594,7 +597,7 @@ namespace ORM {
|
||||
|
||||
template <typename T> bool DeleteRecord(field_name_t FieldName, const T & Value) {
|
||||
try {
|
||||
assert( FieldNames_.find(FieldName) != FieldNames_.end() );
|
||||
assert( ValidFieldName(FieldName) );
|
||||
|
||||
Poco::Data::Session Session = Pool_.get();
|
||||
Poco::Data::Statement Delete(Session);
|
||||
@@ -632,7 +635,7 @@ namespace ORM {
|
||||
|
||||
bool Exists(field_name_t FieldName, const std::string & Value) {
|
||||
try {
|
||||
assert( FieldNames_.find(FieldName) != FieldNames_.end() );
|
||||
assert( ValidFieldName(FieldName) );
|
||||
|
||||
RecordType 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) {
|
||||
try {
|
||||
assert( FieldNames_.find(FieldName) != FieldNames_.end() );
|
||||
assert( ValidFieldName(FieldName) );
|
||||
|
||||
RecordType R;
|
||||
if(GetRecord(FieldName, ParentUUID, R)) {
|
||||
@@ -870,6 +873,15 @@ namespace ORM {
|
||||
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) {
|
||||
if(From<1) From=0;
|
||||
switch(Type_) {
|
||||
|
||||
@@ -415,7 +415,13 @@ namespace OpenWifi::uCentralProtocol {
|
||||
|
||||
static const char *SCRIPT = "script";
|
||||
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 {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user