Class JdbcDriverDownloader
- java.lang.Object
-
- jetbrains.buildServer.serverSide.db.JdbcDriverDownloader
-
@Immutable public final class JdbcDriverDownloader extends Object
JDBC driver download manager.
- Since:
- 2018.1
- Author:
- Andrey Shcheglov <mailto:andrey.shcheglov@jetbrains.com>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
JdbcDriverDownloader.DriverFilePostProcessor
Post-processor for JDBC driver files which runs once a file has been downloaded.static interface
JdbcDriverDownloader.ProgressListener
Download progress listener.static interface
JdbcDriverDownloader.UrlConnectionFactory
The URL connection factory used byJdbcDriverDownloader
.static interface
JdbcDriverDownloader.UrlConnectionWrapper
A wrapper around an open connection to a (local or remote) URL.
-
Field Summary
Fields Modifier and Type Field Description static String
ALLOW_NON_HTTP_URLS_KEY
If "teamcity.maintenance.jdbcDrivers.allowNonHttpUrls" is set totrue
, other URL schemes (such asftp://
andfile://
) will also be supported.static String
DOWNLOAD_URL_KEY
The name of the internal property holding the URL(s) (comma-separated) to download JDBC driver metadata from.static Pattern
LICENSE_FILE_NAME_PATTERN
The regex pattern used to select the license file (DataGrip flavour).
-
Constructor Summary
Constructors Constructor Description JdbcDriverDownloader(Logger logger, URL... downloadUrls)
Creates a new JDBC driver download manager using a custom URL.JdbcDriverDownloader(Logger logger, JdbcDriverDownloader.UrlConnectionFactory urlConnectionFactory, URL... downloadUrls)
Creates a new JDBC driver download manager using custom URL and connection factory.JdbcDriverDownloader(Logger logger, JdbcDriverDownloader.UrlConnectionFactory urlConnectionFactory, TeamCityPropertiesProvider propertiesProvider)
Creates a new JDBC driver download manager using the default URL and a custom connection factory.JdbcDriverDownloader(Logger logger, TeamCityPropertiesProvider propertiesProvider)
Creates a new JDBC driver download manager using the default URL.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
download(DatabaseType type, File targetDirectory, boolean cleanupTargetDirectory, List<Exception> errors)
Attempts to download the driver files into the specified directory.void
download(DatabaseType type, File targetDirectory, boolean cleanupTargetDirectory, List<Exception> errors, Map<DatabaseType,JdbcDriver> drivers)
Attempts to download the driver files into the specified directory.void
download(DatabaseType type, File targetDirectory, boolean cleanupTargetDirectory, List<Exception> errors, JdbcDriverDownloader.ProgressListener progressListener, Map<DatabaseType,JdbcDriver> drivers)
Attempts to download the driver files into the specified directory.static String
getLicenseFileName(DatabaseType type, Map<DatabaseType,JdbcDriver> drivers)
Returns the license file name (if any) for the given JDBC driver type.static String
getLicenseUrl(DatabaseType type, Map<DatabaseType,JdbcDriver> drivers)
Returns the license URL (if any) for the given JDBC driver type.static boolean
isEnabled()
Feature toggle.Map<DatabaseType,JdbcDriver>
listLatest()
Returns the metadata for the most recent JDBC drivers supported by TeamCity.
-
-
-
Field Detail
-
DOWNLOAD_URL_KEY
@NonNls @NotNull public static final String DOWNLOAD_URL_KEY
The name of the internal property holding the URL(s) (comma-separated) to download JDBC driver metadata from. The first URL which returns a valid response will be used.
- See Also:
- Constant Field Values
-
ALLOW_NON_HTTP_URLS_KEY
@NonNls @NotNull public static final String ALLOW_NON_HTTP_URLS_KEY
If "teamcity.maintenance.jdbcDrivers.allowNonHttpUrls" is set to
true
, other URL schemes (such asftp://
andfile://
) will also be supported.Note: this will disable the TeamCity-specific HTTP client implementation, resulting in
teamcity.http.*
andteamcity.https.*
family of internal properties being ignored.- Since:
- 2018.1.1
- See Also:
- Constant Field Values
-
LICENSE_FILE_NAME_PATTERN
@NotNull public static final Pattern LICENSE_FILE_NAME_PATTERN
The regex pattern used to select the license file (DataGrip flavour).
-
-
Constructor Detail
-
JdbcDriverDownloader
public JdbcDriverDownloader(@NotNull Logger logger, @NotNull TeamCityPropertiesProvider propertiesProvider)
Creates a new JDBC driver download manager using the default URL.
- Parameters:
logger
- the logger to be used (normally, eitherLoggers.MAINTENANCE
orLoggers.STARTUP
).propertiesProvider
- the TeamCity properties provider to use.
-
JdbcDriverDownloader
public JdbcDriverDownloader(@NotNull Logger logger, @NotNull JdbcDriverDownloader.UrlConnectionFactory urlConnectionFactory, @NotNull TeamCityPropertiesProvider propertiesProvider)
Creates a new JDBC driver download manager using the default URL and a custom connection factory.
- Parameters:
logger
- the logger to be used (normally, eitherLoggers.MAINTENANCE
orLoggers.STARTUP
).urlConnectionFactory
- the URL connection factory to use.propertiesProvider
- the TeamCity properties provider to use.- Since:
- 2018.1.1
-
JdbcDriverDownloader
public JdbcDriverDownloader(@NotNull Logger logger, @NotNull URL... downloadUrls)
Creates a new JDBC driver download manager using a custom URL.
- Parameters:
logger
- the logger to be used (normally, eitherLoggers.MAINTENANCE
orLoggers.STARTUP
).downloadUrls
- the URL(s) to download JDBC driver metadata from. The URLs will be attempted in a row, the first one to return a valid response will be used.- Throws:
IllegalArgumentException
- ifdownloadUrls
are empty.
-
JdbcDriverDownloader
public JdbcDriverDownloader(@NotNull Logger logger, @NotNull JdbcDriverDownloader.UrlConnectionFactory urlConnectionFactory, @NotNull URL... downloadUrls)
Creates a new JDBC driver download manager using custom URL and connection factory.
- Parameters:
logger
- the logger to be used (normally, eitherLoggers.MAINTENANCE
orLoggers.STARTUP
).urlConnectionFactory
- the URL connection factory to use.downloadUrls
- the URL(s) to download JDBC driver metadata from. The URLs will be attempted in a row, the first one to return a valid response will be used.- Throws:
IllegalArgumentException
- ifdownloadUrls
are empty.
-
-
Method Detail
-
download
public void download(@NotNull DatabaseType type, @NotNull File targetDirectory, boolean cleanupTargetDirectory, @NotNull List<Exception> errors)
Attempts to download the driver files into the specified directory.
- Parameters:
type
- the database driver to download JDBC drivers for.targetDirectory
- the directory to download the drivers into (normally,${TEAMCITY_DATA_PATH}/lib/jdbc
).cleanupTargetDirectory
- whethertargetDirectory
should be cleaned up before the driver is downloaded (normally,true
formaintainDB.sh
andfalse
for the start-up UI).errors
- the download error collector (must be mutable).- See Also:
download(DatabaseType, File, boolean, List, Map)
,download(DatabaseType, File, boolean, List, ProgressListener, Map)
-
download
public void download(@NotNull DatabaseType type, @NotNull File targetDirectory, boolean cleanupTargetDirectory, @NotNull List<Exception> errors, @NotNull Map<DatabaseType,JdbcDriver> drivers)
Attempts to download the driver files into the specified directory.
- Parameters:
type
- the database driver to download JDBC drivers for.targetDirectory
- the directory to download the drivers into (normally,${TEAMCITY_DATA_PATH}/lib/jdbc
).cleanupTargetDirectory
- whethertargetDirectory
should be cleaned up before the driver is downloaded (normally,true
formaintainDB.sh
andfalse
for the start-up UI).errors
- the download error collector (must be mutable).drivers
- the metadata returned bylistLatest()
.- Since:
- 2018.1.1
- See Also:
download(DatabaseType, File, boolean, List)
,download(DatabaseType, File, boolean, List, ProgressListener, Map)
-
download
public void download(@NotNull DatabaseType type, @NotNull File targetDirectory, boolean cleanupTargetDirectory, @NotNull List<Exception> errors, @NotNull JdbcDriverDownloader.ProgressListener progressListener, @NotNull Map<DatabaseType,JdbcDriver> drivers)
Attempts to download the driver files into the specified directory.
- Parameters:
type
- the database driver to download JDBC drivers for.targetDirectory
- the directory to download the drivers into (normally,${TEAMCITY_DATA_PATH}/lib/jdbc
).cleanupTargetDirectory
- whethertargetDirectory
should be cleaned up before the driver is downloaded (normally,true
formaintainDB.sh
andfalse
for the start-up UI).errors
- the download error collector (must be mutable).progressListener
- the download progress listener.drivers
- the metadata returned bylistLatest()
.- See Also:
download(DatabaseType, File, boolean, List)
,download(DatabaseType, File, boolean, List, Map)
,JdbcDriverDownloadProgressListener
-
getLicenseUrl
@Nullable public static String getLicenseUrl(@NotNull DatabaseType type, @NotNull Map<DatabaseType,JdbcDriver> drivers)
Returns the license URL (if any) for the given JDBC driver type.
- Parameters:
type
- the JDBC driver type.drivers
- the metadata returned bylistLatest()
.- Returns:
- the license URL, or
null
if none is available. - Since:
- 2018.1.1
- See Also:
getLicenseFileName(DatabaseType, Map)
-
getLicenseFileName
@Nullable public static String getLicenseFileName(@NotNull DatabaseType type, @NotNull Map<DatabaseType,JdbcDriver> drivers)
Returns the license file name (if any) for the given JDBC driver type.
- Parameters:
type
- the JDBC driver type.drivers
- the metadata returned bylistLatest()
.- Returns:
- the license file name, or
null
if none is available. - See Also:
getLicenseUrl(DatabaseType, Map)
-
isEnabled
public static boolean isEnabled()
Feature toggle.
- Returns:
true
if JDBC driver downloader feature is enabled,false
otherwise.
-
listLatest
@NotNull public Map<DatabaseType,JdbcDriver> listLatest() throws IOException
Returns the metadata for the most recent JDBC drivers supported by TeamCity.
- Returns:
- the metadata for the most recent JDBC drivers supported by TeamCity.
- Throws:
IOException
- if there was a failure downloading a valid XML metadata from any ofmyDownloadUrls
(sources didn't contain a well-formed XML, contained XML elements not expected by the deserializer, or anIOException
was thrown when opening a connection to the URL (e. g. in response to HTTP 404)).
-
-