Class Updater
java.lang.Object
de.iip_ecosphere.platform.support.Updater
Utility class to update application plugins (upon application start).
- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classRepresents a plugin resolution result for a found plugin, potentially with Maven snapshot build number. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static NodegetElement(NodeList list, String name) Returns the XML element with the givennamefrom the nodelist.private static NodegetElement(Node node, String name) Returns the XML child element with the givennamefrom the parentnode.private static booleanisMoreRecent(Object lastBuildNr, String buildNr) Returns whether the actual build number is more recent than the last known one.private static Updater.PluginResolutionResultresolvePlugin(String pluginName, String pluginUrl, Object lastBuildNr) Resolves the givenpluginNamefrom the (initial complete, potentially outdated) MavenpluginUrl.private static Updater.PluginResolutionResultresolvePluginWithMaven(String pluginName, String pluginUrl, Object lastBuildNr) Resolves a not-found plugin with Maven metadata.private static voidunzipPlugin(File file, String name) Unzips a plugin.static voidupdatePlugins(InputStream resolved, File pluginsFolder, boolean updatePlugins) Update plugins.static voidupdatePluginsQuiet(InputStream resolved, File pluginsFolder, boolean updatePlugins) Update plugins quietly.
-
Field Details
-
SNAPSHOT
- See Also:
-
-
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 pluginspluginsFolder- the target plugins folderupdatePlugins- 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 pluginspluginsFolder- the target plugins folderupdatePlugins- whether stored (SNAPSHOT) plugins shall be updated at all- Throws:
IOException- if the resolved plugin file cannot be read
-
unzipPlugin
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 givenpluginNamefrom the (initial complete, potentially outdated) MavenpluginUrl. 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 pluginpluginUrl- the (initial complete, potentially outdated) Maven plugin download URLlastBuildNr- 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 pluginpluginUrl- the (initial complete, potentially outdated) Maven plugin download URLlastBuildNr- 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
Returns whether the actual build number is more recent than the last known one.- Parameters:
lastBuildNr- the last build number, may be null for nonebuildNr- the actual build number as text- Returns:
trueif more recent, nolastBuildNror build numbers not readable,falseif not more recent
-
getElement
Returns the XML child element with the givennamefrom the parentnode.- Parameters:
node- the parent nodename- the child node name- Returns:
- the child node or null for none
-
getElement
Returns the XML element with the givennamefrom the nodelist.- Parameters:
list- the nodes to searchname- the child node name- Returns:
- the child node or null for none
-