Package com.google.gerrit.reviewdb.client

Examples of com.google.gerrit.reviewdb.client.AccountGroup


  @Override
  public final int parseArguments(final Parameters params)
      throws CmdLineException {
    final String n = params.getParameter(0);
    final AccountGroup group = groupCache.get(new AccountGroup.NameKey(n));
    if (group == null) {
      throw new CmdLineException(owner, "Group \"" + n + "\" does not exist");
    }
    setter.addValue(group.getId());
    return 1;
  }
View Full Code Here


              who).toList());

      Set<AccountGroup.UUID> internalGroups = new HashSet<AccountGroup.UUID>();
      for (AccountGroupMember g : db.accountGroupMembers().byAccount(who)) {
        final AccountGroup.Id groupId = g.getAccountGroupId();
        final AccountGroup group = groupCache.get(groupId);
        if (group != null && group.getType() == AccountGroup.Type.INTERNAL) {
          internalGroups.add(group.getGroupUUID());
        }
      }

      internalGroups.add(AccountGroup.REGISTERED_USERS);
      internalGroups.add(AccountGroup.ANONYMOUS_USERS);
View Full Code Here

  public GroupDetail renameGroup(final AccountGroup.Id groupId,
      final String newName) throws OrmException, NameAlreadyUsedException,
      NoSuchGroupException {
    final GroupControl ctl = groupControlFactory.validateFor(groupId);
    final AccountGroup group = db.accountGroups().get(groupId);
    if (group == null || !ctl.isOwner()) {
      throw new NoSuchGroupException(groupId);
    }

    final AccountGroup.NameKey old = group.getNameKey();
    final AccountGroup.NameKey key = new AccountGroup.NameKey(newName);

    try {
      final AccountGroupName id = new AccountGroupName(key, groupId);
      db.accountGroupNames().insert(Collections.singleton(id));
    } catch (OrmDuplicateKeyException dupeErr) {
      // If we are using this identity, don't report the exception.
      //
      AccountGroupName other = db.accountGroupNames().get(key);
      if (other != null && other.getId().equals(groupId)) {
        return groupDetailFactory.create(groupId).call();
      }

      // Otherwise, someone else has this identity.
      //
      throw new NameAlreadyUsedException();
    }

    group.setNameKey(key);
    db.accountGroups().update(Collections.singleton(group));

    AccountGroupName priorName = db.accountGroupNames().get(old);
    if (priorName != null) {
      db.accountGroupNames().delete(Collections.singleton(priorName));
    }

    groupCache.evict(group);
    groupCache.evictAfterRename(old, key);
    renameGroupOpFactory.create( //
        currentUser.newCommitterIdent(new Date(), TimeZone.getDefault()), //
        group.getGroupUUID(), //
        old.get(), newName).start(0, TimeUnit.MILLISECONDS);

    return groupDetailFactory.create(groupId).call();
  }
View Full Code Here

    final ReviewerResult result = new ReviewerResult();
    for (final String reviewer : reviewers) {
      final Account account = accountResolver.find(reviewer);
      if (account == null) {
        AccountGroup group = groupCache.get(new AccountGroup.NameKey(reviewer));

        if (group == null) {
          result.addError(new ReviewerResult.Error(
              ReviewerResult.Error.Type.REVIEWER_NOT_FOUND, reviewer));
          continue;
        }

        if (!isLegalReviewerGroup(group.getGroupUUID())) {
          result.addError(new ReviewerResult.Error(
              ReviewerResult.Error.Type.GROUP_NOT_ALLOWED, reviewer));
          continue;
        }

        final Set<Account> members =
            groupMembersFactory.create().listAccounts(group.getGroupUUID(),
                control.getProject().getNameKey());
        if (members == null || members.size() == 0) {
          result.addError(new ReviewerResult.Error(
              ReviewerResult.Error.Type.GROUP_EMPTY, reviewer));
          continue;
View Full Code Here

          .getConfig()
          .getAccessSection(AccessSection.GLOBAL_CAPABILITIES)
          .getPermission(GlobalCapability.ADMINISTRATE_SERVER);

      final AccountGroup.UUID uuid = admin.getRules().get(0).getGroup().getUUID();
      final AccountGroup g = db.accountGroups().byUUID(uuid).iterator().next();
      final AccountGroup.Id adminId = g.getId();
      final AccountGroupMember m =
          new AccountGroupMember(new AccountGroupMember.Key(newId, adminId));
      db.accountGroupMembersAudit().insert(
          Collections.singleton(new AccountGroupMemberAudit(m, newId)));
      db.accountGroupMembers().insert(Collections.singleton(m));
View Full Code Here

        git.close();
      }
    }

    for (AccountGroup.UUID uuid : resolveToUpdate) {
      AccountGroup group = resolveGroups.get(uuid);
      group.setType(AccountGroup.Type.INTERNAL);
      toUpdate.add(group);

      ui.message(String.format(
          "*** Group has no DN and is inuse. Updated to be INTERNAL: %s",
          group.getName()));
    }

    for (AccountGroup.UUID uuid : toResolve) {
      AccountGroup group = resolveGroups.get(uuid);
      toDelete.add(group.getId());
      namesToDelete.add(group.getNameKey());
    }

    // Update group owners
    db.accountGroups().update(toUpdate);
    // Delete existing LDAP groups
View Full Code Here

        groupList = visibleGroups.get();
      }

      final ColumnFormatter formatter = new ColumnFormatter(stdout, '\t');
      for (final GroupDetail groupDetail : groupList.getGroups()) {
        final AccountGroup g = groupDetail.group;
        formatter.addColumn(g.getName());
        if (verboseOutput) {
          formatter.addColumn(KeyUtil.decode(g.getGroupUUID().toString()));
          formatter.addColumn(
              g.getDescription() != null ? g.getDescription() : "");
          formatter.addColumn(g.getType().toString());
          final AccountGroup owningGroup =
              groupCache.get(g.getOwnerGroupUUID());
          formatter.addColumn(
              owningGroup != null ? owningGroup.getName() : "n/a");
          formatter.addColumn(KeyUtil.decode(g.getOwnerGroupUUID().toString()));
          formatter.addColumn(Boolean.toString(g.isVisibleToAll()));
        }
        formatter.nextLine();
      }
View Full Code Here

TOP

Related Classes of com.google.gerrit.reviewdb.client.AccountGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.