Search in sources :

Example 1 with AuditLogFormatter

use of com.google.gerrit.server.group.db.AuditLogFormatter in project gerrit by GerritCodeReview.

the class SchemaCreatorImpl method createGroupInNoteDb.

private InternalGroup createGroupInNoteDb(Repository allUsersRepo, InternalGroupCreation groupCreation, GroupDelta groupDelta) throws ConfigInvalidException, IOException, DuplicateKeyException {
    // This method is only executed on a new server which doesn't have any accounts or groups.
    AuditLogFormatter auditLogFormatter = AuditLogFormatter.createBackedBy(ImmutableSet.of(), ImmutableSet.of(), serverId);
    GroupConfig groupConfig = GroupConfig.createForNewGroup(allUsersName, allUsersRepo, groupCreation);
    groupConfig.setGroupDelta(groupDelta, auditLogFormatter);
    AccountGroup.NameKey groupName = groupDelta.getName().orElseGet(groupCreation::getNameKey);
    GroupNameNotes groupNameNotes = GroupNameNotes.forNewGroup(allUsersName, allUsersRepo, groupCreation.getGroupUUID(), groupName);
    commit(allUsersRepo, groupConfig, groupNameNotes);
    return groupConfig.getLoadedGroup().orElseThrow(() -> new IllegalStateException("Created group wasn't automatically loaded"));
}
Also used : GroupNameNotes(com.google.gerrit.server.group.db.GroupNameNotes) GroupConfig(com.google.gerrit.server.group.db.GroupConfig) AccountGroup(com.google.gerrit.entities.AccountGroup) AuditLogFormatter(com.google.gerrit.server.group.db.AuditLogFormatter)

Example 2 with AuditLogFormatter

use of com.google.gerrit.server.group.db.AuditLogFormatter in project gerrit by GerritCodeReview.

the class GroupsOnInit method addGroupMemberInNoteDb.

private void addGroupMemberInNoteDb(Repository repository, AccountGroup.UUID groupUuid, Account account) throws IOException, ConfigInvalidException, NoSuchGroupException {
    GroupConfig groupConfig = GroupConfig.loadForGroup(allUsers, repository, groupUuid);
    InternalGroup group = groupConfig.getLoadedGroup().orElseThrow(() -> new NoSuchGroupException(groupUuid));
    GroupDelta groupDelta = getMemberAdditionDelta(account);
    AuditLogFormatter auditLogFormatter = getAuditLogFormatter(account);
    groupConfig.setGroupDelta(groupDelta, auditLogFormatter);
    commit(repository, groupConfig, group.getCreatedOn());
}
Also used : GroupConfig(com.google.gerrit.server.group.db.GroupConfig) GroupDelta(com.google.gerrit.server.group.db.GroupDelta) AuditLogFormatter(com.google.gerrit.server.group.db.AuditLogFormatter) NoSuchGroupException(com.google.gerrit.exceptions.NoSuchGroupException) InternalGroup(com.google.gerrit.entities.InternalGroup)

Aggregations

AuditLogFormatter (com.google.gerrit.server.group.db.AuditLogFormatter)2 GroupConfig (com.google.gerrit.server.group.db.GroupConfig)2 AccountGroup (com.google.gerrit.entities.AccountGroup)1 InternalGroup (com.google.gerrit.entities.InternalGroup)1 NoSuchGroupException (com.google.gerrit.exceptions.NoSuchGroupException)1 GroupDelta (com.google.gerrit.server.group.db.GroupDelta)1 GroupNameNotes (com.google.gerrit.server.group.db.GroupNameNotes)1