Package com.atlassian.bamboo.persister
Class DefaultAuditLogService
- java.lang.Object
-
- com.atlassian.bamboo.persister.DefaultAuditLogService
-
- All Implemented Interfaces:
AuditLogService
public class DefaultAuditLogService extends Object implements AuditLogService
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.atlassian.bamboo.persister.AuditLogService
AuditLogService.FieldChange
-
-
Constructor Summary
Constructors Constructor Description DefaultAuditLogService(AuditLogDao auditLogDao, BambooAuthenticationContext authenticationContext, AdministrationConfigurationAccessor administrationConfigurationAccessor, AdministrationConfigurationPersister administrationConfigurationPersister)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
countAuditLogMessagesForEntity(@NotNull String entityId, @Nullable AuditLogEntityType entityType, long startDate, long endDate, @Nullable String searchTerm)
Count audit log messages for entity in a given time period and with the requested searchTermlong
countAuditLogMessagesForEntity(@NotNull String entityId, AuditLogEntityType entityType, long startDate, long endDate)
Count audit log messages for entity in a given time periodlong
countAuditLogMessagesForPlan(@NotNull ImmutablePlan plan)
Count audit log messages for planlong
countAuditLogMessagesForPlan(@NotNull ImmutablePlan plan, long startDate, long endDate)
Count audit log messages for plan in a given time periodlong
countAuditLogMessagesForPlan(@NotNull ImmutablePlan plan, long startDate, long endDate, @Nullable String searchTerm)
Count audit log messages for plan in a given time period and with the requested searchTermlong
countGlobalAuditLogMessages()
Count global audit log messages.long
countGlobalAuditLogMessages(@Nullable String searchTerm)
Count global audit log messages.List<AuditLogEntry>
getAgentAuditLogsMessagesByAgentName(String agentName)
Provide a list of audit log messages filter by Agent NameList<AuditLogEntry>
getAgentAuditLogsMessagesByAgentName(String agentName, @Nullable String searchTerm)
Provide a list of audit log messages filter by Agent Name and the Search Term.List<AuditLogEntry>
getAuditLogMessagesForEntity(@NotNull String entityId, @Nullable AuditLogEntityType entityType, long startDate, long endDate, int firstResult, int maxResults, @Nullable String searchTerm)
Provide a paginated list of all audit log messages written against an entity between input dates and requested search term.List<AuditLogEntry>
getAuditLogMessagesForEntity(@NotNull String entityId, AuditLogEntityType entityType, long startDate, long endDate, int firstResult, int maxResults)
Provide a paginated list of all audit log messages written against an entity between input dates.List<AuditLogEntry>
getAuditLogMessagesForPlan(@NotNull ImmutablePlan plan, long startDate, long endDate, int firstResult, int maxResults)
Provide a paginated list of all audit log messages written against a plan between input dates.List<AuditLogEntry>
getAuditLogMessagesForPlan(@NotNull ImmutablePlan plan, long startDate, long endDate, int firstResult, int maxResults, @Nullable String searchTerm)
Provide a paginated list of all audit log messages written against a plan between input dates and requested search term.List<AuditLogEntry>
getGlobalAuditLogMessages()
Provide a list of all audit log messages written against the system.List<AuditLogEntry>
getGlobalAuditLogMessages(int firstResult, int maxResults)
Provide a page of a list of all audit log messages written against the system.List<AuditLogEntry>
getGlobalAuditLogMessages(int firstResult, int maxResults, @Nullable String searchTerm)
Provide a page of a list of all audit log messages written against the system filtered by delivered searchTerm.boolean
hasAuditLogMessagesForPlan(@NotNull ImmutablePlan plan, long startDate, long endDate)
Determine whether any log messages have been recorded against the specified plan between the startDate and endDate (inclusive).boolean
isEnabled()
Returns whether logging is enabledboolean
isRssUpdatedLog()
void
log(@NotNull AuditLogEntry msg)
Add a log to the audit log.void
log(@NotNull Iterable<AuditLogService.FieldChange> changes, @Nullable AuditLogEntity entity)
Add 'field change' messages to the system audit log.void
log(@NotNull Iterable<AuditLogService.FieldChange> changes, @Nullable String entityId, @Nullable AuditLogEntityType entityType, @Nullable String childKey, @Nullable AuditLogEntity entity)
void
log(@NotNull String msg)
Add a message to the system audit log.void
log(@NotNull String msg, @Nullable Key key, AuditLogEntityType entityType)
Add a message to the plans audit log.void
log(@NotNull String msg, @Nullable Key key, AuditLogEntityType entityType, @Nullable AuditLogEntity entity)
Add a message to the entity's audit log.void
log(@NotNull String fieldName, @Nullable String oldValue, @Nullable String newValue, @Nullable Key plan)
Add 'field change' message to the system audit log.void
log(@NotNull String fieldName, @Nullable String oldValue, @Nullable String newValue, @Nullable Key key, @Nullable AuditLogEntityType entityType, @Nullable AuditLogEntity entity)
Add 'field change' message to the system audit log.void
log(@NotNull Collection<AuditLogService.FieldChange> changes, @Nullable Key key)
Add 'field change' messages to the system audit log.void
log(@Nullable com.atlassian.user.User user, @NotNull String msg)
Add a message to the system audit log.void
log(@Nullable com.atlassian.user.User user, @NotNull String msg, @Nullable Key key, AuditLogEntityType entityType)
Add a message to the entity's audit log.void
log(@Nullable com.atlassian.user.User user, @NotNull String msg, @Nullable Key key, AuditLogEntityType entityType, @Nullable AuditLogEntity entity)
Add a message to the plans audit log.void
log(@Nullable String username, @NotNull String msg, @Nullable Key key, @Nullable AuditLogEntityType entityType, @Nullable AuditLogEntity field)
void
log(@Nullable String username, @NotNull String msg, @Nullable Key key, AuditLogEntityType entityType)
void
removeAllAuditLogMessages()
Deletes all log messages in the databasevoid
removeAuditLogMessagesByTypeAndEntityId(@NotNull String entityId, @Nullable AuditLogEntityType entityType)
void
removeAuditLogMessagesForPlan(@NotNull ImmutablePlan plan)
Deletes all log messages for a given planvoid
removeGlobalAuditLogMessages()
Deletes all Global audit log messagesvoid
setEnabled(boolean enabled)
sets whether logging is enabled or notvoid
setRssUpdatedLog(Boolean isRss)
sets whether logging is for RSS update.
-
-
-
Constructor Detail
-
DefaultAuditLogService
public DefaultAuditLogService(AuditLogDao auditLogDao, BambooAuthenticationContext authenticationContext, AdministrationConfigurationAccessor administrationConfigurationAccessor, AdministrationConfigurationPersister administrationConfigurationPersister)
-
-
Method Detail
-
log
public void log(@NotNull @NotNull AuditLogEntry msg)
Description copied from interface:AuditLogService
Add a log to the audit log.- Specified by:
log
in interfaceAuditLogService
- Parameters:
msg
- (fully populated) to be logged
-
log
public void log(@NotNull @NotNull String msg)
Description copied from interface:AuditLogService
Add a message to the system audit log. Message will be logged against the user that is currently set in the authentication context.- Specified by:
log
in interfaceAuditLogService
- Parameters:
msg
- the text of the message to add.
-
log
public void log(@Nullable @Nullable com.atlassian.user.User user, @NotNull @NotNull String msg)
Description copied from interface:AuditLogService
Add a message to the system audit log. Message will be logged against the current logged in user (if available)- Specified by:
log
in interfaceAuditLogService
- Parameters:
user
- who caused the event being loggedmsg
- the text of the message to add.
-
log
public void log(@NotNull @NotNull String msg, @Nullable @Nullable Key key, AuditLogEntityType entityType)
Description copied from interface:AuditLogService
Add a message to the plans audit log. Message will be logged against the current logged in user (if available)- Specified by:
log
in interfaceAuditLogService
- Parameters:
msg
- to logkey
- to log it against
-
log
public void log(@NotNull @NotNull String msg, @Nullable @Nullable Key key, AuditLogEntityType entityType, @Nullable @Nullable AuditLogEntity entity)
Description copied from interface:AuditLogService
Add a message to the entity's audit log. Message will be logged against the current logged in user (if available)- Specified by:
log
in interfaceAuditLogService
- Parameters:
msg
- to logkey
- to log it againstentity
- job's task, chain' stage etc. to log against
-
log
public void log(@Nullable @Nullable com.atlassian.user.User user, @NotNull @NotNull String msg, @Nullable @Nullable Key key, AuditLogEntityType entityType)
Description copied from interface:AuditLogService
Add a message to the entity's audit log. Message will be logged against provided user- Specified by:
log
in interfaceAuditLogService
- Parameters:
user
- who caused the event being loggedmsg
- to be loggedkey
- to log the message against.
-
log
public void log(@Nullable @Nullable com.atlassian.user.User user, @NotNull @NotNull String msg, @Nullable @Nullable Key key, AuditLogEntityType entityType, @Nullable @Nullable AuditLogEntity entity)
Description copied from interface:AuditLogService
Add a message to the plans audit log. Message will be logged against provided user- Specified by:
log
in interfaceAuditLogService
- Parameters:
user
- who caused the event being loggedmsg
- to be loggedkey
- to log the message against.entity
- header of job's task, chain' stage etc. to log against
-
log
public void log(@Nullable @Nullable String username, @NotNull @NotNull String msg, @Nullable @Nullable Key key, AuditLogEntityType entityType)
-
log
public void log(@Nullable @Nullable String username, @NotNull @NotNull String msg, @Nullable @Nullable Key key, @Nullable @Nullable AuditLogEntityType entityType, @Nullable @Nullable AuditLogEntity field)
-
getAuditLogMessagesForPlan
public List<AuditLogEntry> getAuditLogMessagesForPlan(@NotNull @NotNull ImmutablePlan plan, long startDate, long endDate, int firstResult, int maxResults)
Description copied from interface:AuditLogService
Provide a paginated list of all audit log messages written against a plan between input dates.- Specified by:
getAuditLogMessagesForPlan
in interfaceAuditLogService
- Parameters:
plan
- to find audit messages forstartDate
- if specified, messages before this date will be excluded. Represented as milliseconds after January 1, 1970 00:00:00 GMT. Passing 0 or a negative number will not set a start range.endDate
- if specified, messages after this date will be excluded. Represented as milliseconds after January 1, 1970 00:00:00 GMT. Passing 0 or a negative number will not set an end range.firstResult
- if specified marks a first item to be returned, passing 0 or negative number will effect with returning elements from the beginningmaxResults
- if specified marks a total number of items to be returned, passing 0 or negative number will effect with returning all elements until the end- Returns:
- List of audit log entries for the given plan
-
getAuditLogMessagesForPlan
public List<AuditLogEntry> getAuditLogMessagesForPlan(@NotNull @NotNull ImmutablePlan plan, long startDate, long endDate, int firstResult, int maxResults, @Nullable @Nullable String searchTerm)
Description copied from interface:AuditLogService
Provide a paginated list of all audit log messages written against a plan between input dates and requested search term.- Specified by:
getAuditLogMessagesForPlan
in interfaceAuditLogService
- Parameters:
plan
- to find audit messages forstartDate
- if specified, messages before this date will be excluded. Represented as milliseconds after January 1, 1970 00:00:00 GMT. Passing 0 or a negative number will not set a start range.endDate
- if specified, messages after this date will be excluded. Represented as milliseconds after January 1, 1970 00:00:00 GMT. Passing 0 or a negative number will not set an end range.firstResult
- if specified marks a first item to be returned, passing 0 or negative number will effect with returning elements from the beginningmaxResults
- if specified marks a total number of items to be returned, passing 0 or negative number will effect with returning all elements until the endsearchTerm
- value against which the results are filtered out- Returns:
- List of audit log entries for the given plan
-
getAuditLogMessagesForEntity
public List<AuditLogEntry> getAuditLogMessagesForEntity(@NotNull @NotNull String entityId, AuditLogEntityType entityType, long startDate, long endDate, int firstResult, int maxResults)
Description copied from interface:AuditLogService
Provide a paginated list of all audit log messages written against an entity between input dates.- Specified by:
getAuditLogMessagesForEntity
in interfaceAuditLogService
- Parameters:
entityId
- to find audit messages forentityType
- type of entity associated with the entityIdstartDate
- if specified, messages before this date will be excluded. Represented as milliseconds after January 1, 1970 00:00:00 GMT. Passing 0 or a negative number will not set a start range.endDate
- if specified, messages after this date will be excluded. Represented as milliseconds after January 1, 1970 00:00:00 GMT. Passing 0 or a negative number will not set an end range.firstResult
- if specified marks a first item to be returned, passing 0 or negative number will effect with returning elements from the beginningmaxResults
- if specified marks a total number of items to be returned, passing 0 or negative number will effect with returning all elements until the end- Returns:
- List of audit log entries for the given entity
-
getAuditLogMessagesForEntity
public List<AuditLogEntry> getAuditLogMessagesForEntity(@NotNull @NotNull String entityId, @Nullable @Nullable AuditLogEntityType entityType, long startDate, long endDate, int firstResult, int maxResults, @Nullable @Nullable String searchTerm)
Description copied from interface:AuditLogService
Provide a paginated list of all audit log messages written against an entity between input dates and requested search term.- Specified by:
getAuditLogMessagesForEntity
in interfaceAuditLogService
- Parameters:
entityId
- to find audit messages forentityType
- type of entity associated with the entityIdstartDate
- if specified, messages before this date will be excluded. Represented as milliseconds after January 1, 1970 00:00:00 GMT. Passing 0 or a negative number will not set a start range.endDate
- if specified, messages after this date will be excluded. Represented as milliseconds after January 1, 1970 00:00:00 GMT. Passing 0 or a negative number will not set an end range.firstResult
- if specified marks a first item to be returned, passing 0 or negative number will effect with returning elements from the beginningmaxResults
- if specified marks a total number of items to be returned, passing 0 or negative number will effect with returning all elements until the endsearchTerm
- value against which the results are filtered out- Returns:
- List of audit log entries for the given entity
-
hasAuditLogMessagesForPlan
public boolean hasAuditLogMessagesForPlan(@NotNull @NotNull ImmutablePlan plan, long startDate, long endDate)
Description copied from interface:AuditLogService
Determine whether any log messages have been recorded against the specified plan between the startDate and endDate (inclusive). This is equivalent to but usually faster than checking the emptiness ofAuditLogService.getAuditLogMessagesForPlan(ImmutablePlan, long, long, int, int)
.- Specified by:
hasAuditLogMessagesForPlan
in interfaceAuditLogService
startDate
- if specified, messages before this date will be excluded. Represented as milliseconds after January 1, 1970 00:00:00 GMT. Passing 0 or a negative number will not set a start range.endDate
- if specified, messages after this date will be excluded. Represented as milliseconds after January 1, 1970 00:00:00 GMT. Passing 0 or a negative number will not set an end range.
-
removeAuditLogMessagesForPlan
public void removeAuditLogMessagesForPlan(@NotNull @NotNull ImmutablePlan plan)
Description copied from interface:AuditLogService
Deletes all log messages for a given plan- Specified by:
removeAuditLogMessagesForPlan
in interfaceAuditLogService
- Parameters:
plan
- to delete messages for
-
removeAuditLogMessagesByTypeAndEntityId
public void removeAuditLogMessagesByTypeAndEntityId(@NotNull @NotNull String entityId, @Nullable @Nullable AuditLogEntityType entityType)
- Specified by:
removeAuditLogMessagesByTypeAndEntityId
in interfaceAuditLogService
-
removeGlobalAuditLogMessages
public void removeGlobalAuditLogMessages()
Description copied from interface:AuditLogService
Deletes all Global audit log messages- Specified by:
removeGlobalAuditLogMessages
in interfaceAuditLogService
-
removeAllAuditLogMessages
public void removeAllAuditLogMessages()
Description copied from interface:AuditLogService
Deletes all log messages in the database- Specified by:
removeAllAuditLogMessages
in interfaceAuditLogService
-
getGlobalAuditLogMessages
public List<AuditLogEntry> getGlobalAuditLogMessages()
Description copied from interface:AuditLogService
Provide a list of all audit log messages written against the system.- Specified by:
getGlobalAuditLogMessages
in interfaceAuditLogService
- Returns:
- a list of audit log entries for the system
-
getGlobalAuditLogMessages
public List<AuditLogEntry> getGlobalAuditLogMessages(int firstResult, int maxResults)
Description copied from interface:AuditLogService
Provide a page of a list of all audit log messages written against the system.- Specified by:
getGlobalAuditLogMessages
in interfaceAuditLogService
- Returns:
- a list of audit log entries for the system
-
getGlobalAuditLogMessages
public List<AuditLogEntry> getGlobalAuditLogMessages(int firstResult, int maxResults, @Nullable @Nullable String searchTerm)
Description copied from interface:AuditLogService
Provide a page of a list of all audit log messages written against the system filtered by delivered searchTerm.- Specified by:
getGlobalAuditLogMessages
in interfaceAuditLogService
searchTerm
- the phrase against which the search will be made- Returns:
- a list of audit log entries for the system
-
countGlobalAuditLogMessages
public long countGlobalAuditLogMessages()
Description copied from interface:AuditLogService
Count global audit log messages.- Specified by:
countGlobalAuditLogMessages
in interfaceAuditLogService
- Returns:
- number of potential results
-
countGlobalAuditLogMessages
public long countGlobalAuditLogMessages(@Nullable @Nullable String searchTerm)
Description copied from interface:AuditLogService
Count global audit log messages.- Specified by:
countGlobalAuditLogMessages
in interfaceAuditLogService
- Parameters:
searchTerm
- the phrase against which the results will be counted- Returns:
- number of potential results
-
countAuditLogMessagesForPlan
public long countAuditLogMessagesForPlan(@NotNull @NotNull ImmutablePlan plan)
Description copied from interface:AuditLogService
Count audit log messages for plan- Specified by:
countAuditLogMessagesForPlan
in interfaceAuditLogService
-
countAuditLogMessagesForPlan
public long countAuditLogMessagesForPlan(@NotNull @NotNull ImmutablePlan plan, long startDate, long endDate)
Description copied from interface:AuditLogService
Count audit log messages for plan in a given time period- Specified by:
countAuditLogMessagesForPlan
in interfaceAuditLogService
-
countAuditLogMessagesForPlan
public long countAuditLogMessagesForPlan(@NotNull @NotNull ImmutablePlan plan, long startDate, long endDate, @Nullable @Nullable String searchTerm)
Description copied from interface:AuditLogService
Count audit log messages for plan in a given time period and with the requested searchTerm- Specified by:
countAuditLogMessagesForPlan
in interfaceAuditLogService
-
countAuditLogMessagesForEntity
public long countAuditLogMessagesForEntity(@NotNull @NotNull String entityId, AuditLogEntityType entityType, long startDate, long endDate)
Description copied from interface:AuditLogService
Count audit log messages for entity in a given time period- Specified by:
countAuditLogMessagesForEntity
in interfaceAuditLogService
-
countAuditLogMessagesForEntity
public long countAuditLogMessagesForEntity(@NotNull @NotNull String entityId, @Nullable @Nullable AuditLogEntityType entityType, long startDate, long endDate, @Nullable @Nullable String searchTerm)
Description copied from interface:AuditLogService
Count audit log messages for entity in a given time period and with the requested searchTerm- Specified by:
countAuditLogMessagesForEntity
in interfaceAuditLogService
-
log
public void log(@NotNull @NotNull Collection<AuditLogService.FieldChange> changes, @Nullable @Nullable Key key)
Description copied from interface:AuditLogService
Add 'field change' messages to the system audit log. The messages will be logged against the user that is currently set in the authentication context. If key is not null the message will be logged against the given entity.- Specified by:
log
in interfaceAuditLogService
-
log
public void log(@NotNull @NotNull Iterable<AuditLogService.FieldChange> changes, @Nullable @Nullable String entityId, @Nullable @Nullable AuditLogEntityType entityType, @Nullable @Nullable String childKey, @Nullable @Nullable AuditLogEntity entity)
- Specified by:
log
in interfaceAuditLogService
-
log
public void log(@NotNull @NotNull Iterable<AuditLogService.FieldChange> changes, @Nullable @Nullable AuditLogEntity entity)
Description copied from interface:AuditLogService
Add 'field change' messages to the system audit log. The messages will be logged against the user that is currently set in the authentication context. The message will be logged with the given entity type.- Specified by:
log
in interfaceAuditLogService
-
log
public void log(@NotNull @NotNull String fieldName, @Nullable @Nullable String oldValue, @Nullable @Nullable String newValue, @Nullable @Nullable Key plan)
Description copied from interface:AuditLogService
Add 'field change' message to the system audit log. The messages will be logged against the user that is currently set in the authentication context. If plan key is not null the message will be logged against the given plan.- Specified by:
log
in interfaceAuditLogService
-
log
public void log(@NotNull @NotNull String fieldName, @Nullable @Nullable String oldValue, @Nullable @Nullable String newValue, @Nullable @Nullable Key key, @Nullable @Nullable AuditLogEntityType entityType, @Nullable @Nullable AuditLogEntity entity)
Description copied from interface:AuditLogService
Add 'field change' message to the system audit log. The messages will be logged against the user that is currently set in the authentication context. If plan key is not null the message will be logged against the given plan.- Specified by:
log
in interfaceAuditLogService
entity
- job's task or chain's stage affected by the change
-
isEnabled
public boolean isEnabled()
Description copied from interface:AuditLogService
Returns whether logging is enabled- Specified by:
isEnabled
in interfaceAuditLogService
-
setEnabled
public void setEnabled(boolean enabled)
Description copied from interface:AuditLogService
sets whether logging is enabled or not- Specified by:
setEnabled
in interfaceAuditLogService
-
getAgentAuditLogsMessagesByAgentName
public List<AuditLogEntry> getAgentAuditLogsMessagesByAgentName(String agentName)
Description copied from interface:AuditLogService
Provide a list of audit log messages filter by Agent Name- Specified by:
getAgentAuditLogsMessagesByAgentName
in interfaceAuditLogService
- Parameters:
agentName
- the name of the agent- Returns:
- List of audit log entries for the given Agent Name
-
getAgentAuditLogsMessagesByAgentName
public List<AuditLogEntry> getAgentAuditLogsMessagesByAgentName(String agentName, @Nullable @Nullable String searchTerm)
Description copied from interface:AuditLogService
Provide a list of audit log messages filter by Agent Name and the Search Term.- Specified by:
getAgentAuditLogsMessagesByAgentName
in interfaceAuditLogService
- Parameters:
agentName
- the name of the agentsearchTerm
- the value searched in the Agent related audit log- Returns:
- List of audit log entries for the given Agent Name and Search Term.
-
isRssUpdatedLog
public boolean isRssUpdatedLog()
- Specified by:
isRssUpdatedLog
in interfaceAuditLogService
- Returns:
- whether logging is for RSS update.
-
setRssUpdatedLog
public void setRssUpdatedLog(Boolean isRss)
Description copied from interface:AuditLogService
sets whether logging is for RSS update.- Specified by:
setRssUpdatedLog
in interfaceAuditLogService
-
-