Interface AuditService

All Known Implementing Classes:
AuditServiceImpl

public interface AuditService
Stores and retrieves audit entries for Automation rule execution. Note that this service only deals with rule execution. Rule config changes are stored in Jira's main audit log.
  • Field Details

    • DEFAULT_NUM_ITEMS_PER_PAGE

      static final long DEFAULT_NUM_ITEMS_PER_PAGE
      See Also:
  • Method Details

    • addEntry

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

      The AuditItemBean must contain an ObjectItem which is the rule that executed. It can also contain a list of AssociatedItems (the things affected by the automation rule) and ItemChanges. (the actual changes carried out by the automation rule actions.

      Parameters:
      context - the tenant database context
      item - the actual audit item to store
    • addEntry

      long addEntry(TenantContext context, AuditItemBean item, AutomationEvent automationEvent, com.codebarrel.automation.api.config.RuleConfigBean ruleConfigBean)
      Stores an audit item for the given tenant. automationEvent and ruleConfig bean are used in the case of a rule execution. automationEvent is used to store extra meta data about the item. ruleConfig determines what counts are incremented
    • getItemsWithDetails

      Items 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:
      Items object containing all matching audit items
    • getItems

      Items 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
      offset - the audit item created offset to retrieve items from
      limit - the maximum number of items to return
      Returns:
      Items object containing all matching audit items
    • updateEntry

      void updateEntry(TenantContext context, long ruleId, AuditItemBean complete)
      Updates an existing audit item with new associated items and item changes. This method also updates end of execution time
      Parameters:
      context - the tenant database context
      ruleId - the rule id that just executed
      complete - the completed audit item to update
    • getItem

      Optional<AuditItemBean> getItem(TenantContext tenantContext, AuditItemFilter filter, long auditId)
      Tries to lookup full item details including all component changes, associated items and item changes.
      Parameters:
      tenantContext - the tenant database context
      auditId - the id of the audit item
      Returns:
      empty if can't be found
    • getLastAuditItem

      Optional<AuditItemBean> getLastAuditItem(TenantContext context, long ruleId)
      Looks up the last audit log item for the given rule.
      Parameters:
      context - the tenant database context
      ruleId - id of teh rule
      Returns:
      empty if it can't find one
    • getAuditLogRetentionPeriodDays

      int getAuditLogRetentionPeriodDays(Environment env)
      Parameters:
      env - The database environment to retrieve items from
      Returns:
      Number of days to keep audit logs for. -1 indicates keeping them forever
    • getObjectItemIdsToDelete

      Set<Long> getObjectItemIdsToDelete(Environment env, long minAuditEntrysToKeep, Timestamp olderThan)
      Retrieves object item ids with audit items marked for deletion.
      Parameters:
      env - The database environment to retrieve items from
      minAuditEntrysToKeep - object item ids with less than this number will not be deleted.
      olderThan - Only object items with audit ids older than this timestamp will be considered for deletion.
      Returns:
      object item ids with audit items marked for deletion.
    • removeAuditItemsFor

      long removeAuditItemsFor(Environment env, Long objectItemId, Timestamp olderThan)
      Removes all audit items for the given object item older than the timestamp provided.
      Parameters:
      env - The database environment to retrieve items from
      objectItemId - the object item id to delete audit logs for
      olderThan - Only object items with audit ids older than this timestamp will be deleted
      Returns:
      number audit 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
    • fetchStaleAuditItemIds

      Set<Long> fetchStaleAuditItemIds(TenantContext context, long startTime, long endTime)
      Fetches the audit item IDs that are considered stale. This method identifies audit item entries that have been into in progress status within the specified time range.
      Parameters:
      context - the tenant database context
      startTime - the start time for the time range
      endTime - the end time for the time range
      Returns:
      the set of stale audit item IDs
    • updateStaleAuditItemEntries

      void updateStaleAuditItemEntries(TenantContext context, Set<Long> staleAuditItemIds)
      Updates the audit item entries that are considered stale
      Parameters:
      context - the tenant database context
      staleAuditItemIds - the set of stale audit item IDs
    • fetchAggregatedEventSourceCounts

      AuditItemEventSourceResult fetchAggregatedEventSourceCounts(AuditItemFilter filter, int limit)
      Fetches the aggregated event source counts for the given filter.
      Parameters:
      filter - the filter to apply
      limit - the maximum number of records to return
      Returns:
      the aggregated event source counts