当前位置: 首页>>代码示例>>Java>>正文


Java IdentifiedUser.getAccountId方法代码示例

本文整理汇总了Java中com.google.gerrit.server.IdentifiedUser.getAccountId方法的典型用法代码示例。如果您正苦于以下问题:Java IdentifiedUser.getAccountId方法的具体用法?Java IdentifiedUser.getAccountId怎么用?Java IdentifiedUser.getAccountId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gerrit.server.IdentifiedUser的用法示例。


在下文中一共展示了IdentifiedUser.getAccountId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import com.google.gerrit.server.IdentifiedUser; //导入方法依赖的package包/类
@Override
public List<GroupInfo> apply(AccountResource resource) throws OrmException {
  IdentifiedUser user = resource.getUser();
  Account.Id userId = user.getAccountId();
  List<GroupInfo> groups = new ArrayList<>();
  for (AccountGroup.UUID uuid : user.getEffectiveGroups().getKnownGroups()) {
    GroupControl ctl;
    try {
      ctl = groupControlFactory.controlFor(uuid);
    } catch (NoSuchGroupException e) {
      continue;
    }
    if (ctl.isVisible() && ctl.canSeeMember(userId)) {
      groups.add(json.format(ctl.getGroup()));
    }
  }
  return groups;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:19,代码来源:GetGroups.java

示例2: add

import com.google.gerrit.server.IdentifiedUser; //导入方法依赖的package包/类
private void add(PGPPublicKeyRing kr, IdentifiedUser user) throws Exception {
  Account.Id id = user.getAccountId();
  List<ExternalId> newExtIds = new ArrayList<>(2);
  newExtIds.add(ExternalId.create(toExtIdKey(kr.getPublicKey()), id));

  String userId = Iterators.getOnlyElement(kr.getPublicKey().getUserIDs(), null);
  if (userId != null) {
    String email = PushCertificateIdent.parse(userId).getEmailAddress();
    assertThat(email).contains("@");
    newExtIds.add(ExternalId.createEmail(id, email));
  }

  store.add(kr);
  PersonIdent ident = new PersonIdent("A U Thor", "[email protected]");
  CommitBuilder cb = new CommitBuilder();
  cb.setAuthor(ident);
  cb.setCommitter(ident);
  assertThat(store.save(cb)).isAnyOf(NEW, FAST_FORWARD, FORCED);

  externalIdsUpdateFactory.create().insert(newExtIds);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:22,代码来源:GerritPublicKeyCheckerTest.java

示例3: setAccountIdentity

import com.google.gerrit.server.IdentifiedUser; //导入方法依赖的package包/类
private void setAccountIdentity(IdentifiedUser user, HttpServletRequest req)
    throws ServletException, ConfigInvalidException {
  String fullName = req.getParameter("fullname");
  String email = req.getParameter("email");
  try {
    Id accountId = user.getAccountId();
    AuthResult result = accountManager.link(accountId, AuthRequest.forEmail(email));
    log.debug("Account {} linked to email {}: result = {}", accountId, email, result);

    putPreferred.apply(new AccountResource.Email(user, email), null);
    PutName.Input nameInput = new PutName.Input();
    nameInput.name = fullName;
    putName.apply(user, nameInput);
    log.debug(
        "Account {} updated with preferredEmail = {} and fullName = {}",
        accountId,
        email,
        fullName);

    accountCache.evict(accountId);
    log.debug("Account cache evicted for {}", accountId);
  } catch (Exception e) {
    throw new ServletException(
        "Cannot associate email '" + email + "' to current user '" + user + "'", e);
  }
}
 
开发者ID:GerritCodeReview,项目名称:plugins_github,代码行数:27,代码来源:AccountController.java

示例4: newComment

import com.google.gerrit.server.IdentifiedUser; //导入方法依赖的package包/类
protected Comment newComment(
    PatchSet.Id psId,
    String filename,
    String UUID,
    CommentRange range,
    int line,
    IdentifiedUser commenter,
    String parentUUID,
    Timestamp t,
    String message,
    short side,
    String commitSHA1,
    boolean unresolved) {
  Comment c =
      new Comment(
          new Comment.Key(UUID, filename, psId.get()),
          commenter.getAccountId(),
          t,
          side,
          message,
          serverId,
          unresolved);
  c.lineNbr = line;
  c.parentUuid = parentUUID;
  c.revId = commitSHA1;
  c.setRange(range);
  return c;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:29,代码来源:AbstractChangeNotesTest.java

示例5: update

import com.google.gerrit.server.IdentifiedUser; //导入方法依赖的package包/类
private void update(AuthRequest who, ExternalId extId)
    throws OrmException, IOException, ConfigInvalidException {
  IdentifiedUser user = userFactory.create(extId.accountId());
  List<Consumer<Account>> accountUpdates = new ArrayList<>();

  // If the email address was modified by the authentication provider,
  // update our records to match the changed email.
  //
  String newEmail = who.getEmailAddress();
  String oldEmail = extId.email();
  if (newEmail != null && !newEmail.equals(oldEmail)) {
    if (oldEmail != null && oldEmail.equals(user.getAccount().getPreferredEmail())) {
      accountUpdates.add(a -> a.setPreferredEmail(newEmail));
    }

    externalIdsUpdateFactory
        .create()
        .replace(
            extId, ExternalId.create(extId.key(), extId.accountId(), newEmail, extId.password()));
  }

  if (!realm.allowsEdit(AccountFieldName.FULL_NAME)
      && !Strings.isNullOrEmpty(who.getDisplayName())
      && !eq(user.getAccount().getFullName(), who.getDisplayName())) {
    accountUpdates.add(a -> a.setFullName(who.getDisplayName()));
  }

  if (!realm.allowsEdit(AccountFieldName.USER_NAME)
      && who.getUserName() != null
      && !eq(user.getUserName(), who.getUserName())) {
    log.warn(
        String.format(
            "Not changing already set username %s to %s", user.getUserName(), who.getUserName()));
  }

  if (!accountUpdates.isEmpty()) {
    Account account = accountsUpdateFactory.create().update(user.getAccountId(), accountUpdates);
    if (account == null) {
      throw new OrmException("Account " + user.getAccountId() + " has been deleted");
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:43,代码来源:AccountManager.java


注:本文中的com.google.gerrit.server.IdentifiedUser.getAccountId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。