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 @@ -7,5 +7,14 @@ std::string generateRandomString(std::size_t length = 20); +std::string generateHolder( + const std::string &backupID, + const std::string &resourceID, + const std::string &blobHash); + +std::string generateHolder( + const std::string &backupID, + const std::string &blobHash); + } // 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,5 +1,7 @@ #include "Tools.h" +#include "GlobalTools.h" + #include #include #include @@ -19,5 +21,23 @@ return random_string; } +std::string generateHolder( + const std::string &backupID, + const std::string &resourceID, + const std::string &blobHash) { + if (resourceID.empty()) { + return backupID + ID_SEPARATOR + blobHash + + ID_SEPARATOR + generateUUID(); + } + return backupID + ID_SEPARATOR + resourceID + ID_SEPARATOR + blobHash + + ID_SEPARATOR + generateUUID(); +} + +std::string generateHolder( + const std::string &backupID, + const std::string &blobHash) { + return generateHolder(backupID, "", blobHash); +} + } // namespace network } // namespace comm