Package org.opennms.upgrade.api
Class AbstractOnmsUpgrade
- java.lang.Object
-
- org.opennms.upgrade.api.AbstractOnmsUpgrade
-
- All Implemented Interfaces:
OnmsUpgrade
- Direct Known Subclasses:
DataCollectionConfigMigrator17Offline,DataCollectionConfigMigratorOffline,DiscoveryConfigurationLocationMigratorOffline,DiscoveryConfigurationMigratorOffline,EOLServiceConfigMigratorOffline,EventParameterMigratorOffline,JettyConfigMigratorOffline,JmxRrdMigratorOffline,KscReportsMigrator,MagicUsersMigratorOffline,RemotePollerServiceConfigMigratorOffline,RequisitionsMigratorOffline,ServiceConfig1701MigratorOffline,ServiceConfigMigratorOffline,SnmpInterfaceRrdMigratorOnline,VmwareAssetsMigratorOffline
public abstract class AbstractOnmsUpgrade extends Object implements OnmsUpgrade
The Abstract class for OpenNMS Upgrade Implementations.This contains the basic methods that may be required for several implementations.
- Author:
- Alejandro Galue
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractOnmsUpgrade.VersionOperator
-
Constructor Summary
Constructors Constructor Description AbstractOnmsUpgrade()Instantiates a new abstract OpenNMS upgrade.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ConnectiongetDbConnection()Gets the DB connection.protected File[]getFiles(File resourceDir, String ext)Gets the files.protected StringgetHomeDirectory()Gets the home directory.StringgetId()Gets the id.protected int[]getInstalledVersion()protected PropertiesgetMainProperties()Gets the main properties.StringgetOpennmsProductDescription()Gets the OpenNMS product description.StringgetOpennmsProductName()Gets the OpenNMS product name.protected StringgetOpennmsVersion()Gets the currently installed OpenNMS version.protected StringgetRrdExtension()Gets the RRD extension.protected PropertiesgetRrdProperties()Gets the RRD properties.protected StringgetRrdStrategy()Gets the RRD strategy.protected voidinitializeDatasource()Initializes the data source.protected booleanisInstalledVersion(AbstractOnmsUpgrade.VersionOperator op, int mayor, int minor, int release)protected booleanisInstalledVersionGreaterOrEqual(int mayor, int minor, int release)Checks if the installed version of OpenNMS is greater or equals than the supplied version.booleanisMeridian()Checks if is meridian.protected booleanisRrdToolEnabled()Checks if is RRDtool enabled.protected booleanisStoreByForeignSourceEnabled()Checks if storeByForeignSource is enabled.protected booleanisStoreByGroupEnabled()Checks if storeByGroup is enabled.protected voidloadProperties(Properties properties, String fileName)Load properties.protected voidlog(String msgFormat, Object... args)Log.protected voidprintFullSettings()Prints the full settings.protected voidprintMainSettings()Prints the settings.protected voidregisterProperties(Properties properties)Register properties.protected voidsetProductDescription(String productDescription)Sets the product description.protected voidsetProductName(String productName)Sets the product name.protected voidsetVersion(String version)Sets the version.protected voidunzipFile(File zipFile, File outputFolder)UNZIP a file.protected static intversionToInteger(int mayor, int minor, int release)protected voidzipDir(File zipFile, File sourceFolder)ZIP a directory.protected FilezipFile(File sourceFile)ZIP a file.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.opennms.upgrade.api.OnmsUpgrade
execute, getDescription, getOrder, postExecute, preExecute, requiresOnmsRunning, rollback
-
-
-
-
Field Detail
-
ZIP_EXT
public static final String ZIP_EXT
The Constant ZIP_EXT.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractOnmsUpgrade
public AbstractOnmsUpgrade() throws OnmsUpgradeExceptionInstantiates a new abstract OpenNMS upgrade.- Throws:
OnmsUpgradeException- the OpenNMS upgrade exception
-
-
Method Detail
-
setVersion
protected void setVersion(String version)
Sets the version.This method is intended for JUnit tests.
- Parameters:
version- the new version
-
setProductName
protected void setProductName(String productName)
Sets the product name.This method is intended for JUnit tests.
- Parameters:
productName- the new product name
-
setProductDescription
protected void setProductDescription(String productDescription)
Sets the product description.This method is intended for JUnit tests.
- Parameters:
productDescription- the new product description
-
getId
public String getId()
Description copied from interface:OnmsUpgradeGets the id.This is for informational purposes, and will be used to store the execution status.
It is recommended to use the class-name, but any other text can be used.
- Specified by:
getIdin interfaceOnmsUpgrade- Returns:
- the id
-
getHomeDirectory
protected String getHomeDirectory()
Gets the home directory.- Returns:
- the home directory
-
getFiles
protected File[] getFiles(File resourceDir, String ext)
Gets the files.- Parameters:
resourceDir- the resource directoryext- the file extension- Returns:
- the files
-
registerProperties
protected void registerProperties(Properties properties)
Register properties.- Parameters:
properties- the properties
-
loadProperties
protected void loadProperties(Properties properties, String fileName) throws OnmsUpgradeException
Load properties.- Parameters:
properties- the propertiesfileName- the file name- Throws:
OnmsUpgradeException- the OpenNMS upgrade exception
-
getMainProperties
protected Properties getMainProperties() throws OnmsUpgradeException
Gets the main properties.- Returns:
- the main properties
- Throws:
OnmsUpgradeException- the OpenNMS upgrade exception
-
getRrdProperties
protected Properties getRrdProperties() throws OnmsUpgradeException
Gets the RRD properties.- Returns:
- the RRD properties
- Throws:
OnmsUpgradeException- the OpenNMS upgrade exception
-
isStoreByGroupEnabled
protected boolean isStoreByGroupEnabled()
Checks if storeByGroup is enabled.- Returns:
- true, if storeByGroup is enabled
-
isStoreByForeignSourceEnabled
protected boolean isStoreByForeignSourceEnabled()
Checks if storeByForeignSource is enabled.- Returns:
- true, if storeByForeignSource is enabled
-
getRrdStrategy
protected String getRrdStrategy() throws OnmsUpgradeException
Gets the RRD strategy.- Returns:
- the RRD strategy
- Throws:
OnmsUpgradeException- the OpenNMS upgrade exception
-
isRrdToolEnabled
protected boolean isRrdToolEnabled() throws OnmsUpgradeExceptionChecks if is RRDtool enabled.- Returns:
- true, if is RRDtool enabled
- Throws:
OnmsUpgradeException- the OpenNMS upgrade exception
-
getRrdExtension
protected String getRrdExtension() throws OnmsUpgradeException
Gets the RRD extension.- Returns:
- the RRD extension
- Throws:
OnmsUpgradeException- the OpenNMS upgrade exception
-
getDbConnection
protected Connection getDbConnection() throws OnmsUpgradeException
Gets the DB connection.- Returns:
- the DB connection
- Throws:
OnmsUpgradeException- the OpenNMS upgrade exception
-
initializeDatasource
protected void initializeDatasource() throws OnmsUpgradeExceptionInitializes the data source.- Throws:
OnmsUpgradeException- the OpenNMS upgrade exception
-
zipDir
protected void zipDir(File zipFile, File sourceFolder) throws OnmsUpgradeException
ZIP a directory.- Parameters:
zipFile- the output ZIP filesourceFolder- the source folder- Throws:
OnmsUpgradeException- the OpenNMS upgrade exception
-
zipFile
protected File zipFile(File sourceFile) throws OnmsUpgradeException
ZIP a file.The name of the ZIP file will be the name of the source file plus ".zip"
- Parameters:
sourceFile- the source file- Throws:
OnmsUpgradeException- the OpenNMS upgrade exception
-
unzipFile
protected void unzipFile(File zipFile, File outputFolder) throws OnmsUpgradeException
UNZIP a file.- Parameters:
zipFile- the input ZIP fileoutputFolder- the output folder- Throws:
OnmsUpgradeException- the OpenNMS upgrade exception
-
getOpennmsVersion
protected String getOpennmsVersion() throws OnmsUpgradeException
Gets the currently installed OpenNMS version.- Returns:
- the OpenNMS version
- Throws:
OnmsUpgradeException- the OpenNMS upgrade exception
-
getOpennmsProductName
public String getOpennmsProductName()
Gets the OpenNMS product name.- Returns:
- the OpenNMS product name
-
getOpennmsProductDescription
public String getOpennmsProductDescription()
Gets the OpenNMS product description.- Returns:
- the OpenNMS product description
-
isMeridian
public boolean isMeridian()
Checks if is meridian.- Returns:
- true, if is meridian
-
isInstalledVersion
protected boolean isInstalledVersion(AbstractOnmsUpgrade.VersionOperator op, int mayor, int minor, int release) throws OnmsUpgradeException
- Throws:
OnmsUpgradeException
-
isInstalledVersionGreaterOrEqual
protected boolean isInstalledVersionGreaterOrEqual(int mayor, int minor, int release) throws OnmsUpgradeExceptionChecks if the installed version of OpenNMS is greater or equals than the supplied version.- Parameters:
mayor- the mayorminor- the minorrelease- the release- Returns:
- true, if the current installed version is greater or equals than $major.$minor.$release
- Throws:
OnmsUpgradeException- the OpenNMS upgrade exception
-
getInstalledVersion
protected int[] getInstalledVersion() throws OnmsUpgradeException- Throws:
OnmsUpgradeException
-
versionToInteger
protected static int versionToInteger(int mayor, int minor, int release) throws OnmsUpgradeException- Throws:
OnmsUpgradeException
-
printMainSettings
protected void printMainSettings() throws OnmsUpgradeExceptionPrints the settings.- Throws:
OnmsUpgradeException- the OpenNMS upgrade exception
-
printFullSettings
protected void printFullSettings() throws OnmsUpgradeExceptionPrints the full settings.- Throws:
OnmsUpgradeException- the OpenNMS upgrade exception
-
-