Class AuditManager

  • All Implemented Interfaces:
    com.helger.commons.log.IHasConditionalLogger, com.helger.dao.IAutoSaveAware, com.helger.dao.IDAO, IAuditManager

    @ThreadSafe
    public class AuditManager
    extends com.helger.photon.app.dao.AbstractPhotonSimpleDAO
    implements IAuditManager
    The class handles all system audit actions. It collects them asynchronously (see AsynchronousAuditor) and writes them to XML files on a per-day basis.
    Author:
    Philip Helger
    • Nested Class Summary

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

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

      Fields 
      Modifier and Type Field 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
      • 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
      AuditManager​(String sBaseDir, com.helger.security.authentication.subject.user.ICurrentUserIDProvider aCurrentUserIDProvider)
      Constructor
    • Field Detail

      • ELEMENT_ITEMS

        public static final String ELEMENT_ITEMS
        Element name of the root element of the serialized XML
        See Also:
        Constant Field Values
      • ELEMENT_ITEM

        public static final String ELEMENT_ITEM
        Element name of each item in the serialized XML
        See Also:
        Constant Field Values
    • Constructor Detail

      • AuditManager

        @ContainsSoftMigration
        public AuditManager​(@Nullable
                            String sBaseDir,
                            @Nonnull
                            com.helger.security.authentication.subject.user.ICurrentUserIDProvider aCurrentUserIDProvider)
                     throws com.helger.dao.DAOException
        Constructor
        Parameters:
        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.
        Throws:
        com.helger.dao.DAOException - In case reading failed
    • Method Detail

      • getRelativeAuditDirectoryYear

        @Nonnull
        @Nonempty
        public static String getRelativeAuditDirectoryYear​(@Nonnull
                                                           int nYear)
      • onRead

        @Nonnull
        protected com.helger.commons.state.EChange onRead​(@Nonnull
                                                          com.helger.xml.microdom.IMicroDocument aDoc)
        Specified by:
        onRead in class com.helger.dao.simple.AbstractSimpleDAO
      • createWriteData

        protected com.helger.xml.microdom.IMicroDocument createWriteData()
        Specified by:
        createWriteData in class com.helger.dao.simple.AbstractSimpleDAO
      • onFilenameChange

        protected void onFilenameChange​(@Nullable
                                        String sPreviousFilename,
                                        @Nonnull
                                        String sNewFilename)
        Overrides:
        onFilenameChange in class com.helger.dao.simple.AbstractSimpleDAO
      • getAuditItemCount

        @Nonnegative
        public int getAuditItemCount()
      • getLastAuditItems

        @Nonnull
        @ReturnsMutableCopy
        @CodingStyleguideUnaware
        public List<IAuditItem> getLastAuditItems​(@Nonnegative
                                                  int nMaxItems)
        Specified by:
        getLastAuditItems in interface IAuditManager
        Parameters:
        nMaxItems - The maximum number of items. Must be > 0.
        Returns:
        The n latest audit items. Never null.
      • stop

        public void stop()
        Description copied from interface: IAuditManager
        Stop taking new audits. Call this upon shutdown for correct cleanup! Consecutive calls to this method have no further effect.
        Specified by:
        stop in interface IAuditManager
      • getEarliestAuditDate

        @Nonnull
        public LocalDate getEarliestAuditDate()
        Specified by:
        getEarliestAuditDate in interface IAuditManager
        Returns:
        The earliest date for which auditing information is present. If this is an in-memory audit manager, it must return the current date. May be null if a persistent storage is used and no entry is present yet.
      • hashCode

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

        public String toString()
        Overrides:
        toString in class com.helger.dao.simple.AbstractSimpleDAO