public AvatarServiceHelper get() { return new AvatarServiceHelper(ComponentAccessor.getAvatarService()); } });
private static Map<String, String> getAvatarURLs(ApplicationUser user) { final AvatarService avatarService = ComponentAccessor.getAvatarService(); final Map<String, String> avatarUrls = new HashMap<String, String>(); for (Avatar.Size size : Avatar.Size.values()) { final int px = size.getPixels(); if (px > 48) continue; // TODO JRADEV-20790 - Don't output higher res URLs in our REST endpoints until we start using them ourselves. final String sizeName = String.format("%dx%d",px,px); // TODO this should be a URI reference and not an absolute URL avatarUrls.put(sizeName, avatarService.getAvatarAbsoluteURL(user, user, size).toString()); } return avatarUrls; }
/** * Returns the avatar URLs a user and a specific Avatar. * * @param avatarUser the user whose avatar this is (or null) * @param avatar the Avatar * @return avatar URLs mapped by size * @deprecated the notion of "all the avatar sizes" is broken. We plan to eventually scale to any reasonable pixel size. */ @Deprecated public static Map<String, URI> getAvatarURLs(ApplicationUser avatarUser, Avatar avatar) { final AvatarService avatarService = ComponentAccessor.getAvatarService(); final Map<String, URI> avatarUrls = new HashMap<String, URI>(); // TODO JRADEV-20790 - Don't output higher res URLs in our REST endpoints until we start using them ourselves. final Iterable<Avatar.Size> lowResAvatars = filter(allOf(Avatar.Size.class), Avatar.Size.LOW_RES); for (Avatar.Size size : lowResAvatars) { final String sizeName = getAuiSizeName(size); avatarUrls.put(sizeName, avatarService.getAvatarUrlNoPermCheck(avatarUser, avatar, size)); } return avatarUrls; }
public static Map<String, String> getAvatarUrls(final Project project) { AvatarService avatarService = ComponentAccessor.getAvatarService(); final Avatar avatar = project.getAvatar(); if (avatar == null) return null; final Map<String, String> avatarUrls = new HashMap<String, String>(); for (Avatar.Size size : Avatar.Size.values()) { final int px = size.getPixels(); final String sizeName = String.format("%dx%d",px,px); if (px > 48) continue; // TODO JRADEV-20790 - Don't output higher res URLs in our REST endpoints until we start using them ourselves. avatarUrls.put(sizeName, avatarService.getProjectAvatarAbsoluteURL(project, size).toString()); } return avatarUrls; }
/** * Returns the avatar URLs a user and a specific Avatar. * * @param avatarUser the user whose avatar this is (or null) * @param avatar the Avatar * @return avatar URLs mapped by size * @deprecated the notion of "all the avatar sizes" is broken. We plan to eventually scale to any reasonable pixel size. */ @Deprecated public static Map<String, URI> getAvatarURLs(ApplicationUser avatarUser, Avatar avatar) { final AvatarService avatarService = ComponentAccessor.getAvatarService(); final Map<String, URI> avatarUrls = new HashMap<String, URI>(); for (Avatar.Size size : Avatar.Size.values()) { final int px = size.getPixels(); if (px <= 48) // TODO JRADEV-20790 - Don't output higher res URLs in our REST endpoints until we start using them ourselves. { final String sizeName = String.format("%dx%d", px, px); avatarUrls.put(sizeName, avatarService.getAvatarUrlNoPermCheck(avatarUser, avatar, size)); } } return avatarUrls; } }
private void redirectToExternalAvatar(HttpServletResponse response, String ownerId, AvatarManager.ImageSize size) throws IOException { AvatarService avatarService = ComponentAccessor.getAvatarService(); if (!getAvatarManager().hasPermissionToView(getAuthenticationContext().getUser(), getUserUtil().getUserByKey(ownerId))) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } ApplicationUser loggedInUser = getAuthenticationContext().getUser(); URI gravatarURL = avatarService.getAvatarURL(loggedInUser, getUserUtil().getUserByKey(ownerId), size.getSize()); response.sendRedirect(gravatarURL.toString()); }
@Override protected void defaultDoGet(HttpServletRequest request, HttpServletResponse response, String ownerId, Long avatarId, AvatarManager.ImageSize size) throws IOException, ServletException { final AvatarService avatarService = ComponentAccessor.getAvatarService(); final ApplicationUser avatarUser = getUserUtil().getUserByName(ownerId); if (avatarUser != null && avatarService.isUsingExternalAvatar(getAuthenticationContext().getUser(), avatarUser)) { redirectToExternalAvatar(response, ownerId, size); return; } super.defaultDoGet(request, response, ownerId, avatarId, size); }
private void searchForUserNames( final Set<UserReference> userReferences, final int maxUsers, final Set<String> projectKeys) throws SearchException { final String name = "JiraInviteUserNameSetBuilder::searchForUserNames(SearchQuery, String, Calendar, String):Set<AbstractPage>"; UtilTimerStack.push(name); try { final AvatarService avatarService = ComponentAccessor.getAvatarService(); final Query query = buildIssuesQuery(projectKeys); final ApplicationUser currentApplicationUser = jiraAuthenticationContext.getUser(); final User currentUser = ApplicationUsers.toDirectoryUser(currentApplicationUser); final String currentUserNameToExclude = currentUser.getName(); final int startAt = 0; final int searchMaxLimit = IssueSearchLimits.DEFAULT_MAX_RESULTS; final PagerFilter pager = new PagerFilter(startAt, searchMaxLimit); final SearchResults searchResults = searchService.search(currentApplicationUser, query, pager); processSearchResults(currentApplicationUser, currentUserNameToExclude, avatarService, userReferences, maxUsers, searchResults, true, false); if (userReferences.size() < maxUsers) { processSearchResults(currentApplicationUser, currentUserNameToExclude, avatarService, userReferences, maxUsers, searchResults, false, true); } } finally { UtilTimerStack.pop(name); } }