Package hudson.model
Class DownloadService.Downloadable
java.lang.Object
hudson.model.DownloadService.Downloadable
- All Implemented Interfaces:
ExtensionPoint
- Enclosing class:
- DownloadService
Represents a periodically updated JSON data file obtained from a remote URL.
This mechanism is one of the basis of the update center, which involves fetching up-to-date data file.
- Since:
- 1.305
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Constructor Summary
ConstructorDescriptionCreates a new downloadable.Downloadable
(Class<?> clazz) Creates a new downloadable.Downloadable
(String id) Creates a new downloadable with a specific ID.Downloadable
(String id, String url) Creates a new downloadable with a specific ID and URL.Downloadable
(String id, String url, long interval) Creates a new downloadable. -
Method Summary
Modifier and TypeMethodDescriptionall()
Returns all the registeredDownloadService.Downloadable
s.static DownloadService.Downloadable
Returns theDownloadService.Downloadable
that has an ID associated with the specified class (as computed viaidFor(Class)
).static DownloadService.Downloadable
Returns theDownloadService.Downloadable
that has the given ID.net.sf.json.JSONObject
getData()
Loads the current file into JSON and returns it, or null if no data exists.This is where the retrieved file will be stored.long
getDue()
When shall we retrieve this file next time?getId()
long
How often do we retrieve the new image?getUrl()
URL to download.getUrls()
URLs to download from.static <T> boolean
hasDuplicates
(List<T> genericList, String comparator) check if the list of update center entries has duplicatesstatic String
Generates an ID based on a class.net.sf.json.JSONObject
Function that takes multiple JSONObjects and returns a single one.
-
Constructor Details
-
Downloadable
Creates a new downloadable.- Parameters:
id
- The ID to use.url
- URL relative toUpdateCenter.getDefaultBaseUrl()
. So if this string is "foo.json", the ultimate URL will be something like "http://updates.jenkins-ci.org/updates/foo.json" For security and privacy reasons, we don't allow the retrieval from random locations.interval
- The interval, in milliseconds, between attempts to update this downloadable's data.
-
Downloadable
public Downloadable()Creates a new downloadable. This will generate an ID based on this downloadable's class (usingidFor(Class)
. The URL will be set to that ID, with an added.json
extension, and the default interval will be used. -
Downloadable
Creates a new downloadable. This will generate an ID based on the specified class (usingidFor(Class)
. The URL will be set to that ID, with an added.json
extension, and the default interval will be used.- Parameters:
clazz
- The class to use to generate the ID.
-
Downloadable
Creates a new downloadable with a specific ID. The URL will be set to that ID, with an added.json
extension, and the default interval will be used.- Parameters:
id
- The ID to use.
-
Downloadable
Creates a new downloadable with a specific ID and URL. The default interval will be used.- Parameters:
id
- The ID to use.url
- URL relative toUpdateCenter.getDefaultBaseUrl()
. So if this string is "foo.json", the ultimate URL will be something like "http://updates.jenkins-ci.org/updates/foo.json".For security and privacy reasons, we don't allow the retrieval from random locations.
-
-
Method Details
-
getId
-
idFor
Generates an ID based on a class.- Parameters:
clazz
- The class to use to generate an ID.- Returns:
- The ID generated based on the specified class.
- Since:
- 2.244
-
getUrl
URL to download. -
getUrls
URLs to download from. -
getInterval
public long getInterval()How often do we retrieve the new image?- Returns:
- number of milliseconds between retrieval.
-
getDataFile
This is where the retrieved file will be stored. -
getDue
public long getDue()When shall we retrieve this file next time? -
getData
Loads the current file into JSON and returns it, or null if no data exists.- Throws:
IOException
-
updateNow
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public FormValidation updateNow() throws IOException- Throws:
IOException
-
reduce
Function that takes multiple JSONObjects and returns a single one.- Parameters:
jsonList
- to be processed- Returns:
- a single JSONObject
-
hasDuplicates
check if the list of update center entries has duplicates- Type Parameters:
T
- the generic class- Parameters:
genericList
- list of entries coming from multiple update centerscomparator
- the unique ID of an entry- Returns:
- true if the list has duplicates, false otherwise
-
all
Returns all the registeredDownloadService.Downloadable
s. -
get
Returns theDownloadService.Downloadable
that has an ID associated with the specified class (as computed viaidFor(Class)
).- Parameters:
clazz
- The class to use to determine the downloadable's ID.- Since:
- 2.244
-
get
Returns theDownloadService.Downloadable
that has the given ID.- Parameters:
id
- The ID to look for.
-