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
SCMNavigator
implementation that corresponds to a GitHub Team could use thegetAvatarImageOf(String)
to return the GitHub Team logo
- Since:
- 2.0
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final String
avatarIconClassNameImageOf
(String iconClassName, String size) Helper method to resolve the icon image url.protected final String
cachedResizedImageOf
(String url, String size) Helper method to resolve an external image, cache it and resize it to the specified size.abstract boolean
Returns the description to use for the tool tip of the avatar of this object.Returns theIcon
class specification for the avatar of this objectgetAvatarImageOf
(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
-
Constructor Details
-
AvatarMetadataAction
public AvatarMetadataAction()
-
-
Method Details
-
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:
-
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 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
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()
-