use of com.google.gerrit.server.group.db.GroupNameNotes in project gerrit by GerritCodeReview.
the class Schema_184 method upgrade.
@Override
public void upgrade(Arguments args, UpdateUI ui) throws Exception {
try (Repository allUsersRepo = args.repoManager.openRepository(args.allUsers)) {
AccountGroup.NameKey newName = AccountGroup.nameKey(ServiceUserClassifier.SERVICE_USERS);
Optional<GroupReference> nonInteractiveUsers = GroupNameNotes.loadAllGroups(allUsersRepo).stream().filter(g -> g.getName().equals("Non-Interactive Users")).findAny();
if (!nonInteractiveUsers.isPresent()) {
return;
}
GroupNameNotes newNameNotes = GroupNameNotes.forRename(args.allUsers, allUsersRepo, nonInteractiveUsers.get().getUUID(), AccountGroup.nameKey(nonInteractiveUsers.get().getName()), newName);
GroupConfig groupConfig = GroupConfig.loadForGroup(args.allUsers, allUsersRepo, nonInteractiveUsers.get().getUUID());
groupConfig.setGroupDelta(GroupDelta.builder().setName(newName).build(), AuditLogFormatter.createPartiallyWorkingFallBack());
commit(args.allUsers, args.serverUser, allUsersRepo, groupConfig, newNameNotes);
index(args.groupIndexCollection, groupConfig.getLoadedGroup().orElseThrow(() -> new IllegalStateException("Created group wasn't automatically loaded")));
}
}
use of com.google.gerrit.server.group.db.GroupNameNotes 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"));
}
Aggregations