Skip to content
Snippets Groups Projects
Commit 8f57e66f authored by Steven Murray's avatar Steven Murray
Browse files

Added RdbmsCatalogue::modifyTapePoolComment()

parent abe5cb2c
No related branches found
No related tags found
No related merge requests found
......@@ -1045,6 +1045,59 @@ TEST_P(cta_catalogue_CatalogueTest, modifyTapePoolNbPartialTapes) {
ASSERT_EQ(creationLog, lastModificationLog);
}
}
TEST_P(cta_catalogue_CatalogueTest, modifyTapePoolComment) {
using namespace cta;
ASSERT_TRUE(m_catalogue->getTapePools().empty());
const std::string tapePoolName = "tape_pool";
const uint64_t nbPartialTapes = 2;
const bool is_encrypted = true;
const std::string comment = "Create tape pool";
m_catalogue->createTapePool(m_cliSI, tapePoolName, nbPartialTapes, is_encrypted, comment);
{
const std::list<common::dataStructures::TapePool> pools = m_catalogue->getTapePools();
ASSERT_EQ(1, pools.size());
const common::dataStructures::TapePool pool = pools.front();
ASSERT_EQ(tapePoolName, pool.name);
ASSERT_EQ(nbPartialTapes, pool.nbPartialTapes);
ASSERT_EQ(is_encrypted, pool.encryption);
ASSERT_EQ(comment, pool.comment);
const common::dataStructures::EntryLog creationLog = pool.creationLog;
ASSERT_EQ(m_cliSI.username, creationLog.username);
ASSERT_EQ(m_cliSI.host, creationLog.host);
const common::dataStructures::EntryLog lastModificationLog = pool.lastModificationLog;
ASSERT_EQ(creationLog, lastModificationLog);
}
const std::string modifiedComment = "Modified comment";
m_catalogue->modifyTapePoolComment(m_cliSI, tapePoolName, modifiedComment);
{
const std::list<common::dataStructures::TapePool> pools = m_catalogue->getTapePools();
ASSERT_EQ(1, pools.size());
const common::dataStructures::TapePool pool = pools.front();
ASSERT_EQ(tapePoolName, pool.name);
ASSERT_EQ(nbPartialTapes, pool.nbPartialTapes);
ASSERT_EQ(is_encrypted, pool.encryption);
ASSERT_EQ(modifiedComment, pool.comment);
const common::dataStructures::EntryLog creationLog = pool.creationLog;
ASSERT_EQ(m_cliSI.username, creationLog.username);
ASSERT_EQ(m_cliSI.host, creationLog.host);
const common::dataStructures::EntryLog lastModificationLog = pool.lastModificationLog;
ASSERT_EQ(creationLog, lastModificationLog);
}
}
TEST_P(cta_catalogue_CatalogueTest, createArchiveRoute) {
using namespace cta;
......
......@@ -841,7 +841,27 @@ void RdbmsCatalogue::modifyTapePoolNbPartialTapes(const common::dataStructures::
// modifyTapePoolComment
//------------------------------------------------------------------------------
void RdbmsCatalogue::modifyTapePoolComment(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const std::string &comment) {
throw exception::Exception(std::string(__FUNCTION__) + " not implemented");
try {
const time_t now = time(nullptr);
const char *const sql =
"UPDATE TAPE_POOL SET "
"USER_COMMENT = :USER_COMMENT,"
"LAST_UPDATE_USER_NAME = :LAST_UPDATE_USER_NAME,"
"LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME,"
"LAST_UPDATE_TIME = :LAST_UPDATE_TIME "
"WHERE "
"TAPE_POOL_NAME = :TAPE_POOL_NAME";
auto conn = m_connPool.getConn();
auto stmt = conn->createStmt(sql, rdbms::Stmt::AutocommitMode::ON);
stmt->bindString(":USER_COMMENT", comment);
stmt->bindString(":LAST_UPDATE_USER_NAME", cliIdentity.username);
stmt->bindString(":LAST_UPDATE_HOST_NAME", cliIdentity.host);
stmt->bindUint64(":LAST_UPDATE_TIME", now);
stmt->bindString(":TAPE_POOL_NAME", name);
stmt->executeNonQuery();
} catch(exception::Exception &ex) {
throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str());
}
}
//------------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment