Class LoggerService

java.lang.Object
com.inesm.KeyManager.services.LoggerService

@Service public class LoggerService extends Object
Provides methods to log operations.
  • Method Details

    • initLog

      public long initLog(User user, int operationID)
      Inits a log instance of an operation. Will save in the log fields the current username, roleName, operationName, resourceType and the current timestamp.

      After the log instance is initialized it will be necessary to call updateLog(long, Resource, boolean, String) in order to properly update the log instance, regarding the outcome of the operation.

      Parameters:
      user - the user performing the operation, if null the log will use 'undefined' to reference the user performing the operation
      operationID - the operationID of the operation being logged
      Returns:
      the logID of the created log or -1 if an error occurred
    • updateLog

      public void updateLog(long logID, Resource data, boolean error, String info)
      Updates a log instance regarding a the outcome of the operation, and the received parameters.
      Parameters:
      logID - the logID of the log being updated
      data - the input data of the operation, can be null
      error - the flag indicating if the operation terminated successfully
      info - the message to display as the cause of the operation interruption (or more information on the conclusion status), can be null
    • getLogs

      public List<Log> getLogs(Log filter)
      Fetches all logs from the database that match the filter.

      All the fields except the timestamps are checked for equality, the timestamp is used with timestampEnd to define a time interval.

      If some of the log fields are not set, they will not be considered for filtering. Ultimately, an "empty" (not null) log object will provide all the logs inside the database.

      Parameters:
      filter - the object containing the values of the filter, not null
      Returns:
      a list containing all the logs that matched the filter, not null, maybe empty