Package hudson.model

Class DownloadService.Downloadable

java.lang.Object
hudson.model.DownloadService.Downloadable
All Implemented Interfaces:
ExtensionPoint
Enclosing class:
DownloadService

public static class DownloadService.Downloadable extends Object implements ExtensionPoint
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
  • Constructor Details

    • Downloadable

      public Downloadable(@NonNull String id, @NonNull String url, long interval)
      Creates a new downloadable.
      Parameters:
      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.
    • Downloadable

      public Downloadable()
      Creates a new downloadable. This will generate an ID based on this downloadable's class (using idFor(Class). The URL will be set to that ID, with an added .json extension, and the default interval will be used.
    • Downloadable

      public Downloadable(@NonNull Class<?> clazz)
      Creates a new downloadable. This will generate an ID based on the specified class (using idFor(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

      public Downloadable(@NonNull String id)
      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

      public Downloadable(@NonNull String id, @NonNull String url)
      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 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.

  • Method Details

    • getId

      @NonNull public String getId()
    • idFor

      @NonNull public static String idFor(@NonNull Class<?> clazz)
      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

      public String getUrl()
      URL to download.
    • getUrls

      public List<String> getUrls()
      URLs to download from.
    • getInterval

      public long getInterval()
      How often do we retrieve the new image?
      Returns:
      number of milliseconds between retrieval.
    • getDataFile

      public TextFile getDataFile()
      This is where the retrieved file will be stored.
    • getDue

      public long getDue()
      When shall we retrieve this file next time?
    • getData

      public net.sf.json.JSONObject getData() throws IOException
      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

      public net.sf.json.JSONObject reduce(List<net.sf.json.JSONObject> jsonList)
      Function that takes multiple JSONObjects and returns a single one.
      Parameters:
      jsonList - to be processed
      Returns:
      a single JSONObject
    • hasDuplicates

      public static <T> boolean hasDuplicates(List<T> genericList, String comparator)
      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 centers
      comparator - the unique ID of an entry
      Returns:
      true if the list has duplicates, false otherwise
    • all

      @NonNull public static ExtensionList<DownloadService.Downloadable> all()
      Returns all the registered DownloadService.Downloadables.
    • get

      @CheckForNull public static DownloadService.Downloadable get(@NonNull Class<?> clazz)
      Returns the DownloadService.Downloadable that has an ID associated with the specified class (as computed via idFor(Class)).
      Parameters:
      clazz - The class to use to determine the downloadable's ID.
      Since:
      2.244
    • get

      @CheckForNull public static DownloadService.Downloadable get(String id)
      Returns the DownloadService.Downloadable that has the given ID.
      Parameters:
      id - The ID to look for.