Class AuditMessagesManagerImpl

java.lang.Object
cz.metacentrum.perun.core.impl.AuditMessagesManagerImpl
All Implemented Interfaces:
AuditMessagesManagerImplApi

public class AuditMessagesManagerImpl extends Object implements AuditMessagesManagerImplApi
Implementation of AuditMessagesManagerImplApi with methods used to read stored auditer messages.
Author:
Pavel Zlámal
  • Constructor Details

    • AuditMessagesManagerImpl

      public AuditMessagesManagerImpl(DataSource perunPool)
  • Method Details

    • checkAuditerConsumerExists

      public boolean checkAuditerConsumerExists(PerunSession session, String consumerName)
      Description copied from interface: AuditMessagesManagerImplApi
      Returns TRUE if auditer consumer with specified name exist.
      Specified by:
      checkAuditerConsumerExists in interface AuditMessagesManagerImplApi
      Parameters:
      session - PerunSession
      consumerName - Name of consumer to check
      Returns:
      TRUE if consumer exists by name / FALSE otherwise
    • createAuditerConsumer

      public void createAuditerConsumer(PerunSession perunSession, String consumerName)
      Description copied from interface: AuditMessagesManagerImplApi
      Creates new auditer consumer with last processed id which equals current auditer log max id.
      Specified by:
      createAuditerConsumer in interface AuditMessagesManagerImplApi
      Parameters:
      perunSession - perun session
      consumerName - new name for consumer
    • getAllAuditerConsumers

      public Map<String,Integer> getAllAuditerConsumers(PerunSession sess)
      Description copied from interface: AuditMessagesManagerImplApi
      Get all registered auditer consumers as map name(String)=lastProcessedId(Integer).
      Specified by:
      getAllAuditerConsumers in interface AuditMessagesManagerImplApi
      Parameters:
      sess - perun session
      Returns:
      Mapping of auditer consumer names to their last processed ID.
    • getAuditerMessagesCount

      public int getAuditerMessagesCount(PerunSession perunSession)
      Description copied from interface: AuditMessagesManagerImplApi
      Get count of all messages in auditLOG.
      Specified by:
      getAuditerMessagesCount in interface AuditMessagesManagerImplApi
      Parameters:
      perunSession - perun session
      Returns:
      Count of all messages in audit log
    • getLastMessageId

      public int getLastMessageId(PerunSession perunSession)
      Description copied from interface: AuditMessagesManagerImplApi
      Get ID of last (newest) message in audit log (max_id).
      Specified by:
      getLastMessageId in interface AuditMessagesManagerImplApi
      Parameters:
      perunSession - perun session
      Returns:
      ID of last (newest) message.
    • getMessages

      public List<AuditMessage> getMessages(PerunSession perunSession, int count)
      Description copied from interface: AuditMessagesManagerImplApi
      Returns exact number of newest audit messages defined by 'count' param (disregarding message IDs). If there is less messages present, then all of them are returned.
      Specified by:
      getMessages in interface AuditMessagesManagerImplApi
      Parameters:
      perunSession - perun session
      count - Count of returned messages.
      Returns:
      List of audit messages
    • getMessagesByCount

      public List<AuditMessage> getMessagesByCount(PerunSession perunSession, int count)
      Description copied from interface: AuditMessagesManagerImplApi
      Returns all messages with IDs within the range from max(ID) to (max(ID)-count), where number of returned messages is equal or less than 'count' param, because some IDs could be skipped in the sequence.
      Specified by:
      getMessagesByCount in interface AuditMessagesManagerImplApi
      Parameters:
      perunSession - perun session
      count - Number of IDs to subtract from max(ID)
      Returns:
      List of audit messages
    • getMessagesByIdAndCount

      public List<AuditMessage> getMessagesByIdAndCount(PerunSession perunSession, int id, int count)
      Description copied from interface: AuditMessagesManagerImplApi
      Returns "count" number of messages that are more or equal than the given ID (ascending order), i.e. the method returns newer messages by provided ID.
      Specified by:
      getMessagesByIdAndCount in interface AuditMessagesManagerImplApi
      Parameters:
      perunSession - perun session
      id - starting id from which the messages will be taken
      count - Number of messages that will be returned
      Returns:
      List of audit messages
    • getMessagesPage

      public Paginated<AuditMessage> getMessagesPage(PerunSession perunSession, MessagesPageQuery query)
      Description copied from interface: AuditMessagesManagerImplApi
      Returns page of audit messages. Query parameter specifies offset and page size and allows filtering by name of event. Total count is only estimated.
      Specified by:
      getMessagesPage in interface AuditMessagesManagerImplApi
      Parameters:
      perunSession - perun session
      Returns:
      Page of audit messages
    • pollConsumerEvents

      public List<AuditEvent> pollConsumerEvents(PerunSession perunSession, String consumerName, int lastProcessedId)
      Description copied from interface: AuditMessagesManagerImplApi
      Returns list of AuditEvents from audit log with IDs > lastProcessedId for registered auditer consumer. Number of returned events for one call is limited (by default 10 000). You might need to fetch additional events by repeating this call.
      Specified by:
      pollConsumerEvents in interface AuditMessagesManagerImplApi
      Parameters:
      perunSession - perun session
      consumerName - consumer to get messages for
      lastProcessedId - id of the last message
      Returns:
      List of audit messages
    • pollConsumerMessages

      public List<AuditMessage> pollConsumerMessages(PerunSession perunSession, String consumerName)
      Description copied from interface: AuditMessagesManagerImplApi
      Returns list of AuditMessages from audit log with IDs > lastProcessedId for registered auditer consumer. Number of returned messages for one call is limited (by default 10 000). You might need to fetch additional messages by repeating this call.
      Specified by:
      pollConsumerMessages in interface AuditMessagesManagerImplApi
      Parameters:
      perunSession - perun session
      consumerName - consumer to get messages for
      Returns:
      List of audit messages
    • pollConsumerMessages

      public List<AuditMessage> pollConsumerMessages(PerunSession perunSession, String consumerName, int lastProcessedId)
      Description copied from interface: AuditMessagesManagerImplApi
      Returns list of AuditMessages from audit log with IDs > lastProcessedId for registered auditer consumer. Number of returned messages for one call is limited (by default 10 000). You might need to fetch additional messages by repeating this call.
      Specified by:
      pollConsumerMessages in interface AuditMessagesManagerImplApi
      Parameters:
      perunSession - perun session
      consumerName - consumer to get messages for
      lastProcessedId - id of the last message
      Returns:
      List of audit messages
    • setLastProcessedId

      public void setLastProcessedId(PerunSession perunSession, String consumerName, int lastProcessedId)
      Description copied from interface: AuditMessagesManagerImplApi
      Set ID of last processed message for specified consumer.
      Specified by:
      setLastProcessedId in interface AuditMessagesManagerImplApi
      Parameters:
      perunSession - perun session
      consumerName - name of consumer
      lastProcessedId - id of last processed message in consumer