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

AdminUser now inherits from ConfigurationItem

parent de6f01dd
Branches
Tags
No related merge requests found
......@@ -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;
}
#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
......@@ -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;
......
......@@ -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();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment