Interface AuditItemStore
- All Known Implementing Classes:
JiraAuditItemStore
public interface AuditItemStore
-
Method Summary
Modifier and TypeMethodDescriptionlongaddEntry(TenantContext context, AuditItem item) Stores an audit item for the given tenant.longaddEntry(TenantContext context, AuditItem auditItem, 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).voidSometimes 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.fetchStaleAuditItemIds(TenantContext context, long startTime, long endTime) getItem(TenantContext context, AuditItemFilter filter, long auditItemId) 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.getLastRuleExecution(TenantContext context) Return the most recent rule execution on a tenant.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 timestamplongremoveAuditItemsFor(Environment env, Long objectItemId, Timestamp olderThan) Delete all audit items for the given object item id older than the timestvoidupdateEntry(TenantContext context, long ruleId, AuditItem updates) voidupdateStaleAuditItemEntries(TenantContext context, Set<Long> staleAuditItemIds)
-
Method Details
-
addEntry
Stores an audit item for the given tenant.- Parameters:
context- the tenant database contextitem- 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
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 contextfilter- filter to constrict querylimit- 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 contextfilter- filter to constrict queryoffset- The page offset to start retrieving items fromlimit- the maximum number of items to return- Returns:
- Items object containing all matching audit items
-
getItem
-
updateEntry
-
getObjectItemIdsToDelete
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 environmentminAuditEntrysToKeep- minimum number of audit items an object item needs to haveolderThan- Only return items with audit items older than this timestamp- Returns:
- set of object itemIds to delete.
-
removeAuditItemsFor
Delete all audit items for the given object item id older than the timest- Parameters:
env- The tenant database environmentobjectItemId- the object item to delete audit entries forolderThan- 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
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
-
getLastRuleExecution
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
-
updateStaleAuditItemEntries
-