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 interfaceJdbcDriverDownloader.DriverFilePostProcessorPost-processor for JDBC driver files which runs once a file has been downloaded.static interfaceJdbcDriverDownloader.ProgressListenerDownload progress listener.static interfaceJdbcDriverDownloader.UrlConnectionFactoryThe URL connection factory used byJdbcDriverDownloader.static interfaceJdbcDriverDownloader.UrlConnectionWrapperA wrapper around an open connection to a (local or remote) URL.
-
Field Summary
Fields Modifier and Type Field Description static StringALLOW_NON_HTTP_URLS_KEYIf "teamcity.maintenance.jdbcDrivers.allowNonHttpUrls" is set totrue, other URL schemes (such asftp://andfile://) will also be supported.static StringDOWNLOAD_URL_KEYThe name of the internal property holding the URL(s) (comma-separated) to download JDBC driver metadata from.static PatternLICENSE_FILE_NAME_PATTERNThe 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 voiddownload(DatabaseType type, File targetDirectory, boolean cleanupTargetDirectory, List<Exception> errors)Attempts to download the driver files into the specified directory.voiddownload(DatabaseType type, File targetDirectory, boolean cleanupTargetDirectory, List<Exception> errors, Map<DatabaseType,JdbcDriver> drivers)Attempts to download the driver files into the specified directory.voiddownload(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 StringgetLicenseFileName(DatabaseType type, Map<DatabaseType,JdbcDriver> drivers)Returns the license file name (if any) for the given JDBC driver type.static StringgetLicenseUrl(DatabaseType type, Map<DatabaseType,JdbcDriver> drivers)Returns the license URL (if any) for the given JDBC driver type.static booleanisEnabled()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.MAINTENANCEorLoggers.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.MAINTENANCEorLoggers.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.MAINTENANCEorLoggers.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- ifdownloadUrlsare 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.MAINTENANCEorLoggers.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- ifdownloadUrlsare 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- whethertargetDirectoryshould be cleaned up before the driver is downloaded (normally,trueformaintainDB.shandfalsefor 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- whethertargetDirectoryshould be cleaned up before the driver is downloaded (normally,trueformaintainDB.shandfalsefor 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- whethertargetDirectoryshould be cleaned up before the driver is downloaded (normally,trueformaintainDB.shandfalsefor 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
nullif 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
nullif none is available. - See Also:
getLicenseUrl(DatabaseType, Map)
-
isEnabled
public static boolean isEnabled()
Feature toggle.
- Returns:
trueif JDBC driver downloader feature is enabled,falseotherwise.
-
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 anIOExceptionwas thrown when opening a connection to the URL (e. g. in response to HTTP 404)).
-
-