diff --git a/services/backup/src/Tools.h b/services/backup/src/Tools.h --- a/services/backup/src/Tools.h +++ b/services/backup/src/Tools.h @@ -13,6 +13,8 @@ const std::string &backupID, const std::string &resourceID = ""); +std::string validateAttachmentHolders(const std::string &holders); + } // namespace tools } // namespace network } // namespace comm diff --git a/services/backup/src/Tools.cpp b/services/backup/src/Tools.cpp --- a/services/backup/src/Tools.cpp +++ b/services/backup/src/Tools.cpp @@ -1,10 +1,13 @@ #include "Tools.h" +#include "GlobalConstants.h" #include "GlobalTools.h" #include #include #include +#include +#include namespace comm { namespace network { @@ -30,6 +33,25 @@ ID_SEPARATOR + tools::generateUUID(); } +std::string validateAttachmentHolders(const std::string &holders) { + std::stringstream stream(holders); + std::string item; + std::string result; + + while (std::getline(stream, item, ATTACHMENT_DELIMITER)) { + if (item.empty()) { + throw std::runtime_error("empty holder detected"); + } + result += item; + result += ATTACHMENT_DELIMITER; + } + if (result.empty()) { + throw std::runtime_error("parse attachment holders failed"); + } + + return result; +} + } // namespace tools } // namespace network } // namespace comm diff --git a/services/lib/src/GlobalConstants.h b/services/lib/src/GlobalConstants.h --- a/services/lib/src/GlobalConstants.h +++ b/services/lib/src/GlobalConstants.h @@ -22,7 +22,7 @@ const std::string AWS_REGION = "us-east-2"; -const std::string ATTACHMENT_DELIMITER = ";"; +const char ATTACHMENT_DELIMITER = ';'; } // namespace network } // namespace comm