Package com.helger.photon.audit
Class SimpleAuditManager
- java.lang.Object
-
- com.helger.dao.AbstractDAO
-
- com.helger.dao.wal.AbstractWALDAO<DATATYPE>
-
- com.helger.photon.app.dao.AbstractPhotonWALDAO<AuditItem>
-
- com.helger.photon.audit.SimpleAuditManager
-
- All Implemented Interfaces:
com.helger.commons.log.IHasConditionalLogger,com.helger.dao.IAutoSaveAware,com.helger.dao.IDAO,IAuditor
@ThreadSafe public class SimpleAuditManager extends com.helger.photon.app.dao.AbstractPhotonWALDAO<AuditItem> implements IAuditor
The class handles audit actions in a very simple way. All actions are synchronously written to a single large file.- Author:
- Philip Helger
-
-
Constructor Summary
Constructors Constructor Description SimpleAuditManager(String sFilename, com.helger.security.authentication.subject.user.ICurrentUserIDProvider aCurrentUserIDProvider)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateAuditItem(EAuditActionType eActionType, com.helger.commons.state.ESuccess eSuccess, com.helger.commons.type.ObjectType aActionObjectType, String sAction, Object... aArgs)Create a new audit item.protected com.helger.xml.microdom.IMicroDocumentcreateWriteData()booleanequals(Object o)com.helger.commons.collection.impl.ICommonsList<IAuditItem>getAllAuditItems()intgetAuditItemCount()List<IAuditItem>getLastAuditItems(int nMaxItems)inthashCode()protected com.helger.commons.state.EChangeonRead(com.helger.xml.microdom.IMicroDocument aDoc)protected voidonRecoveryCreate(AuditItem aItem)protected voidonRecoveryDelete(AuditItem aElement)protected voidonRecoveryUpdate(AuditItem aElement)StringtoString()-
Methods inherited from class com.helger.dao.wal.AbstractWALDAO
convertNativeToWALString, convertWALStringToNative, getDataTypeClass, getFilenameProvider, getInitCount, getIO, getLastFilename, getLastInitDateTime, getLastReadDateTime, getLastWriteDateTime, getReadCount, getSafeFile, getWaitingTime, getWALXMLWriterSettings, getWriteCount, getXMLWriterSettings, initialRead, markAsChanged, markAsChanged, modifyWriteData, onBetweenReadAndWAL, onFilenameChange, onInit, onRecoveryErrorConvertToNative, setWaitingTime, triggerExceptionHandlersRead, triggerExceptionHandlersWrite, writeToFileOnPendingChanges
-
Methods inherited from class com.helger.dao.AbstractDAO
beginWithoutAutoSave, checkFileAccess, endWithoutAutoSave, exceptionHandlersRead, exceptionHandlersWrite, hasPendingChanges, internalHasPendingChanges, internalIsAutoSaveEnabled, internalSetPendingChanges, isAutoSaveEnabled, isSilentMode, setSilentMode
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.helger.photon.audit.IAuditor
onCreateFailure, onCreateSuccess, onDeleteFailure, onDeleteSuccess, onExecuteFailure, onExecuteFailure, onExecuteSuccess, onExecuteSuccess, onModifyFailure, onModifySuccess, onUndeleteFailure, onUndeleteSuccess
-
-
-
-
Constructor Detail
-
SimpleAuditManager
public SimpleAuditManager(@Nullable String sFilename, @Nonnull com.helger.security.authentication.subject.user.ICurrentUserIDProvider aCurrentUserIDProvider) throws com.helger.dao.DAOException
Constructor- Parameters:
sFilename- The filename to write the audits to. May benullto indicate an in-memory auditor only.aCurrentUserIDProvider- The current user ID provider. May not benull.- Throws:
com.helger.dao.DAOException- In case reading failed
-
-
Method Detail
-
onRecoveryCreate
@IsLocked(WRITE) protected void onRecoveryCreate(@Nonnull AuditItem aItem)
- Specified by:
onRecoveryCreatein classcom.helger.dao.wal.AbstractWALDAO<AuditItem>
-
onRecoveryUpdate
@IsLocked(WRITE) protected void onRecoveryUpdate(@Nonnull AuditItem aElement)
- Specified by:
onRecoveryUpdatein classcom.helger.dao.wal.AbstractWALDAO<AuditItem>
-
onRecoveryDelete
@IsLocked(WRITE) protected void onRecoveryDelete(@Nonnull AuditItem aElement)
- Specified by:
onRecoveryDeletein classcom.helger.dao.wal.AbstractWALDAO<AuditItem>
-
onRead
@Nonnull protected com.helger.commons.state.EChange onRead(@Nonnull com.helger.xml.microdom.IMicroDocument aDoc)
- Specified by:
onReadin classcom.helger.dao.wal.AbstractWALDAO<AuditItem>
-
createWriteData
protected com.helger.xml.microdom.IMicroDocument createWriteData()
- Specified by:
createWriteDatain classcom.helger.dao.wal.AbstractWALDAO<AuditItem>
-
createAuditItem
public void createAuditItem(@Nonnull EAuditActionType eActionType, @Nonnull com.helger.commons.state.ESuccess eSuccess, @Nullable com.helger.commons.type.ObjectType aActionObjectType, @Nullable String sAction, @Nullable Object... aArgs)
Description copied from interface:IAuditorCreate a new audit item.- Specified by:
createAuditItemin interfaceIAuditor- Parameters:
eActionType- Action type. May not benull.eSuccess- Success or failure? May not benull.aActionObjectType- Action object type. May benullif sAction is set.sAction- The performed action. May benullif aActionObjectType is set.aArgs- An optional array of arguments. May benullor empty.
-
getAuditItemCount
@Nonnegative public int getAuditItemCount()
-
getAllAuditItems
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<IAuditItem> getAllAuditItems()
-
getLastAuditItems
@Nonnull @ReturnsMutableCopy public List<IAuditItem> getLastAuditItems(@Nonnegative int nMaxItems)
-
-