public static class DownloadService.Downloadable extends Object implements ExtensionPoint
This mechanism is one of the basis of the update center, which involves fetching up-to-date data file.
ExtensionPoint.LegacyInstancesAreScopedToHudson
Constructor and Description |
---|
Downloadable()
Creates 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.
|
Modifier and Type | Method and Description |
---|---|
static ExtensionList<DownloadService.Downloadable> |
all()
Returns all the registered
DownloadService.Downloadable s. |
static DownloadService.Downloadable |
get(Class<?> clazz)
Returns the
DownloadService.Downloadable that has an ID associated with the specified class (as computed via
idFor(Class) ). |
static DownloadService.Downloadable |
get(String id)
Returns the
DownloadService.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.
|
TextFile |
getDataFile()
This is where the retrieved file will be stored.
|
long |
getDue()
When shall we retrieve this file next time?
|
String |
getId() |
long |
getInterval()
How often do we retrieve the new image?
|
String |
getUrl()
URL to download.
|
List<String> |
getUrls()
URLs to download from.
|
static <T> boolean |
hasDuplicates(List<T> genericList,
String comparator)
check if the list of update center entries has duplicates
|
static String |
idFor(Class<?> clazz)
Generates an ID based on a class.
|
net.sf.json.JSONObject |
reduce(List<net.sf.json.JSONObject> jsonList)
Function that takes multiple JSONObjects and returns a single one.
|
FormValidation |
updateNow() |
public Downloadable(@NonNull String id, @NonNull String url, long interval)
id
- The ID to use.url
- URL relative to UpdateCenter.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.public Downloadable()
idFor(Class)
. The URL will be set
to that ID, with an added .json
extension, and the default interval will be used.public Downloadable(@NonNull Class<?> clazz)
idFor(Class)
. The URL will be set to
that ID, with an added .json
extension, and the default interval will be used.clazz
- The class to use to generate the ID.public Downloadable(@NonNull String id)
.json
extension, and the default interval will be used.id
- The ID to use.public Downloadable(@NonNull String id, @NonNull String url)
id
- The ID to use.url
- URL relative to UpdateCenter.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.
@NonNull public String getId()
@NonNull public static String idFor(@NonNull Class<?> clazz)
clazz
- The class to use to generate an ID.public String getUrl()
public long getInterval()
public TextFile getDataFile()
public long getDue()
public net.sf.json.JSONObject getData() throws IOException
IOException
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public FormValidation updateNow() throws IOException
IOException
public net.sf.json.JSONObject reduce(List<net.sf.json.JSONObject> jsonList)
jsonList
- to be processedpublic static <T> boolean hasDuplicates(List<T> genericList, String comparator)
T
- the generic classgenericList
- list of entries coming from multiple update centerscomparator
- the unique ID of an entry@NonNull public static ExtensionList<DownloadService.Downloadable> all()
DownloadService.Downloadable
s.@CheckForNull public static DownloadService.Downloadable get(@NonNull Class<?> clazz)
DownloadService.Downloadable
that has an ID associated with the specified class (as computed via
idFor(Class)
).clazz
- The class to use to determine the downloadable's ID.@CheckForNull public static DownloadService.Downloadable get(String id)
DownloadService.Downloadable
that has the given ID.id
- The ID to look for.Copyright © 2004–2021. All rights reserved.