use of com.google.gerrit.server.group.InternalGroupDescription in project gerrit by GerritCodeReview.
the class AccountGroupUUIDHandler method parseArguments.
@Override
public final int parseArguments(Parameters params) throws CmdLineException {
final String n = params.getParameter(0);
AccountGroup.UUID uuid = AccountGroup.uuid(n);
if (groupBackend.handles(uuid)) {
GroupDescription.Basic d = groupBackend.get(uuid);
if (d != null) {
setter.addValue(uuid);
return 1;
}
}
// Might be a numeric AccountGroup.Id. -> Internal group.
if (n.matches("^[1-9][0-9]*$")) {
try {
AccountGroup.Id groupId = AccountGroup.Id.parse(n);
Optional<InternalGroup> groupInternal = groupCache.get(groupId);
if (groupInternal.isPresent()) {
uuid = new InternalGroupDescription(groupInternal.get()).getGroupUUID();
setter.addValue(uuid);
return 1;
}
} catch (IllegalArgumentException e) {
// Ignored
}
}
GroupReference group = GroupBackends.findExactSuggestion(groupBackend, n);
if (group == null) {
throw new CmdLineException(owner, localizable("Group \"%s\" does not exist"), n);
}
setter.addValue(group.getUUID());
return 1;
}
Aggregations