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


Java CurrentUser.getUserName方法代码示例

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


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

示例1: getGitHubExternalId

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
private ExternalId getGitHubExternalId(CurrentUser user) {
  Collection<ExternalId> accountExtIds =
      accountCache.get(((IdentifiedUser) user).getAccountId()).getExternalIds();
  Collection<ExternalId> gitHubExtId =
      Collections2.filter(
          accountExtIds,
          new Predicate<ExternalId>() {
            @Override
            public boolean apply(ExternalId externalId) {
              return externalId
                  .key()
                  .get()
                  .startsWith(IdentifiedUserGitHubLoginProvider.EXTERNAL_ID_PREFIX);
            }
          });

  if (gitHubExtId.isEmpty()) {
    throw new IllegalStateException(
        "Current Gerrit user " + user.getUserName() + " has no GitHub OAuth external ID");
  }
  return gitHubExtId.iterator().next();
}
 
开发者ID:GerritCodeReview,项目名称:plugins_github,代码行数:23,代码来源:GitHubOAuthFilter.java

示例2: updateProjectRef

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
public static void updateProjectRef(ObjectId treeId, ObjectInserter objectInserter, Repository repository, CurrentUser currentUser)
        throws IOException, NoFilepatternException, GitAPIException {
    // Create a branch
    Ref gerritCiRef = repository.getRef("refs/meta/gerrit-ci");
    CommitBuilder commitBuilder = new CommitBuilder();
    commitBuilder.setTreeId(treeId);
    logger.info("treeId: " + treeId);

    if (gerritCiRef != null) {
        ObjectId prevCommit = gerritCiRef.getObjectId();
        logger.info("prevCommit: " + prevCommit);
        commitBuilder.setParentId(prevCommit);
    }
    // build commit
    logger.info("Adding git tree : " + treeId);
    commitBuilder.setMessage("Modify project build rules.");
    final IdentifiedUser iUser = (IdentifiedUser) currentUser;
    PersonIdent user = new PersonIdent(currentUser.getUserName(), iUser.getEmailAddresses().iterator().next());
    commitBuilder.setAuthor(user);
    commitBuilder.setCommitter(user);
    ObjectId commitId = objectInserter.insert(commitBuilder);
    objectInserter.flush();
    logger.info(" Making new commit: " + commitId);
    RefUpdate newRef = repository.updateRef("refs/meta/gerrit-ci");
    newRef.setNewObjectId(commitId);
    newRef.update();
    repository.close();
}
 
开发者ID:palantir,项目名称:gerrit-ci,代码行数:29,代码来源:JobsServlet.java

示例3: getUsernames

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
private Iterable<String> getUsernames(CurrentUser user) {
  if (user.isIdentifiedUser()) {
    Set<String> emails = user.asIdentifiedUser().getEmailAddresses();
    if (user.getUserName() == null) {
      return emails;
    } else if (emails.isEmpty()) {
      return ImmutableSet.of(user.getUserName());
    }
    return Iterables.concat(emails, ImmutableSet.of(user.getUserName()));
  }
  if (user.getUserName() != null) {
    return ImmutableSet.of(user.getUserName());
  }
  return ImmutableSet.of();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:16,代码来源:RefPatternMatcher.java

示例4: ccCurrentUser

import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
Addition ccCurrentUser(CurrentUser user, RevisionResource revision) {
  return new Addition(
      user.getUserName(),
      revision.getChangeResource(),
      ImmutableSet.of(user.getAccountId()),
      null,
      CC,
      NotifyHandling.NONE,
      ImmutableListMultimap.of());
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:11,代码来源:PostReviewers.java


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