Class PluginMetadataHelper
- java.lang.Object
-
- org.jivesoftware.openfire.container.PluginMetadataHelper
-
public class PluginMetadataHelper extends Object
Various helper methods to retrieve plugin metadat from plugin.xml files.- Author:
- Guus der Kinderen, guus.der.kinderen@gmail.com
-
-
Constructor Summary
Constructors Constructor Description PluginMetadataHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetAuthor(Path pluginDir)Returns the author of a plugin.static StringgetAuthor(Plugin plugin)Returns the author of a plugin.static StringgetCanonicalName(Path pluginPath)Returns the canonical name for the plugin, derived from the plugin directory or archive file name.static StringgetCanonicalName(Plugin plugin)Returns the canonical name for the plugin, derived from the plugin archive file name.static URLgetChangelog(Path pluginDir)static URLgetChangelog(Plugin plugin)static StringgetDatabaseKey(Path pluginDir)Returns the database schema key of a plugin, if it exists.static StringgetDatabaseKey(Plugin plugin)Returns the database schema key of a plugin, if it exists.static intgetDatabaseVersion(Path pluginDir)Returns the database schema version of a plugin, if it exists.static intgetDatabaseVersion(Plugin plugin)Returns the database schema version of a plugin, if it exists.static StringgetDescription(Path pluginDir)Returns the description of a plugin.static StringgetDescription(Plugin plugin)Returns the description of a plugin.static URLgetIcon(Path pluginDir)static URLgetIcon(Plugin plugin)static StringgetLicense(Path pluginDir)Returns the license agreement type that the plugin is governed by.static StringgetLicense(Plugin plugin)Returns the license agreement type that the plugin is governed by.static JavaSpecVersiongetMinJavaVersion(Path pluginDir)Returns the minimum Java specification version this plugin needs to run.static JavaSpecVersiongetMinJavaVersion(Plugin plugin)Returns the minimum Java specification version this plugin needs to run.static VersiongetMinServerVersion(Path pluginDir)Returns the minimum server version this plugin can run within.static VersiongetMinServerVersion(Plugin plugin)Returns the minimum server version this plugin can run within.static StringgetName(Path pluginDir)Returns the name of a plugin.static StringgetName(Plugin plugin)Returns the name of a plugin.static StringgetParentPlugin(Path pluginDir)Returns the name of the directory of the parent for this plugin.static StringgetParentPlugin(Plugin plugin)Returns the name of the directory of the parent for this plugin.static VersiongetPriorToServerVersion(Path pluginDir)Returns the server version up, but not including, in which this plugin can run within.static VersiongetPriorToServerVersion(Plugin plugin)Returns the server version up, but not including, in which this plugin can run within.static URLgetReadme(Path pluginDir)static URLgetReadme(Plugin plugin)static VersiongetVersion(Path pluginDir)Returns the version of a plugin.static VersiongetVersion(Plugin plugin)Returns the version of a plugin.static booleanisCsrfProtectionEnabled(Path pluginDir)static booleanisCsrfProtectionEnabled(Plugin plugin)
-
-
-
Method Detail
-
getParentPlugin
public static String getParentPlugin(Plugin plugin)
Returns the name of the directory of the parent for this plugin. The value is retrieved from the plugin.xml file of the plugin (which is casted down to lower-case). If the value could not be found,nullwill be returned.- Parameters:
plugin- The plugin (cannot be null)- Returns:
- the parent plugin's directory name
-
getParentPlugin
public static String getParentPlugin(Path pluginDir)
Returns the name of the directory of the parent for this plugin. The value is retrieved from the plugin.xml file of the plugin (which is casted down to lower-case). If the value could not be found,nullwill be returned.- Parameters:
pluginDir- the path of the plugin directory.- Returns:
- the parent plugin's directory name
-
getCanonicalName
public static String getCanonicalName(Plugin plugin)
Returns the canonical name for the plugin, derived from the plugin archive file name. Note that this value can be different from the 'human readable' plugin name, as returned bygetName(Path). Note that this method will return data only for plugins that have successfully been installed. To obtain data from plugin (directories) that have not (yet) been installed, refer to the overloaded method that takes a Path argument.- Parameters:
plugin- The plugin (cannot be null)- Returns:
- the plugin's canonical name.
-
getCanonicalName
public static String getCanonicalName(Path pluginPath)
Returns the canonical name for the plugin, derived from the plugin directory or archive file name. The provided path can refer to either the plugin archive file, or the directory in which the archive was extracted. Note that this value can be different from the 'human readable' plugin name, as returned bygetName(Path).- Parameters:
pluginPath- the path of the plugin directory, or plugin archive file.- Returns:
- the plugin's canonical name.
-
getName
public static String getName(Plugin plugin)
Returns the name of a plugin. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found,nullwill be returned. Note that this value is a 'human readable' name, which can be distinct from the name of the plugin directory as returned bygetCanonicalName(Path). Note that this method will return data only for plugins that have successfully been installed. To obtain data from plugin (directories) that have not (yet) been installed, refer to the overloaded method that takes a Path argument.- Parameters:
plugin- The plugin (cannot be null)- Returns:
- the plugin's human-readable name.
-
getName
public static String getName(Path pluginDir)
Returns the name of a plugin. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found,nullwill be returned. Note that this value is a 'human readable' name, which can be distinct from the name of the plugin directory as returned bygetCanonicalName(Path).- Parameters:
pluginDir- the path of the plugin directory.- Returns:
- the plugin's human-readable name.
-
getDescription
public static String getDescription(Plugin plugin)
Returns the description of a plugin. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found,nullwill be returned. Note that this method will return data only for plugins that have successfully been installed. To obtain data from plugin (directories) that have not (yet) been installed, refer to the overloaded method that takes a Path argument.- Parameters:
plugin- The plugin (cannot be null)- Returns:
- the plugin's description.
-
getDescription
public static String getDescription(Path pluginDir)
Returns the description of a plugin. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found,nullwill be returned.- Parameters:
pluginDir- the path of the plugin directory.- Returns:
- the plugin's description.
-
getAuthor
public static String getAuthor(Plugin plugin)
Returns the author of a plugin. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found,nullwill be returned. Note that this method will return data only for plugins that have successfully been installed. To obtain data from plugin (directories) that have not (yet) been installed, refer to the overloaded method that takes a Path argument.- Parameters:
plugin- The plugin (cannot be null)- Returns:
- the plugin's author.
-
getAuthor
public static String getAuthor(Path pluginDir)
Returns the author of a plugin. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found,nullwill be returned.- Parameters:
pluginDir- the path of the plugin directory.- Returns:
- the plugin's author.
-
getVersion
public static Version getVersion(Plugin plugin)
Returns the version of a plugin. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found,nullwill be returned. Note that this method will return data only for plugins that have successfully been installed. To obtain data from plugin (directories) that have not (yet) been installed, refer to the overloaded method that takes a Path argument.- Parameters:
plugin- The plugin (cannot be null)- Returns:
- the plugin's version.
-
getVersion
public static Version getVersion(Path pluginDir)
Returns the version of a plugin. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found,nullwill be returned.- Parameters:
pluginDir- the path of the plugin directory.- Returns:
- the plugin's version.
-
getMinServerVersion
public static Version getMinServerVersion(Plugin plugin)
Returns the minimum server version this plugin can run within. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found,nullwill be returned. Note that this method will return data only for plugins that have successfully been installed. To obtain data from plugin (directories) that have not (yet) been installed, refer to the overloaded method that takes a Path argument.- Parameters:
plugin- The plugin (cannot be null)- Returns:
- the plugin's minimum server version (possibly null).
-
getMinServerVersion
public static Version getMinServerVersion(Path pluginDir)
Returns the minimum server version this plugin can run within. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found,nullwill be returned.- Parameters:
pluginDir- the path of the plugin directory.- Returns:
- the plugin's minimum server version (possibly null).
-
getPriorToServerVersion
public static Version getPriorToServerVersion(Plugin plugin)
Returns the server version up, but not including, in which this plugin can run within. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found,nullwill be returned. Note that this method will return data only for plugins that have successfully been installed. To obtain data from plugin (directories) that have not (yet) been installed, refer to the overloaded method that takes a Path argument.- Parameters:
plugin- The plugin (cannot be null)- Returns:
- the plugin's maximum server version (possibly null).
-
getPriorToServerVersion
public static Version getPriorToServerVersion(Path pluginDir)
Returns the server version up, but not including, in which this plugin can run within. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found,nullwill be returned.- Parameters:
pluginDir- the path of the plugin directory.- Returns:
- the plugin's maximum server version (possibly null).
-
getMinJavaVersion
public static JavaSpecVersion getMinJavaVersion(Plugin plugin)
Returns the minimum Java specification version this plugin needs to run. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found,nullwill be returned. Note that this method will return data only for plugins that have successfully been installed. To obtain data from plugin (directories) that have not (yet) been installed, refer to the overloaded method that takes a Path argument.- Parameters:
plugin- The plugin (cannot be null)- Returns:
- the plugin's minimum Java version (possibly null).
-
getMinJavaVersion
public static JavaSpecVersion getMinJavaVersion(Path pluginDir)
Returns the minimum Java specification version this plugin needs to run. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found,nullwill be returned.- Parameters:
pluginDir- the path of the plugin directory.- Returns:
- the plugin's minimum Java version (possibly null).
-
isCsrfProtectionEnabled
public static boolean isCsrfProtectionEnabled(Plugin plugin)
-
isCsrfProtectionEnabled
public static boolean isCsrfProtectionEnabled(Path pluginDir)
-
getDatabaseKey
public static String getDatabaseKey(Plugin plugin)
Returns the database schema key of a plugin, if it exists. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found,nullwill be returned. Note that this method will return data only for plugins that have successfully been installed. To obtain data from plugin (directories) that have not (yet) been installed, refer to the overloaded method that takes a Path argument.- Parameters:
plugin- The plugin (cannot be null)- Returns:
- the plugin's database schema key or
nullif it doesn't exist.
-
getDatabaseKey
public static String getDatabaseKey(Path pluginDir)
Returns the database schema key of a plugin, if it exists. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found,nullwill be returned.- Parameters:
pluginDir- the path of the plugin directory.- Returns:
- the plugin's database schema key or
nullif it doesn't exist.
-
getDatabaseVersion
public static int getDatabaseVersion(Plugin plugin)
Returns the database schema version of a plugin, if it exists. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found,-1will be returned. Note that this method will return data only for plugins that have successfully been installed. To obtain data from plugin (directories) that have not (yet) been installed, refer to the overloaded method that takes a Path argument.- Parameters:
plugin- The plugin (cannot be null)- Returns:
- the plugin's database schema version or
-1if it doesn't exist.
-
getDatabaseVersion
public static int getDatabaseVersion(Path pluginDir)
Returns the database schema version of a plugin, if it exists. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found,-1will be returned.- Parameters:
pluginDir- the path of the plugin directory.- Returns:
- the plugin's database schema version or
-1if it doesn't exist.
-
getLicense
public static String getLicense(Plugin plugin)
Returns the license agreement type that the plugin is governed by. The value is retrieved from the plugin.xml file of the plugin. Note that this method will return data only for plugins that have successfully been installed. To obtain data from plugin (directories) that have not (yet) been installed, refer to the overloaded method that takes a Path argument.- Parameters:
plugin- The plugin (cannot be null)- Returns:
- the plugin's license agreement.
-
getLicense
public static String getLicense(Path pluginDir)
Returns the license agreement type that the plugin is governed by. The value is retrieved from the plugin.xml file of the plugin.- Parameters:
pluginDir- the path of the plugin directory.- Returns:
- the plugin's license agreement.
-
-