diff options
author | claiff <claiff@mail.ru> | 2022-10-06 12:26:45 +0300 |
---|---|---|
committer | claiff <claiff@mail.ru> | 2022-10-06 12:26:45 +0300 |
commit | da5f91a0ce15351a82beb061c3ccc965164529bc (patch) | |
tree | 1f4cd2d1e2f8cf2442d055c519d06c6e0692febc /src/management/builder | |
parent | 8edef99a5b52643e0b919c424357752cbbc9a8dd (diff) | |
download | obmc-sila-smtp-da5f91a0ce15351a82beb061c3ccc965164529bc.tar.xz |
create settings on startbugfix/proxy_file_reader
Diffstat (limited to 'src/management/builder')
-rw-r--r-- | src/management/builder/mail.cpp | 16 | ||||
-rw-r--r-- | src/management/builder/mail.hpp | 4 | ||||
-rw-r--r-- | src/management/builder/settings.cpp | 15 | ||||
-rw-r--r-- | src/management/builder/settings.hpp | 4 |
4 files changed, 31 insertions, 8 deletions
diff --git a/src/management/builder/mail.cpp b/src/management/builder/mail.cpp index a96fd33..7a8aa42 100644 --- a/src/management/builder/mail.cpp +++ b/src/management/builder/mail.cpp @@ -7,6 +7,8 @@ #include "file/mail/checker_decorator.hpp" #include "file/mail/sort_decorator.hpp" +#include "file/errors/not_create.hpp" + namespace smtp::manage::builder { smtp::manage::Mail Mail::Build() const @@ -18,12 +20,20 @@ namespace smtp::manage::builder { static const std::string PATH = {"/var/lib/smtp/mails.txt"}; auto result = std::make_shared<file::mail::SortDecorator>() ; - result->Apply(std::make_shared<file::mail::CheckerDecorator>( BuildErrorRegistrator() )) - .Apply(std::make_shared<file::mail::FileDecorator>( PATH )); + result->Apply(std::make_shared<file::mail::CheckerDecorator>( BuildSettingsErrorRegistrator() )) + .Apply(std::make_shared<file::mail::FileDecorator>( PATH, BuildFileErrorRegistrator(PATH) )); + return result; + } + + file::errors::Registrator Mail::BuildFileErrorRegistrator( std::string const& path ) const + { + file::errors::Registrator result; + auto not_created_file_error = std::make_shared<file::errors::NotCreatedFile>(path); + result.Add(not_created_file_error, ENOENT); return result; } - checker::RegistratorMails Mail::BuildErrorRegistrator() const + checker::RegistratorMails Mail::BuildSettingsErrorRegistrator() const { checker::RegistratorMails result; result.Add( std::make_shared < checker::errors::mail::Empty >()); diff --git a/src/management/builder/mail.hpp b/src/management/builder/mail.hpp index 7cbb29d..ecd6de4 100644 --- a/src/management/builder/mail.hpp +++ b/src/management/builder/mail.hpp @@ -3,6 +3,7 @@ #include "management/mail.hpp" #include "checker/registrator_mails.hpp" #include "file/mail/types/ifile_manipulator.hpp" +#include "file/errors/registrator.hpp" namespace smtp::manage::builder { @@ -15,7 +16,8 @@ namespace smtp::manage::builder smtp::manage::Mail Build() const; private: file::mail::types::IFileManipulatorPtr BuildFileManipulator() const; - checker::RegistratorMails BuildErrorRegistrator() const; + file::errors::Registrator BuildFileErrorRegistrator( std::string const& path ) const; + checker::RegistratorMails BuildSettingsErrorRegistrator() const; }; } diff --git a/src/management/builder/settings.cpp b/src/management/builder/settings.cpp index b682c49..bf345e7 100644 --- a/src/management/builder/settings.cpp +++ b/src/management/builder/settings.cpp @@ -4,6 +4,7 @@ #include "file/settings/settings.hpp" #include "file/settings/checker_decorator.hpp" #include "file/settings/file_decorator.hpp" +#include "file/errors/not_create.hpp" namespace smtp::manage::builder { @@ -17,12 +18,20 @@ namespace smtp::manage::builder { static const std::string PATH = "/var/lib/smtp/settings.txt"; - auto result = std::make_shared<file::settings::CheckerDecorator>(BuildErrorRegistrator()); - result->Apply(std::make_shared<file::settings::FileDecorator>(PATH)); + auto result = std::make_shared<file::settings::CheckerDecorator>(BuildSettingsErrorRegistrator()); + result->Apply(std::make_shared<file::settings::FileDecorator>(PATH, BuildFileErrorRegistrator(PATH))); return result; } - checker::RegistratorSettings Settings::BuildErrorRegistrator() const + file::errors::Registrator Settings::BuildFileErrorRegistrator( std::string const& path ) const + { + file::errors::Registrator result; + auto not_created_file_error = std::make_shared<file::errors::NotCreatedFile>(path); + result.Add(not_created_file_error, ENOENT); + return result; + } + + checker::RegistratorSettings Settings::BuildSettingsErrorRegistrator() const { checker::RegistratorSettings result; diff --git a/src/management/builder/settings.hpp b/src/management/builder/settings.hpp index b7215e2..2cfbd5d 100644 --- a/src/management/builder/settings.hpp +++ b/src/management/builder/settings.hpp @@ -3,6 +3,7 @@ #include "management/settings.hpp" #include "checker/registrator_settings.hpp" #include "file/settings/types/ifile_manipulator.hpp" +#include "file/errors/registrator.hpp" namespace smtp::manage::builder { @@ -15,7 +16,8 @@ namespace smtp::manage::builder smtp::manage::Settings Build() const; private: file::settings::types::IFileManipulatorPtr BuildFileManipulator()const; - checker::RegistratorSettings BuildErrorRegistrator() const; + file::errors::Registrator BuildFileErrorRegistrator( std::string const& path ) const; + checker::RegistratorSettings BuildSettingsErrorRegistrator() const; }; } |