Class 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
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface com.helger.dao.IDAO

        com.helger.dao.IDAO.EMode
    • Field Summary

      • Fields inherited from class com.helger.dao.wal.AbstractWALDAO

        DEFAULT_WAITING_TIME, WAL_XWS, WRITE_XWS
      • Fields inherited from class com.helger.dao.AbstractDAO

        CONDLOG, DEFAULT_AUTO_SAVE_ENABLED, FILENAME_EXTENSION_NEW, FILENAME_EXTENSION_PREV, m_aRWLock, RW_LOCK
    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleAuditManager​(String sFilename, com.helger.security.authentication.subject.user.ICurrentUserIDProvider aCurrentUserIDProvider)
      Constructor
    • 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 be null to indicate an in-memory auditor only.
        aCurrentUserIDProvider - The current user ID provider. May not be null.
        Throws:
        com.helger.dao.DAOException - In case reading failed
    • Method Detail

      • onRecoveryCreate

        @IsLocked(WRITE)
        protected void onRecoveryCreate​(@Nonnull
                                        AuditItem aItem)
        Specified by:
        onRecoveryCreate in class com.helger.dao.wal.AbstractWALDAO<AuditItem>
      • onRecoveryUpdate

        @IsLocked(WRITE)
        protected void onRecoveryUpdate​(@Nonnull
                                        AuditItem aElement)
        Specified by:
        onRecoveryUpdate in class com.helger.dao.wal.AbstractWALDAO<AuditItem>
      • onRecoveryDelete

        @IsLocked(WRITE)
        protected void onRecoveryDelete​(@Nonnull
                                        AuditItem aElement)
        Specified by:
        onRecoveryDelete in class com.helger.dao.wal.AbstractWALDAO<AuditItem>
      • onRead

        @Nonnull
        protected com.helger.commons.state.EChange onRead​(@Nonnull
                                                          com.helger.xml.microdom.IMicroDocument aDoc)
        Specified by:
        onRead in class com.helger.dao.wal.AbstractWALDAO<AuditItem>
      • createWriteData

        protected com.helger.xml.microdom.IMicroDocument createWriteData()
        Specified by:
        createWriteData in class com.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: IAuditor
        Create a new audit item.
        Specified by:
        createAuditItem in interface IAuditor
        Parameters:
        eActionType - Action type. May not be null.
        eSuccess - Success or failure? May not be null.
        aActionObjectType - Action object type. May be null if sAction is set.
        sAction - The performed action. May be null if aActionObjectType is set.
        aArgs - An optional array of arguments. May be null or empty.
      • getAuditItemCount

        @Nonnegative
        public int getAuditItemCount()
      • getAllAuditItems

        @Nonnull
        @ReturnsMutableCopy
        public com.helger.commons.collection.impl.ICommonsList<IAuditItem> getAllAuditItems()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • toString

        public String toString()
        Overrides:
        toString in class com.helger.dao.wal.AbstractWALDAO<AuditItem>