Package com.google.gerrit.reviewdb.client

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


  @SuppressWarnings("unchecked")
  private void add(Watchers matching, NotifyConfig nc, Project.NameKey project)
      throws OrmException, QueryParseException {
    for (GroupReference ref : nc.getGroups()) {
      AccountGroup group =
          GroupDescriptions.toAccountGroup(args.groupBackend.get(ref.getUUID()));
      if (group == null) {
        log.warn(String.format(
            "Project %s has invalid group %s in notify section %s",
            project.get(), ref.getName(), nc.getName()));
        continue;
      }

      if (group.getType() != AccountGroup.Type.INTERNAL) {
        log.warn(String.format(
            "Project %s cannot use group %s of type %s in notify section %s",
            project.get(), ref.getName(), group.getType(), nc.getName()));
        continue;
      }

      ChangeQueryBuilder qb = args.queryBuilder.create(new SingleGroupUser(
          args.capabilityControlFactory,
View Full Code Here


      populate(row, detail);
    }
  }

  void populate(final int row, final GroupDetail detail) {
    AccountGroup k = detail.group;
    if (enableLink) {
      table.setWidget(row, 1, new Hyperlink(k.getName(),
          Dispatcher.toGroup(k.getId())));
    } else {
      table.setText(row, 1, k.getName());
    }
    table.setText(row, 2, k.getDescription());
    table.setText(row, 3, detail.ownerGroup.getName());
    table.setText(row, 4, k.getType().toString());
    if (k.isVisibleToAll()) {
      table.setWidget(row, 5, new Image(Gerrit.RESOURCES.greenCheck()));
    }

    final FlexCellFormatter fmt = table.getFlexCellFormatter();
    fmt.addStyleName(row, 1, Gerrit.RESOURCES.css().groupName());
View Full Code Here

        });
  }

  @Override
  protected void display(final GroupDetail groupDetail) {
    final AccountGroup group = groupDetail.group;
    groupUUIDLabel.setText(group.getGroupUUID().get());
    groupNameTxt.setText(group.getName());
    if (groupDetail.ownerGroup != null) {
      ownerTxt.setText(groupDetail.ownerGroup.getName());
    } else {
      ownerTxt.setText(Util.M.deletedReference(group.getOwnerGroupUUID().get()));
    }
    descTxt.setText(group.getDescription());

    visibleToAllCheckBox.setValue(group.isVisibleToAll());

    setType(group.getType());

    enableForm(groupDetail.canModify);
    saveName.setVisible(groupDetail.canModify);
    saveOwner.setVisible(groupDetail.canModify);
    saveDesc.setVisible(groupDetail.canModify);
View Full Code Here

    }

    // Update the ownerGroupUUID.
    List<AccountGroup> toUpdate = Lists.newArrayListWithCapacity(idMap.size());
    for (Entry<AccountGroup.Id, AccountGroup.Id> entry : idMap.entrySet()) {
      AccountGroup group = groups.get(entry.getKey());
      AccountGroup owner = groups.get(entry.getValue());
      group.setOwnerGroupUUID(owner.getGroupUUID());
      toUpdate.add(group);
    }

    db.accountGroups().update(toUpdate);
  }
