diff --git a/middletier/cta/AdminUser.cpp b/middletier/cta/AdminUser.cpp index 2a2240a63a2e01ad5eced00ac3be810cbbbb2fce..16ac207c36219d42d135304a341a738c4038e685 100644 --- a/middletier/cta/AdminUser.cpp +++ b/middletier/cta/AdminUser.cpp @@ -3,8 +3,13 @@ //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -cta::AdminUser::AdminUser(): - m_creationTime(time(NULL)) { +cta::AdminUser::AdminUser() { +} + +//------------------------------------------------------------------------------ +// destructor +//------------------------------------------------------------------------------ +cta::AdminUser::~AdminUser() throw() { } //------------------------------------------------------------------------------ @@ -13,12 +18,10 @@ cta::AdminUser::AdminUser(): cta::AdminUser::AdminUser( const UserIdentity &user, const UserIdentity &creator, - const time_t creationTime, - const std::string &comment): - m_user(user), - m_creationTime(creationTime), - m_creator(creator), - m_comment(comment) { + const std::string &comment, + const time_t creationTime): + ConfigurationItem(creator, comment, creationTime), + m_user(user) { } //------------------------------------------------------------------------------ @@ -27,25 +30,3 @@ cta::AdminUser::AdminUser( const cta::UserIdentity &cta::AdminUser::getUser() const throw() { return m_user; } - -//------------------------------------------------------------------------------ -// getCreationTime -//------------------------------------------------------------------------------ -time_t cta::AdminUser::getCreationTime() const throw() { - return m_creationTime; -} - -//------------------------------------------------------------------------------ -// getCreator -//------------------------------------------------------------------------------ -const cta::UserIdentity &cta::AdminUser::getCreator() - const throw() { - return m_creator; -} - -//------------------------------------------------------------------------------ -// getComment -//------------------------------------------------------------------------------ -const std::string &cta::AdminUser::getComment() const throw() { - return m_comment; -} diff --git a/middletier/cta/AdminUser.hpp b/middletier/cta/AdminUser.hpp index e069058f247d8a3e9ffe8c290e394c6f0183f171..d864aa793d4810baf3b8070cd71a3e16182d0f30 100644 --- a/middletier/cta/AdminUser.hpp +++ b/middletier/cta/AdminUser.hpp @@ -1,5 +1,6 @@ #pragma once +#include "cta/ConfigurationItem.hpp" #include "cta/UserIdentity.hpp" #include <string> @@ -9,7 +10,7 @@ namespace cta { /** * Class representing an administrator. */ -class AdminUser { +class AdminUser: public ConfigurationItem { public: /** @@ -17,20 +18,28 @@ public: */ AdminUser(); + /** + * Destructor. + */ + ~AdminUser() throw(); + /** * Constructor. * * @param user The identity of the administrator. - * @param creator The identity of the user that created the administrator. - * @param creationTime The absolute time at which the admin user entry was - * created. - * @param comment The comment describing the administrator. + * @param creator The identity of the user that created this configuration + * item. + * @param comment The comment made by the creator of this configuration + * item. + * @param creationTime Optionally the absolute time at which this + * configuration item was created. If no value is given then the current + * time is used. */ AdminUser( const UserIdentity &user, const UserIdentity &creator, - const time_t creationTime, - const std::string &comment); + const std::string &comment, + const time_t creationTime = time(NULL)); /** * Returns the identity of the administrator. @@ -39,27 +48,6 @@ public: */ const UserIdentity &getUser() const throw(); - /** - * Returns the time when the administrator was created. - * - * @return The time when the administrator was created. - */ - time_t getCreationTime() const throw(); - - /** - * Returns the identity of the user that created the administrator. - * - * @return The identity of the user that created the administrator. - */ - const UserIdentity &getCreator() const throw(); - - /** - * Returns the comment describing the administrator. - * - * @return The comment describing the administrator. - */ - const std::string &getComment() const throw(); - private: /** @@ -67,21 +55,6 @@ private: */ UserIdentity m_user; - /** - * The time when the administrator was created. - */ - time_t m_creationTime; - - /** - * The identity of the user that created the administrator. - */ - UserIdentity m_creator; - - /** - * Comment describing the administrator. - */ - std::string m_comment; - }; // class AdminUser } // namespace cta diff --git a/middletier/cta/SqliteDatabase.cpp b/middletier/cta/SqliteDatabase.cpp index a6ff4536cb09e4d89d6a6ba173de289c8e65c6da..f930b48953fc9efb1e0b7db95c6b536c80614d1a 100644 --- a/middletier/cta/SqliteDatabase.cpp +++ b/middletier/cta/SqliteDatabase.cpp @@ -1048,12 +1048,16 @@ std::list<cta::AdminUser> cta::SqliteDatabase::selectAllAdminUsers(const Securit } while(sqlite3_step(statement)==SQLITE_ROW) { SqliteColumnNameToIndex idx(statement); + const UserIdentity user(sqlite3_column_int(statement,idx("ADMIN_UID")), + sqlite3_column_int(statement,idx("ADMIN_GID"))); + const UserIdentity creator(sqlite3_column_int(statement,idx("UID")), + sqlite3_column_int(statement,idx("GID"))); list.push_back(cta::AdminUser( - cta::UserIdentity(sqlite3_column_int(statement,idx("ADMIN_UID")),sqlite3_column_int(statement,idx("ADMIN_GID"))), - cta::UserIdentity(sqlite3_column_int(statement,idx("UID")),sqlite3_column_int(statement,idx("GID"))), - time_t(sqlite3_column_int(statement,idx("CREATIONTIME"))), - std::string((char *)sqlite3_column_text(statement,idx("COMMENT"))) - )); + user, + creator, + std::string((char *)sqlite3_column_text(statement,idx("COMMENT"))), + time_t(sqlite3_column_int(statement,idx("CREATIONTIME"))) + )); } sqlite3_finalize(statement); return list; diff --git a/objectstore_middletier/ObjectStoreMiddleTier.cpp b/objectstore_middletier/ObjectStoreMiddleTier.cpp index 2eb3364725bc533e474df77fed74ef96964c73b6..869b1e74f2ab22122170b3c0bbc3269df230edbf 100644 --- a/objectstore_middletier/ObjectStoreMiddleTier.cpp +++ b/objectstore_middletier/ObjectStoreMiddleTier.cpp @@ -39,7 +39,7 @@ void OStoreMiddleTierAdmin::createAdminUser( reLock.release(); objectstore::ScopedExclusiveLock auLock(aul); aul.fetch(); - AdminUser au(user, requester.user, time(NULL), comment); + AdminUser au(user, requester.user, comment); aul.add(au); aul.commit(); }