Class DatabasePropertiesFile
- java.lang.Object
-
- jetbrains.buildServer.serverSide.db.DatabasePropertiesFile
-
public final class DatabasePropertiesFile extends Object
Represents our 'database.properties' file and manipulations with it.- Since:
- 8.0
- Author:
- Leonid Bushuev from JetBrains
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DatabasePropertiesFile.DatabasePropertiesFileException
static class
DatabasePropertiesFile.Origin
The origin of the "database.properties" file.
-
Field Summary
Fields Modifier and Type Field Description static String
CONNECTION_PASSWORD_KEY
static String
CONNECTION_URL_KEY
The ""connectionUrl"" key.static String
CONNECTION_USER_KEY
static String
DATABASE_PROPERTIES_FILE_NAME
static String
TEAMCITY_DB_URL_ENV
-
Constructor Summary
Constructors Constructor Description DatabasePropertiesFile(File dataDir)
Constructs the class for a properties file in the default location.DatabasePropertiesFile(File dataDir, Map<String,String> environment)
Constructs the class for a properties file in the default location.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DatabasePropertiesFile
createForBackupRestore(File dataDir, File file, DatabasePropertiesFile.Origin origin)
static DatabasePropertiesFile
createForBackupRestoreWithEnv(File dataDirectory, File file, DatabasePropertiesFile.Origin origin)
String
getConnectionUrl()
DatabaseType
getDatabaseType()
File
getDataDir()
String
getExplicitConnectionDescription(boolean html)
It is supposed to use this method as "TeamCity database is" + getExplicitConnectionDescription(false)File
getFile()
DatabasePropertiesFile.Origin
getOrigin()
Returns the origin of the "database.properties" file.Properties
getProperties()
int
getSpecifiedHsqlMajorVersion()
static boolean
hasDatabaseUrlInEnvironment(Map<String,String> environment)
boolean
isConfigurationPresent()
boolean
isFileExists()
void
refreshState(boolean setupExplicitly)
For all origins except virtual, re-reads the database properties from disk, optionally falling back to the default (HSQL) connection if the custom "database.properties" doesn't exist.static void
removeExtraSpacesFromPropertiesValues(Properties properties)
Workarounds a problem (feature aka bug) injava.util.Properties#load0(java.util.Properties.LineReader)
with trailing white spaces.String
toString()
-
-
-
Field Detail
-
DATABASE_PROPERTIES_FILE_NAME
public static final String DATABASE_PROPERTIES_FILE_NAME
- See Also:
- Constant Field Values
-
CONNECTION_URL_KEY
@NotNull public static final String CONNECTION_URL_KEY
The ""connectionUrl"" key.
- Since:
- 10.0.5
- See Also:
- Constant Field Values
-
CONNECTION_USER_KEY
@NotNull public static final String CONNECTION_USER_KEY
- See Also:
- Constant Field Values
-
CONNECTION_PASSWORD_KEY
@NotNull public static final String CONNECTION_PASSWORD_KEY
- See Also:
- Constant Field Values
-
TEAMCITY_DB_URL_ENV
public static final String TEAMCITY_DB_URL_ENV
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DatabasePropertiesFile
public DatabasePropertiesFile(@NotNull File dataDir)
Constructs the class for a properties file in the default location.- Parameters:
dataDir
- the TeamCity Data Directory.
-
-
Method Detail
-
createForBackupRestore
public static DatabasePropertiesFile createForBackupRestore(@NotNull File dataDir, @NotNull File file, @NotNull DatabasePropertiesFile.Origin origin)
-
createForBackupRestoreWithEnv
public static DatabasePropertiesFile createForBackupRestoreWithEnv(@NotNull File dataDirectory, @NotNull File file, @NotNull DatabasePropertiesFile.Origin origin)
-
refreshState
public void refreshState(boolean setupExplicitly)
For all origins except virtual, re-reads the database properties from disk, optionally falling back to the default (HSQL) connection if the custom "database.properties" doesn't exist.
If the underlying file exists, the
setupExplicitly
parameter is ignored. If the "database.properties" file doesn't exist andsetupExplicitly
isfalse
, this method does nothing.If the current origin is virtual, the file is ignored if it exists, the
setupExplicitly
parameter is ignored, too, and the default (HSQL) connection is always used.- Parameters:
setupExplicitly
- whether database properties should be initialized with the default (HSQL) connection in case "database.properties" doesn't exist.
-
removeExtraSpacesFromPropertiesValues
public static void removeExtraSpacesFromPropertiesValues(@NotNull Properties properties)
Workarounds a problem (feature aka bug) injava.util.Properties#load0(java.util.Properties.LineReader)
with trailing white spaces.- Parameters:
properties
- a set of properties; their values will be truncated in place.
-
getDataDir
@NotNull public File getDataDir()
-
getFile
@NotNull public File getFile()
-
getOrigin
@NotNull public DatabasePropertiesFile.Origin getOrigin()
Returns the origin of the "database.properties" file.
- Returns:
- The origin of the "database.properties" file.
- Since:
- 10.0.5
-
isConfigurationPresent
public boolean isConfigurationPresent()
- Returns:
- true if database properties were configured, either via properties file or via environment variables, or both
- Since:
- 2023.11
-
isFileExists
public boolean isFileExists()
-
getProperties
@Nullable public Properties getProperties()
-
getDatabaseType
@NotNull public DatabaseType getDatabaseType()
-
getExplicitConnectionDescription
@NotNull public String getExplicitConnectionDescription(boolean html)
It is supposed to use this method as "TeamCity database is" + getExplicitConnectionDescription(false)- Returns:
- textual description of the explicit DB configuration, see above
-
hasDatabaseUrlInEnvironment
public static boolean hasDatabaseUrlInEnvironment(Map<String,String> environment)
-
getSpecifiedHsqlMajorVersion
public int getSpecifiedHsqlMajorVersion()
-
getConnectionUrl
@NotNull public String getConnectionUrl()
-
-