Class GuardianService

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

@Service @Component public class GuardianService extends Object
GuardianService is responsible for handling and managing guardian logs, stack traces, sending error notification emails, and purging old logs. It provides methods to log errors, notify users, and interact with the database for storing or purging data.
  • Constructor Details

    • GuardianService

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

    • addStacktrace

      public void addStacktrace(String keyIO, Object... objectsIO)
      Adds a stack trace entry with the specified key and additional context information.
      Parameters:
      keyIO - the key associated with the stack trace entry
      objectsIO - additional context information related to the stack trace
    • addStacktrace

      public void addStacktrace(SecurityLevel levelIO, String keyIO, Object... objectsIO)
      Adds a stack trace to the logging or error handling system with the specified parameters.
      Parameters:
      levelIO - the security level associated with the stack trace
      keyIO - the key or identifier for the stack trace
      objectsIO - the additional objects or parameters to be included in the stack trace
    • addStacktrace

      public void addStacktrace(Exception exceptionIO, String keyIO, Object... objectsIO)
      Adds a stack trace for the given exception along with additional context.
      Parameters:
      exceptionIO - The exception for which the stack trace is being added.
      keyIO - The key associated with the stack trace entry.
      objectsIO - Additional objects providing context or information related to the stack trace.
    • addStacktrace

      public void addStacktrace(Exception exceptionIO, String keyIO, SecurityLevel levelIO, Object... objectsIO)
      Adds a stack trace entry to the logging or tracking system with the specified parameters.
      Parameters:
      exceptionIO - the exception whose stack trace is to be added
      keyIO - the key identifying the context or category of the entry
      levelIO - the security level associated with the stack trace entry
      objectsIO - additional context objects related to the stack trace entry
    • addStacktrace

      public void addStacktrace(Exception exceptionIO, String keyIO, boolean mailIO, SecurityLevel levelIO, Object... objectsIO)
      Adds a stack trace to the database and optionally sends error mails.
      Parameters:
      exceptionIO - The exception to be recorded.
      keyIO - The identifying key for the error.
      mailIO - Flag indicating whether to send error mails.
      levelIO - The security level associated with the error.
      objectsIO - Additional objects for context or data related to the error.
    • purgeOldLogs

      public void purgeOldLogs(Integer maxAge)
      Purges logs that are older than the specified maximum age.
      Parameters:
      maxAge - The maximum age of logs (in days) to keep. Logs older than this age will be deleted.
    • toLocalisedString

      public String toLocalisedString(GuardianLog guardianLog)
      Converts a GuardianLog object into a localized string representation using predefined message formatting. Splits the key from the GuardianLog into group and key components, if applicable, and formats the string using the associated group and key along with the log's value.
      Parameters:
      guardianLog - The GuardianLog object containing the key and value to be localized. The key is expected to follow the format "group/key" or just "key".
    • 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