Class AuditManager

  • All Implemented Interfaces:
    IAuditManager

    public class AuditManager
    extends java.lang.Object
    implements IAuditManager
    Manager for Auditing.
    Since:
    6.0.0
    Version:
    $Revision: 24978 $ $Date: 2022-05-02 16:46:33 -0300 (Mon, 02 May 2022) $
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  AuditManager.AuditType
      Enum of audit types used by audit actions taken.
    • Constructor Summary

      Constructors 
      Constructor Description
      AuditManager()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void audit​(java.lang.String title, java.lang.String description, java.lang.String typeKey)
      Register an audit entry.
      lumis.portal.audit.AuditEntry audit​(java.lang.String title, java.lang.String description, java.lang.String typeKey, boolean registerChilds, ITransaction t)
      Starts an operation for audit and add register an observer to the transaction in order to end the operation.
      lumis.portal.audit.AuditEntry beginAudit​(java.lang.String title, java.lang.String description, java.lang.String typeKey, boolean registerChilds)
      Starts an operation for audit.
      boolean clearContextThreadData()
      Clears the AuditContext thread data.
      void disableType​(java.lang.String auditEntryTypeId)
      Disable the AuditEntryType by it's id.
      void enableType​(java.lang.String auditEntryTypeId)
      Enable the AuditEntryType by it's id.
      void endAudit​(lumis.portal.audit.AuditEntry auditEntry)
      Ends the AuditEntry operation.
      protected void endContext​(lumis.portal.audit.AuditEntry auditEntry)
      End the audit context.
      protected AuditCategory findCategoryById​(java.lang.String categoryId)
      Find the category by it's id.
      protected AuditCategory findCategoryByKey​(java.lang.String categoryKey)
      Find the AuditCategory by it's key.
      protected AuditEntryType findEntryTypeByKey​(java.lang.String entryTypeKey)
      Find the AuditEntryType by it's key.
      protected void initContext​(lumis.portal.audit.AuditEntry auditEntry, boolean registerChilds)
      Initializes the audit context.
      protected lumis.portal.audit.AuditEntry initEntry​(java.lang.String userId, java.lang.String userLogin, java.lang.String title, java.lang.String description, AuditEntryType type, boolean registerChilds)
      Creates an instance of AuditEntry.
      protected void logEntry​(lumis.portal.audit.AuditEntry auditEntry)
      Log the audit entry.
      AuditConfig obtainConfiguration()
      Obtain the audit configuration.
      protected void registerEntry​(lumis.portal.audit.AuditEntry auditEntry, AuditEntryState state)
      Register the audit entry in database.
      void removeOldEntries()
      Remove audit entries older than the number of days specified by the cleanInterval field in configuration.
      void updateCleanInterval​(int cleanInterval)
      Updates the time interval to clean audit entries.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AuditManager

        public AuditManager()
    • Method Detail

      • audit

        public void audit​(java.lang.String title,
                          java.lang.String description,
                          java.lang.String typeKey)
                   throws PortalException
        Register an audit entry.
        Specified by:
        audit in interface IAuditManager
        Parameters:
        title - the operation title. If the title is bigger than the allowed size, the string is truncated.
        description - the operation description.
        typeKey - the AuditEntryType key.
        Throws:
        PortalException
        Since:
        6.0.0
      • audit

        public lumis.portal.audit.AuditEntry audit​(java.lang.String title,
                                                   java.lang.String description,
                                                   java.lang.String typeKey,
                                                   boolean registerChilds,
                                                   ITransaction t)
                                            throws PortalException
        Starts an operation for audit and add register an observer to the transaction in order to end the operation. The entry is registered in database as initialized.
        Parameters:
        title - the operation title.
        description - the operation description.
        categoryKey - the AuditCategory key.
        typeKey - the AuditEntryType key.
        registerChilds - true if the child entries must be saved in database, false otherwise.
        Returns:
        an instance of AuditEntry representing the operation.
        Throws:
        PortalException
        Since:
        6.0.0
      • beginAudit

        public lumis.portal.audit.AuditEntry beginAudit​(java.lang.String title,
                                                        java.lang.String description,
                                                        java.lang.String typeKey,
                                                        boolean registerChilds)
                                                 throws PortalException
        Starts an operation for audit. The entry is registered in database as initialized.
        Parameters:
        title - the operation title.
        description - the operation description.
        categoryKey - the AuditCategory key.
        typeKey - the AuditEntryType key.
        registerChilds - true if the child entries must be saved in database, false otherwise.
        Returns:
        an instance of AuditEntry representing the operation.
        Throws:
        PortalException
        Since:
        6.0.0
      • endAudit

        public void endAudit​(lumis.portal.audit.AuditEntry auditEntry)
                      throws PortalException
        Ends the AuditEntry operation.
        Parameters:
        auditEntry - the AuditEntry instance.
        Throws:
        PortalException
        Since:
        6.0.0
      • removeOldEntries

        public void removeOldEntries()
                              throws PortalException
        Remove audit entries older than the number of days specified by the cleanInterval field in configuration.
        Throws:
        PortalException
        Since:
        6.0.0
      • updateCleanInterval

        public void updateCleanInterval​(int cleanInterval)
                                 throws PortalException
        Updates the time interval to clean audit entries.
        Parameters:
        cleanInterval - the new value for time interval in days.
        Throws:
        AccessDeniedException - if the user has not permission to use management functions.
        PortalException - if an error occur updating the time interval.
        Since:
        6.0.0
      • clearContextThreadData

        public boolean clearContextThreadData()
        Clears the AuditContext thread data.
        Returns:
        true if there was data to be cleared or false if the thread data was already clear.
        Since:
        6.0.0
      • initEntry

        protected lumis.portal.audit.AuditEntry initEntry​(java.lang.String userId,
                                                          java.lang.String userLogin,
                                                          java.lang.String title,
                                                          java.lang.String description,
                                                          AuditEntryType type,
                                                          boolean registerChilds)
        Creates an instance of AuditEntry.
        Parameters:
        user - user.
        title - a title for the operation being audited. If the title is bigger than the allowed, a substring is created.
        description - a description for the operation.
        type - the AuditEntryType instance.
        registerChilds - true if the child entries must be saved in database, false otherwise.
        Returns:
        an instance of AuditEntry.
        Since:
        6.0.0
      • findCategoryByKey

        protected AuditCategory findCategoryByKey​(java.lang.String categoryKey)
                                           throws PortalException
        Find the AuditCategory by it's key.
        Parameters:
        categoryKey - the audit category key.
        Returns:
        the instance of AuditCategory.
        Throws:
        PortalException - if an error occur in audit category dao.
        Since:
        6.0.0
      • findCategoryById

        protected AuditCategory findCategoryById​(java.lang.String categoryId)
                                          throws PortalException
        Find the category by it's id.
        Parameters:
        categoryId - the category id.
        Returns:
        the AuditCategory instance.
        Throws:
        PortalException
        Since:
        6.0.0
      • findEntryTypeByKey

        protected AuditEntryType findEntryTypeByKey​(java.lang.String entryTypeKey)
                                             throws PortalException
        Find the AuditEntryType by it's key.
        Parameters:
        entryTypeKey - the audit entry type key.
        Returns:
        the instance of AuditEntryType.
        Throws:
        PortalException - if an error occur in audit entry type dao.
        Since:
        6.0.0
      • initContext

        protected void initContext​(lumis.portal.audit.AuditEntry auditEntry,
                                   boolean registerChilds)
        Initializes the audit context.
        Parameters:
        auditEntry - the AuditEntry instance.
        registerChilds - true if the child entries must be saved in database, false otherwise.
        Since:
        6.0.0
      • endContext

        protected void endContext​(lumis.portal.audit.AuditEntry auditEntry)
        End the audit context.
        Parameters:
        auditEntry - the AuditEntry instance.
        Since:
        6.0.0
      • logEntry

        protected void logEntry​(lumis.portal.audit.AuditEntry auditEntry)
        Log the audit entry.
        Parameters:
        auditEntry - the AuditEntry instance.
        Since:
        6.0.0
      • registerEntry

        protected void registerEntry​(lumis.portal.audit.AuditEntry auditEntry,
                                     AuditEntryState state)
                              throws PortalException
        Register the audit entry in database.
        Parameters:
        auditEntry - the AuditEntry instance.
        state - the state of audit entry.
        Throws:
        PortalException
        Since:
        6.0.0