Package jenkins.scm.api.metadata
Class AvatarMetadataAction
java.lang.Object
hudson.model.InvisibleAction
jenkins.scm.api.metadata.AvatarMetadataAction
- All Implemented Interfaces:
Action,ModelObject,Serializable
@ExportedBean
public abstract class AvatarMetadataAction
extends InvisibleAction
implements Serializable
Holds metadata about an avatar to be associated with a
SCMSource or SCMNavigator (also valid for
SCMRevision and SCMHead, but would be considered unusual).
For example:
- A
SCMNavigatorimplementation that corresponds to a GitHub Team could use thegetAvatarImageOf(String)to return the GitHub Team logo
- Since:
- 2.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final StringavatarIconClassNameImageOf(String iconClassName, String size) Helper method to resolve the icon image url.protected final StringcachedResizedImageOf(String url, String size) Helper method to resolve an external image, cache it and resize it to the specified size.abstract booleanReturns the description to use for the tool tip of the avatar of this object.Returns theIconclass specification for the avatar of this objectgetAvatarImageOf(String size) Returns the URL of the avatar of this object in the requested size ornullif there is no avatar for this object.abstract inthashCode()Methods inherited from class hudson.model.InvisibleAction
getDisplayName, getIconFileName, getUrlName
-
Constructor Details
-
AvatarMetadataAction
public AvatarMetadataAction()
-
-
Method Details
-
getAvatarIconClassName
Returns theIconclass specification for the avatar of this object- Returns:
- the
Iconclass specification ornullto checkgetAvatarImageOf(String). - Throws:
IllegalStateException- if called outside of a request handling thread.- See Also:
-
getAvatarDescription
Returns the description to use for the tool tip of the avatar of this object.- Returns:
- the avatar description or
null - Throws:
IllegalStateException- if called outside of a request handling thread.
-
getAvatarImageOf
Returns the URL of the avatar of this object in the requested size ornullif there is no avatar for this object. Ideally onlygetAvatarIconClassName()would be used, but to allow for the case where the avatar is hosted on an external server this method can be used to retrieve the avatar image.- Parameters:
size- the size, the following sizes must be supported:16x16,24x24,32x32and48x48.- Returns:
- the url or
null - Throws:
IllegalStateException- if called outside of a request handling thread.
-
avatarIconClassNameImageOf
@CheckForNull protected final String avatarIconClassNameImageOf(@CheckForNull String iconClassName, @NonNull String size) Helper method to resolve the icon image url.- Parameters:
iconClassName- the icon class name.size- the size string, e.g.16x16,24x24, etc.- Returns:
- the icon image url or
null - Throws:
IllegalStateException- if called outside of a request handling thread.
-
cachedResizedImageOf
Helper method to resolve an external image, cache it and resize it to the specified size. If the external URL cannot be retrieved by Jenkins, then a randomly generated avatar will be generated using the external URL as a seed (so that the generated avatar image for any given external URL will be consistent across both Jenkins instances and restarts).- Parameters:
url- the URL of the image to cache.size- the size string, e.g.16x16,24x24, etc.- Returns:
- the icon image url.
- Throws:
IllegalStateException- if called outside of a request handling thread.- Since:
- 2.2.0
-
equals
-
hashCode
public abstract int hashCode()
-