Interface AuditItemStore

All Known Implementing Classes:
JiraAuditItemStore

public interface AuditItemStore
  • Method Details

    • addEntry

      long addEntry(TenantContext context, AuditItem item)
      Stores an audit item for the given tenant.

      Parameters:
      context - the tenant database context
      item - the actual audit item to store
      Returns:
      the id of the new item.
    • addEntry

      long addEntry(TenantContext context, AuditItem auditItem, AutomationEvent automationEvent, com.codebarrel.automation.api.config.RuleConfigBean ruleConfigBean)
      Stores an audit item for the given tenant. automationEvent can provide extra meta data for the audit log. ruleConfigBean determines what counts we increment.
    • cleanupStuckAuditItems

      void cleanupStuckAuditItems(Environment env)
      Sometimes it can happen that audit items are stuck IN_PROGRESS (perhaps the server was shut down during rule execution), or there was a lambda outage or unexpected exceptions during rule execution etc. This method will move all of those audi items into a state that causes less user anxiety. (AUT-152)
      Parameters:
      env - the db environment to run in
    • getItemsWithDetails

      ResultsPage<AuditItem> getItemsWithDetails(TenantContext context, AuditItemFilter filter, long limit)
      Retrieves all audit items for the tenant context for the specified filter.

      This method will return items with details (associated items, change items, component changes). It is written for getting logs to write them to the file. Use it wisely as it can influence performance.

      Parameters:
      context - the tenant database context
      filter - filter to constrict query
      limit - the maximum number of records to be returned from database
      Returns:
      all matching audit items packed to ResultPage obect
    • getItems

      ResultsPage<AuditItem> getItems(TenantContext context, AuditItemFilter filter, long offset, long limit)
      Retrieves all audit items for the tenant context in the project specified.

      This method will only return items as specified by the offset (page start) and maxResults (max items to return in one call in reverse order (by created date).

      Parameters:
      context - the tenant database context
      filter - filter to constrict query
      offset - The page offset to start retrieving items from
      limit - the maximum number of items to return
      Returns:
      Items object containing all matching audit items
    • getItem

      Optional<AuditItem> getItem(TenantContext context, AuditItemFilter filter, long auditItemId)
    • updateEntry

      void updateEntry(TenantContext context, long ruleId, AuditItem updates)
    • getObjectItemIdsToDelete

      Set<Long> getObjectItemIdsToDelete(Environment env, long minAuditEntrysToKeep, Timestamp olderThan)
      Returns all object item ids that have audit logs that:
      • where the total number of audit logs per object item id is greater than minAuditEntrysToKeep
      • There's entries older than the specified olderThan timestamp

      These ids can then be used to schedule a deletion.

      Parameters:
      env - The tenant database environment
      minAuditEntrysToKeep - minimum number of audit items an object item needs to have
      olderThan - Only return items with audit items older than this timestamp
      Returns:
      set of object itemIds to delete.
    • removeAuditItemsFor

      long removeAuditItemsFor(Environment env, Long objectItemId, Timestamp olderThan)
      Delete all audit items for the given object item id older than the timest
      Parameters:
      env - The tenant database environment
      objectItemId - the object item to delete audit entries for
      olderThan - Only delete items with audit items older than this timestamp
      Returns:
      number of items deleted.
    • getItemCountForAssociatedItem

      long getItemCountForAssociatedItem(TenantContext tenant, AssociatedItem.Type type, String associatedItemId)
    • getItemsForAssociatedItem

      List<LimitedAuditItemBean> getItemsForAssociatedItem(TenantContext tenant, AssociatedItem.Type type, String associatedItemId, long offset, long limit)
    • addGlobalMessageOnce

      boolean addGlobalMessageOnce(TenantContext context, long auditItemId, String messageKey)
      Adds a global message to the audit item specified (only if it doesn't exist already).

      The returns true only if this performed an audit log update.

      Parameters:
      context - the tenant database context
      auditItemId - the audit log entry to update
      Returns:
      true if an update was performed. false otherwise
    • getLastRuleExecution

      Optional<Instant> getLastRuleExecution(TenantContext context)
      Return the most recent rule execution on a tenant. Could be empty, if all audit items have expired.
      Parameters:
      context - the tenant database context
      Returns:
      Date of most recent rule execution.
    • fetchStaleAuditItemIds

      Set<Long> fetchStaleAuditItemIds(TenantContext context, long startTime, long endTime)
    • updateStaleAuditItemEntries

      void updateStaleAuditItemEntries(TenantContext context, Set<Long> staleAuditItemIds)