Search in sources :

Example 6 with InternalGroupDescription

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;
}
Also used : GroupDescription(com.google.gerrit.entities.GroupDescription) InternalGroupDescription(com.google.gerrit.server.group.InternalGroupDescription) InternalGroupDescription(com.google.gerrit.server.group.InternalGroupDescription) AccountGroup(com.google.gerrit.entities.AccountGroup) GroupReference(com.google.gerrit.entities.GroupReference) CmdLineException(org.kohsuke.args4j.CmdLineException) InternalGroup(com.google.gerrit.entities.InternalGroup)

Aggregations

InternalGroupDescription (com.google.gerrit.server.group.InternalGroupDescription)6 AccountGroup (com.google.gerrit.entities.AccountGroup)4 InternalGroup (com.google.gerrit.entities.InternalGroup)3 Account (com.google.gerrit.entities.Account)2 GroupDescription (com.google.gerrit.entities.GroupDescription)2 GroupInfo (com.google.gerrit.extensions.common.GroupInfo)2 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)2 ArrayList (java.util.ArrayList)2 Streams (com.google.common.collect.Streams)1 AccountGroupByIdAudit (com.google.gerrit.entities.AccountGroupByIdAudit)1 AccountGroupMemberAudit (com.google.gerrit.entities.AccountGroupMemberAudit)1 GroupReference (com.google.gerrit.entities.GroupReference)1 GroupInput (com.google.gerrit.extensions.api.groups.GroupInput)1 AccountInfo (com.google.gerrit.extensions.common.AccountInfo)1 GroupAuditEventInfo (com.google.gerrit.extensions.common.GroupAuditEventInfo)1 AuthException (com.google.gerrit.extensions.restapi.AuthException)1 IdString (com.google.gerrit.extensions.restapi.IdString)1 MethodNotAllowedException (com.google.gerrit.extensions.restapi.MethodNotAllowedException)1 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)1 UnprocessableEntityException (com.google.gerrit.extensions.restapi.UnprocessableEntityException)1