Class AuditLogFormatter
- java.lang.Object
-
- com.google.gerrit.server.group.db.AuditLogFormatter
-
public class AuditLogFormatter extends Object
A formatter for entities used in an audit log which is typically represented by NoteDb commits.The formatted representation of those entities must be parsable so that we can read them later on and map them back to their original entities.
AuditLogFormatter
andNoteDbUtil
contain some of those parsing/mapping methods.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AuditLogFormatter
create(Function<Account.Id,Optional<Account>> accountRetriever, Function<AccountGroup.UUID,Optional<GroupDescription.Basic>> groupRetriever, String serverId)
static AuditLogFormatter
createBackedBy(com.google.common.collect.ImmutableSet<Account> allAccounts, com.google.common.collect.ImmutableSet<GroupDescription.Basic> allGroups, String serverId)
static AuditLogFormatter
createBackedBy(AccountCache accountCache, GroupBackend groupBackend, String serverId)
static AuditLogFormatter
createPartiallyWorkingFallBack()
String
getParsableAccount(Account.Id accountId)
Provides a parsable representation of an account for use in e.g.org.eclipse.jgit.lib.PersonIdent
getParsableAuthorIdent(Account.Id accountId, org.eclipse.jgit.lib.PersonIdent personIdent)
Creates a parsablePersonIdent
for commits which are used as an audit log.org.eclipse.jgit.lib.PersonIdent
getParsableAuthorIdent(Account account, org.eclipse.jgit.lib.PersonIdent personIdent)
Creates a parsablePersonIdent
for commits which are used as an audit log.String
getParsableGroup(AccountGroup.UUID groupUuid)
Provides a parsable representation of a group for use in e.g.
-
-
-
Method Detail
-
createBackedBy
public static AuditLogFormatter createBackedBy(AccountCache accountCache, GroupBackend groupBackend, String serverId)
-
createBackedBy
public static AuditLogFormatter createBackedBy(com.google.common.collect.ImmutableSet<Account> allAccounts, com.google.common.collect.ImmutableSet<GroupDescription.Basic> allGroups, String serverId)
-
createPartiallyWorkingFallBack
public static AuditLogFormatter createPartiallyWorkingFallBack()
-
create
public static AuditLogFormatter create(Function<Account.Id,Optional<Account>> accountRetriever, Function<AccountGroup.UUID,Optional<GroupDescription.Basic>> groupRetriever, String serverId)
-
getParsableAuthorIdent
public org.eclipse.jgit.lib.PersonIdent getParsableAuthorIdent(Account account, org.eclipse.jgit.lib.PersonIdent personIdent)
Creates a parsablePersonIdent
for commits which are used as an audit log.Parsable means that we can unambiguously identify the original account when being presented with a
PersonIdent
of a commit.We typically use the initiator of an action as the author of the commit when using those commits as an audit log. That's something which has to be specified by a caller of this method as this class doesn't create any commits itself.
- Parameters:
account
- theAccount
of the user who should be representedpersonIdent
- aPersonIdent
which provides the timestamp for the createdPersonIdent
- Returns:
- a
PersonIdent
which can be used for the author of a commit
-
getParsableAuthorIdent
public org.eclipse.jgit.lib.PersonIdent getParsableAuthorIdent(Account.Id accountId, org.eclipse.jgit.lib.PersonIdent personIdent)
Creates a parsablePersonIdent
for commits which are used as an audit log.See
getParsableAuthorIdent(Account, PersonIdent)
for further details.- Parameters:
accountId
- the ID of the account of the user who should be representedpersonIdent
- aPersonIdent
which provides the timestamp for the createdPersonIdent
- Returns:
- a
PersonIdent
which can be used for the author of a commit
-
getParsableAccount
public String getParsableAccount(Account.Id accountId)
Provides a parsable representation of an account for use in e.g. commit messages.- Parameters:
accountId
- the ID of the account of the user who should be represented- Returns:
- the
String
representation of the account
-
getParsableGroup
public String getParsableGroup(AccountGroup.UUID groupUuid)
Provides a parsable representation of a group for use in e.g. commit messages.- Parameters:
groupUuid
- the UUID of the group- Returns:
- the
String
representation of the group
-
-