blob: bf345e74d146f274e2c3cc8cb444d0982e6c53b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#include "settings.hpp"
#include "checker/errors/settings/port_number.hpp"
#include "checker/errors/settings/server.hpp"
#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
{
smtp::manage::Settings Settings::Build() const
{
file::settings::Settings settings{ BuildFileManipulator() };
return smtp::manage::Settings{settings};
}
file::settings::types::IFileManipulatorPtr Settings::BuildFileManipulator() const
{
static const std::string PATH = "/var/lib/smtp/settings.txt";
auto result = std::make_shared<file::settings::CheckerDecorator>(BuildSettingsErrorRegistrator());
result->Apply(std::make_shared<file::settings::FileDecorator>(PATH, BuildFileErrorRegistrator(PATH)));
return result;
}
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;
result.Add( std::make_shared < checker::errors::settings::PortNumber >());
result.Add( std::make_shared < checker::errors::settings::Server >());
return result;
}
}
|