Replace use of AccountGroup by an interface for various classes
Previously, GroupDescription.Internal served only as a marker for internal groups and simply delegated to AccountGroup. By converting GroupDescription.Internal to a real interface, we gain a lot of flexibility. For instance, we are free to use another class to represent internal groups (which will be necessary for the migration of groups to NoteDb). Change-Id: If7397898d8508184a2ccdc7c371ed60ada7d6f3e
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
|
||||
package com.google.gerrit.server.group;
|
||||
|
||||
import com.google.gerrit.common.data.GroupDescriptions;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.Response;
|
||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||
@@ -44,14 +43,15 @@ public class Index implements RestModifyView<GroupResource, Input> {
|
||||
throw new AuthException("not allowed to index group");
|
||||
}
|
||||
|
||||
AccountGroup group = GroupDescriptions.toAccountGroup(rsrc.getGroup());
|
||||
if (group == null) {
|
||||
AccountGroup.UUID groupUuid = rsrc.getGroup().getGroupUUID();
|
||||
if (!rsrc.isInternalGroup()) {
|
||||
throw new UnprocessableEntityException(
|
||||
String.format("External Group Not Allowed: %s", rsrc.getGroupUUID().get()));
|
||||
String.format("External Group Not Allowed: %s", groupUuid.get()));
|
||||
}
|
||||
|
||||
AccountGroup accountGroup = groupCache.get(groupUuid);
|
||||
// evicting the group from the cache, reindexes the group
|
||||
groupCache.evict(group);
|
||||
groupCache.evict(accountGroup);
|
||||
return Response.none();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user