stephb9959
2023-02-15 08:31:54 -08:00
parent 17f95a64ad
commit daa264c984
4 changed files with 946 additions and 351 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -4,11 +4,15 @@
#pragma once
#include <nlohmann/json-schema.hpp>
#include "framework/SubSystemServer.h"
using nlohmann::json;
using nlohmann::json_schema::json_validator;
#include <valijson/adapters/poco_json_adapter.hpp>
#include <valijson/utils/poco_json_utils.hpp>
#include <valijson/schema.hpp>
#include <valijson/schema_parser.hpp>
#include <valijson/validator.hpp>
#include <valijson/constraints/constraint.hpp>
#include <valijson/constraints/constraint_visitor.hpp>
namespace OpenWifi {
class ConfigurationValidator : public SubSystemServer {
@@ -19,8 +23,7 @@ namespace OpenWifi {
return instance_;
}
bool Validate(const std::string &C, std::string &Error);
static void my_format_checker(const std::string &format, const std::string &value);
bool Validate(const std::string &C, std::vector<std::string> &Errors, bool Strict);
int Start() override;
void Stop() override;
void reinitialize(Poco::Util::Application &self) override;
@@ -29,7 +32,11 @@ namespace OpenWifi {
bool Initialized_=false;
bool Working_=false;
void Init();
nlohmann::json RootSchema_;
std::unique_ptr<valijson::Schema> RootSchema_;
std::unique_ptr<valijson::SchemaParser> SchemaParser_;
std::unique_ptr<valijson::adapters::PocoJsonAdapter> PocoJsonAdapter_;
Poco::JSON::Object::Ptr SchemaDocPtr_;
bool SetSchema(const std::string &SchemaStr);
ConfigurationValidator():
SubSystemServer("ConfigValidator", "CFG-VALIDATOR", "config.validator") {
@@ -37,6 +44,6 @@ namespace OpenWifi {
};
inline auto ConfigurationValidator() { return ConfigurationValidator::instance(); }
inline bool ValidateUCentralConfiguration(const std::string &C, std::string &Error) { return ConfigurationValidator::instance()->Validate(C, Error); }
inline bool ValidateUCentralConfiguration(const std::string &C, std::vector<std::string> &Error, bool strict) { return ConfigurationValidator::instance()->Validate(C, Error, strict); }
}

View File

@@ -561,6 +561,21 @@ namespace ORM {
return false;
}
template <typename T> bool Join(const std::string &statement, std::vector<T> &records) {
try {
Poco::Data::Session Session = Pool_.get();
Poco::Data::Statement Select(Session);
Select << statement ,
Poco::Data::Keywords::into(records);
Select.execute();
return true;
} catch (const Poco::Exception &E) {
Logger_.log(E);
}
return false;
}
typedef std::vector<RecordTuple> RecordList;
typedef std::vector<RecordType> RecordVec;
typedef RecordType RecordName;

View File

@@ -251,6 +251,7 @@ namespace OpenWifi::RESTAPI::Errors {
static const struct msg CertificateTransferEntityNoLongerExists{1167,"The entity tied to this transfer no longer seems to exist."};
static const struct msg CannotRollBackDueToDigiCert{1168,"The change could not be rolled back at this time. Please try later."};
static const struct msg CertificateTransferAlreadyRolledBack{1169,"The certificate has already been rolled back."};
static const struct msg FirmwareBDInProgress{1170,"Firmware DB update already in progress."};
}