Package org.jivesoftware.openfire.update
Class UpdateManager
- java.lang.Object
-
- org.jivesoftware.openfire.container.BasicModule
-
- org.jivesoftware.openfire.update.UpdateManager
-
- All Implemented Interfaces:
Module
public class UpdateManager extends BasicModule
Service that frequently checks for new server or plugins releases. By default the service will check every 48 hours for updates. Use the system propertyupdate.frequency
to set new values.New versions of plugins can be downloaded and installed. However, new server releases should be manually installed.
- Author:
- Gaston Dombiak
-
-
Constructor Summary
Constructors Constructor Description UpdateManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkForPluginsUpdates(boolean notificationsEnabled)
Queries the igniterealtime.org server.void
checkForServerUpdate(boolean notificationsEnabled)
Queries the igniterealtime.org server with a request that contains the currently installed server version.boolean
downloadPlugin(String url)
Download and install latest version of plugin.String
getNotificationMessage()
Returns the message to send to admins when new updates are available.List<AvailablePlugin>
getNotInstalledPlugins()
Returns the list of available plugins, sorted alphabetically, to install as reported by igniterealtime.org.Update
getPluginUpdate(String pluginName, Version currentVersion)
Returns the plugin update ornull
if the plugin is up to date.Collection<Update>
getPluginUpdates()
Returns a previously fetched list of updates.String
getProxyHost()
Returns the host of the proxy to use to connect to igniterealtime.org ornull
if no proxy is used.int
getProxyPort()
Returns the port of the proxy to use to connect to igniterealtime.org or -1 if no proxy is being used.Update
getServerUpdate()
Returns the server update ornull
if the server is up to date.void
initialize(XMPPServer server)
Initializes the basic module.boolean
isNotificationEnabled()
Returns true if admins should be notified by IM when new updates are available.boolean
isPluginDownloaded(String url)
Returns true if the plugin downloaded from the specified URL has been downloaded.boolean
isServiceEnabled()
Returns true if the check for updates service is enabled.boolean
isUsingProxy()
Returns true if a proxy is being used to connect to igniterealtime.org or false if a direct connection should be attempted.void
setNotificationEnabled(boolean enabled)
Sets if admins should be notified by IM when new updates are available.void
setProxyHost(String host)
Sets the host of the proxy to use to connect to igniterealtime.org ornull
if no proxy is used.void
setProxyPort(int port)
Sets the port of the proxy to use to connect to igniterealtime.org or -1 if no proxy is being used.void
setServiceEnabled(boolean enabled)
Sets if the check for updates service is enabled.void
start()
Starts the basic module.-
Methods inherited from class org.jivesoftware.openfire.container.BasicModule
destroy, getName, stop
-
-
-
-
Method Detail
-
start
public void start() throws IllegalStateException
Description copied from class:BasicModule
Starts the basic module.
Inheriting classes that choose to override this method MUST call this start() method before accessing BasicModule resources.
- Specified by:
start
in interfaceModule
- Overrides:
start
in classBasicModule
- Throws:
IllegalStateException
- If start is called before initialize successfully returns
-
initialize
public void initialize(XMPPServer server)
Description copied from class:BasicModule
Initializes the basic module.
Inheriting classes that choose to override this method MUST call this initialize() method before accessing BasicModule resources.
- Specified by:
initialize
in interfaceModule
- Overrides:
initialize
in classBasicModule
- Parameters:
server
- the server hosting this module.
-
checkForServerUpdate
public void checkForServerUpdate(boolean notificationsEnabled) throws Exception
Queries the igniterealtime.org server with a request that contains the currently installed server version. It's response indicates if a server update (a newer version of Openfire) is available.- Parameters:
notificationsEnabled
- true if admins will be notified when new updates are found.- Throws:
Exception
- if some error happens during the query.
-
checkForPluginsUpdates
public void checkForPluginsUpdates(boolean notificationsEnabled) throws Exception
Queries the igniterealtime.org server. It's response is expected to include a list of plugins that are available on the server / for download.- Parameters:
notificationsEnabled
- true if admins will be notified when new updates are found.- Throws:
Exception
- if some error happens during the query.
-
downloadPlugin
public boolean downloadPlugin(String url)
Download and install latest version of plugin.- Parameters:
url
- the URL of the latest version of the plugin.- Returns:
- true if the plugin was successfully downloaded and installed.
-
isPluginDownloaded
public boolean isPluginDownloaded(String url)
Returns true if the plugin downloaded from the specified URL has been downloaded. Plugins may be downloaded but not installed. The install process may take like 30 seconds to detect new plugins to install.- Parameters:
url
- the URL of the latest version of the plugin.- Returns:
- true if the plugin downloaded from the specified URL has been downloaded.
-
getNotInstalledPlugins
public List<AvailablePlugin> getNotInstalledPlugins()
Returns the list of available plugins, sorted alphabetically, to install as reported by igniterealtime.org. Currently downloaded plugins will not be included, nor will plugins that require a newer or older server version.- Returns:
- the list of available plugins to install as reported by igniterealtime.org.
-
getNotificationMessage
public String getNotificationMessage()
Returns the message to send to admins when new updates are available. When sending this message information about the new updates avaiable will be appended.- Returns:
- the message to send to admins when new updates are available.
-
isServiceEnabled
public boolean isServiceEnabled()
Returns true if the check for updates service is enabled.- Returns:
- true if the check for updates service is enabled.
-
setServiceEnabled
public void setServiceEnabled(boolean enabled)
Sets if the check for updates service is enabled.- Parameters:
enabled
- true if the check for updates service is enabled.
-
isNotificationEnabled
public boolean isNotificationEnabled()
Returns true if admins should be notified by IM when new updates are available.- Returns:
- true if admins should be notified by IM when new updates are available.
-
setNotificationEnabled
public void setNotificationEnabled(boolean enabled)
Sets if admins should be notified by IM when new updates are available.- Parameters:
enabled
- true if admins should be notified by IM when new updates are available.
-
isUsingProxy
public boolean isUsingProxy()
Returns true if a proxy is being used to connect to igniterealtime.org or false if a direct connection should be attempted.- Returns:
- true if a proxy is being used to connect to igniterealtime.org.
-
getProxyHost
public String getProxyHost()
Returns the host of the proxy to use to connect to igniterealtime.org ornull
if no proxy is used.- Returns:
- the host of the proxy or null if no proxy is used.
-
setProxyHost
public void setProxyHost(String host)
Sets the host of the proxy to use to connect to igniterealtime.org ornull
if no proxy is used.- Parameters:
host
- the host of the proxy or null if no proxy is used.
-
getProxyPort
public int getProxyPort()
Returns the port of the proxy to use to connect to igniterealtime.org or -1 if no proxy is being used.- Returns:
- the port of the proxy to use to connect to igniterealtime.org or -1 if no proxy is being used.
-
setProxyPort
public void setProxyPort(int port)
Sets the port of the proxy to use to connect to igniterealtime.org or -1 if no proxy is being used.- Parameters:
port
- the port of the proxy to use to connect to igniterealtime.org or -1 if no proxy is being used.
-
getServerUpdate
public Update getServerUpdate()
Returns the server update ornull
if the server is up to date.- Returns:
- the server update or null if the server is up to date.
-
getPluginUpdate
public Update getPluginUpdate(String pluginName, Version currentVersion)
Returns the plugin update ornull
if the plugin is up to date.- Parameters:
pluginName
- the name of the plugin (as described in the meta-data).currentVersion
- current version of the plugin that is installed.- Returns:
- the plugin update or null if the plugin is up to date.
-
getPluginUpdates
public Collection<Update> getPluginUpdates()
Returns a previously fetched list of updates.- Returns:
- a previously fetched list of updates.
-
-