Class Updater

java.lang.Object
de.iip_ecosphere.platform.support.Updater

public class Updater extends Object
Utility class to update application plugins (upon application start).
Author:
Holger Eichelberger, SSE
  • Field Details

  • Constructor Details

    • Updater

      public Updater()
  • Method Details

    • updatePluginsQuiet

      public static void updatePluginsQuiet(InputStream resolved, File pluginsFolder, boolean updatePlugins)
      Update plugins quietly.
      Parameters:
      resolved - the resolved plugin file as written by the oktoflow resource plugin for packaging oktoflow plugins
      pluginsFolder - the target plugins folder
      updatePlugins - whether stored (SNAPSHOT) plugins shall be updated at all
    • updatePlugins

      public static void updatePlugins(InputStream resolved, File pluginsFolder, boolean updatePlugins) throws IOException
      Update plugins.
      Parameters:
      resolved - the resolved plugin file as written by the oktoflow resource plugin for packaging oktoflow plugins
      pluginsFolder - the target plugins folder
      updatePlugins - whether stored (SNAPSHOT) plugins shall be updated at all
      Throws:
      IOException - if the resolved plugin file cannot be read
    • unzipPlugin

      private static void unzipPlugin(File file, String name) throws IOException
      Unzips a plugin.
      Parameters:
      file - the file containing the plugin (stored in plugins folder)
      name - the name of the plugin
      Throws:
      IOException - if unzipping fails
    • resolvePlugin

      private static Updater.PluginResolutionResult resolvePlugin(String pluginName, String pluginUrl, Object lastBuildNr)
      Resolves the given pluginName from the (initial complete, potentially outdated) Maven pluginUrl. If the URL does not exist anymore, this method tries to resolve it based on Maven metadata in the containing folder.
      Parameters:
      pluginName - the name of the plugin
      pluginUrl - the (initial complete, potentially outdated) Maven plugin download URL
      lastBuildNr - the build number of the last update, may be null or empty for none
      Returns:
      the input stream of the resolved plugin or null for none
    • resolvePluginWithMaven

      private static Updater.PluginResolutionResult resolvePluginWithMaven(String pluginName, String pluginUrl, Object lastBuildNr) throws MalformedURLException
      Resolves a not-found plugin with Maven metadata.
      Parameters:
      pluginName - the name of the plugin
      pluginUrl - the (initial complete, potentially outdated) Maven plugin download URL
      lastBuildNr - the build number of the last update, may be null or empty for none
      Returns:
      the input stream of the resolved plugin or null for none
      Throws:
      MalformedURLException - in case that creating an URL fails
    • isMoreRecent

      private static boolean isMoreRecent(Object lastBuildNr, String buildNr)
      Returns whether the actual build number is more recent than the last known one.
      Parameters:
      lastBuildNr - the last build number, may be null for none
      buildNr - the actual build number as text
      Returns:
      true if more recent, no lastBuildNr or build numbers not readable, false if not more recent
    • getElement

      private static Node getElement(Node node, String name)
      Returns the XML child element with the given name from the parent node.
      Parameters:
      node - the parent node
      name - the child node name
      Returns:
      the child node or null for none
    • getElement

      private static Node getElement(NodeList list, String name)
      Returns the XML element with the given name from the node list.
      Parameters:
      list - the nodes to search
      name - the child node name
      Returns:
      the child node or null for none