in src/main/java/com/googlesource/gerrit/plugins/importer/ImportGroup.java [129:178]
private void validate(Input input, GroupInfo groupInfo)
throws IOException, OrmException, NoSuchAccountException, RestApiException,
ConfigInvalidException {
if (!isInternalGroup(new AccountGroup.UUID(groupInfo.id))) {
throw new MethodNotAllowedException(
String.format(
"Group with name %s is not an internal group and cannot be imported",
groupInfo.name));
}
if (getGroupByUUID(groupInfo.id) != null) {
throw new ResourceConflictException(
String.format("Group with UUID %s already exists", groupInfo.id));
}
if (!groupInfo.id.equals(groupInfo.ownerId))
if (!input.importOwnerGroup && getGroupByUUID(groupInfo.ownerId) == null) {
throw new PreconditionFailedException(
String.format(
"Owner group %s with UUID %s does not exist",
getGroupName(groupInfo.ownerId), groupInfo.ownerId));
}
if (groupInfo.members != null) {
for (AccountInfo member : groupInfo.members) {
try {
accountUtil.resolveUser(api, member);
} catch (NoSuchAccountException e) {
throw new PreconditionFailedException(e.getMessage());
}
}
}
if (!input.importIncludedGroups) {
if (groupInfo.includes != null) {
for (GroupInfo include : groupInfo.includes) {
if (getGroupByUUID(include.id) == null) {
throw new PreconditionFailedException(
String.format(
"Included group %s with UUID %s does not exist",
getGroupName(include.id), include.id));
}
}
}
}
for (GroupCreationValidationListener l : groupCreationValidationListeners) {
try {
l.validateNewGroup(toCreateGroupArgs(groupInfo));
} catch (ValidationException e) {
throw new ResourceConflictException(e.getMessage(), e);
}
}
}