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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionlongaddEntry(TenantContext context, AuditItemBean item) Stores an audit item for the given tenant.longaddEntry(TenantContext context, AuditItemBean item, AutomationEvent automationEvent, com.codebarrel.automation.api.config.RuleConfigBean ruleConfigBean) Stores an audit item for the given tenant.booleanaddGlobalMessageOnce(TenantContext context, long auditItemId, String messageKey) Adds a global message to the audit item specified (only if it doesn't exist already).fetchAggregatedEventSourceCounts(AuditItemFilter filter, int limit) Fetches the aggregated event source counts for the given filter.fetchStaleAuditItemIds(TenantContext context, long startTime, long endTime) Fetches the audit item IDs that are considered stale.intgetItem(TenantContext tenantContext, AuditItemFilter filter, long auditId) Tries to lookup full item details including all component changes, associated items and item changes.longgetItemCountForAssociatedItem(TenantContext tenant, AssociatedItem.Type type, String associatedItemId) getItems(TenantContext context, AuditItemFilter filter, long offset, long limit) Retrieves all audit items for the tenant context in the project specified.getItemsForAssociatedItem(TenantContext tenant, AssociatedItem.Type type, String associatedItemId, long offset, long limit) getItemsWithDetails(TenantContext context, AuditItemFilter filter, long limit) Retrieves all audit items for the tenant context for the specified filter.getLastAuditItem(TenantContext context, long ruleId) Looks up the last audit log item for the given rule.getObjectItemIdsToDelete(Environment env, long minAuditEntrysToKeep, Timestamp olderThan) Retrieves object item ids with audit items marked for deletion.longremoveAuditItemsFor(Environment env, Long objectItemId, Timestamp olderThan) Removes all audit items for the given object item older than the timestamp provided.voidupdateEntry(TenantContext context, long ruleId, AuditItemBean complete) Updates an existing audit item with new associated items and item changes.voidupdateStaleAuditItemEntries(TenantContext context, Set<Long> staleAuditItemIds) Updates the audit item entries that are considered stale
-
Field Details
-
DEFAULT_NUM_ITEMS_PER_PAGE
static final long DEFAULT_NUM_ITEMS_PER_PAGE- See Also:
-
-
Method Details
-
addEntry
Stores an audit item for the given tenant.The AuditItemBean must contain an
ObjectItemwhich is the rule that executed. It can also contain a list ofAssociatedItems (the things affected by the automation rule) andItemChanges. (the actual changes carried out by the automation rule actions.- Parameters:
context- the tenant database contextitem- 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
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 contextfilter- filter to constrict querylimit- the maximum number of records to be returned from database- Returns:
- Items object containing all matching audit items
-
getItems
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 contextoffset- the audit item created offset to retrieve items fromlimit- the maximum number of items to return- Returns:
- Items object containing all matching audit items
-
updateEntry
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 contextruleId- the rule id that just executedcomplete- the completed audit item to update
-
getItem
Tries to lookup full item details including all component changes, associated items and item changes.- Parameters:
tenantContext- the tenant database contextauditId- the id of the audit item- Returns:
- empty if can't be found
-
getLastAuditItem
Looks up the last audit log item for the given rule.- Parameters:
context- the tenant database contextruleId- id of teh rule- Returns:
- empty if it can't find one
-
getAuditLogRetentionPeriodDays
- Parameters:
env- The database environment to retrieve items from- Returns:
- Number of days to keep audit logs for. -1 indicates keeping them forever
-
getObjectItemIdsToDelete
Retrieves object item ids with audit items marked for deletion.- Parameters:
env- The database environment to retrieve items fromminAuditEntrysToKeep- 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
Removes all audit items for the given object item older than the timestamp provided.- Parameters:
env- The database environment to retrieve items fromobjectItemId- the object item id to delete audit logs forolderThan- 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
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 contextauditItemId- the audit log entry to update- Returns:
- true if an update was performed. false otherwise
-
fetchStaleAuditItemIds
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 contextstartTime- the start time for the time rangeendTime- the end time for the time range- Returns:
- the set of stale audit item IDs
-
updateStaleAuditItemEntries
Updates the audit item entries that are considered stale- Parameters:
context- the tenant database contextstaleAuditItemIds- the set of stale audit item IDs
-
fetchAggregatedEventSourceCounts
Fetches the aggregated event source counts for the given filter.- Parameters:
filter- the filter to applylimit- the maximum number of records to return- Returns:
- the aggregated event source counts
-