Switch to UUID of groups for all public methods of GroupsUpdate

Change-Id: I9a4bb23b69bf50b19b30f29ddbf65e621e42968a
This commit is contained in:
Alice Kober-Sotzek
2017-07-28 11:27:25 +02:00
parent 6f2b3c95d6
commit 01154ca574
7 changed files with 36 additions and 54 deletions

View File

@@ -132,7 +132,7 @@ public class CreateAccount implements RestModifyView<TopLevelResource, AccountIn
"Username '" + username + "' must contain only letters, numbers, _, - or .");
}
Set<AccountGroup.Id> groups = parseGroups(input.groups);
Set<AccountGroup.UUID> groups = parseGroups(input.groups);
Account.Id id = new Account.Id(seq.nextAccountId());
@@ -185,8 +185,8 @@ public class CreateAccount implements RestModifyView<TopLevelResource, AccountIn
a.setPreferredEmail(input.email);
});
for (AccountGroup.Id groupId : groups) {
groupsUpdate.get().addGroupMember(db, groupId, id);
for (AccountGroup.UUID groupUuid : groups) {
groupsUpdate.get().addGroupMember(db, groupUuid, id);
}
if (input.sshKey != null) {
@@ -207,14 +207,15 @@ public class CreateAccount implements RestModifyView<TopLevelResource, AccountIn
return Response.created(info);
}
private Set<AccountGroup.Id> parseGroups(List<String> groups)
private Set<AccountGroup.UUID> parseGroups(List<String> groups)
throws UnprocessableEntityException {
Set<AccountGroup.Id> groupIds = new HashSet<>();
Set<AccountGroup.UUID> groupUuids = new HashSet<>();
if (groups != null) {
for (String g : groups) {
groupIds.add(GroupDescriptions.toAccountGroup(groupsCollection.parseInternal(g)).getId());
AccountGroup group = GroupDescriptions.toAccountGroup(groupsCollection.parseInternal(g));
groupUuids.add(group.getGroupUUID());
}
}
return groupIds;
return groupUuids;
}
}

View File

@@ -98,7 +98,7 @@ public class PutAgreement implements RestModifyView<AccountResource, AgreementIn
}
Account account = self.get().getAccount();
addMembers.addMembers(group.getId(), ImmutableList.of(account.getId()));
addMembers.addMembers(group.getGroupUUID(), ImmutableList.of(account.getId()));
agreementSignup.fire(account, agreementName);
return Response.ok(agreementName);