Class AuditService

java.lang.Object
de.bytestore.hostinger.internal.service.AuditService

@Service @Component public class AuditService extends Object
AuditService provides functionalities for auditing application activities, managing error notifications, and maintaining log records. It includes features for adding stack traces, purging old logs, sending error notifications via email, and converting logs to localized strings. This class leverages dependency injection for its collaborative services.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AuditService(io.jmix.core.Messages messages, io.jmix.core.security.CurrentAuthentication currentAuthentication)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addEntry(String keyIO, Object... objectsIO)
    Adds a stacktrace related to the given key and associated objects for tracking or debugging purposes.
    static String
    objectToString(Object... objectsIO)
    Converts the given objects into their JSON string representation.
    void
    Purges old log entries from the database that are older than or equal to the specified maximum age.
    stringToObject(String jsonString)
    Converts a JSON string into an object of the specified type.
    Converts the given AuditLog object into a localized string representation by extracting its key and formatting it using a message provider.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AuditService

      public AuditService(io.jmix.core.Messages messages, io.jmix.core.security.CurrentAuthentication currentAuthentication)
  • Method Details

    • addEntry

      public void addEntry(String keyIO, Object... objectsIO)
      Adds a stacktrace related to the given key and associated objects for tracking or debugging purposes.
      Parameters:
      keyIO - the identifier or key associated with the stacktrace
      objectsIO - the objects or context information related to the stacktrace
    • purgeOldLogs

      public void purgeOldLogs(Integer maxAge)
      Purges old log entries from the database that are older than or equal to the specified maximum age. This method retrieves the log entries meeting the criteria and removes them.
      Parameters:
      maxAge - The maximum age (in days) for the log entries to retain. Entries older than or equal to this value will be deleted.
    • toLocalisedString

      public String toLocalisedString(AuditLog guardianLog)
      Converts the given AuditLog object into a localized string representation by extracting its key and formatting it using a message provider.
      Parameters:
      guardianLog - the AuditLog object containing the key and value to be localized.
      Returns:
      the localized string representation formatted based on the extracted key and value.
    • objectToString

      public static String objectToString(Object... objectsIO)
      Converts the given objects into their JSON string representation.
      Parameters:
      objectsIO - The objects to be converted to a JSON string.
      Returns:
      The JSON string representation of the provided objects.
    • stringToObject

      public static ArrayList<Object> stringToObject(String jsonString)
      Converts a JSON string into an object of the specified type.
      Parameters:
      jsonString - the JSON string to be deserialized
      Returns:
      the deserialized object of the specified