Class GuardianService
java.lang.Object
de.bytestore.hostinger.internal.service.GuardianService
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 Summary
ConstructorsConstructorDescriptionGuardianService(io.jmix.core.Messages messages, io.jmix.core.security.CurrentAuthentication currentAuthentication) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStacktrace(SecurityLevel levelIO, String keyIO, Object... objectsIO) Adds a stack trace to the logging or error handling system with the specified parameters.voidaddStacktrace(Exception exceptionIO, String keyIO, boolean mailIO, SecurityLevel levelIO, Object... objectsIO) Adds a stack trace to the database and optionally sends error mails.voidaddStacktrace(Exception exceptionIO, String keyIO, SecurityLevel levelIO, Object... objectsIO) Adds a stack trace entry to the logging or tracking system with the specified parameters.voidaddStacktrace(Exception exceptionIO, String keyIO, Object... objectsIO) Adds a stack trace for the given exception along with additional context.voidaddStacktrace(String keyIO, Object... objectsIO) Adds a stack trace entry with the specified key and additional context information.static StringobjectToString(Object... objectsIO) Converts the given objects into their JSON string representation.voidpurgeOldLogs(Integer maxAge) Purges logs that are older than the specified maximum age.stringToObject(String jsonString) Converts a JSON string into an object of the specified type.toLocalisedString(GuardianLog guardianLog) Converts a GuardianLog object into a localized string representation using predefined message formatting.
-
Constructor Details
-
GuardianService
public GuardianService(io.jmix.core.Messages messages, io.jmix.core.security.CurrentAuthentication currentAuthentication)
-
-
Method Details
-
addStacktrace
Adds a stack trace entry with the specified key and additional context information.- Parameters:
keyIO- the key associated with the stack trace entryobjectsIO- additional context information related to the stack trace
-
addStacktrace
Adds a stack trace to the logging or error handling system with the specified parameters.- Parameters:
levelIO- the security level associated with the stack tracekeyIO- the key or identifier for the stack traceobjectsIO- the additional objects or parameters to be included in the stack trace
-
addStacktrace
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 addedkeyIO- the key identifying the context or category of the entrylevelIO- the security level associated with the stack trace entryobjectsIO- 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
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
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
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
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
-