Leosac
0.8.0
Open Source Access Control
|
Implementation of IAuditEntry, backed by ODB. More...
#include <AuditEntry.hpp>
Public Member Functions | |
AuditEntry (const AuditEntry &)=delete | |
virtual | ~AuditEntry ()=default |
virtual AuditEntryId | id () const override |
Retrieve the identifier of the entry. More... | |
virtual void | finalize () override |
Mark the entry as finalized, and update it wrt the database. More... | |
virtual bool | finalized () const override |
Is this entry finalized. More... | |
virtual void | event_mask (const EventMask &mask) override |
Set the event mask for the entry. More... | |
virtual const EventMask & | event_mask () const override |
Retrieve the current event mask. More... | |
virtual void | author (Auth::UserPtr user) override |
Set the author of the entry. More... | |
virtual Auth::UserId | author_id () const override |
Retrieve the user id of the author of this entry. More... | |
virtual void | set_parent (IAuditEntryPtr parent) override |
Set parent as the parent audit entry for this entry. More... | |
virtual IAuditEntryPtr | parent () const override |
Retrieve the parent of this entry. More... | |
virtual void | remove_parent () override |
Remove the parent-child relationship between this entry and its parent. More... | |
virtual size_t | children_count () const override |
Returns the number of children that this entry has. More... | |
virtual size_t | version () const override |
Returns the ODB version of the object. More... | |
virtual void | reload () override |
Reload the object from the database. More... | |
virtual boost::posix_time::ptime | timestamp () const override |
Retrieve unix timestamp. More... | |
void | database (DBPtr db) |
Set the database pointer. More... | |
Public Member Functions inherited from Leosac::Audit::IAuditEntry | |
MAKE_VISITABLE () | |
virtual std::string | generate_description () const |
Generate a description for this event. More... | |
Public Member Functions inherited from Leosac::Tools::IVisitable | |
virtual void | accept (::Leosac::Tools::BaseVisitor &)=0 |
Accept a visitor that may mutate this . More... | |
virtual void | accept (::Leosac::Tools::BaseVisitor &) const =0 |
Accept a visitor that will not mutate this . More... | |
Static Public Member Functions | |
static AuditEntryPtr | get_last_audit (DBPtr db) |
Retrieve the last (finalized) audit entry. More... | |
Protected Member Functions | |
AuditEntry () | |
Protected Attributes | |
AuditEntryWPtr | parent_ |
std::string | msg_ |
Auth::UserLPtr | author_ |
The user at the source of the entry. More... | |
EventMask | event_mask_ |
size_t | duration_ |
How long did it take for the Audit object to be finalized. More... | |
bool | finalized_ |
Audit entry are sometime persisted multiple time before reaching their final state. More... | |
DBPtr | database_ |
Pointer to the database. More... | |
Tools::ElapsedTimeCounter | etc_ |
Keep track of how long the object has been alive. More... | |
Private Member Functions | |
void | odb_callback (odb::callback_event e, odb::database &) const |
Implementation of an ODB callback. More... | |
Private Attributes | |
AuditEntryId | id_ |
boost::posix_time::ptime | timestamp_ |
std::vector< AuditEntryPtr > | children_ |
const size_t | version_ |
Friends | |
class | odb::access |
Additional Inherited Members | |
Static Protected Member Functions inherited from Leosac::Tools::IVisitable | |
template<class T > | |
static bool | visitor_dispatch (T &visited, BaseVisitor &visitor, bool abort_on_failure) |
Implementation of IAuditEntry, backed by ODB.
This class, as well as all its child are backed by ODB, and are therefore persisted in a SQL database.
Definition at line 45 of file AuditEntry.hpp.
|
protected |
Definition at line 31 of file AuditEntry.cpp.
|
delete |
|
virtualdefault |
|
overridevirtual |
Set the author of the entry.
The author is the user that is responsible (aka at the source) of the event.
Pre-Conditions:
user
pointer, if not null, must point to an already persisted user object. Implements Leosac::Audit::IAuditEntry.
Definition at line 88 of file AuditEntry.cpp.
|
overridevirtual |
Retrieve the user id of the author of this entry.
It may returns 0, which is not a valid user_id.
Implements Leosac::Audit::IAuditEntry.
Definition at line 149 of file AuditEntry.cpp.
|
overridevirtual |
Returns the number of children that this entry has.
Implements Leosac::Audit::IAuditEntry.
Definition at line 123 of file AuditEntry.cpp.
void AuditEntry::database | ( | DBPtr | db | ) |
Set the database pointer.
This is used by the DBService.
Definition at line 144 of file AuditEntry.cpp.
|
overridevirtual |
Retrieve the current event mask.
Implements Leosac::Audit::IAuditEntry.
Definition at line 83 of file AuditEntry.cpp.
|
overridevirtual |
Set the event mask for the entry.
mask |
Implements Leosac::Audit::IAuditEntry.
Definition at line 77 of file AuditEntry.cpp.
|
overridevirtual |
Mark the entry as finalized, and update it wrt the database.
Calling finalize()
on an already finalized entry has no effect.
Subclasses must prevent modification of every attributes once this method has been called.
Pre-Conditions:
commit()
ed. Make sure to commit the transaction to guarantee that the audit is stored in the database. Implements Leosac::Audit::IAuditEntry.
Definition at line 57 of file AuditEntry.cpp.
|
overridevirtual |
Is this entry finalized.
Implements Leosac::Audit::IAuditEntry.
Definition at line 72 of file AuditEntry.cpp.
|
static |
Retrieve the last (finalized) audit entry.
Definition at line 161 of file AuditEntry.cpp.
|
overridevirtual |
Retrieve the identifier of the entry.
An id
of 0 means that the entry is not persisted yet.
Implements Leosac::Audit::IAuditEntry.
Definition at line 39 of file AuditEntry.cpp.
|
private |
Implementation of an ODB callback.
The callback will make sure to update the parent (if any). This is to ensure that parent-child relationship are persisted when saving the child.
Note that the reverse is not needed, because the child must always be fully saved before the parent gets its final update.
Definition at line 44 of file AuditEntry.cpp.
|
overridevirtual |
Retrieve the parent of this entry.
Implements Leosac::Audit::IAuditEntry.
Definition at line 139 of file AuditEntry.cpp.
|
overridevirtual |
Reload the object from the database.
Pre-Conditions:
reload()
ing the object. Implements Leosac::Audit::IAuditEntry.
Definition at line 133 of file AuditEntry.cpp.
|
overridevirtual |
Remove the parent-child relationship between this entry and its parent.
This effectively also remove this
from the children of its current parent.
Implements Leosac::Audit::IAuditEntry.
Definition at line 111 of file AuditEntry.cpp.
|
overridevirtual |
Set parent
as the parent audit entry for this entry.
The set_parent()
will copy the parent's author to this->author_ if there currently is no author assigned to the entry.
Pre-Conditions:
parent
must be a non-null, already persisted object.parent
must be of type AuditEntryPtr. This should always be the case.Post-Conditions:
parent->children_
array. Implements Leosac::Audit::IAuditEntry.
Definition at line 95 of file AuditEntry.cpp.
|
overridevirtual |
Retrieve unix timestamp.
Implements Leosac::Audit::IAuditEntry.
Definition at line 156 of file AuditEntry.cpp.
|
overridevirtual |
Returns the ODB version of the object.
This call is for debugging purpose.
Implements Leosac::Audit::IAuditEntry.
Definition at line 128 of file AuditEntry.cpp.
|
friend |
Definition at line 155 of file AuditEntry.hpp.
|
protected |
|
private |
Definition at line 103 of file AuditEntry.hpp.
|
protected |
Pointer to the database.
Required to implement finalize()
.
Manually set by Audit::Factory.
Definition at line 142 of file AuditEntry.hpp.
|
protected |
How long did it take for the Audit object to be finalized.
Definition at line 124 of file AuditEntry.hpp.
|
protected |
Keep track of how long the object has been alive.
This helps populates the duration_
field.
Definition at line 149 of file AuditEntry.hpp.
|
protected |
Definition at line 119 of file AuditEntry.hpp.
|
protected |
Audit entry are sometime persisted multiple time before reaching their final state.
When set to true, this flag indicates that the audit entry has reach its final status. This is useful to detect incomplete audit entry.
Definition at line 133 of file AuditEntry.hpp.
|
private |
Definition at line 97 of file AuditEntry.hpp.
|
protected |
Definition at line 110 of file AuditEntry.hpp.
|
protected |
Definition at line 107 of file AuditEntry.hpp.
|
private |
Definition at line 100 of file AuditEntry.hpp.
|
private |
Definition at line 153 of file AuditEntry.hpp.