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 aSCMSource
orSCMNavigator
(also valid forSCMRevision
andSCMHead
, but would be considered unusual).For example:
- A
SCMNavigator
implementation that corresponds to a GitHub Team could use thegetAvatarImageOf(String)
to return the GitHub Team logo
- Since:
- 2.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AvatarMetadataAction()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected String
avatarIconClassNameImageOf(String iconClassName, String size)
Helper method to resolve the icon image url.protected String
cachedResizedImageOf(String url, String size)
Helper method to resolve an external image, cache it and resize it to the specified size.abstract boolean
equals(Object o)
String
getAvatarDescription()
Returns the description to use for the tool tip of the avatar of this object.String
getAvatarIconClassName()
Returns theIcon
class specification for the avatar of this objectString
getAvatarImageOf(String size)
Returns the URL of the avatar of this object in the requested size ornull
if there is no avatar for this object.abstract int
hashCode()
-
Methods inherited from class hudson.model.InvisibleAction
getDisplayName, getIconFileName, getUrlName
-
-
-
-
Method Detail
-
getAvatarIconClassName
@CheckForNull public String getAvatarIconClassName()
Returns theIcon
class specification for the avatar of this object- Returns:
- the
Icon
class specification ornull
to checkgetAvatarImageOf(String)
. - Throws:
IllegalStateException
- if called outside of a request handling thread.- See Also:
IconSpec.getIconClassName()
-
getAvatarDescription
@CheckForNull public String 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
@CheckForNull public String getAvatarImageOf(@NonNull String size)
Returns the URL of the avatar of this object in the requested size ornull
if 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
,32x32
and48x48
.- 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
@NonNull protected final String cachedResizedImageOf(@NonNull String url, @NonNull String size)
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
-
-