@ThreadSafe public class AuditManager extends AbstractSimpleDAO implements IAuditManager
AsynchronousAuditor) and writes them to XML files on a per-day
basis.IDAO.EMode| Modifier and Type | Field and Description |
|---|---|
static String |
ELEMENT_ITEM
Element name of each item in the serialized XML
|
static String |
ELEMENT_ITEMS
Element name of the root element of the serialized XML
|
DEFAULT_AUTO_SAVE_ENABLED, m_aRWLock| Constructor and Description |
|---|
AuditManager(String sBaseDir,
ICurrentUserIDProvider aCurrentUserIDProvider)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
protected com.helger.xml.microdom.IMicroDocument |
createWriteData()
Create the XML document that should be saved to the file.
|
boolean |
equals(Object o) |
com.helger.commons.collection.ext.ICommonsList<IAuditItem> |
getAllAuditItemsOfDate(LocalDate aDate) |
int |
getAuditItemCount() |
AsynchronousAuditor |
getAuditor() |
String |
getBaseDir() |
LocalDate |
getEarliestAuditDate() |
List<IAuditItem> |
getLastAuditItems(int nMaxItems) |
static String |
getRelativeAuditDirectory(LocalDate aDate) |
static String |
getRelativeAuditDirectoryYear(int nYear) |
static String |
getRelativeAuditFilename(LocalDate aDate) |
int |
hashCode() |
boolean |
isInMemory() |
protected void |
onFilenameChange(String sPreviousFilename,
String sNewFilename)
Called after a successful write of the file, if the filename is different
from the previous filename.
|
protected com.helger.commons.state.EChange |
onRead(com.helger.xml.microdom.IMicroDocument aDoc)
Fill the internal structures with from the passed XML document.
|
static void |
readFromXML(com.helger.xml.microdom.IMicroDocument aDoc,
IAuditManagerReadHandler aHandler) |
void |
stop()
Stop taking new audits.
|
String |
toString() |
beforeWriteToFile, getDAOIO, getFilenameProvider, getInitCount, getLastFilename, getLastInitDateTime, getLastReadDateTime, getLastWriteDateTime, getReadCount, getSafeFile, getWriteCount, getXMLWriterSettings, initialRead, markAsChanged, modifyWriteData, onInit, triggerExceptionHandlersRead, triggerExceptionHandlersWrite, writeToFileOnPendingChangesbeginWithoutAutoSave, endWithoutAutoSave, getExceptionHandlersRead, getExceptionHandlersWrite, hasPendingChanges, internalHasPendingChanges, internalIsAutoSaveEnabled, internalSetPendingChanges, isAutoSaveEnabled, isDebugLogging, performWithoutAutoSave, performWithoutAutoSave, performWithoutAutoSaveThrowing, performWithoutAutoSaveThrowingpublic static final String ELEMENT_ITEMS
public static final String ELEMENT_ITEM
@ContainsSoftMigration public AuditManager(@Nullable String sBaseDir, @Nonnull ICurrentUserIDProvider aCurrentUserIDProvider) throws DAOException
sBaseDir - The base directory, relative to the default IO base directory. May
be null to indicate an in-memory auditor only.aCurrentUserIDProvider - The current user ID provider. May not be null.DAOException - In case reading failed@Nonnull @Nonempty public static String getRelativeAuditDirectoryYear(@Nonnull int nYear)
@Nonnull @Nonempty public static String getRelativeAuditDirectory(@Nonnull LocalDate aDate)
@Nonnull @Nonempty public static String getRelativeAuditFilename(@Nonnull LocalDate aDate)
public boolean isInMemory()
isInMemory in interface IAuditManagertrue if this manager operates only in memory,
false if it keeps persistent files.IAuditManager.getBaseDir()@Nullable public String getBaseDir()
getBaseDir in interface IAuditManagernull
to indicate in-memory only auditing. If the results is not
null it must end with a path separator (slash).IAuditManager.isInMemory()@Nonnull public AsynchronousAuditor getAuditor()
getAuditor in interface IAuditManagernull.public static void readFromXML(@Nonnull com.helger.xml.microdom.IMicroDocument aDoc, @Nonnull IAuditManagerReadHandler aHandler)
@Nonnull protected com.helger.commons.state.EChange onRead(@Nonnull com.helger.xml.microdom.IMicroDocument aDoc)
AbstractSimpleDAOonRead in class AbstractSimpleDAOaDoc - The XML document to read from. Never null.EChange.CHANGED if reading the data changed something in
the internal structures that requires a writing.protected com.helger.xml.microdom.IMicroDocument createWriteData()
AbstractSimpleDAOcreateWriteData in class AbstractSimpleDAOnull document to write to the file.protected void onFilenameChange(@Nullable String sPreviousFilename, @Nonnull String sNewFilename)
AbstractSimpleDAOonFilenameChange in class AbstractSimpleDAOsPreviousFilename - The previous filename. May be null.sNewFilename - The new filename. Never null.@Nonnegative public int getAuditItemCount()
@Nonnull @ReturnsMutableCopy @CodingStyleguideUnaware public List<IAuditItem> getLastAuditItems(@Nonnegative int nMaxItems)
getLastAuditItems in interface IAuditManagernMaxItems - The maximum number of items. Must be > 0.null.public void stop()
IAuditManagerstop in interface IAuditManager@Nullable @ReturnsMutableCopy public com.helger.commons.collection.ext.ICommonsList<IAuditItem> getAllAuditItemsOfDate(@Nonnull LocalDate aDate)
@Nonnull public LocalDate getEarliestAuditDate()
getEarliestAuditDate in interface IAuditManagernull.public String toString()
toString in class AbstractSimpleDAOCopyright © 2014–2017 Philip Helger. All rights reserved.