本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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());
}