View Full Code Here

        commit.setCommitter(new PersonIdent(serverUser, new Date(minTime)));
        commit.setMessage("Add the ContributorAgreements for upgrade to Gerrit Code Review schema 65\n");
        batch.write(commit);

        for (AccountGroupAgreement aga : groupAgreements) {
          AccountGroup group = db.accountGroups().get(aga.groupId);
          if (group == null) {
            continue;
          }

          ContributorAgreement agreement = agreements.get(aga.claId);
          agreement.getAccepted().add(new PermissionRule(config.resolve(group)));
          base.replace(agreement);

          PersonIdent ident = null;
          if (aga.reviewedBy != null) {
            Account ua = db.accounts().get(aga.reviewedBy);
            if (ua != null) {
              String name = ua.getFullName();
              String email = ua.getPreferredEmail();

              if (email == null || email.isEmpty()) {
                // No preferred email is configured. Use a generic identity so we
                // don't leak an address the user may have given us, but doesn't
                // necessarily want to publish through Git records.
                //
                String user = ua.getUserName();
                if (user == null || user.isEmpty()) {
                  user = "account-" + ua.getId().toString();
                }

                String host = SystemReader.getInstance().getHostname();
                email = user + "@" + host;
              }

              if (name == null || name.isEmpty()) {
                final int at = email.indexOf('@');
                if (0 < at) {
                  name = email.substring(0, at);
                } else {
                  name = anonymousCowardName;
                }
              }

              ident = new PersonIdent(name, email, new Date(aga.getTime()), TimeZone.getDefault());
            }
          }
          if (ident == null) {
            ident = new PersonIdent(serverUser, new Date(aga.getTime()));
          }

          // Build the commits such that it keeps track of the date added and
          // who added it.
          commit = new CommitBuilder();
          commit.setAuthor(ident);
          commit.setCommitter(new PersonIdent(serverUser, new Date(aga.getTime())));

          String msg = String.format("Accept %s contributor agreement for %s\n",
              agreement.getName(), group.getName());
          if (!Strings.isNullOrEmpty(aga.reviewComments)) {
            msg += "\n" + aga.reviewComments + "\n";
          }
          commit.setMessage(msg);
          batch.write(commit);
View Full Code Here

          throws OrmException {
    final AccountGroup.Id groupId =
        new AccountGroup.Id(db.nextAccountGroupId());
    final AccountGroup.NameKey nameKey = new AccountGroup.NameKey(groupName);
    final AccountGroup.UUID uuid = GroupUUID.make(groupName, serverUser);
    final AccountGroup group = new AccountGroup(nameKey, groupId, uuid);
    group.setOwnerGroupUUID(adminGroupUUID);
    group.setDescription(description);
    final AccountGroupName gn = new AccountGroupName(group);
    // first insert the group name to validate that the group name hasn't
    // already been used to create another group
    db.accountGroupNames().insert(Collections.singleton(gn));
    db.accountGroups().insert(Collections.singleton(group));
View Full Code Here

    }

    String name = "CLA Accepted - " + agreement.getName();
    AccountGroupName agn =
        db.accountGroupNames().get(new AccountGroup.NameKey(name));
    AccountGroup ag;
    if (agn != null) {
      ag = db.accountGroups().get(agn.getId());
      if (ag == null) {
        throw new IllegalStateException(
            "account group name exists but account group does not: " + name);
      }

      if (!adminGroupUUIDs.contains(ag.getOwnerGroupUUID())) {
        throw new IllegalStateException(
            "individual group exists with non admin owner group: " + name);
      }
    } else {
      ag = createGroup(db, name, adminGroupUUIDs.get(0),
View Full Code Here

    final Set<AccountGroup> groups =
        new TreeSet<AccountGroup>(new GroupComparator());
    for (final ProjectControl projectControl : projects) {
      final Set<GroupReference> groupsRefs = projectControl.getAllGroups();
      for (final GroupReference groupRef : groupsRefs) {
        final AccountGroup group = groupCache.get(groupRef.getUUID());
        if (group == null) {
          throw new NoSuchGroupException(groupRef.getUUID());
        }
        groups.add(group);
      }
View Full Code Here

      final Set<AccountGroup.UUID> effective =
          user.getEffectiveGroups().getKnownGroups();
      final Set<AccountGroup> groups =
          new TreeSet<AccountGroup>(new GroupComparator());
      for (final AccountGroup.UUID groupId : effective) {
        AccountGroup group = groupCache.get(groupId);
        if (group != null) {
          groups.add(group);
        }
      }
      return createGroupList(filterGroups(groups));
View Full Code Here

  private AccountGroup newGroup(ReviewDb c, String name, AccountGroup.UUID uuid)
      throws OrmException {
    if (uuid == null) {
      uuid = GroupUUID.make(name, serverUser);
    }
    return new AccountGroup( //
        new AccountGroup.NameKey(name), //
        new AccountGroup.Id(c.nextAccountGroupId()), //
        uuid);
  }
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.