public abstract class AbstractOnmsUpgrade extends Object implements OnmsUpgrade
This contains the basic methods that may be required for several implementations.
Modifier and Type | Class and Description |
---|---|
static class |
AbstractOnmsUpgrade.VersionOperator |
Modifier and Type | Field and Description |
---|---|
static String |
ZIP_EXT
The Constant ZIP_EXT.
|
Constructor and Description |
---|
AbstractOnmsUpgrade()
Instantiates a new abstract OpenNMS upgrade.
|
Modifier and Type | Method and Description |
---|---|
protected Connection |
getDbConnection()
Gets the DB connection.
|
protected File[] |
getFiles(File resourceDir,
String ext)
Gets the files.
|
protected String |
getHomeDirectory()
Gets the home directory.
|
String |
getId()
Gets the id.
|
protected int[] |
getInstalledVersion() |
protected Properties |
getMainProperties()
Gets the main properties.
|
String |
getOpennmsProductDescription()
Gets the OpenNMS product description.
|
String |
getOpennmsProductName()
Gets the OpenNMS product name.
|
protected String |
getOpennmsVersion()
Gets the currently installed OpenNMS version.
|
protected String |
getRrdExtension()
Gets the RRD extension.
|
protected Properties |
getRrdProperties()
Gets the RRD properties.
|
protected String |
getRrdStrategy()
Gets the RRD strategy.
|
protected void |
initializeDatasource()
Initializes the data source.
|
protected boolean |
isInstalledVersion(AbstractOnmsUpgrade.VersionOperator op,
int mayor,
int minor,
int release) |
protected boolean |
isInstalledVersionGreaterOrEqual(int mayor,
int minor,
int release)
Checks if the installed version of OpenNMS is greater or equals than the supplied version.
|
boolean |
isMeridian()
Checks if is meridian.
|
protected boolean |
isRrdToolEnabled()
Checks if is RRDtool enabled.
|
protected boolean |
isStoreByForeignSourceEnabled()
Checks if storeByForeignSource is enabled.
|
protected boolean |
isStoreByGroupEnabled()
Checks if storeByGroup is enabled.
|
protected void |
loadProperties(Properties properties,
String fileName)
Load properties.
|
protected void |
log(String msgFormat,
Object... args)
Log.
|
protected void |
printFullSettings()
Prints the full settings.
|
protected void |
printMainSettings()
Prints the settings.
|
protected void |
registerProperties(Properties properties)
Register properties.
|
protected void |
setProductDescription(String productDescription)
Sets the product description.
|
protected void |
setProductName(String productName)
Sets the product name.
|
protected void |
setVersion(String version)
Sets the version.
|
protected void |
unzipFile(File zipFile,
File outputFolder)
UNZIP a file.
|
protected static int |
versionToInteger(int mayor,
int minor,
int release) |
protected void |
zipDir(File zipFile,
File sourceFolder)
ZIP a directory.
|
protected File |
zipFile(File sourceFile)
ZIP a file.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
execute, getDescription, getOrder, postExecute, preExecute, requiresOnmsRunning, rollback
public static final String ZIP_EXT
public AbstractOnmsUpgrade() throws OnmsUpgradeException
OnmsUpgradeException
- the OpenNMS upgrade exceptionprotected void setVersion(String version)
This method is intended for JUnit tests.
version
- the new versionprotected void setProductName(String productName)
This method is intended for JUnit tests.
productName
- the new product nameprotected void setProductDescription(String productDescription)
This method is intended for JUnit tests.
productDescription
- the new product descriptionpublic String getId()
OnmsUpgrade
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.
getId
in interface OnmsUpgrade
protected String getHomeDirectory()
protected File[] getFiles(File resourceDir, String ext)
resourceDir
- the resource directoryext
- the file extensionprotected void registerProperties(Properties properties)
properties
- the propertiesprotected void loadProperties(Properties properties, String fileName) throws OnmsUpgradeException
properties
- the propertiesfileName
- the file nameOnmsUpgradeException
- the OpenNMS upgrade exceptionprotected Properties getMainProperties() throws OnmsUpgradeException
OnmsUpgradeException
- the OpenNMS upgrade exceptionprotected Properties getRrdProperties() throws OnmsUpgradeException
OnmsUpgradeException
- the OpenNMS upgrade exceptionprotected boolean isStoreByGroupEnabled()
protected boolean isStoreByForeignSourceEnabled()
protected String getRrdStrategy() throws OnmsUpgradeException
OnmsUpgradeException
- the OpenNMS upgrade exceptionprotected boolean isRrdToolEnabled() throws OnmsUpgradeException
OnmsUpgradeException
- the OpenNMS upgrade exceptionprotected String getRrdExtension() throws OnmsUpgradeException
OnmsUpgradeException
- the OpenNMS upgrade exceptionprotected Connection getDbConnection() throws OnmsUpgradeException
OnmsUpgradeException
- the OpenNMS upgrade exceptionprotected void initializeDatasource() throws OnmsUpgradeException
OnmsUpgradeException
- the OpenNMS upgrade exceptionprotected void zipDir(File zipFile, File sourceFolder) throws OnmsUpgradeException
zipFile
- the output ZIP filesourceFolder
- the source folderOnmsUpgradeException
- the OpenNMS upgrade exceptionprotected File zipFile(File sourceFile) throws OnmsUpgradeException
The name of the ZIP file will be the name of the source file plus ".zip"
sourceFile
- the source fileOnmsUpgradeException
- the OpenNMS upgrade exceptionprotected void unzipFile(File zipFile, File outputFolder) throws OnmsUpgradeException
zipFile
- the input ZIP fileoutputFolder
- the output folderOnmsUpgradeException
- the OpenNMS upgrade exceptionprotected String getOpennmsVersion() throws OnmsUpgradeException
OnmsUpgradeException
- the OpenNMS upgrade exceptionpublic String getOpennmsProductName()
public String getOpennmsProductDescription()
public boolean isMeridian()
protected boolean isInstalledVersion(AbstractOnmsUpgrade.VersionOperator op, int mayor, int minor, int release) throws OnmsUpgradeException
OnmsUpgradeException
protected boolean isInstalledVersionGreaterOrEqual(int mayor, int minor, int release) throws OnmsUpgradeException
mayor
- the mayorminor
- the minorrelease
- the releaseOnmsUpgradeException
- the OpenNMS upgrade exceptionprotected int[] getInstalledVersion() throws OnmsUpgradeException
OnmsUpgradeException
protected static int versionToInteger(int mayor, int minor, int release) throws OnmsUpgradeException
OnmsUpgradeException
protected void printMainSettings() throws OnmsUpgradeException
OnmsUpgradeException
- the OpenNMS upgrade exceptionprotected void printFullSettings() throws OnmsUpgradeException
OnmsUpgradeException
- the OpenNMS upgrade exceptionCopyright © 2021. All rights reserved.