private static Map<String, Size> createParamToSizeMap() { final ImmutableMap.Builder<String, Size> paramToSize = ImmutableMap.builder(); for( Size size : Size.values()) { paramToSize.put(size.getParam(), size); } return paramToSize.build(); }
static List<Size> inPixelOrder() { if (null != orderedSizes) return orderedSizes; List<Size> orderedSizes = Arrays.asList(Size.values()); Collections.sort(orderedSizes, new Comparator<Size>() { @Override public int compare(final Size o1, final Size o2) { if (o1.getPixels() == o2.getPixels()) return 0; return (o1.getPixels() < o2.getPixels()) ? -1 : 1; } }); return orderedSizes; }
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; }
try for (Avatar.Size size : Avatar.Size.values())
/** * 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; } }
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; }