Class VersionManager
- java.lang.Object
-
- jetbrains.buildServer.serverSide.versioning.VersionManager
-
public class VersionManager extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONFIG_VERSION_FILE_NAME
static String
CONFIG_VERSION_TIMESTAMP_PROPERTY
static String
CONFIG_VERSION_VERSION_PROPERTY
static String
MAIN_CONFIG_FILE_NAME
static int
MAIN_CONFIG_VERSION_SINCE
static int
MINIMAL_VERSION_WE_CAN_UPGRADE_FROM
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
checkVersionMatchingInCaseOfDataDirOnly(ServerPaths serverPaths)
Checks that the version of data directory matches this siftware version.static void
checkVersionsAndUpgradeSchemaIfNeeded(DBFunctions dbf, ServerPaths serverPaths)
Upgrades an existance schema if needed.static void
ensureActualDatabase(TeamCityDatabaseManager tcdbm, ServerPaths serverPaths)
static boolean
isDatabaseCreatedOnStartup()
static int
loadConsistentVersion(ServerPaths serverPaths, DBFunctions dbf)
Loads versions for both configuration and database (if possible).static int
loadVersionFromDisk(ServerPaths serverPaths)
Loads data format version of the configuration.static int
loadVersionFromFormerFile(String systemDirPath)
static int
loadVersionFromMainConfigFile(String configDirPath)
static void
setDatabaseCreatedOnStartup(boolean createdOnStartup)
static void
upgradeIt(ServerPaths serverPaths, DBFunctions dbf, IntInterval upgradeRange)
WARNING! - we're assume that upgradeRange.B will be exactly the current software version number.static void
writeSoftwareVersionIntoMainConfigXml(org.jdom.Element rootElement)
static void
writeVersionIntoMainConfigFile(String configDirPath, int version)
static void
writeVersionToDisk(ServerPaths serverPaths, int version, Date time)
-
-
-
Field Detail
-
MAIN_CONFIG_FILE_NAME
public static final String MAIN_CONFIG_FILE_NAME
- See Also:
- Constant Field Values
-
CONFIG_VERSION_FILE_NAME
public static final String CONFIG_VERSION_FILE_NAME
- See Also:
- Constant Field Values
-
CONFIG_VERSION_VERSION_PROPERTY
public static final String CONFIG_VERSION_VERSION_PROPERTY
- See Also:
- Constant Field Values
-
CONFIG_VERSION_TIMESTAMP_PROPERTY
public static final String CONFIG_VERSION_TIMESTAMP_PROPERTY
- See Also:
- Constant Field Values
-
MINIMAL_VERSION_WE_CAN_UPGRADE_FROM
public static final int MINIMAL_VERSION_WE_CAN_UPGRADE_FROM
- See Also:
- Constant Field Values
-
MAIN_CONFIG_VERSION_SINCE
public static final int MAIN_CONFIG_VERSION_SINCE
- See Also:
- Constant Field Values
-
-
Method Detail
-
loadVersionFromDisk
public static int loadVersionFromDisk(ServerPaths serverPaths) throws DataDirectoryVersionException
Loads data format version of the configuration. This version is loaded from "main-config.xml" file or from "version.dat" file.- Parameters:
serverPaths
-- Returns:
- the loaded version, or 0 if could not loaded.
- Throws:
DataDirectoryVersionException
-
loadVersionFromMainConfigFile
public static int loadVersionFromMainConfigFile(String configDirPath)
-
loadVersionFromFormerFile
public static int loadVersionFromFormerFile(String systemDirPath)
-
writeVersionToDisk
public static void writeVersionToDisk(@NotNull ServerPaths serverPaths, int version, Date time) throws IOException
- Throws:
IOException
-
writeVersionIntoMainConfigFile
public static void writeVersionIntoMainConfigFile(String configDirPath, int version) throws IOException
- Throws:
IOException
-
writeSoftwareVersionIntoMainConfigXml
public static void writeSoftwareVersionIntoMainConfigXml(@NotNull org.jdom.Element rootElement)
-
checkVersionMatchingInCaseOfDataDirOnly
public static void checkVersionMatchingInCaseOfDataDirOnly(ServerPaths serverPaths) throws DatabaseVersionMismatchException
Checks that the version of data directory matches this siftware version. Assumed that there is no database.- Parameters:
systemDirPath
- where to look for the 'version.dat' file.- Throws:
DatabaseVersionMismatchException
-
checkVersionsAndUpgradeSchemaIfNeeded
public static void checkVersionsAndUpgradeSchemaIfNeeded(@NotNull DBFunctions dbf, @NotNull ServerPaths serverPaths) throws ConvertException, DBException, DataPartsInconsistentException, DatabaseVersionMismatchException
Upgrades an existance schema if needed. Assumed that schema does exist.- Throws:
DBException
- when DBExceptionDataPartsInconsistentException
- when config files xor database exists.ConvertException
DatabaseVersionMismatchException
-
upgradeIt
public static void upgradeIt(@NotNull ServerPaths serverPaths, @NotNull DBFunctions dbf, @NotNull IntInterval upgradeRange) throws ConvertException, DBException
WARNING! - we're assume that upgradeRange.B will be exactly the current software version number.- Throws:
ConvertException
DBException
-
ensureActualDatabase
public static void ensureActualDatabase(@NotNull TeamCityDatabaseManager tcdbm, @NotNull ServerPaths serverPaths) throws DBException, DataPartsInconsistentException, DatabaseVersionMismatchException, IOException
-
loadConsistentVersion
public static int loadConsistentVersion(@Nullable ServerPaths serverPaths, @Nullable DBFunctions dbf)
Loads versions for both configuration and database (if possible). Returns the version number if both loaded numbers are the same, or throws an exception when differ.- Parameters:
serverPaths
-dbf
-- Returns:
- consistent data format version number.
- Throws:
IllegalStateException
- when the configuration version and the database version are not same.
-
isDatabaseCreatedOnStartup
public static boolean isDatabaseCreatedOnStartup()
-
setDatabaseCreatedOnStartup
public static void setDatabaseCreatedOnStartup(boolean createdOnStartup)
-
-