Package jenkins.scm.impl.avatars
Class AvatarCache
- java.lang.Object
-
- jenkins.scm.impl.avatars.AvatarCache
-
- All Implemented Interfaces:
ExtensionPoint
,Action
,ModelObject
,RootAction
,UnprotectedRootAction
@Extension public class AvatarCache extends Object implements UnprotectedRootAction
An avatar cache that will serve URLs that have been recently registered throughbuildUrl(String, String)
.- Since:
- 2.2.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description AvatarCache()
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
buildUrl(String url, String size)
Builds the URL for the cached avatar image of the required size.static String
buildUrl(AvatarImageSource source, String size)
Builds the URL for the cached avatar image of the required size.org.kohsuke.stapler.HttpResponse
doDynamic(org.kohsuke.stapler.StaplerRequest req, String size)
Serves the cached image.String
getDisplayName()
String
getIconFileName()
String
getUrlName()
-
-
-
Method Detail
-
buildUrl
public static String buildUrl(@NonNull String url, @NonNull String size)
Builds the URL for the cached avatar image of the required size.- Parameters:
url
- the URL of the source avatar image.size
- the size of the image.- Returns:
- the URL of the cached image.
- Throws:
IllegalStateException
- if called outside of a request handling thread.
-
buildUrl
public static String buildUrl(@NonNull AvatarImageSource source, @NonNull String size)
Builds the URL for the cached avatar image of the required size.- Parameters:
source
- source avatar image definition.size
- the size of the image.- Returns:
- the URL of the cached image.
- Throws:
IllegalStateException
- if called outside of a request handling thread.
-
getIconFileName
public String getIconFileName()
- Specified by:
getIconFileName
in interfaceAction
-
getDisplayName
public String getDisplayName()
- Specified by:
getDisplayName
in interfaceAction
- Specified by:
getDisplayName
in interfaceModelObject
-
getUrlName
public String getUrlName()
- Specified by:
getUrlName
in interfaceAction
-
doDynamic
public org.kohsuke.stapler.HttpResponse doDynamic(org.kohsuke.stapler.StaplerRequest req, @QueryParameter String size)
Serves the cached image.- Parameters:
req
- the request.size
- the requested size (defaults to48x48
if unspecified).- Returns:
- the response.
-
-