本文整理汇总了Java中com.google.gerrit.server.CurrentUser.isIdentifiedUser方法的典型用法代码示例。如果您正苦于以下问题:Java CurrentUser.isIdentifiedUser方法的具体用法?Java CurrentUser.isIdentifiedUser怎么用?Java CurrentUser.isIdentifiedUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gerrit.server.CurrentUser
的用法示例。
在下文中一共展示了CurrentUser.isIdentifiedUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateName
import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
private String generateName(HttpServletRequest req) {
String userName = "";
CurrentUser who = user.get();
if (who.isIdentifiedUser()) {
String name = who.asIdentifiedUser().getUserName();
if (name != null && !name.isEmpty()) {
userName = " (" + name + ")";
}
}
String uri = req.getServletPath();
Matcher m = URI_PATTERN.matcher(uri);
if (m.matches()) {
String path = m.group(1);
String cmd = m.group(2);
return cmd + " " + path + userName;
}
return req.getMethod() + " " + uri + userName;
}
示例2: abandon
import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
public Change abandon(
BatchUpdate.Factory updateFactory,
ChangeNotes notes,
CurrentUser user,
String msgTxt,
NotifyHandling notifyHandling,
ListMultimap<RecipientType, Account.Id> accountsToNotify)
throws RestApiException, UpdateException {
Account account = user.isIdentifiedUser() ? user.asIdentifiedUser().getAccount() : null;
AbandonOp op = abandonOpFactory.create(account, msgTxt, notifyHandling, accountsToNotify);
try (BatchUpdate u =
updateFactory.create(dbProvider.get(), notes.getProjectName(), user, TimeUtil.nowTs())) {
u.addOp(notes.getChangeId(), op).execute();
}
return op.getChange();
}
示例3: match
import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
@Override
public boolean match(String ref, CurrentUser user) {
if (!ref.startsWith(prefix)) {
return false;
}
for (String username : getUsernames(user)) {
String u;
if (isRE(template.getPattern())) {
u = Pattern.quote(username);
} else {
u = username;
}
Account.Id accountId = user.isIdentifiedUser() ? user.getAccountId() : null;
RefPatternMatcher next = getMatcher(expand(template, u, accountId));
if (next != null && next.match(expand(ref, u, accountId), user)) {
return true;
}
}
return false;
}
示例4: byChange
import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
/**
* Retrieve edit for a change and the given user.
*
* <p>At most one change edit can exist per user and change.
*
* @param notes change notes of change to retrieve change edits for.
* @param user user to retrieve edits as.
* @return edit for this change for this user, if present.
* @throws AuthException if this is not a logged-in user.
* @throws IOException if an error occurs.
*/
public Optional<ChangeEdit> byChange(ChangeNotes notes, CurrentUser user)
throws AuthException, IOException {
if (!user.isIdentifiedUser()) {
throw new AuthException("Authentication required");
}
IdentifiedUser u = user.asIdentifiedUser();
Change change = notes.getChange();
try (Repository repo = gitManager.openRepository(change.getProject())) {
int n = change.currentPatchSetId().get();
String[] refNames = new String[n];
for (int i = n; i > 0; i--) {
refNames[i - 1] =
RefNames.refsEdit(u.getAccountId(), change.getId(), new PatchSet.Id(change.getId(), i));
}
Ref ref = repo.getRefDatabase().firstExactRef(refNames);
if (ref == null) {
return Optional.empty();
}
try (RevWalk rw = new RevWalk(repo)) {
RevCommit commit = rw.parseCommit(ref.getObjectId());
PatchSet basePs = getBasePatchSet(notes, ref);
return Optional.of(new ChangeEdit(change, ref.getName(), commit, basePs));
}
}
}
示例5: initVelocityModel
import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
private PluginVelocityModel initVelocityModel(HttpServletRequest request) throws IOException {
PluginVelocityModel model = modelProvider.get();
GitHubLogin gitHubLogin = loginProvider.get(request);
model.put("myself", gitHubLogin.getMyself());
model.put("config", config);
CurrentUser user = userProvider.get();
if (user.isIdentifiedUser()) {
model.put("user", user);
model.put("hub", gitHubLogin.getHub());
model.put("scopeCookie", gitHubLogin.getScopesKeyFromCookie(request));
}
for (Entry<String, String[]> reqPar : request.getParameterMap().entrySet()) {
model.put(reqPar.getKey(), reqPar.getValue());
}
return model;
}
示例6: parse
import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
@Override
public GroupResource parse(TopLevelResource parent, IdString id)
throws AuthException, ResourceNotFoundException {
final CurrentUser user = self.get();
if (user instanceof AnonymousUser) {
throw new AuthException("Authentication required");
} else if (!(user.isIdentifiedUser())) {
throw new ResourceNotFoundException(id);
}
GroupDescription.Basic group = parseId(id.get());
if (group == null) {
throw new ResourceNotFoundException(id.get());
}
GroupControl ctl = groupControlFactory.controlFor(group);
if (!ctl.isVisible()) {
throw new ResourceNotFoundException(id);
}
return new GroupResource(ctl);
}
示例7: toActionMap
import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
private Map<String, ActionInfo> toActionMap(
ChangeNotes notes, List<ActionVisitor> visitors, ChangeInfo changeInfo) {
CurrentUser user = userProvider.get();
Map<String, ActionInfo> out = new LinkedHashMap<>();
if (!user.isIdentifiedUser()) {
return out;
}
Iterable<UiAction.Description> descs =
uiActions.from(changeViews, changeResourceFactory.create(notes, user));
// The followup action is a client-side only operation that does not
// have a server side handler. It must be manually registered into the
// resulting action map.
Status status = notes.getChange().getStatus();
if (status.isOpen() || status.equals(Status.MERGED)) {
UiAction.Description descr = new UiAction.Description();
PrivateInternals_UiActionDescription.setId(descr, "followup");
PrivateInternals_UiActionDescription.setMethod(descr, "POST");
descr.setTitle("Create follow-up change");
descr.setLabel("Follow-Up");
descs = Iterables.concat(descs, Collections.singleton(descr));
}
ACTION:
for (UiAction.Description d : descs) {
ActionInfo actionInfo = new ActionInfo(d);
for (ActionVisitor visitor : visitors) {
if (!visitor.visit(d.getId(), actionInfo, changeInfo)) {
continue ACTION;
}
}
out.put(d.getId(), actionInfo);
}
return out;
}
示例8: getUser
import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
@Override
public CurrentUser getUser() {
CurrentUser user = session.getUser();
if (user != null && user.isIdentifiedUser()) {
IdentifiedUser identifiedUser = userFactory.create(user.getAccountId());
identifiedUser.setAccessPath(user.getAccessPath());
return identifiedUser;
}
return user;
}
示例9: doFilter
import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
@Override
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
throws IOException, ServletException {
CurrentUser user = userProvider.get();
if (user != null && user.isIdentifiedUser()) {
IdentifiedUser who = user.asIdentifiedUser();
if (who.getUserName() != null && !who.getUserName().isEmpty()) {
req.setAttribute(REQ_ATTR_KEY, who.getUserName());
} else {
req.setAttribute(REQ_ATTR_KEY, "a/" + who.getAccountId());
}
}
chain.doFilter(req, resp);
}
示例10: checkUserSession
import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
private void checkUserSession(HttpServletRequest req) throws AuthException {
CurrentUser user = globals.currentUser.get();
if (isRead(req)) {
user.setAccessPath(AccessPath.REST_API);
} else if (user instanceof AnonymousUser) {
throw new AuthException("Authentication required");
} else if (!globals.webSession.get().isAccessPathOk(AccessPath.REST_API)) {
throw new AuthException(
"Invalid authentication method. In order to authenticate, "
+ "prefix the REST endpoint URL with /a/ (e.g. http://example.com/a/projects/).");
}
if (user.isIdentifiedUser()) {
user.setLastLoginExternalIdKey(globals.webSession.get().getLastLoginExternalId());
}
}
示例11: describe
import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
public static String describe(CurrentUser user) {
if (user.isIdentifiedUser()) {
return user.getAccountId().toString();
}
if (user instanceof SingleGroupUser) {
return "group:" + user.getEffectiveGroups().getKnownGroups().iterator().next().toString();
}
return user.toString();
}
示例12: canRemoveReviewerWithoutPermissionCheck
import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
private boolean canRemoveReviewerWithoutPermissionCheck(
Change change, CurrentUser currentUser, Account.Id reviewer, int value)
throws NoSuchProjectException, IOException {
if (!change.getStatus().isOpen()) {
return false;
}
if (currentUser.isIdentifiedUser()) {
Account.Id aId = currentUser.getAccountId();
if (aId.equals(reviewer)) {
return true; // A user can always remove themselves.
} else if (aId.equals(change.getOwner()) && 0 <= value) {
return true; // The change owner may remove any zero or positive score.
}
}
// Users with the remove reviewer permission, the branch owner, project
// owner and site admin can remove anyone
// TODO(hiesel): Remove all Control usage
ProjectControl ctl = projectControlFactory.controlFor(change.getProject(), currentUser);
if (ctl.controlForRef(change.getDest()).isOwner() // branch owner
|| ctl.isOwner() // project owner
|| ctl.isAdmin()) { // project admin
return true;
}
return false;
}
示例13: 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();
}
示例14: getIdentifiedUser
import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
IdentifiedUser getIdentifiedUser() throws QueryParseException {
try {
CurrentUser u = getUser();
if (u.isIdentifiedUser()) {
return u.asIdentifiedUser();
}
throw new QueryParseException(NotSignedInException.MESSAGE);
} catch (ProvisionException e) {
throw new QueryParseException(NotSignedInException.MESSAGE, e);
}
}
示例15: getWatches
import com.google.gerrit.server.CurrentUser; //导入方法依赖的package包/类
protected static Collection<ProjectWatchKey> getWatches(ChangeQueryBuilder.Arguments args)
throws QueryParseException {
CurrentUser user = args.getUser();
if (user.isIdentifiedUser()) {
return args.accountCache.get(args.getUser().getAccountId()).getProjectWatches().keySet();
}
return Collections.<ProjectWatchKey>emptySet();
}