diff --git a/middletier/CMakeLists.txt b/middletier/CMakeLists.txt index dc67a56e50f6bb428943cd92a0117ce343249e53..2ed46215a24a49cfbb8f0feb36a6a20887ef6f3f 100644 --- a/middletier/CMakeLists.txt +++ b/middletier/CMakeLists.txt @@ -16,7 +16,7 @@ set (MIDDLE_TIER_LIB_SRC_FILES cta/ArchiveRouteId.cpp cta/ArchiveToDirRequest.cpp cta/ArchiveToFileRequest.cpp - cta/ConfigurationEntry.cpp + cta/ConfigurationItem.cpp cta/DirectoryEntry.cpp cta/DirectoryIterator.cpp cta/DiskException.cpp diff --git a/middletier/cta/ArchivalRequestHandler.hpp b/middletier/cta/ArchivalRequestHandler.hpp index 3c49289f647fa96ffd07755186e2f597e20907ce..74abc75dd1f7dbe06fd9e96cfa21dc0c5607b598 100644 --- a/middletier/cta/ArchivalRequestHandler.hpp +++ b/middletier/cta/ArchivalRequestHandler.hpp @@ -2,8 +2,14 @@ namespace cta { +/** + * Class representing the API for archiving files. + */ class ArchivalRequestHandler { public: + /** + * Creates and queues a request to archive one or files. + */ void createArchivalRequest(); }; // class ArchivalRequestHandler diff --git a/middletier/cta/ConfigurationEntry.cpp b/middletier/cta/ConfigurationItem.cpp similarity index 68% rename from middletier/cta/ConfigurationEntry.cpp rename to middletier/cta/ConfigurationItem.cpp index 6b2509cf64e361116973c9e90420a6529303656a..cd843c5332e0587aec8158486039dd678368f56a 100644 --- a/middletier/cta/ConfigurationEntry.cpp +++ b/middletier/cta/ConfigurationItem.cpp @@ -1,44 +1,44 @@ -#include "cta/ConfigurationEntry.hpp" +#include "cta/ConfigurationItem.hpp" //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -cta::ConfigurationEntry::ConfigurationEntry() { +cta::ConfigurationItem::ConfigurationItem() { } //------------------------------------------------------------------------------ // destructor //------------------------------------------------------------------------------ -cta::ConfigurationEntry::~ConfigurationEntry() throw() { +cta::ConfigurationItem::~ConfigurationItem() throw() { } //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -cta::ConfigurationEntry::ConfigurationEntry(const UserIdentity &creator, - const std::string &comment): - m_creationTime(time(NULL)), +cta::ConfigurationItem::ConfigurationItem(const UserIdentity &creator, + const std::string &comment, const time_t creationTime): m_creator(creator), - m_comment(comment) { -} - -//------------------------------------------------------------------------------ -// getCreationTime -//------------------------------------------------------------------------------ -time_t cta::ConfigurationEntry::getCreationTime() const throw() { - return m_creationTime; + m_comment(comment), + m_creationTime(creationTime) { } //------------------------------------------------------------------------------ // getCreator //------------------------------------------------------------------------------ -const cta::UserIdentity &cta::ConfigurationEntry::getCreator() const throw() { +const cta::UserIdentity &cta::ConfigurationItem::getCreator() const throw() { return m_creator; } //------------------------------------------------------------------------------ // getComment //------------------------------------------------------------------------------ -const std::string &cta::ConfigurationEntry::getComment() const throw() { +const std::string &cta::ConfigurationItem::getComment() const throw() { return m_comment; } + +//------------------------------------------------------------------------------ +// getCreationTime +//------------------------------------------------------------------------------ +time_t cta::ConfigurationItem::getCreationTime() const throw() { + return m_creationTime; +} diff --git a/middletier/cta/ConfigurationEntry.hpp b/middletier/cta/ConfigurationItem.hpp similarity index 57% rename from middletier/cta/ConfigurationEntry.hpp rename to middletier/cta/ConfigurationItem.hpp index 408a17ffa4985f5d29e2b346559771dcacae736b..5fb2408164cd584bc96d628554c833b9e608c843 100644 --- a/middletier/cta/ConfigurationEntry.hpp +++ b/middletier/cta/ConfigurationItem.hpp @@ -8,42 +8,39 @@ namespace cta { /** - * Abstract class representing a configuration entry. + * Abstract class representing a configuration item. */ -class ConfigurationEntry { +class ConfigurationItem { public: /** * Constructor. */ - ConfigurationEntry(); + ConfigurationItem(); /** * Destructor. */ - virtual ~ConfigurationEntry() throw() = 0; + virtual ~ConfigurationItem() throw() = 0; /** * Constructor. * * @param creator The identity of the user that created the configuration - * entry. + * item. * @param comment The comment made by the creator of the configuration * request. + * @param creationTime Optionally the absolute time at which the + * configuration item was created. If no value is given then the current + * time is used. */ - ConfigurationEntry(const UserIdentity &creator, const std::string &comment); + ConfigurationItem(const UserIdentity &creator, const std::string &comment, + const time_t creationTime = time(NULL)); /** - * Returns the absolute time at which the configuration entry was created. + * Returns the identity of the user that created the configuration item. * - * @return The absolute time at which the configuration entry was created. - */ - time_t getCreationTime() const throw(); - - /** - * Returns the identity of the user that created the configuration entry. - * - * @return The identity of the user that created the configuration entry. + * @return The identity of the user that created the configuration item. */ const UserIdentity &getCreator() const throw(); @@ -54,15 +51,17 @@ public: */ const std::string &getComment() const throw(); -private: - /** - * The absolute time at which the configuration entry was created. + * Returns the absolute time at which the configuration item was created. + * + * @return The absolute time at which the configuration item was created. */ - time_t m_creationTime; + time_t getCreationTime() const throw(); + +private: /** - * The identity of the user that created the configuration entry. + * The identity of the user that created the configuration item. */ UserIdentity m_creator; @@ -71,6 +70,11 @@ private: */ std::string m_comment; -}; // class ConfigurationEntry + /** + * The absolute time at which the configuration item was created. + */ + time_t m_creationTime; + +}; // class ConfigurationItem } // namespace cta diff --git a/middletier/cta/SqliteDatabase.cpp b/middletier/cta/SqliteDatabase.cpp index c7d31fa867a9cc2a0f138df315ef1d4e20bee52f..48326d88ae41c1e0ceeea385fd23c2488d147de1 100644 --- a/middletier/cta/SqliteDatabase.cpp +++ b/middletier/cta/SqliteDatabase.cpp @@ -934,9 +934,10 @@ std::list<cta::Tape> cta::SqliteDatabase::selectAllTapes(const SecurityIdentity std::string((char *)sqlite3_column_text(statement,2)), sqlite3_column_int(statement,3), sqlite3_column_int(statement,4), - cta::UserIdentity(sqlite3_column_int(statement,5),sqlite3_column_int(statement,6)), - time_t(sqlite3_column_int(statement,7)), - std::string((char *)sqlite3_column_text(statement,8)) + cta::UserIdentity(sqlite3_column_int(statement,5), + sqlite3_column_int(statement,6)), + std::string((char *)sqlite3_column_text(statement,8)), + time_t(sqlite3_column_int(statement,7)) )); } sqlite3_finalize(statement); @@ -1145,9 +1146,10 @@ cta::Tape cta::SqliteDatabase::getTapeByVid(const SecurityIdentity &requester, c std::string((char *)sqlite3_column_text(statement,2)), sqlite3_column_int(statement,3), sqlite3_column_int(statement,4), - cta::UserIdentity(sqlite3_column_int(statement,5),sqlite3_column_int(statement,6)), - time_t(sqlite3_column_int(statement,7)), - std::string((char *)sqlite3_column_text(statement,8)) + cta::UserIdentity(sqlite3_column_int(statement,5), + sqlite3_column_int(statement,6)), + std::string((char *)sqlite3_column_text(statement,8), + time_t(sqlite3_column_int(statement,7))) ); } else if(res==SQLITE_DONE) { diff --git a/middletier/cta/Tape.cpp b/middletier/cta/Tape.cpp index 3ceb41c367b99821b77941e6f973c1beecea4bda..1ea76baa67a3525fd81685a8e43ef9203f933539 100644 --- a/middletier/cta/Tape.cpp +++ b/middletier/cta/Tape.cpp @@ -5,8 +5,13 @@ //------------------------------------------------------------------------------ cta::Tape::Tape(): m_capacityInBytes(0), - m_dataOnTapeInBytes(0), - m_creationTime(time(NULL)) { + m_dataOnTapeInBytes(0) { +} + +//------------------------------------------------------------------------------ +// destructor +//------------------------------------------------------------------------------ +cta::Tape::~Tape() throw() { } //------------------------------------------------------------------------------ @@ -19,16 +24,14 @@ cta::Tape::Tape( const uint64_t capacityInBytes, const uint64_t dataOnTapeInBytes, const UserIdentity &creator, - const time_t creationTime, - const std::string &comment): + const std::string &comment, + const time_t creationTime): + ConfigurationItem(creator, comment, creationTime), m_vid(vid), m_logicalLibraryName(logicalLibraryName), m_tapePoolName(tapePoolName), m_capacityInBytes(capacityInBytes), - m_dataOnTapeInBytes(dataOnTapeInBytes), - m_creationTime(creationTime), - m_creator(creator), - m_comment(comment) { + m_dataOnTapeInBytes(dataOnTapeInBytes) { } //------------------------------------------------------------------------------ @@ -72,25 +75,3 @@ uint64_t cta::Tape::getCapacityInBytes() const throw() { uint64_t cta::Tape::getDataOnTapeInBytes() const throw() { return m_dataOnTapeInBytes; } - -//------------------------------------------------------------------------------ -// getCreationTime -//------------------------------------------------------------------------------ -time_t cta::Tape::getCreationTime() const throw() { - return m_creationTime; -} - -//------------------------------------------------------------------------------ -// getCreator -//------------------------------------------------------------------------------ -const cta::UserIdentity &cta::Tape::getCreator() - const throw() { - return m_creator; -} - -//------------------------------------------------------------------------------ -// getComment -//------------------------------------------------------------------------------ -const std::string &cta::Tape::getComment() const throw() { - return m_comment; -} diff --git a/middletier/cta/Tape.hpp b/middletier/cta/Tape.hpp index b3400119180170e84536dd846afb57fd0f175691..1fd5a2af0c9c951d3bd8a145be1f713b6d4bbf13 100644 --- a/middletier/cta/Tape.hpp +++ b/middletier/cta/Tape.hpp @@ -1,7 +1,9 @@ #pragma once +#include "cta/ConfigurationItem.hpp" #include "cta/UserIdentity.hpp" +#include <stdint.h> #include <string> namespace cta { @@ -9,7 +11,7 @@ namespace cta { /** * Class representing a tape. */ -class Tape { +class Tape: public ConfigurationItem { public: /** @@ -17,6 +19,11 @@ public: */ Tape(); + /** + * Destructor. + */ + ~Tape() throw(); + /** * Constructor. * @@ -27,6 +34,9 @@ public: * @param capacityInBytes The capacity of the tape. * @param creator The identity of the user that created the tape. * @param comment The comment describing the tape. + * @param creationTime Optionally the absolute time at which the + * configuration item was created. If no value is given then the current + * time is used. */ Tape( const std::string &vid, @@ -35,8 +45,8 @@ public: const uint64_t capacityInBytes, const uint64_t dataOnTapeInBytes, const UserIdentity &creator, - const time_t creationTime, - const std::string &comment); + const std::string &comment, + const time_t creationTime = time(NULL)); /** * Less than operator. @@ -80,27 +90,6 @@ public: */ uint64_t getDataOnTapeInBytes() const throw(); - /** - * Returns the time when the tape was created. - * - * @return The time when the tape was created. - */ - time_t getCreationTime() const throw(); - - /** - * Returns the identity of the user that created the tape. - * - * @return The identity of the user that created the tape. - */ - const UserIdentity &getCreator() const throw(); - - /** - * Returns the comment describing the tape. - * - * @return The comment describing the tape. - */ - const std::string &getComment() const throw(); - private: /** @@ -128,21 +117,6 @@ private: */ uint64_t m_dataOnTapeInBytes; - /** - * The time when the tape was created. - */ - time_t m_creationTime; - - /** - * The identity of the user that created the tape. - */ - UserIdentity m_creator; - - /** - * Comment describing the tape. - */ - std::string m_comment; - }; // class Tape } // namespace cta